File: qmimesourcefactory.html

package info (click to toggle)
qt-embedded 2.3.2-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 68,608 kB
  • ctags: 45,998
  • sloc: cpp: 276,654; ansic: 71,987; makefile: 29,074; sh: 12,305; yacc: 2,465; python: 1,863; perl: 481; lex: 480; xml: 68; lisp: 15
file content (193 lines) | stat: -rw-r--r-- 13,694 bytes parent folder | download
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QMimeSourceFactory Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">

<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>

<h1 align=center>QMimeSourceFactory Class Reference</h1><br clear="all">
<p>
An extensible supply of MIME-typed data.
<a href="#details">More...</a>
<p>
<code>#include &lt;<a href="qmime-h.html">qmime.h</a>&gt;</code>
<p><a href="qmimesourcefactory-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#e6d779"><b>QMimeSourceFactory</b></a>()</div>
<li><div class="fn">virtual<a href="#62d312"><b>~QMimeSourceFactory</b></a>()</div>
<li><div class="fn">virtualconstQMimeSource*<a href="#91bb48"><b>data</b></a>(constQString&amp;abs_name)const</div>
<li><div class="fn">virtualQString<a href="#83807a"><b>makeAbsolute</b></a>(constQString&amp;abs_or_rel_name, constQString&amp;context)const</div>
<li><div class="fn">constQMimeSource*<a href="#ca43af"><b>data</b></a>(constQString&amp;abs_or_rel_name, constQString&amp;context)const</div>
<li><div class="fn">virtualvoid<a href="#f9a521"><b>setText</b></a>(constQString&amp;abs_name, constQString&amp;text)</div>
<li><div class="fn">virtualvoid<a href="#98a0a3"><b>setImage</b></a>(constQString&amp;abs_name, constQImage&amp;im)</div>
<li><div class="fn">virtualvoid<a href="#b37381"><b>setPixmap</b></a>(constQString&amp;abs_name, constQPixmap&amp;pm)</div>
<li><div class="fn">virtualvoid<a href="#f56560"><b>setData</b></a>(constQString&amp;abs_name, QMimeSource*data)</div>
<li><div class="fn">virtualvoid<a href="#0ba422"><b>setFilePath</b></a>(constQStringList&amp;)</div>
<li><div class="fn">virtualQStringList<a href="#65f831"><b>filePath</b></a>()const</div>
<li><div class="fn">void<a href="#817ef6"><b>addFilePath</b></a>(constQString&amp;)</div>
<li><div class="fn">virtualvoid<a href="#02e77d"><b>setExtensionType</b></a>(constQString&amp;ext, constchar*mimetype)</div>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class="fn">QMimeSourceFactory*<a href="#5c7072"><b>defaultFactory</b></a>()</div>
<li><div class="fn">void<a href="#c76f04"><b>setDefaultFactory</b></a>(QMimeSourceFactory*)</div>
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
An extensible supply of MIME-typed data.
<p>
A QMimeSourceFactory provides an abstract interface to a collection of
information.  Each piece of information is represented by a <a href="qmimesource.html">QMimeSource</a>
object, which can be examined and converted to concrete data types by
functions like <a href="qimagedrag.html#c35128">QImageDrag::canDecode</a>() and <a href="qimagedrag.html#037fd2">QImageDrag::decode</a>().
<p>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 <a href="#0ba422">setFilePath</a>() before accessing data.  For stored data, call
<a href="#f56560">setData</a>() for each item (there are also convenience functions <a href="#f9a521">setText</a>(),
<a href="#98a0a3">setImage</a>(), and <a href="#b37381">setPixmap</a>() that simply call setData() with massaged
parameters).
<p>The rich text widgets <a href="qtextview.html">QTextView</a> and <a href="qtextbrowser.html">QTextBrowser</a> use
QMimeSourceFactory to resolve references such as images or links
within rich text documents. They either access the default factory (
see <a href="#5c7072">defaultFactory</a>() ) or their own ( see
<a href="qtextview.html#8d1f6b">QTextView::setMimeSourceFactory</a>() ). Other classes that are capable
of displaying rich text like <a href="qlabel.html">QLabel</a>, <a href="qwhatsthis.html">QWhatsThis</a> or <a href="qmessagebox.html">QMessageBox</a>
always use the default factory.
<p>As mentioned earlier, a factory can also be used as 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
<p><pre>  static const char* myimage_xpm[]={
  "...",
  ...
  "..."};
