A QMimeSourceFactory provides an abstract interface to a collection of information. Each piece of information is represented by a QMimeSource object which can be examined and converted to concrete data types by functions such as TQImageDrag::canDecode() and TQImageDrag::decode().
The base QMimeSourceFactory can be used in two ways: as an abstraction of a collection of files or as specifically stored data. For it to access files, call setFilePath() before accessing data. For stored data, call setData() for each item (there are also convenience functions, e.g. setText(), setImage() and setPixmap(), that simply call setData() with appropriate parameters).
.PP
The rich text widgets, QTextEdit and QTextBrowser, use QMimeSourceFactory to resolve references such as images or links within rich text documents. They either access the default factory (see defaultFactory()) or their own (see QTextEdit::setMimeSourceFactory()). Other classes that are capable of displaying rich text (such as QLabel, QWhatsThis or QMessageBox) always use the default factory.
.PP
A factory can also be used as a container to store data associated with a name. This technique is useful whenever rich text contains images that are stored in the program itself, not loaded from the hard disk. Your program may, for example, define some image data as:
To be able to use this image within some rich text, for example inside a QLabel, you must create a TQImage from the raw data and insert it into the factory with a unique name:
Destroys the QMimeSourceFactory, deleting all stored content.
.SH "void QMimeSourceFactory::addFactory ( QMimeSourceFactory * f )\fC [static]\fR"
Adds the QMimeSourceFactory \fIf\fR to the list of available mimesource factories. If the defaultFactory() can't resolve a data() it iterates over the list of installed mimesource factories until the data can be resolved.
Returns a reference to the data associated with \fIabs_name\fR. The return value remains valid only until the next data() or setData() call, so you should immediately decode the result.
.PP
If there is no data associated with \fIabs_name\fR in the factory's store, the factory tries to access the local filesystem. If \fIabs_name\fR isn't an absolute file name, the factory will search for it in all defined paths (see setFilePath()).
The factory understands all the image formats supported by TQImageIO. Any other mime types are determined by the file name extension. The default settings are
The effect of these is that file names ending in "txt" will be treated as text encoded in the local encoding; those ending in" xml" will be treated as text encoded in Unicode UTF-8 encoding. The text/html type is treated specially, since the encoding can be specified in the html file itself. "html" or "htm" will be treated as text encoded in the encoding specified by the html meta tag, if none could be found, the charset of the mime type will be used. The text subtype ("html", "plain", or "xml") does not affect the factory, but users of the factory may behave differently. We recommend creating "xml" files where practical. These files can be viewed regardless of the runtime encoding and can encode any Unicode characters without resorting to encoding definitions inside the file.
.PP
Any file data that is not recognized will be retrieved as a QMimeSource providing the "application/octet-stream" mime type, meaning uninterpreted binary data.
.PP
You can add further extensions or change existing ones with subsequent calls to setExtensionType(). If the extension mechanism is not sufficient for your problem domain, you can inherit QMimeSourceFactory and reimplement this function to perform some more specialized mime-type detection. The same applies if you want to use the mime source factory to access URL referenced data over a network.
Returns the application-wide default mime source factory. This factory is used by rich text rendering classes such as QSimpleRichText, QWhatsThis and QMessageBox to resolve named references within rich text documents. It serves also as the initial factory for the more complex render widgets, QTextEdit and QTextBrowser.
.PP
See also setDefaultFactory().
.PP
Examples:
.)l action/application.cpp and application/application.cpp.
Converts the absolute or relative data item name \fIabs_or_rel_name\fR to an absolute name, interpreted within the context (path) of the data item named \fIcontext\fR (this must be an absolute name).
.SH "void QMimeSourceFactory::removeFactory ( QMimeSourceFactory * f )\fC [static]\fR"
Removes the mimesource factory \fIf\fR from the list of available mimesource factories.
Sets \fIdata\fR to be the data item associated with the absolute name \fIabs_name\fR. Note that the ownership of \fIdata\fR is transferred to the factory: do not delete or access the pointer after passing it to this function.
.PP
Passing 0 for data removes previously stored data.
Sets the mime-type to be associated with the file name extension, \fIext\fR to \fImimetype\fR. This determines the mime-type for files found via the paths set by setFilePath().