1QMimeSourceFactory(3qt)                                QMimeSourceFactory(3qt)
2
3
4

NAME

6       QMimeSourceFactory - Extensible provider of mime-typed data
7

SYNOPSIS

9       #include <qmime.h>
10
11   Public Members
12       QMimeSourceFactory ()
13       virtual ~QMimeSourceFactory ()
14       virtual const QMimeSource * data ( const QString & abs_name ) const
15       virtual QString makeAbsolute ( const QString & abs_or_rel_name, const
16           QString & context ) const
17       const QMimeSource * data ( const QString & abs_or_rel_name, const
18           QString & context ) const
19       virtual void setText ( const QString & abs_name, const QString & text )
20       virtual void setImage ( const QString & abs_name, const QImage & image
21           )
22       virtual void setPixmap ( const QString & abs_name, const QPixmap &
23           pixmap )
24       virtual void setData ( const QString & abs_name, QMimeSource * data )
25       virtual void setFilePath ( const QStringList & path )
26       virtual QStringList filePath () const
27       void addFilePath ( const QString & p )
28       virtual void setExtensionType ( const QString & ext, const char *
29           mimetype )
30
31   Static Public Members
32       QMimeSourceFactory * defaultFactory ()
33       void setDefaultFactory ( QMimeSourceFactory * factory )
34       QMimeSourceFactory * takeDefaultFactory ()
35       void addFactory ( QMimeSourceFactory * f )
36       void removeFactory ( QMimeSourceFactory * f )
37

DESCRIPTION

39       The QMimeSourceFactory class is an extensible provider of mime-typed
40       data.
41
42       A QMimeSourceFactory provides an abstract interface to a collection of
43       information. Each piece of information is represented by a QMimeSource
44       object which can be examined and converted to concrete data types by
45       functions such as QImageDrag::canDecode() and QImageDrag::decode().
46
47       The base QMimeSourceFactory can be used in two ways: as an abstraction
48       of a collection of files or as specifically stored data. For it to
49       access files, call setFilePath() before accessing data. For stored
50       data, call setData() for each item (there are also convenience
51       functions, e.g. setText(), setImage() and setPixmap(), that simply call
52       setData() with appropriate parameters).
53
54       The rich text widgets, QTextEdit and QTextBrowser, use
55       QMimeSourceFactory to resolve references such as images or links within
56       rich text documents. They either access the default factory (see
57       defaultFactory()) or their own (see QTextEdit::setMimeSourceFactory()).
58       Other classes that are capable of displaying rich text (such as QLabel,
59       QWhatsThis or QMessageBox) always use the default factory.
60
61       A factory can also be used as a container to store data associated with
62       a name. This technique is useful whenever rich text contains images
63       that are stored in the program itself, not loaded from the hard disk.
64       Your program may, for example, define some image data as:
65
66           static const char* myimage_data[]={
67           "...",
68           ...
69           "..."};
70
71       To be able to use this image within some rich text, for example inside
72       a QLabel, you must create a QImage from the raw data and insert it into
73       the factory with a unique name:
74
75           QMimeSourceFactory::defaultFactory()->setImage( "myimage", QImage(myimage_data) );
76
77       Now you can create a rich text QLabel with
78
79           QLabel* label = new QLabel(
80               "Rich text with embedded image:<img source=\"myimage\">"
81               "Isn't that <em>cute</em>?" );
82
83       When no longer needed, you can clear the data from the factory:
84
85           delete label;
86           QMimeSourceFactory::defaultFactory()->setData( "myimage", 0 );
87
88       See also Environment Classes and Input/Output and Networking.
89

MEMBER FUNCTION DOCUMENTATION

QMimeSourceFactory::QMimeSourceFactory ()

92       Constructs a QMimeSourceFactory that has no file path and no stored
93       content.
94

QMimeSourceFactory::~QMimeSourceFactory () [virtual]

96       Destroys the QMimeSourceFactory, deleting all stored content.
97

void QMimeSourceFactory::addFactory ( QMimeSourceFactory * f ) [static]

99       Adds the QMimeSourceFactory f to the list of available mimesource
100       factories. If the defaultFactory() can't resolve a data() it iterates
101       over the list of installed mimesource factories until the data can be
102       resolved.
103
104       See also removeFactory().
105

void QMimeSourceFactory::addFilePath ( const QString & p )

107       Adds another search path, p to the existing search paths.
108
109       See also setFilePath().
110

const QMimeSource * QMimeSourceFactory::data ( const QString & abs_name )

