'\" t .TH TQMimeSourceFactory 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*- .\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the .\" license file included in the distribution for a complete license .\" statement. .\" .ad l .nh .SH NAME TQMimeSourceFactory \- Extensible provider of mime-typed data .SH SYNOPSIS \fC#include \fR .PP .SS "Public Members" .in +1c .ti -1c .BI "\fBTQMimeSourceFactory\fR ()" .br .ti -1c .BI "virtual \fB~TQMimeSourceFactory\fR ()" .br .ti -1c .BI "virtual const TQMimeSource * \fBdata\fR ( const TQString & abs_name ) const" .br .ti -1c .BI "virtual TQString \fBmakeAbsolute\fR ( const TQString & abs_or_rel_name, const TQString & context ) const" .br .ti -1c .BI "const TQMimeSource * \fBdata\fR ( const TQString & abs_or_rel_name, const TQString & context ) const" .br .ti -1c .BI "virtual void \fBsetText\fR ( const TQString & abs_name, const TQString & text )" .br .ti -1c .BI "virtual void \fBsetImage\fR ( const TQString & abs_name, const TQImage & image )" .br .ti -1c .BI "virtual void \fBsetPixmap\fR ( const TQString & abs_name, const TQPixmap & pixmap )" .br .ti -1c .BI "virtual void \fBsetData\fR ( const TQString & abs_name, TQMimeSource * data )" .br .ti -1c .BI "virtual void \fBsetFilePath\fR ( const TQStringList & path )" .br .ti -1c .BI "virtual TQStringList \fBfilePath\fR () const" .br .ti -1c .BI "void \fBaddFilePath\fR ( const TQString & p )" .br .ti -1c .BI "virtual void \fBsetExtensionType\fR ( const TQString & ext, const char * mimetype )" .br .in -1c .SS "Static Public Members" .in +1c .ti -1c .BI "TQMimeSourceFactory * \fBdefaultFactory\fR ()" .br .ti -1c .BI "void \fBsetDefaultFactory\fR ( TQMimeSourceFactory * factory )" .br .ti -1c .BI "TQMimeSourceFactory * \fBtakeDefaultFactory\fR ()" .br .ti -1c .BI "void \fBaddFactory\fR ( TQMimeSourceFactory * f )" .br .ti -1c .BI "void \fBremoveFactory\fR ( TQMimeSourceFactory * f )" .br .in -1c .SH DESCRIPTION The TQMimeSourceFactory class is an extensible provider of mime-typed data. .PP A TQMimeSourceFactory provides an abstract interface to a collection of information. Each piece of information is represented by a TQMimeSource object which can be examined and converted to concrete data types by functions such as TQImageDrag::canDecode() and TQImageDrag::decode(). .PP The base TQMimeSourceFactory 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, TQTextEdit and TQTextBrowser, use TQMimeSourceFactory to resolve references such as images or links within rich text documents. They either access the default factory (see defaultFactory()) or their own (see TQTextEdit::setMimeSourceFactory()). Other classes that are capable of displaying rich text (such as TQLabel, TQWhatsThis or TQMessageBox) 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: .PP .nf .br static const char* myimage_data[]={ .br "...", .br ... .br "..."}; .br .fi .PP To be able to use this image within some rich text, for example inside a TQLabel, you must create a TQImage from the raw data and insert it into the factory with a unique name: .PP .nf .br TQMimeSourceFactory::defaultFactory()->setImage( "myimage", TQImage(myimage_data) ); .br .fi .PP Now you can create a rich text TQLabel with .PP .nf .br TQLabel* label = new TQLabel( .br "Rich text with embedded image:" .br "Isn't that cute?" ); .br .fi .PP When no longer needed, you can clear the data from the factory: .PP .nf .br delete label; .br TQMimeSourceFactory::defaultFactory()->setData( "myimage", 0 ); .br .fi .PP See also Environment Classes and Input/Output and Networking. .SH MEMBER FUNCTION DOCUMENTATION .SH "TQMimeSourceFactory::TQMimeSourceFactory ()" Constructs a TQMimeSourceFactory that has no file path and no stored content. .SH "TQMimeSourceFactory::~TQMimeSourceFactory ()\fC [virtual]\fR" Destroys the TQMimeSourceFactory, deleting all stored content. .SH "void TQMimeSourceFactory::addFactory ( TQMimeSourceFactory * f )\fC [static]\fR" Adds the TQMimeSourceFactory \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. .PP See also removeFactory(). .SH "void TQMimeSourceFactory::addFilePath ( const TQString & p )" Adds another search path, \fIp\fR to the existing search paths. .PP See also setFilePath(). .SH "const TQMimeSource * TQMimeSourceFactory::data ( const TQString & abs_name ) const\fC [virtual]\fR" 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()). .PP 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 .PP .nf .br setExtensionType("html", "text/html;charset=iso8859-1"); .br setExtensionType("htm", "text/html;charset=iso8859-1"); .br setExtensionType("txt", "text/plain"); .br setExtensionType("xml", "text/xml;charset=UTF-8"); .br .fi 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 TQMimeSource 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 TQMimeSourceFactory 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. .SH "const TQMimeSource * TQMimeSourceFactory::data ( const TQString & abs_or_rel_name, const TQString & context ) const" This is an overloaded member function, provided for convenience. It behaves essentially like the above function. .PP A convenience function. See data(const TQString& abs_name). The file name is given in \fIabs_or_rel_name\fR and the path is in \fIcontext\fR. .SH "TQMimeSourceFactory * TQMimeSourceFactory::defaultFactory ()\fC [static]\fR" Returns the application-wide default mime source factory. This factory is used by rich text rendering classes such as TQSimpleRichText, TQWhatsThis and TQMessageBox to resolve named references within rich text documents. It serves also as the initial factory for the more complex render widgets, TQTextEdit and TQTextBrowser. .PP See also setDefaultFactory(). .PP Examples: .)l action/application.cpp and application/application.cpp. .SH "TQStringList TQMimeSourceFactory::filePath () const\fC [virtual]\fR" Returns the currently set search paths. .SH "TQString TQMimeSourceFactory::makeAbsolute ( const TQString & abs_or_rel_name, const TQString & context ) const\fC [virtual]\fR" 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 TQMimeSourceFactory::removeFactory ( TQMimeSourceFactory * f )\fC [static]\fR" Removes the mimesource factory \fIf\fR from the list of available mimesource factories. .PP See also addFactory(). .SH "void TQMimeSourceFactory::setData ( const TQString & abs_name, TQMimeSource * data )\fC [virtual]\fR" 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. .SH "void TQMimeSourceFactory::setDefaultFactory ( TQMimeSourceFactory * factory )\fC [static]\fR" Sets the default \fIfactory\fR, destroying any previously set mime source provider. The ownership of the factory is transferred to Qt. .PP See also defaultFactory(). .SH "void TQMimeSourceFactory::setExtensionType ( const TQString & ext, const char * mimetype )\fC [virtual]\fR" 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(). .SH "void TQMimeSourceFactory::setFilePath ( const TQStringList & path )\fC [virtual]\fR" Sets the list of directories that will be searched when named data is requested to the those given in the string list \fIpath\fR. .PP See also filePath(). .SH "void TQMimeSourceFactory::setImage ( const TQString & abs_name, const TQImage & image )\fC [virtual]\fR" Sets \fIimage\fR to be the data item associated with the absolute name \fIabs_name\fR. .PP Equivalent to setData(abs_name, new TQImageDrag(image)). .SH "void TQMimeSourceFactory::setPixmap ( const TQString & abs_name, const TQPixmap & pixmap )\fC [virtual]\fR" Sets \fIpixmap\fR to be the data item associated with the absolute name \fIabs_name\fR. .SH "void TQMimeSourceFactory::setText ( const TQString & abs_name, const TQString & text )\fC [virtual]\fR" Sets \fItext\fR to be the data item associated with the absolute name \fIabs_name\fR. .PP Equivalent to setData(abs_name, new TQTextDrag(text)). .SH "TQMimeSourceFactory * TQMimeSourceFactory::takeDefaultFactory ()\fC [static]\fR" Sets the defaultFactory() to 0 and returns the previous one. .SH "SEE ALSO" .BR http://doc.trolltech.com/tqmimesourcefactory.html .BR http://www.trolltech.com/faq/tech.html .SH COPYRIGHT Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. .SH AUTHOR Generated automatically from the source code. .SH BUGS If you find a bug in Qt, please report it as described in .BR http://doc.trolltech.com/bughowto.html . Good bug reports help us to help you. Thank you. .P The definitive TQt documentation is provided in HTML format; it is located at $TQTDIR/doc/html and can be read using TQt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. .P If you find errors in this manual page, please report them to .BR qt-bugs@trolltech.com . Please include the name of the manual page (tqmimesourcefactory.3qt) and the Qt version (3.3.8).