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

## com.trolltech.qt.core
Class QDirIterator

    java.lang.Object
      com.trolltech.qt.QSignalEmitter
          com.trolltech.qt.QtJambiObject
              com.trolltech.qt.core.QDirIterator

All Implemented Interfaces:
  QtJambiInterface

    public class QDirIterator

extends QtJambiObject

The `QDirIterator` class provides an iterator for directory entrylists.

You can use `QDirIterator` to navigate entries of a directory one at a time. It is similar to QDir::entryList() and QDir::entryInfoList(), but because it lists entries one at a time instead of all at once, it scales better and is more suitable for large directories. It also supports listing directory contents recursively, and following symbolic links. Unlike QDir::entryList(), `QDirIterator` does not support sorting.

The `QDirIterator` constructor takes a `QDir` or a directory as argument. After construction, the iterator is located before the first directory entry. Here's how to iterate over all the entries sequentially:

        QDirIterator it("/etc", QDirIterator::Subdirectories);
        while (it.hasNext()) {
            qDebug() << it.next();

            // /etc/.
            // /etc/..
            // /etc/X11
            // /etc/X11/fs
            // ...
        }

The `next` function returns the path to the next directory entry and advances the iterator. You can also call `filePath` to get the current file path without advancing the iterator. The `fileName` function returns only the name of the file, similar to how QDir::entryList() works. You can also call `fileInfo` to get a `QFileInfo` for the current entry.

Unlike Qt's container iterators, `QDirIterator` is uni-directional (i.e., you cannot iterate directories in reverse order) and does not allow random access.

`QDirIterator` works with all supported file engines, and is implemented using `QAbstractFileEngineIterator`.

See Also:
  `QDir`, `QDir::entryList`, `QAbstractFileEngineIterator`

