Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.core
Class QAbstractFileEngineHandler

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.core.QAbstractFileEngineHandler

All Implemented Interfaces:
  QtJambiInterface

    public abstract class QAbstractFileEngineHandler

extends QtJambiObject

The `QAbstractFileEngineHandler` class provides a way to register custom file engines with your application. `QAbstractFileEngineHandler` is a factory for creating `QAbstractFileEngine` objects (file engines), which are used internally by `QFile`, `QFileInfo`, and `QDir` when working with files and directories.

When you open a file, Qt chooses a suitable file engine by passing the file name from `QFile` or `QDir` 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 `QAbstractFileEngine` subclasses.

To install an application-specific file engine, you subclass `QAbstractFileEngineHandler` and reimplement `create()`. When you instantiate the handler (e.g. 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.)

For example:

        public static class ZipEngineHandler extends QAbstractFileEngineHandler
        {
            public QAbstractFileEngine create(String fileName)
            {
                // ZipEngineHandler returns a ZipEngine for all .zip files
                if (fileName.toLowerCase().endsWith(".zip")) {
                    return new ZipEngine(fileName);
                } else {
                    return null;
                }
            }
        }

        // ...

        public static void main(String args[])
        {
            QApplication.initialize(args);

            ZipEngineHandler engine = new ZipEngineHandler();

            MainWindow window = new MainWindow(null);
            window.show();

            QApplication.exec();
        }

When the handler is destroyed, it is automatically removed from Qt.

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. 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.

See also:
  `QAbstractFileEngine`, and `QAbstractFileEngine::create()`.

Nested Class Summary

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QAbstractFileEngineHandler()` Constructs a file handler and registers it with Qt.

Method Summary
`abstract QAbstractFileEngine` | `create(java.lang.String fileName)` Creates a file engine for file `fileName`.

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QAbstractFileEngineHandler

    public QAbstractFileEngineHandler()

  Constructs a file handler and registers it with Qt. Once created this handler's `create()` 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. that returns a `QAbstractFileEngine`) is used for the new path.

See also:
  `create()`.

Method Detail

### create

    public abstract QAbstractFileEngine create(java.lang.String fileName)

  Creates a file engine for file `fileName`. Returns 0 if this file handler cannot handle `fileName`.

  Example:

          public QAbstractFileEngine create(String fileName)
          {
              // ZipEngineHandler returns a ZipEngine for all .zip files
              if (fileName.toLowerCase().endsWith(".zip")) {
                  return new ZipEngine(fileName);
              } else {
                  return null;
              }
          }

See also:
  `QAbstractFileEngine::create()`.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD