📄 qmimesourcefactory.3qt
字号:
'\" t.TH QMimeSourceFactory 3qt "11 October 2001" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQMimeSourceFactory \- Extensible provider of mime-typed data.PP\fC#include <qmime.h>\fR.PP.SS "Public Members".in +1c.ti -1c.BI "\fBQMimeSourceFactory\fR ()".br.ti -1c.BI "virtual \fB~QMimeSourceFactory\fR ()".br.ti -1c.BI "virtual const QMimeSource * \fBdata\fR ( const QString & abs_name ) const".br.ti -1c.BI "virtual QString \fBmakeAbsolute\fR ( const QString & abs_or_rel_name, const QString & context ) const".br.ti -1c.BI "const QMimeSource * \fBdata\fR ( const QString & abs_or_rel_name, const QString & context ) const".br.ti -1c.BI "virtual void \fBsetText\fR ( const QString & abs_name, const QString & text )".br.ti -1c.BI "virtual void \fBsetImage\fR ( const QString & abs_name, const QImage & image )".br.ti -1c.BI "virtual void \fBsetPixmap\fR ( const QString & abs_name, const QPixmap & pixmap )".br.ti -1c.BI "virtual void \fBsetData\fR ( const QString & abs_name, QMimeSource * data )".br.ti -1c.BI "virtual void \fBsetFilePath\fR ( const QStringList & path )".br.ti -1c.BI "virtual QStringList \fBfilePath\fR () const".br.ti -1c.BI "void \fBaddFilePath\fR ( const QString & p )".br.ti -1c.BI "virtual void \fBsetExtensionType\fR ( const QString & ext, const char * mimetype )".br.in -1c.SS "Static Public Members".in +1c.ti -1c.BI "QMimeSourceFactory * \fBdefaultFactory\fR ()".br.ti -1c.BI "void \fBsetDefaultFactory\fR ( QMimeSourceFactory * factory )".br.ti -1c.BI "QMimeSourceFactory * \fBtakeDefaultFactory\fR ()".br.ti -1c.BI "void \fBaddFactory\fR ( QMimeSourceFactory * f )".br.ti -1c.BI "void \fBremoveFactory\fR ( QMimeSourceFactory * f )".br.in -1c.SH DESCRIPTIONThe QMimeSourceFactory class is an extensible provider of mime-typed data..PPA QMimeSourceFactory provides an abstract interface to a collection of information. Each piece of information is represented by a QMimeSource object which can be examined and converted to concrete data types by functions such as QImageDrag::canDecode() and QImageDrag::decode()..PPThe 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 setFilePath() before accessing data. For stored data, call setData() for each item (there are also convenience functions setText(), setImage(), and setPixmap() that simply call setData() with massaged parameters)..PPThe rich text widgets QTextEdit and QTextBrowser use QMimeSourceFactory to resolve references such as images or links within rich text documents. They either access the default factory (see defaultFactory()) or their own (see QTextEdit::setMimeSourceFactory()). Other classes that are capable of displaying rich text (such as QLabel, QWhatsThis or QMessageBox) always use the default factory..PPAs 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.PP.nf.brstatic const char* myimage_data[]={".br...",.br...".br..."};.fi.PPTo be able to use this image within some rich text, for example inside a QLabel, you have to create a QImage from the raw data and insert it into the factory with a unique name:.PP.nf.brQMimeSourceFactory::defaultFactory()->setImage( "myimage", QImage(myimage_data) );.fi.PPNow you can create a rich text QLabel with.PP.nf.brQLabel* label = new QLabel(.br "Rich text with embedded image:<img source=\\"myimage\\">".br "Isn't that <em>cute</em>?" );.fi.PPSee also Environment Classes and Input/Output and Networking..SH MEMBER FUNCTION DOCUMENTATION.SH "QMimeSourceFactory::QMimeSourceFactory ()"Constructs a QMimeSourceFactory that has no file path and no stored content..SH "QMimeSourceFactory::~QMimeSourceFactory ()\fC [virtual]\fR"Destroys the QMimeSourceFactory, deleting all stored content..SH "void QMimeSourceFactory::addFactory ( QMimeSourceFactory * f )\fC [static]\fR"Adds the QMimeSourceFactory \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..PPSee also removeFactory()..SH "void QMimeSourceFactory::addFilePath ( const QString & p )"Adds another search path, \fIp\fR to the existing search paths..PPSee also setFilePath()..SH "const QMimeSource * QMimeSourceFactory::data ( const QString & 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..PPIf 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 on all defined paths (see setFilePath())..PPThe factory understands all image formats supported by QImageIO. Any other mime types are determined by the file name extension. The default settings are.PP.nf.brsetExtensionType("html", "text/html;charset=iso8859-1");.brsetExtensionType("htm", "text/html;charset=iso8859-1");.brsetExtensionType("txt", "text/plain");.brsetExtensionType("xml", "text/xml;charset=UTF-8");.fiThe effect of these is that file names 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 the 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. These files can be viewed regardless of the runtime encoding and can encode any Unicode characters without resorting to encoding definitions inside the file..PPAny file data that is not recognized will be retrieved as a QMimeSource providing the "application/octet-stream" mime type, meaning uninterpreted binary data..PPYou 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 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 to access URL referenced data over a network..SH "const QMimeSource * QMimeSourceFactory::data ( const QString & abs_or_rel_name, const QString & context ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPA convenience function. See data(const QString& abs_name). The file name is given in \fIabs_or_rel_name\fR and the path is in \fIcontext\fR..SH "QMimeSourceFactory * QMimeSourceFactory::defaultFactory ()\fC [static]\fR"Returns the application-wide default mime source factory. This factory is used by rich text rendering classes such as QSimpleRichText, QWhatsThis and QMessageBox to resolve named references within rich text documents. It serves also as initial factory for the more complex render widgets QTextEdit and QTextBrowser..PPSee also setDefaultFactory()..PPExamples:.)l action/application.cpp and application/application.cpp..SH "QStringList QMimeSourceFactory::filePath () const\fC [virtual]\fR"Returns the currently set search paths..SH "QString QMimeSourceFactory::makeAbsolute ( const QString & abs_or_rel_name, const QString & 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 QMimeSourceFactory::removeFactory ( QMimeSourceFactory * f )\fC [static]\fR"Removes the mimesource factory \fIf\fR from the list of available mimesource factories..PPSee also addFactory()..SH "void QMimeSourceFactory::setData ( const QString & abs_name, QMimeSource * 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..SH "void QMimeSourceFactory::setDefaultFactory ( QMimeSourceFactory * factory )\fC [static]\fR"Sets the default \fIfactory\fR, destroying any previously set mime source provider. The ownership of the factory is transferred..PPSee also defaultFactory()..SH "void QMimeSourceFactory::setExtensionType ( const QString & 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 QMimeSourceFactory::setFilePath ( const QStringList & 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..PPSee also filePath()..SH "void QMimeSourceFactory::setImage ( const QString & abs_name, const QImage & image )\fC [virtual]\fR"Sets \fIimage\fR to be the data item associated with the absolute name \fIabs_name\fR..PPEquivalent to setData(abs_name, new QImageDrag(image))..SH "void QMimeSourceFactory::setPixmap ( const QString & abs_name, const QPixmap & pixmap )\fC [virtual]\fR"Sets \fIpixmap\fR to be the data item associated with the absolute name \fIabs_name\fR..SH "void QMimeSourceFactory::setText ( const QString & abs_name, const QString & text )\fC [virtual]\fR"Sets \fItext\fR to be the data item associated with the absolute name \fIabs_name\fR..PPEquivalent to setData(abs_name, new QTextDrag(text))..SH "QMimeSourceFactory * QMimeSourceFactory::takeDefaultFactory ()\fC [static]\fR"Sets the defaultFactory() to 0 and returns the previous one. .SH "SEE ALSO".BR http://doc.trolltech.com/qmimesourcefactory.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf 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..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qmimesourcefactory.3qt) and the Qtversion (3.0.0).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -