Home

QtDirectoryBrowser Class Reference

The QtDirectoryBrowser class provides a tree view of a directory in the file system. More...

#include <qtdirectorybrowser.h>

List of all member functions.

Public Members

Public Slots

Signals

Properties


Detailed Description

The QtDirectoryBrowser class provides a tree view of a directory in the file system.

QtDirectoryBrowser is based on QListView, and displays the contents of one or more directories in a tree view. The paths can be specified in the constructor or using setStartPaths().

QtDirectoryBrowser can display several columns for each object in a directory, including the file or directory name, type, size, date, owner, group, and the access permissions. To show or hide a column, call setColumnEnabled(). The user can also show or hide a column by right-clicking the QListView header.

The class emits itemClicked(), itemDoubleClicked(), and itemRightClicked() signals when the user clicks on an item in the view. Each signal is emitted with the relevant QtDirectoryBrowserItem as the argument. In addition to these, all the standard signals from QListView are also emitted.

The user can change the path displayed in the directory browser using drag and drop or copy and paste. Both features can be disabled with setCopyPasteEnabled() and setDragDropEnabled().

Dropping a directory on the list view causes that directory to become the currently displayed directory.

The copy and paste menu can be accessed by right-clicking the view. Pasting a directory path causes this path to be currently displayed directory.

Example:

        QStringList rootPaths << "/" << "/home/robert" << "/usr";
        QtDirectoryBrowser *dirBrowser = new QtDirectoryBrowser(rootPaths);
        dirBrowser->show();
    

See also


Member Type Documentation

QtDirectoryBrowser::Column

This enum specifies the different types of information that can be displayed in a column.

See also setColumnHidden().

QtDirectoryBrowser::FlagStyle

This enum specifies the different file permission styles.

See also flagStyle.

QtDirectoryBrowser::FolderIcon

This enum specifies the different folder icons that are used in the directory browser.

See also setFolderIcon().

QtDirectoryBrowser::SizeStyle

This enum specifies the different size display styles.

See also sizeStyle.


Member Function Documentation

QtDirectoryBrowser::QtDirectoryBrowser ( QWidget * parent = 0, const char * name = 0 )

Constructs a new directory browser with the given parent and name. The browser will display the contents of the directories specified by the default start paths.

See also startPaths.

QtDirectoryBrowser::QtDirectoryBrowser ( const QStringList & startPaths, QWidget * parent = 0, const char * name = 0 )

Constructs a new directory browser widget with the given parent and name, and adds each of the directories specified by startPaths to the list of currently displayed directories.

QtDirectoryBrowser::~QtDirectoryBrowser ()

Destroys the directory browser.

QDir::FilterSpec QtDirectoryBrowser::filter () const

Returns the currently set file filter. See QDir::FilterSpec for details.

FlagStyle QtDirectoryBrowser::flagStyle () const

Returns the format for displaying file attributes. See the "flagStyle" property for details.

bool QtDirectoryBrowser::isCopyPasteEnabled () const

Returns TRUE if copy and paste is enabled If this property is true, a copy and paste popup menu is displayed when the user right-clicks inside the directory browser; otherwise returns FALSE. See the "copyPasteEnabled" property for details.

bool QtDirectoryBrowser::isDisplayDirectoriesOnlyEnabled () const

Returns TRUE if only directories are displayed in the directory browser; otherwise returns FALSE. See the "displayDirectoriesOnly" property for details.

bool QtDirectoryBrowser::isDisplaySymlinkTargetsEnabled () const

Returns TRUE if the directory browser should show symbolic link targets; otherwise returns FALSE. See the "displaySymlinkTargets" property for details.

bool QtDirectoryBrowser::isDragDropEnabled () const

Returns TRUE if drag and drop is enabled; otherwise returns FALSE. See the "dragDropEnabled" property for details.

void QtDirectoryBrowser::itemClicked ( QtDirectoryBrowserItem * item ) [signal]

This signal is emitted whenever the user clicks on an item in the list view. item is the directory browser item that was clicked.

void QtDirectoryBrowser::itemDoubleClicked ( QtDirectoryBrowserItem * item ) [signal]

This signal is emitted whenever an item is double-clicked. It is emitted on the second button press, not the second button release. item is the directory browser item that was double-clicked.

void QtDirectoryBrowser::itemRightClicked ( QtDirectoryBrowserItem * item ) [signal]

This signal is emitted when the right button is clicked. item is the directory browser item that was clicked.

void QtDirectoryBrowser::resetStartPaths ()

Resets the paths displayed in the directory browser view. See the "startPaths" property for details.

void QtDirectoryBrowser::setColumnHidden ( Column column, bool hidden )

Hides the given column if hidden is true; otherwise shows it. Note that hiding the name column is not allowed.

void QtDirectoryBrowser::setCopyPasteEnabled ( bool enable ) [slot]

Sets whether copy and paste is enabled If this property is true, a copy and paste popup menu is displayed when the user right-clicks inside the directory browser to enable. See the "copyPasteEnabled" property for details.