</pre>
<p>To be able to use this image within some rich text, for example inside a
QLabel, you have to create a <a href="qimage.html">QImage</a> from the raw data and insert it
into the factory with a unique name:
<p><pre>  <a href="#5c7072">QMimeSourceFactory::defaultFactory</a>()-&gt;setImage( "myimage", QImage(myimage_data) );
</pre>
<p>Now you can create a rich text QLabel with
<p><pre>  <a href="qlabel.html">QLabel</a>* label = new <a href="qlabel.html">QLabel</a>(
      "Rich text with embedded image:&lt;img source=\"myimage\"&gt;"
      "Isn't that &lt;em&gt;cute&lt;/em&gt;?" );
</pre>

<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="e6d779"></a>QMimeSourceFactory::QMimeSourceFactory()</h3>
<p>Constructs a QMimeSourceFactory which has no file path and no stored
content.
<h3 class="fn"><a name="62d312"></a>QMimeSourceFactory::~QMimeSourceFactory() <code>[virtual]</code></h3>
<p>Destructs the QMimeSourceFactory, deleting all stored content.
<h3 class="fn">void<a name="817ef6"></a>QMimeSourceFactory::addFilePath(const<a href="qstring.html">QString</a>&amp;p)</h3>
<p>Adds another search path.
<p>See also  <a href="#0ba422">setFilePath</a>().
<h3 class="fn">const<a href="qmimesource.html">QMimeSource</a>*<a name="91bb48"></a>QMimeSourceFactory::data(const<a href="qstring.html">QString</a>&amp;abs_name)const <code>[virtual]</code></h3>
<p>Returns a reference to the data associated with <em>abs_name.</em>  The return
value only remains valid until a subsequent call to this function for
the same object, and only if <a href="#f56560">setData</a>() is not called to modify the data,
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 filename, the factory will search for it
on all defined paths ( see <a href="#0ba422">setFilePath</a>() ).
<p>The factory understands all image formats supported by
<a href="qimageio.html">QImageIO</a>. Any other mime types are determined by the filename
extension. The default settings are
<pre>  setExtensionType("html", "text/html;charset=iso8859-1");
  setExtensionType("htm", "text/html;charset=iso8859-1");
  setExtensionType("txt", "text/plain");
  setExtensionType("xml", "text/xml;charset=UTF-8");
