1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/tqmime.cpp:179 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQMimeSourceFactory Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQMimeSourceFactory Class Reference</h1>
<p>The TQMimeSourceFactory class is an extensible provider of mime-typed data.
<a href="#details">More...</a>
<p><tt>#include <<a href="tqmime-h.html">tqmime.h</a>></tt>
<p><a href="tqmimesourcefactory-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQMimeSourceFactory"><b>TQMimeSourceFactory</b></a> ()</li>
<li class=fn>virtual <a href="#~TQMimeSourceFactory"><b>~TQMimeSourceFactory</b></a> ()</li>
<li class=fn>virtual const TQMimeSource * <a href="#data"><b>data</b></a> ( const TQString & abs_name ) const</li>
<li class=fn>virtual TQString <a href="#makeAbsolute"><b>makeAbsolute</b></a> ( const TQString & abs_or_rel_name, const TQString & context ) const</li>
<li class=fn>const TQMimeSource * <a href="#data-2"><b>data</b></a> ( const TQString & abs_or_rel_name, const TQString & context ) const</li>
<li class=fn>virtual void <a href="#setText"><b>setText</b></a> ( const TQString & abs_name, const TQString & text )</li>
<li class=fn>virtual void <a href="#setImage"><b>setImage</b></a> ( const TQString & abs_name, const TQImage & image )</li>
<li class=fn>virtual void <a href="#setPixmap"><b>setPixmap</b></a> ( const TQString & abs_name, const TQPixmap & pixmap )</li>
<li class=fn>virtual void <a href="#setData"><b>setData</b></a> ( const TQString & abs_name, TQMimeSource * data )</li>
<li class=fn>virtual void <a href="#setFilePath"><b>setFilePath</b></a> ( const TQStringList & path )</li>
<li class=fn>virtual TQStringList <a href="#filePath"><b>filePath</b></a> () const</li>
<li class=fn>void <a href="#addFilePath"><b>addFilePath</b></a> ( const TQString & p )</li>
<li class=fn>virtual void <a href="#setExtensionType"><b>setExtensionType</b></a> ( const TQString & ext, const char * mimetype )</li>
</ul>
<h2>Static Public Members</h2>
<ul>
<li class=fn>TQMimeSourceFactory * <a href="#defaultFactory"><b>defaultFactory</b></a> ()</li>
<li class=fn>void <a href="#setDefaultFactory"><b>setDefaultFactory</b></a> ( TQMimeSourceFactory * factory )</li>
<li class=fn>TQMimeSourceFactory * <a href="#takeDefaultFactory"><b>takeDefaultFactory</b></a> ()</li>
<li class=fn>void <a href="#addFactory"><b>addFactory</b></a> ( TQMimeSourceFactory * f )</li>
<li class=fn>void <a href="#removeFactory"><b>removeFactory</b></a> ( TQMimeSourceFactory * f )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQMimeSourceFactory class is an extensible provider of mime-typed data.
<p>
<p> A TQMimeSourceFactory provides an abstract interface to a
collection of information. Each piece of information is
represented by a <a href="tqmimesource.html">TQMimeSource</a> object which can be examined and
converted to concrete data types by functions such as
<a href="tqimagedrag.html#canDecode">TQImageDrag::canDecode</a>() and <a href="tqimagedrag.html#decode">TQImageDrag::decode</a>().
<p> 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 <a href="#setFilePath">setFilePath</a>() before accessing
data. For stored data, call <a href="#setData">setData</a>() for each item (there are
also convenience functions, e.g. <a href="#setText">setText</a>(), <a href="#setImage">setImage</a>() and
<a href="#setPixmap">setPixmap</a>(), that simply call setData() with appropriate
parameters).
<p> The rich text widgets, <a href="tqtextedit.html">TQTextEdit</a> and <a href="tqtextbrowser.html">TQTextBrowser</a>, use
TQMimeSourceFactory to resolve references such as images or links
within rich text documents. They either access the default factory
(see <a href="#defaultFactory">defaultFactory</a>()) or their own (see
<a href="tqtextedit.html#setMimeSourceFactory">TQTextEdit::setMimeSourceFactory</a>()). Other classes that are
capable of displaying rich text (such as <a href="ntqlabel.html">TQLabel</a>, <a href="ntqwhatsthis.html">TQWhatsThis</a> or
<a href="ntqmessagebox.html">TQMessageBox</a>) always use the default factory.
<p> 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:
<pre>
static const char* myimage_data[]={
"...",
...
"..."};
</pre>
<p> To be able to use this image within some rich text, for example
inside a TQLabel, you must create a <a href="tqimage.html">TQImage</a> from the raw data and
insert it into the factory with a unique name:
<pre>
TQMimeSourceFactory::<a href="#defaultFactory">defaultFactory</a>()->setImage( "myimage", TQImage(myimage_data) );
</pre>
<p> Now you can create a rich text TQLabel with
<p> <pre>
<a href="ntqlabel.html">TQLabel</a>* label = new <a href="ntqlabel.html">TQLabel</a>(
"Rich text with embedded image:<img source=\"myimage\">"
"Isn't that <em>cute</em>?" );
</pre>
<p> When no longer needed, you can clear the data from the factory:
<p> <pre>
delete label;
TQMimeSourceFactory::<a href="#defaultFactory">defaultFactory</a>()->setData( "myimage", 0 );
</pre>
<p>See also <a href="environment.html">Environment Classes</a> and <a href="io.html">Input/Output and Networking</a>.
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQMimeSourceFactory"></a>TQMimeSourceFactory::TQMimeSourceFactory ()
</h3>
Constructs a TQMimeSourceFactory that has no file path and no
stored content.
<h3 class=fn><a name="~TQMimeSourceFactory"></a>TQMimeSourceFactory::~TQMimeSourceFactory ()<tt> [virtual]</tt>
</h3>
Destroys the TQMimeSourceFactory, deleting all stored content.
<h3 class=fn>void <a name="addFactory"></a>TQMimeSourceFactory::addFactory ( <a href="tqmimesourcefactory.html">TQMimeSourceFactory</a> * f )<tt> [static]</tt>
</h3>
Adds the TQMimeSourceFactory <em>f</em> to the list of available
mimesource factories. If the <a href="#defaultFactory">defaultFactory</a>() can't resolve a
<a href="#data">data</a>() it iterates over the list of installed mimesource factories
until the data can be resolved.
<p> <p>See also <a href="#removeFactory">removeFactory</a>().
<h3 class=fn>void <a name="addFilePath"></a>TQMimeSourceFactory::addFilePath ( const <a href="tqstring.html">TQString</a> & p )
</h3>
Adds another search path, <em>p</em> to the existing search paths.
<p> <p>See also <a href="#setFilePath">setFilePath</a>().
<h3 class=fn>const <a href="tqmimesource.html">TQMimeSource</a> * <a name="data"></a>TQMimeSourceFactory::data ( const <a href="tqstring.html">TQString</a> & abs_name ) const<tt> [virtual]</tt>
</h3>
Returns a reference to the data associated with <em>abs_name</em>. The
return value remains valid only until the next <a href="#data">data</a>() or <a href="#setData">setData</a>()
call, so you should immediately decode the result.
<p> If there is no data associated with <em>abs_name</em> in the factory's
store, the factory tries to access the local filesystem. If <em>abs_name</em> isn't an absolute file name, the factory will search for
it in all defined paths (see <a href="#setFilePath">setFilePath</a>()).
<p> The factory understands all the image formats supported by
<a href="tqimageio.html">TQImageIO</a>. Any other mime types are determined by the file name
extension. The default settings are
<pre>
<a href="#setExtensionType">setExtensionType</a>("html", "text/html;charset=iso8859-1");
<a href="#setExtensionType">setExtensionType</a>("htm", "text/html;charset=iso8859-1");
<a href="#setExtensionType">setExtensionType</a>("txt", "text/plain");
<a href="#setExtensionType">setExtensionType</a>("xml", "text/xml;charset=UTF-8");
</pre>
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.
<p> Any file data that is not recognized will be retrieved as a
<a href="tqmimesource.html">TQMimeSource</a> providing the "application/octet-stream" mime type,
meaning uninterpreted binary data.
<p> You can add further extensions or change existing ones with
subsequent calls to <a href="#setExtensionType">setExtensionType</a>(). 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.
<h3 class=fn>const <a href="tqmimesource.html">TQMimeSource</a> * <a name="data-2"></a>TQMimeSourceFactory::data ( const <a href="tqstring.html">TQString</a> & abs_or_rel_name, const <a href="tqstring.html">TQString</a> & context ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> A convenience function. See <a href="#data">data</a>(const <a href="tqstring.html">TQString</a>& abs_name). The
file name is given in <em>abs_or_rel_name</em> and the path is in <em>context</em>.
<h3 class=fn><a href="tqmimesourcefactory.html">TQMimeSourceFactory</a> * <a name="defaultFactory"></a>TQMimeSourceFactory::defaultFactory ()<tt> [static]</tt>
</h3>
Returns the application-wide default mime source factory. This
factory is used by rich text rendering classes such as
<a href="ntqsimplerichtext.html">TQSimpleRichText</a>, <a href="ntqwhatsthis.html">TQWhatsThis</a> and <a href="ntqmessagebox.html">TQMessageBox</a> to resolve named
references within rich text documents. It serves also as the
initial factory for the more complex render widgets, <a href="tqtextedit.html">TQTextEdit</a> and
<a href="tqtextbrowser.html">TQTextBrowser</a>.
<p> <p>See also <a href="#setDefaultFactory">setDefaultFactory</a>().
<p>Examples: <a href="tqaction-application-example.html#x1140">action/application.cpp</a> and <a href="simple-application-example.html#x1558">application/application.cpp</a>.
<h3 class=fn><a href="tqstringlist.html">TQStringList</a> <a name="filePath"></a>TQMimeSourceFactory::filePath () const<tt> [virtual]</tt>
</h3>
Returns the currently set search paths.
<h3 class=fn><a href="tqstring.html">TQString</a> <a name="makeAbsolute"></a>TQMimeSourceFactory::makeAbsolute ( const <a href="tqstring.html">TQString</a> & abs_or_rel_name, const <a href="tqstring.html">TQString</a> & context ) const<tt> [virtual]</tt>
</h3>
Converts the absolute or relative data item name <em>abs_or_rel_name</em> to an absolute name, interpreted within the
context (path) of the data item named <em>context</em> (this must be an
absolute name).
<h3 class=fn>void <a name="removeFactory"></a>TQMimeSourceFactory::removeFactory ( <a href="tqmimesourcefactory.html">TQMimeSourceFactory</a> * f )<tt> [static]</tt>
</h3>
Removes the mimesource factory <em>f</em> from the list of available
mimesource factories.
<p> <p>See also <a href="#addFactory">addFactory</a>().
<h3 class=fn>void <a name="setData"></a>TQMimeSourceFactory::setData ( const <a href="tqstring.html">TQString</a> & abs_name, <a href="tqmimesource.html">TQMimeSource</a> * data )<tt> [virtual]</tt>
</h3>
Sets <em>data</em> to be the data item associated with
the absolute name <em>abs_name</em>. Note that the ownership of <em>data</em> is
transferred to the factory: do not delete or access the pointer after
passing it to this function.
<p> Passing 0 for data removes previously stored data.
<h3 class=fn>void <a name="setDefaultFactory"></a>TQMimeSourceFactory::setDefaultFactory ( <a href="tqmimesourcefactory.html">TQMimeSourceFactory</a> * factory )<tt> [static]</tt>
</h3>
Sets the default <em>factory</em>, destroying any previously set mime
source provider. The ownership of the factory is transferred to
TQt.
<p> <p>See also <a href="#defaultFactory">defaultFactory</a>().
<h3 class=fn>void <a name="setExtensionType"></a>TQMimeSourceFactory::setExtensionType ( const <a href="tqstring.html">TQString</a> & ext, const char * mimetype )<tt> [virtual]</tt>
</h3>
Sets the mime-type to be associated with the file name extension,
<em>ext</em> to <em>mimetype</em>. This determines the mime-type for files
found via the paths set by <a href="#setFilePath">setFilePath</a>().
<h3 class=fn>void <a name="setFilePath"></a>TQMimeSourceFactory::setFilePath ( const <a href="tqstringlist.html">TQStringList</a> & path )<tt> [virtual]</tt>
</h3>
Sets the list of directories that will be searched when named data
is requested to the those given in the string list <em>path</em>.
<p> <p>See also <a href="#filePath">filePath</a>().
<h3 class=fn>void <a name="setImage"></a>TQMimeSourceFactory::setImage ( const <a href="tqstring.html">TQString</a> & abs_name, const <a href="tqimage.html">TQImage</a> & image )<tt> [virtual]</tt>
</h3>
Sets <em>image</em> to be the data item associated with the absolute
name <em>abs_name</em>.
<p> Equivalent to <a href="#setData">setData</a>(abs_name, new <a href="tqimagedrag.html">TQImageDrag</a>(image)).
<h3 class=fn>void <a name="setPixmap"></a>TQMimeSourceFactory::setPixmap ( const <a href="tqstring.html">TQString</a> & abs_name, const <a href="ntqpixmap.html">TQPixmap</a> & pixmap )<tt> [virtual]</tt>
</h3>
Sets <em>pixmap</em> to be the data item associated with the absolute
name <em>abs_name</em>.
<h3 class=fn>void <a name="setText"></a>TQMimeSourceFactory::setText ( const <a href="tqstring.html">TQString</a> & abs_name, const <a href="tqstring.html">TQString</a> & text )<tt> [virtual]</tt>
</h3>
Sets <em>text</em> to be the data item associated with the absolute name
<em>abs_name</em>.
<p> Equivalent to <a href="#setData">setData</a>(abs_name, new <a href="tqtextdrag.html">TQTextDrag</a>(text)).
<h3 class=fn><a href="tqmimesourcefactory.html">TQMimeSourceFactory</a> * <a name="takeDefaultFactory"></a>TQMimeSourceFactory::takeDefaultFactory ()<tt> [static]</tt>
</h3>
Sets the <a href="#defaultFactory">defaultFactory</a>() to 0 and returns the previous one.
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright © 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright © 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>
|