Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

Developing "Literature"

0.1

Introduction

This section aims at providing a short overview over the design and the principal components of the software. The software is based on the qt/kde libraries and uses postgresql as a database backend.

The shell

The application resembles a web browser. MainWindowImpl acts as a shell and displays on demand different widgets (e.g. by MainWindowImpl::showAuthor() ). The widget displays the data of a certain record from the database. The specification of the widget is coded in an URL-like format.

The string "lit://publicationoverview" indicates, that the widget PublicationOverview should be loaded. The widged will be loaded by MainWindowImpl::showPublicationOverview(). This one is more complex: "lit://bibliography/publication?no=9939". It indicates that the widget Bibliography should be loaded. The data which will be displayed in the widger comes from the table "publication". The clause behind the "?" indicates a kind of sql-"where"-clause. Its the record from table publication with "no=9939". A "lit://author?new" signals to the Author widget that a new author should be created. The url can be manipulated by editing the text-input of the toolbar (next to back-forward buttons).

The class LitUrl encapsulates the lit-url.

It is sent through the qt-event queue. The following code from Part causes the current Part-object to be unloaded. The new widget PartMemo will be loaded instead.

void Part::showPartMemo() {
qApp->postEvent(topLevelWidget(), new UrlEvent(LitUrl("lit://partmemo/part?no="+no(url())), false));
}

The event is received by MainWindowImpl::customEvent() . This method handles the loading and unloading of the widgets.

Shell widgets

The classes ReadOnlyFormBase and ReadWriteFormBase serve as abstract base classes for the widgets to be displayed by the shell. ReadOnlyFormBase provides functions common to all shell widgets like background selection, reloading of the widget from the database, and gui-states.

It is inherited by a number of widgets like AuthorOverview ,..., State , and Search. ReadWriteFormBase extends the functionality of ReadOnlyFormBase. It manages a QSqlCursor and provides the database - locking mechanisms. Classes like Author, File, and PartMemo inherit this class. The differentiation between ReadOnlyFormBase and ReadWriteFormBase is currently somewhat messy and needs some cleanup in the future.

Threading

Although the retrieval of one record is fast, operations using aggregated data are often quite slow. For this reason, some operations use multi-threading to avoid the blocking of the user interface. The data of a widget is usually set in the "setData()" - method of a given object (eg. Author::setData()).
The following code demonstrates multi-threading:

authorform->parts->clear();
fillpart=new FillLinkListBox(this, "partauthorfllb", authorform->parts,
"select part.no, part.title from part, part_author " <br> "where part.no=part_author.part_no and part_author.author_no="+no+" "<br> "order by part.title", "part/part", loadPixmap("showpart.png"));
fillpart->start();
threads.append(fillpart);

A LinkListBox is to be filled with the parts written by a specific author ("authorform->parts"). The class FillLinkListBox retrieves the necessary data in the background and ensures that is inserted into the LinkListBox. This is done in a seperate thread. Each widget which is inherited from ReadWriteFormBase has a list with pending threads. Each running threads must be inserted into this list in order to ensure that the thread is properly cleaned up before the destuction of the current widget.


Generated on Sat Mar 27 19:20:37 2004 for Literature by doxygen 1.3.6-20040222