112       const [virtual]
113       Returns a reference to the data associated with abs_name. The return
114       value remains valid only until the next data() or setData() call, so
115       you should immediately decode the result.
116
117       If there is no data associated with abs_name in the factory's store,
118       the factory tries to access the local filesystem. If abs_name isn't an
119       absolute file name, the factory will search for it in all defined paths
120       (see setFilePath()).
121
122       The factory understands all the image formats supported by QImageIO.
123       Any other mime types are determined by the file name extension. The
124       default settings are
125
126           setExtensionType("html", "text/html;charset=iso8859-1");
127           setExtensionType("htm", "text/html;charset=iso8859-1");
128           setExtensionType("txt", "text/plain");
129           setExtensionType("xml", "text/xml;charset=UTF-8");
130       The effect of these is that file names ending in "txt" will be treated
131       as text encoded in the local encoding; those ending in" xml" will be
132       treated as text encoded in Unicode UTF-8 encoding. The text/html type
133       is treated specially, since the encoding can be specified in the html
134       file itself. "html" or "htm" will be treated as text encoded in the
135       encoding specified by the html meta tag, if none could be found, the
136       charset of the mime type will be used. The text subtype ("html",
137       "plain", or "xml") does not affect the factory, but users of the
138       factory may behave differently. We recommend creating "xml" files where
139       practical. These files can be viewed regardless of the runtime encoding
140       and can encode any Unicode characters without resorting to encoding
141       definitions inside the file.
142
143       Any file data that is not recognized will be retrieved as a QMimeSource
144       providing the "application/octet-stream" mime type, meaning
145       uninterpreted binary data.
146
147       You can add further extensions or change existing ones with subsequent
148       calls to setExtensionType(). If the extension mechanism is not
149       sufficient for your problem domain, you can inherit QMimeSourceFactory
150       and reimplement this function to perform some more specialized mime-
151       type detection. The same applies if you want to use the mime source
152       factory to access URL referenced data over a network.
153

const QMimeSource * QMimeSourceFactory::data ( const QString &

155       abs_or_rel_name, const QString & context ) const
156       This is an overloaded member function, provided for convenience. It
157       behaves essentially like the above function.
158
159       A convenience function. See data(const QString& abs_name). The file
160       name is given in abs_or_rel_name and the path is in context.
161

QMimeSourceFactory * QMimeSourceFactory::defaultFactory () [static]

163       Returns the application-wide default mime source factory. This factory
164       is used by rich text rendering classes such as QSimpleRichText,
165       QWhatsThis and QMessageBox to resolve named references within rich text
166       documents. It serves also as the initial factory for the more complex
167       render widgets, QTextEdit and QTextBrowser.
168
169       See also setDefaultFactory().
170
171       Examples:
172

QStringList QMimeSourceFactory::filePath () const [virtual]

174       Returns the currently set search paths.
175

QString QMimeSourceFactory::makeAbsolute ( const QString & abs_or_rel_name,

177       const QString & context ) const [virtual]
178       Converts the absolute or relative data item name abs_or_rel_name to an
179       absolute name, interpreted within the context (path) of the data item
180       named context (this must be an absolute name).
181

void QMimeSourceFactory::removeFactory ( QMimeSourceFactory * f ) [static]

183       Removes the mimesource factory f from the list of available mimesource
184       factories.
185
186       See also addFactory().
187

void QMimeSourceFactory::setData ( const QString & abs_name, QMimeSource *

189       data ) [virtual]
190       Sets data to be the data item associated with the absolute name
191       abs_name. Note that the ownership of data is transferred to the
192       factory: do not delete or access the pointer after passing it to this
193       function.
194
195       Passing 0 for data removes previously stored data.
196

void QMimeSourceFactory::setDefaultFactory ( QMimeSourceFactory * factory )

198       [static]
199       Sets the default factory, destroying any previously set mime source
200       provider. The ownership of the factory is transferred to Qt.
201
202       See also defaultFactory().
203

void QMimeSourceFactory::setExtensionType ( const QString & ext, const char *

205       mimetype ) [virtual]
206       Sets the mime-type to be associated with the file name extension, ext
207       to mimetype. This determines the mime-type for files found via the
208       paths set by setFilePath().
209

void QMimeSourceFactory::setFilePath ( const QStringList & path ) [virtual]

211       Sets the list of directories that will be searched when named data is
212       requested to the those given in the string list path.
213
214       See also filePath().
215

void QMimeSourceFactory::setImage ( const QString & abs_name, const QImage &

217       image ) [virtual]
218       Sets image to be the data item associated with the absolute name
219       abs_name.
220
221       Equivalent to setData(abs_name, new QImageDrag(image)).
222

void QMimeSourceFactory::setPixmap ( const QString & abs_name, const QPixmap &

224       pixmap ) [virtual]
225       Sets pixmap to be the data item associated with the absolute name
226       abs_name.
227

void QMimeSourceFactory::setText ( const QString & abs_name, const QString &

229       text ) [virtual]
230       Sets text to be the data item associated with the absolute name
231       abs_name.
232
233       Equivalent to setData(abs_name, new QTextDrag(text)).
234

QMimeSourceFactory * QMimeSourceFactory::takeDefaultFactory () [static]

236       Sets the defaultFactory() to 0 and returns the previous one.
237
238

SEE ALSO

240       http://doc.trolltech.com/qmimesourcefactory.html
241       http://www.trolltech.com/faq/tech.html
242
244       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
245       license file included in the distribution for a complete license
246       statement.
247

AUTHOR

249       Generated automatically from the source code.
250

BUGS

252       If you find a bug in Qt, please report it as described in
253       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
254       help you. Thank you.
255
256       The definitive Qt documentation is provided in HTML format; it is
257       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
258       web browser. This man page is provided as a convenience for those users
259       who prefer man pages, although this format is not officially supported
260       by Trolltech.
261
262       If you find errors in this manual page, please report them to qt-
263       bugs@trolltech.com.  Please include the name of the manual page
264       (qmimesourcefactory.3qt) and the Qt version (3.3.8).
265
266
267
268Trolltech AS                    2 February 2007        QMimeSourceFactory(3qt)
Impressum