Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > a6711891ce757817bba854bf3f25205a > files > 1887

qtjambi-doc-4.3.3-3mdv2008.1.i586.rpm

<class name="QAbstractFileEngineHandler" doc="/**
&lt;p&gt;The &lt;a href=&quot;QAbstractFileEngineHandler.html#QAbstractFileEngineHandler()&quot;&gt;&lt;tt&gt;QAbstractFileEngineHandler&lt;/tt&gt;&lt;/a&gt; class provides a way to register custom file engines with your application.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;QAbstractFileEngineHandler.html#QAbstractFileEngineHandler()&quot;&gt;&lt;tt&gt;QAbstractFileEngineHandler&lt;/tt&gt;&lt;/a&gt; is a factory for creating &lt;a href=&quot;QAbstractFileEngine.html&quot;&gt;&lt;tt&gt;QAbstractFileEngine&lt;/tt&gt;&lt;/a&gt; objects (file engines), which are used internally by &lt;a href=&quot;QFile.html&quot;&gt;&lt;tt&gt;QFile&lt;/tt&gt;&lt;/a&gt;, &lt;a href=&quot;QFileInfo.html&quot;&gt;&lt;tt&gt;QFileInfo&lt;/tt&gt;&lt;/a&gt;, and &lt;a href=&quot;QDir.html&quot;&gt;&lt;tt&gt;QDir&lt;/tt&gt;&lt;/a&gt; when working with files and directories.&lt;/p&gt;
&lt;p&gt;When you open a file, Qt chooses a suitable file engine by passing the file name from &lt;a href=&quot;QFile.html&quot;&gt;&lt;tt&gt;QFile&lt;/tt&gt;&lt;/a&gt; or &lt;a href=&quot;QDir.html&quot;&gt;&lt;tt&gt;QDir&lt;/tt&gt;&lt;/a&gt; through an internal list of registered file engine handlers. The first handler to recognize the file name is used to create the engine. Qt provides internal file engines for working with regular files and resources, but you can also register your own &lt;a href=&quot;QAbstractFileEngine.html&quot;&gt;&lt;tt&gt;QAbstractFileEngine&lt;/tt&gt;&lt;/a&gt; subclasses.&lt;/p&gt;
&lt;p&gt;To install an application-specific file engine, you subclass &lt;a href=&quot;QAbstractFileEngineHandler.html#QAbstractFileEngineHandler()&quot;&gt;&lt;tt&gt;QAbstractFileEngineHandler&lt;/tt&gt;&lt;/a&gt; and reimplement &lt;a href=&quot;QAbstractFileEngineHandler.html#create(java.lang.String)&quot;&gt;&lt;tt&gt;create&lt;/tt&gt;&lt;/a&gt;. When you instantiate the handler (e.g&amp;#x2e; by creating an instance on the stack or on the heap), it will automatically register with Qt. (The latest registered handler takes precedence over existing handlers.)&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre&gt;    class ZipEngineHandler : public QAbstractFileEngineHandler
    {
    public:
        QAbstractFileEngine *create(const QString &amp;amp;fileName) const;
    };

    QAbstractFileEngine *ZipEngineHandler::create(const QString &amp;amp;fileName) const
    {
        &lt;span class=&quot;comment&quot;&gt;// ZipEngineHandler returns a ZipEngine for all .zip files&lt;/span&gt;
        return fileName.toLower().endsWith(&amp;quot;.zip&amp;quot;) ? new ZipEngine(fileName) : 0;
    }

    int main(int argc, char **argv)
    {
        QApplication app(argc, argv);

        ZipEngineHandler engine;

        MainWindow window;
        window.show();

        return app.exec();
    }&lt;/pre&gt;
&lt;p&gt;When the handler is destroyed, it is automatically removed from Qt.&lt;/p&gt;
&lt;p&gt;The most common approach to registering a handler is to create an instance as part of the start-up phase of your application. It is also possible to limit the scope of the file engine handler to a particular area of interest (e.g&amp;#x2e; a special file dialog that needs a custom file engine). By creating the handler inside a local scope, you can precisely control the area in which your engine will be applied without disturbing file operations in other parts of your application.&lt;/p&gt;

@see &lt;a href=&quot;QAbstractFileEngine.html&quot;&gt;&lt;tt&gt;QAbstractFileEngine&lt;/tt&gt;&lt;/a&gt;
@see &lt;tt&gt;QAbstractFileEngine::create&lt;/tt&gt; */">
    <method name="public QAbstractFileEngineHandler()" doc="/**
&lt;p&gt;Constructs a file handler and registers it with Qt. Once created this handler's &lt;a href=&quot;QAbstractFileEngineHandler.html#create(java.lang.String)&quot;&gt;&lt;tt&gt;create&lt;/tt&gt;&lt;/a&gt; function will be called (along with all the other handlers) for any paths used. The most recently created handler that recognizes the given path (i.e&amp;#x2e; that returns a &lt;a href=&quot;QAbstractFileEngine.html&quot;&gt;&lt;tt&gt;QAbstractFileEngine&lt;/tt&gt;&lt;/a&gt;) is used for the new path.&lt;/p&gt;

@see &lt;a href=&quot;QAbstractFileEngineHandler.html#create(java.lang.String)&quot;&gt;&lt;tt&gt;create&lt;/tt&gt;&lt;/a&gt; */"/>
    <method name="public abstract com.trolltech.qt.core.QAbstractFileEngine create(java.lang.String fileName)" doc="/**
&lt;p&gt;Creates a file engine for file &lt;tt&gt;fileName&lt;/tt&gt;. Returns 0 if this file handler cannot handle &lt;tt&gt;fileName&lt;/tt&gt;.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;pre&gt;    QAbstractSocketEngine *ZipEngineHandler::create(const QString &amp;amp;fileName) const
    {
        &lt;span class=&quot;comment&quot;&gt;// ZipEngineHandler returns a ZipEngine for all .zip files&lt;/span&gt;
        return fileName.toLower().endsWith(&amp;quot;.zip&amp;quot;) ? new ZipEngine(fileName) : 0;
    }&lt;/pre&gt;

@see &lt;tt&gt;QAbstractFileEngine::create&lt;/tt&gt; */"/>
</class>