void QtDirectoryBrowser::setDisplayDirectoriesOnly ( bool enable ) [slot]

Sets whether only directories are displayed in the directory browser to enable. See the "displayDirectoriesOnly" property for details.

void QtDirectoryBrowser::setDisplaySymlinkTargetsEnabled ( bool enable ) [slot]

Sets whether the directory browser should show symbolic link targets to enable. See the "displaySymlinkTargets" property for details.

void QtDirectoryBrowser::setDragDropEnabled ( bool enable ) [slot]

Sets whether drag and drop is enabled to enable. See the "dragDropEnabled" property for details.

void QtDirectoryBrowser::setFileIconProvider ( QFileIconProvider * fileIconProvider )

Set the file icon provider to be fileIconProvider. This provides the icons that are displayed with each file.

void QtDirectoryBrowser::setFilter ( int filter )

Sets the filter used for displaying files to the specified filter. The filter value is a combination of values defined by QDir::FilterSpec.

void QtDirectoryBrowser::setFlagStyle ( FlagStyle style ) [slot]

Sets the format for displaying file attributes to style. See the "flagStyle" property for details.

void QtDirectoryBrowser::setFolderIcon ( FolderIcon icon, const QPixmap & pixmap )

Sets the image to be used for the given directory icon to be the pixmap specified.

void QtDirectoryBrowser::setSizeStyle ( SizeStyle style ) [slot]

Sets the style used when displying file sizes to style. See the "sizeStyle" property for details.

void QtDirectoryBrowser::setStartPaths ( const QStringList startPaths ) [slot]

Sets the paths displayed in the directory browser view to startPaths. See the "startPaths" property for details.

SizeStyle QtDirectoryBrowser::sizeStyle () const

Returns the style used when displying file sizes. See the "sizeStyle" property for details.

QStringList QtDirectoryBrowser::startPaths () const

Returns the paths displayed in the directory browser view. See the "startPaths" property for details.

void QtDirectoryBrowser::triggerFilesystemUpdate () [slot]

Updates the directory browser view by scanning the file system for changes.

Property Documentation

bool copyPasteEnabled

This property holds whether copy and paste is enabled If this property is true, a copy and paste popup menu is displayed when the user right-clicks inside the directory browser.

This menu can be used to copy file or directory paths to the clipboard, or to display a directory by pasting its path from the clipboard.

The default is true (copy and paste is enabled).

Set this property's value with setCopyPasteEnabled() and get this property's value with isCopyPasteEnabled().

bool displayDirectoriesOnly

This property holds whether only directories are displayed in the directory browser.

By default, this property is false (files will also be displayed).

See also displaySymlinkTargets.

Set this property's value with setDisplayDirectoriesOnly() and get this property's value with isDisplayDirectoriesOnlyEnabled().

bool displaySymlinkTargets

This property holds whether the directory browser should show symbolic link targets.

If this property is true then the symbolic link target is displayed after each symbolic link in the Name column.

The default is true (link targets are shown).

Set this property's value with setDisplaySymlinkTargetsEnabled() and get this property's value with isDisplaySymlinkTargetsEnabled().

bool dragDropEnabled

This property holds whether drag and drop is enabled.

If this property is true, the user can drag and drop filenames to and from the directory browser.

When a directory is dropped on the view, the view is updated to display the new directory.

The default is true (drag and drop is enabled).

Set this property's value with setDragDropEnabled() and get this property's value with isDragDropEnabled().

FlagStyle flagStyle

This property holds the format for displaying file attributes.

FlagStyle selects whether file attributes are displayed like a Unix file permission string (UnixStyle) or as Windows read/write/execute attributes (WindowsStyle).

The default is WindowsStyle on windows and UnixStyle on other systems. Note that UnixStyle can be slow when viewing directory structures residing on an NTFS file system.

Set this property's value with setFlagStyle() and get this property's value with flagStyle().

SizeStyle sizeStyle

This property holds the style used when displying file sizes.

The size style can be either UnformattedSize or FormattedSize. UnformattedSize shows the size in bytes, while FormattedSize displays the size in a style that is easier to read by showing the size in bytes, kilobytes, megabytes, or gigabytes.

The default is QtDirectoryBrowser::FormattedSize.

Set this property's value with setSizeStyle() and get this property's value with sizeStyle().

QStringList startPaths

This property holds the paths displayed in the directory browser view.

The start paths are the directories that are shown in the directory browser if no other paths are specified when it is constructed.

The default is the system's root path(s) (for example, "A:\", "C:\", "D:\" on Windows, and "/" on Unix and Mac OS X).

Set this property's value with setStartPaths(), get this property's value with startPaths(), and reset this property's value with resetStartPaths().


This file is part of the Qt Solutions. Copyright © 2003-2005 Trolltech. All Rights Reserved.

Copyright © 2003-2005 TrolltechTrademarks
Qt Solutions