Qt API | Qtopia API | Qtopia Documentation | ![]() |
Applications which view or edit a particular type or types of files are called document-oriented applications. Qtopia has framework support to simplify the implementation of such applications.
The top-level widget of a document-oriented application must have a slot declared:
public slot: void setDocument( const QString& applnk_filename );
This slot should then be implemented to save the application's current document (if any) and to show (and possibly edit) the specified document. An example implementation is:
void Main::setDocument( const QString& applnk_filename ) { FileManager fm; if ( current ) { if ( !fm.saveFile( *current, data ) ) { // error return; } delete current; } current = new DocLnk( applnk_filename ); if ( !fm.loadFile( *current, data ) ) { // error } }
Document-oriented applications will always declare the the MIME types that they support by adding a line to their .desktop file, specifying each supported type, seperated by semi-colons:
MimeType=type/subtype;type/subtype;...
The subtype can be "*", indicating that this application can process all forms of the given type. Such an application is only invoked if no other more specific application is available.
At installation, you may also choose to execute the following:
qtopia-addmimetype type/subtype extension
This will allow plain filenames such as those on CF or SD cards inserted into the device to be recognized as MIME-typed documents.
Copyright © 2001-2002 Trolltech | Trademarks | Qtopia version 1.7.1
|