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 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 = new QDirIterator("/etc",
                new QDirIterator.IteratorFlags(QDirIterator.IteratorFlag.Subdirectories));
            while (it.hasNext()) {
                System.out.println(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()`, and `QAbstractFileEngineIterator`.

Nested Class Summary
`static class` | `QDirIterator.IteratorFlag` These flags can be passed to a `QTreeWidgetItemIterator` constructor (OR-ed together if more than one is used), so that the iterator will only iterate over items that match the given flags.
`static class` | `QDirIterator.IteratorFlags` This is a flags class for com.trolltech.qt.core.QDirIterator.IteratorFlag

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

Constructor Summary
`QDirIterator(QDir dir)` Constructs a `QDirIterator` that can iterate over `dir`'s entrylist, using `dir`'s name filters and regular filters.
`QDirIterator(QDir dir, QDirIterator.IteratorFlag[] flags)` Constructs a `QDirIterator` that can iterate over `dir`'s entrylist, using `dir`'s name filters and regular filters.
`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)` Constructs a `QDirIterator` that can iterate over `path`.
`QDirIterator(java.lang.String path, java.util.List nameFilters)` Constructs a `QDirIterator` that can iterate over `path`, using `nameFilters` and `filters`.
`QDirIterator(java.lang.String path, java.util.List nameFilters, QDir.Filters filters)` Constructs a `QDirIterator` that can iterate over `path`, using `nameFilters` and `filters`.
`QDirIterator(java.lang.String path, java.util.List nameFilters, QDir.Filters filters, QDirIterator.IteratorFlag[] flags)` Constructs a `QDirIterator` that can iterate over `path`, using `nameFilters` and `filters`.
`QDirIterator(java.lang.String path, java.util.List 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)` Constructs a `QDirIterator` that can iterate over `path`, with no name filtering and `filters` for entry filtering.
`QDirIterator(java.lang.String path, QDir.Filters filter, QDirIterator.IteratorFlag[] flags)` Constructs a `QDirIterator` that can iterate over `path`, with no name filtering and `filters` for entry filtering.
`QDirIterator(java.lang.String path, QDir.Filters filter, QDirIterator.IteratorFlags flags)` Constructs a `QDirIterator` that can iterate over `path`, with no name filtering and `filters` for entry filtering.
`QDirIterator(java.lang.String path, QDirIterator.IteratorFlag[] flags)` Constructs a `QDirIterator` that can iterate over `path`.
`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 method 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, equals, 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, 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,
                        QDirIterator.IteratorFlag[] 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()`, and IteratorFlags.

### QDirIterator

    public QDirIterator(QDir dir)

  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()`, and IteratorFlags.

### 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()`, and IteratorFlags.

### QDirIterator

    public QDirIterator(java.lang.String path,
                        QDir.Filters filter,
                        QDirIterator.IteratorFlag[] flags)

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

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

See also:
  `hasNext()`, `next()`, and IteratorFlags.

### QDirIterator

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

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

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

See also:
  `hasNext()`, `next()`, and IteratorFlags.

### 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 `filters` for entry filtering. You can pass options via `flags` to decide how the directory should be iterated.

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

See also:
  `hasNext()`, `next()`, and IteratorFlags.

### QDirIterator

    public QDirIterator(java.lang.String path,
                        QDirIterator.IteratorFlag[] 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()`, and IteratorFlags.

### QDirIterator

    public QDirIterator(java.lang.String path)

  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()`, and IteratorFlags.

### 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()`, and IteratorFlags.

### QDirIterator

    public QDirIterator(java.lang.String path,
                        java.util.List nameFilters,
                        QDir.Filters filters,
                        QDirIterator.IteratorFlag[] 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()`, and IteratorFlags.

### QDirIterator

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

  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()`, and IteratorFlags.

### QDirIterator

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

  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()`, and IteratorFlags.

### QDirIterator

    public QDirIterator(java.lang.String path,
                        java.util.List 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()`, and 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()`, and `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()`, and `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()`, and `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()`, and `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()`, and `fileInfo()`.

### path

    public final java.lang.String path()

  Returns the base directory of the iterator.

### fromNativePointer

    public static QDirIterator fromNativePointer(QNativePointer nativePointer)

  This method returns the QDirIterator instance pointed to by `nativePointer`.

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