Nested Class Summary
`static class` | `QDirIterator.IteratorFlag` This enum describes flags that you can combine to configure the behavior of `QDirIterator`.
`static class` | `QDirIterator.IteratorFlags` This QFlag class provides flags for the int enum.

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>`

Constructor Summary
`QDirIterator(QDir dir)` Equivalent to `QDirIterator`(`dir`, NoIteratorFlags).
`QDirIterator(QDir dir, QDirIterator.IteratorFlags flags)` Constructs a `QDirIterator` that can iterate over `dir`'s entrylist, using `dir`'s name filters and regular filters.
`QDirIterator(java.lang.String path)` Equivalent to `QDirIterator`(`path`, NoIteratorFlags).
`QDirIterator(java.lang.String path, java.util.List<java.lang.String> nameFilters)` Equivalent to `QDirIterator`(`path`, `nameFilters`, QDir::NoFilter, NoIteratorFlags).
`QDirIterator(java.lang.String path, java.util.List<java.lang.String> nameFilters, QDir.Filters filters)` Equivalent to `QDirIterator`(`path`, `nameFilters`, `filters`, NoIteratorFlags).
`QDirIterator(java.lang.String path, java.util.List<java.lang.String> nameFilters, QDir.Filters filters, QDirIterator.IteratorFlags flags)` Constructs a `QDirIterator` that can iterate over `path`, using `nameFilters` and `filters`.
`QDirIterator(java.lang.String path, QDir.Filters filter)` Equivalent to `QDirIterator`(`path`, `filter`, NoIteratorFlags).
`QDirIterator(java.lang.String path, QDir.Filters filter, QDirIterator.IteratorFlags flags)` Constructs a `QDirIterator` that can iterate over `path`, with no name filtering and `filter` for entry filtering.
`QDirIterator(java.lang.String path, QDirIterator.IteratorFlags flags)` Constructs a `QDirIterator` that can iterate over `path`.

Method Summary
`QFileInfo` | `fileInfo()` Returns a `QFileInfo` for the current directory entry.
`java.lang.String` | `fileName()` Returns the file name for the current directory entry, without the path prepended.
`java.lang.String` | `filePath()` Returns the full file path for the current directory entry.
`static QDirIterator` | `fromNativePointer(QNativePointer nativePointer)` This function returns the QDirIterator instance pointed to by nativePointer
`boolean` | `hasNext()` Returns true if there is at least one more entry in the directory; otherwise, false is returned.
`java.lang.String` | `next()` Advances the iterator to the next entry, and returns the file path of this new entry.
`java.lang.String` | `path()` Returns the base directory of the iterator.

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

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

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

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

Constructor Detail

### QDirIterator

    public QDirIterator(QDir dir)

  Equivalent to `QDirIterator`(`dir`, NoIteratorFlags).

### QDirIterator

    public QDirIterator(QDir dir,
                        QDirIterator.IteratorFlags flags)

  Constructs a `QDirIterator` that can iterate over `dir`'s entrylist, using `dir`'s name filters and regular filters. You can pass options via `flags` to decide how the directory should be iterated.

  By default, `flags` is `NoIteratorFlags`, which provides the same behavior as in QDir::entryList().

  The sorting in `dir` is ignored.

  See Also:
    `hasNext`, `next`, `IteratorFlags`

### QDirIterator

    public QDirIterator(java.lang.String path)

  Equivalent to `QDirIterator`(`path`, NoIteratorFlags).

### QDirIterator

    public QDirIterator(java.lang.String path,
                        QDirIterator.IteratorFlags flags)

  Constructs a `QDirIterator` that can iterate over `path`. You can pass options via `flags` to decide how the directory should be iterated.

  By default, `flags` is `NoIteratorFlags`, which provides the same behavior as in QDir::entryList().

  See Also:
    `hasNext`, `next`, `IteratorFlags`

### QDirIterator

    public QDirIterator(java.lang.String path,
                        java.util.List<java.lang.String> nameFilters,
                        QDir.Filters filters)

  Equivalent to `QDirIterator`(`path`, `nameFilters`, `filters`, NoIteratorFlags).

### QDirIterator

    public QDirIterator(java.lang.String path,
                        java.util.List<java.lang.String> nameFilters)

  Equivalent to `QDirIterator`(`path`, `nameFilters`, QDir::NoFilter, NoIteratorFlags).

### QDirIterator

    public QDirIterator(java.lang.String path,
                        java.util.List<java.lang.String> nameFilters,
                        QDir.Filters filters,
                        QDirIterator.IteratorFlags flags)

  Constructs a `QDirIterator` that can iterate over `path`, using `nameFilters` and `filters`. You can pass options via `flags` to decide how the directory should be iterated.

  By default, `flags` is `NoIteratorFlags`, which provides the same behavior as QDir::entryList().

  See Also:
    `hasNext`, `next`, `IteratorFlags`

### QDirIterator

    public QDirIterator(java.lang.String path,
                        QDir.Filters filter)

  Equivalent to `QDirIterator`(`path`, `filter`, NoIteratorFlags).

### QDirIterator

    public QDirIterator(java.lang.String path,
                        QDir.Filters filter,
                        QDirIterator.IteratorFlags flags)

  Constructs a `QDirIterator` that can iterate over `path`, with no name filtering and `filter` for entry filtering. You can pass options via `flags` to decide how the directory should be iterated.

  By default, `filter` is QDir::NoFilter, and `flags` is `NoIteratorFlags`, which provides the same behavior as in QDir::entryList().

  See Also:
    `hasNext`, `next`, `IteratorFlags`

Method Detail

### fileInfo

    public final QFileInfo fileInfo()

  Returns a `QFileInfo` for the current directory entry. If the current entry is invalid (i.e., isValid() returns false), a null `QFileInfo` is returned.

  See Also:
    `filePath`, `fileName`

### fileName

    public final java.lang.String fileName()

  Returns the file name for the current directory entry, without the path prepended. If the current entry is invalid (i.e., isValid() returns false), a null `QString` is returned.

  This function is provided for the convenience when iterating single directories. For recursive iteration, you should call `filePath` or `fileInfo` instead.

  See Also:
    `filePath`, `fileInfo`

### filePath

    public final java.lang.String filePath()

  Returns the full file path for the current directory entry. If the current entry is invalid (i.e., isValid() returns false), a null `QString` is returned.

  See Also:
    `fileInfo`, `fileName`

### hasNext

    public final boolean hasNext()

  Returns true if there is at least one more entry in the directory; otherwise, false is returned.

  See Also:
    `next`, `fileName`, `filePath`, `fileInfo`

### next

    public final java.lang.String next()

  Advances the iterator to the next entry, and returns the file path of this new entry. If `hasNext` returns false, this function does nothing, and returns a null `QString`.

  You can call `fileName` or `filePath` to get the current entry file name or path, or `fileInfo` to get a `QFileInfo` for the current entry.

  See Also:
    `hasNext`, `fileName`, `filePath`, `fileInfo`

### path

    public final java.lang.String path()

  Returns the base directory of the iterator.

### fromNativePointer

    public static QDirIterator fromNativePointer(QNativePointer nativePointer)

  This function returns the QDirIterator instance pointed to by nativePointer

  Parameters:
    `nativePointer` - the QNativePointer of which object should be returned.

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