You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
278 lines
17 KiB
278 lines
17 KiB
13 years ago
|
<!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/qmime.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="qmime-h.html">qmime.h</a>></tt>
|
||
|
<p><a href="qmimesourcefactory-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="qmimesource.html">TQMimeSource</a> object which can be examined and
|
||
|
converted to concrete data types by functions such as
|
||
|
<a href="qimagedrag.html#canDecode">TQImageDrag::canDecode</a>() and <a href="qimagedrag.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="qtextedit.html">TQTextEdit</a> and <a href="qtextbrowser.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="qtextedit.html#setMimeSourceFactory">TQTextEdit::setMimeSourceFactory</a>()). Other classes that are
|
||
|
capable of displaying rich text (such as <a href="qlabel.html">TQLabel</a>, <a href="qwhatsthis.html">TQWhatsThis</a> or
|
||
|
<a href="qmessagebox.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="qimage.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="qlabel.html">TQLabel</a>* label = new <a href="qlabel.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="qmimesourcefactory.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="qstring.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="qmimesource.html">TQMimeSource</a> * <a name="data"></a>TQMimeSourceFactory::data ( const <a href="qstring.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="qimageio.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="qmimesource.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="qmimesource.html">TQMimeSource</a> * <a name="data-2"></a>TQMimeSourceFactory::data ( const <a href="qstring.html">TQString</a> & abs_or_rel_name, const <a href="qstring.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="qstring.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="qmimesourcefactory.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="qsimplerichtext.html">TQSimpleRichText</a>, <a href="qwhatsthis.html">TQWhatsThis</a> and <a href="qmessagebox.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="qtextedit.html">TQTextEdit</a> and
|
||
|
<a href="qtextbrowser.html">TQTextBrowser</a>.
|
||
|
<p> <p>See also <a href="#setDefaultFactory">setDefaultFactory</a>().
|
||
|
|
||
|
<p>Examples: <a href="qaction-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="qstringlist.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="qstring.html">TQString</a> <a name="makeAbsolute"></a>TQMimeSourceFactory::makeAbsolute ( const <a href="qstring.html">TQString</a> & abs_or_rel_name, const <a href="qstring.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="qmimesourcefactory.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="qstring.html">TQString</a> & abs_name, <a href="qmimesource.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="qmimesourcefactory.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="qstring.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="qstringlist.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="qstring.html">TQString</a> & abs_name, const <a href="qimage.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="qimagedrag.html">TQImageDrag</a>(image)).
|
||
|
|
||
|
<h3 class=fn>void <a name="setPixmap"></a>TQMimeSourceFactory::setPixmap ( const <a href="qstring.html">TQString</a> & abs_name, const <a href="qpixmap.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="qstring.html">TQString</a> & abs_name, const <a href="qstring.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="qtextdrag.html">TQTextDrag</a>(text)).
|
||
|
|
||
|
<h3 class=fn><a href="qmimesourcefactory.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>
|