</pre>
<p>The effect of these is that filenames ending in "html" or "htm" will
be treated as text encoded in the iso8859-1 encoding, those ending in "txt"
will be treated as text encoded in the local encoding; those ending in "xml"
will be treated as text encoded in UTF8 encoding.  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
as such files can be viewed regardless of the run-time 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="qmimesource.html">QMimeSource</a>
providing the "application/octet-stream" MIME type, which is just
uninterpreted binary data.
You can add further extensions or change existing ones with
subsequent calls to <a href="#02e77d">setExtensionType</a>(). If the extension mechanism
is not sufficient for you problem domain, you may inherit
QMimeSourceFactory and reimplement this function to perform some
more clever mime type detection. The same applies if you want to use
the mime source factory for accessing URL referenced data over a
network.
<h3 class="fn">const<a href="qmimesource.html">QMimeSource</a>*<a name="ca43af"></a>QMimeSourceFactory::data(const<a href="qstring.html">QString</a>&amp;abs_or_rel_name, const<a href="qstring.html">QString</a>&amp;context)const</h3>
<p>A convenience function. See <a href="#91bb48">data</a>(const <a href="qstring.html">QString</a>& abs_name).
<h3 class="fn">QMimeSourceFactory*<a name="5c7072"></a>QMimeSourceFactory::defaultFactory() <code>[static]</code></h3>
<p>Returns the application-wide default mime source factory. This
factory is used by rich text rendering classes such as
<a href="qsimplerichtext.html">QSimpleRichText</a>, <a href="qwhatsthis.html">QWhatsThis</a> and also <a href="qmessagebox.html">QMessageBox</a> to resolve named
references within rich text documents. It serves also as initial
factory for the more complex render widgets <a href="qtextview.html">QTextView</a> and
<a href="qtextbrowser.html">QTextBrowser</a>.
<p>See also  <a href="#c76f04">setDefaultFactory</a>().
<h3 class="fn"><a href="qstringlist.html">QStringList</a><a name="65f831"></a>QMimeSourceFactory::filePath()const <code>[virtual]</code></h3>
<p>Returns the currently set search paths.
<h3 class="fn"><a href="qstring.html">QString</a><a name="83807a"></a>QMimeSourceFactory::makeAbsolute(const<a href="qstring.html">QString</a>&amp;abs_or_rel_name, const<a href="qstring.html">QString</a>&amp;context)const <code>[virtual]</code></h3>
<p>Converts the absolute or relative data item name <em>abs_or_rel_name</em>
to an absolute name, interpreted within the context of the data
item named <em>context</em> (this must be an absolute name).
<h3 class="fn">void<a name="f56560"></a>QMimeSourceFactory::setData(const<a href="qstring.html">QString</a>&amp;abs_name, <a href="qmimesource.html">QMimeSource</a>*data) <code>[virtual]</code></h3>
<p>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.
<h3 class="fn">void<a name="c76f04"></a>QMimeSourceFactory::setDefaultFactory(QMimeSourceFactory*factory) <code>[static]</code></h3>
<p>Sets the default <em>factory,</em> destroying any previously set mime source
provider. The ownership of the factory is transferred.
<p>See also  <a href="#5c7072">defaultFactory</a>().
<h3 class="fn">void<a name="02e77d"></a>QMimeSourceFactory::setExtensionType(const<a href="qstring.html">QString</a>&amp;ext, constchar*mimetype) <code>[virtual]</code></h3>
<p>Sets the MIME-type to be associated with a filename extension.  This
determines the MIME-type for files found via a path set by <a href="#0ba422">setFilePath</a>().
<h3 class="fn">void<a name="0ba422"></a>QMimeSourceFactory::setFilePath(const<a href="qstringlist.html">QStringList</a>&amp;path) <code>[virtual]</code></h3>
<p>Sets a list of directories which will be searched when named data
is requested.
<p>See also  <a href="#65f831">filePath</a>().
<h3 class="fn">void<a name="98a0a3"></a>QMimeSourceFactory::setImage(const<a href="qstring.html">QString</a>&amp;abs_name, const<a href="qimage.html">QImage</a>&amp;image) <code>[virtual]</code></h3>
<p>Sets <em>image</em> to be the data item associated with
the absolute name <em>abs_name.</em>
<p>Equivalent to <a href="#f56560">setData</a>(abs_name, new <a href="qimagedrag.html">QImageDrag</a>(image)).
<h3 class="fn">void<a name="b37381"></a>QMimeSourceFactory::setPixmap(const<a href="qstring.html">QString</a>&amp;abs_name, const<a href="qpixmap.html">QPixmap</a>&amp;pixmap) <code>[virtual]</code></h3>
<p>Sets <em>pixmap</em> to be the data item associated with
the absolute name <em>abs_name.</em>
<h3 class="fn">void<a name="f9a521"></a>QMimeSourceFactory::setText(const<a href="qstring.html">QString</a>&amp;abs_name, const<a href="qstring.html">QString</a>&amp;text) <code>[virtual]</code></h3>
<p>Sets <em>text</em> to be the data item associated with
the absolute name <em>abs_name.</em>
<p>Equivalent to <a href="#f56560">setData</a>(abs_name, new <a href="qtextdrag.html">QTextDrag</a>(text)).
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright &copy; 1995-2001
<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  2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>