CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Public Types | Public Slots | Signals | Public Member Functions | Protected Attributes | Properties | List of all members
ctkPathListWidget Class Reference

The ctkPathListWidget lists files and/or directories. More...

#include <Libs/Widgets/ctkPathListWidget.h>

Inheritance diagram for ctkPathListWidget:
Inheritance graph
[legend]
Collaboration diagram for ctkPathListWidget:
Collaboration graph
[legend]

Public Types

enum  { AbsolutePathRole = Qt::UserRole + 1 }
 
enum  Mode { Any = 0 , FilesOnly , DirectoriesOnly }
 
enum  PathOption {
  None = 0x00 , Exists = 0x01 , Readable = 0x02 , Writable = 0x04 ,
  Executable = 0x08
}
 Describes constraints on paths. More...
 
typedef QListView Superclass
 Superclass typedef. More...
 

Public Slots

bool addPath (const QString &path)
 
QStringList addPaths (const QStringList &paths)
 
void clear ()
 Remove all paths from the list. More...
 
bool removePath (const QString &path)
 
QStringList removePaths (const QStringList &paths)
 
void removeSelectedPaths ()
 Remove all currently selected paths from the list. More...
 
void setMode (Mode mode)
 
void setPaths (const QStringList &paths)
 

Signals

void currentPathChanged (const QString &currentAbsolutePath, const QString &previousAbsolutePath)
 
void pathActivated (const QString &absolutePath)
 
void pathClicked (const QString &absolutePath)
 The user clicked on a path entry. More...
 
void pathDoubleClicked (const QString &absolutePath)
 The user double-clicked on a path entry. More...
 
void pathsChanged (const QStringList &added, const QStringList &removed)
 

Public Member Functions

bool contains (const QString &path) const
 
int count () const
 
 ctkPathListWidget (QWidget *parent=0)
 Constructor. More...
 
QString currentPath (bool absolutePath=false) const
 
QStringList directories (bool absolutePath=false) const
 
QIcon directoryIcon () const
 
PathOptions directoryOptions () const
 
bool editPath (const QModelIndex &index, const QString &newPath)
 
bool editPath (const QString &oldPath, const QString &newPath)
 
QIcon fileIcon () const
 
PathOptions fileOptions () const
 
QStringList files (bool absolutePath=false) const
 
bool isDirectory (const QString &path) const
 
bool isFile (const QString &path) const
 
QStandardItem * item (const QString &absolutePath) const
 
QStandardItem * item (int row) const
 
QStandardItem * itemAt (const QPoint &point) const
 
QStandardItem * itemAt (int x, int y) const
 
Mode mode () const
 
QString path (int row) const
 
QString pathAt (const QPoint &point) const
 
QString pathAt (int x, int y) const
 
QStringList paths (bool absolutePath=false) const
 
int row (const QString &path) const
 
QStringList selectedPaths (bool absolutePath=false) const
 
void setDirectoryIcon (const QIcon &icon)
 
void setDirectoryOptions (PathOptions directoryOptions)
 
void setFileIcon (const QIcon &icon)
 
void setFileOptions (PathOptions fileOptions)
 
void unsetDirectoryIcon ()
 Un-set any custom directory icon. More...
 
void unsetFileIcon ()
 Un-set any custom file icon. More...
 
virtual ~ctkPathListWidget ()
 Destructor. More...
 

Protected Attributes

QScopedPointer< ctkPathListWidgetPrivate > d_ptr
 

Properties

QIcon directoryIcon
 The icon to be shown for a directory entry. More...
 
PathOptions directoryOptions
 Constraints on the directory type. More...
 
QIcon fileIcon
 The icon to be shown for a file entry. More...
 
PathOptions fileOptions
 Constraints on the file type. More...
 
Mode mode
 The mode for this ctkPathListWidget. More...
 
QStringList paths
 The current list of paths. More...
 

Detailed Description

The ctkPathListWidget lists files and/or directories.

The ctkPathListWidget is a QListView sub-class tailored specifically for displaying lists of file and/or directory entries. A path denotes either a file or a directory. Paths can be relative or absolute and the range of valid paths can be constrained by setting file and directory options.

See also
ctkPathLineEdit, ctkDirectoryButton

Definition at line 47 of file ctkPathListWidget.h.

Member Typedef Documentation

◆ Superclass

typedef QListView ctkPathListWidget::Superclass

Superclass typedef.

Definition at line 107 of file ctkPathListWidget.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
AbsolutePathRole 

A role for getting the absolute path from items in this list views model.

Definition at line 74 of file ctkPathListWidget.h.

◆ Mode

Enumerator
Any 

Allow all paths.

FilesOnly 

Allow only file entries.

DirectoriesOnly 

Allow only directory entries.

Definition at line 96 of file ctkPathListWidget.h.

◆ PathOption

Describes constraints on paths.

Enumerator
None 

No constraints.

Exists 

The path must exist in the file system.

Readable 

The path must be readable by the current user.

Writable 

The path must be writable by the current user.

Executable 

The path must be executable by the current user.

Definition at line 81 of file ctkPathListWidget.h.

Constructor & Destructor Documentation

◆ ctkPathListWidget()

ctkPathListWidget::ctkPathListWidget ( QWidget *  parent = 0)
explicit

Constructor.

◆ ~ctkPathListWidget()

virtual ctkPathListWidget::~ctkPathListWidget ( )
virtual

Destructor.

Member Function Documentation

◆ addPath

bool ctkPathListWidget::addPath ( const QString &  path)
slot

Depending on the mode and path constraints, add path to the entry list and emit signal pathListChanged().

Parameters
pathThe path to add.
Returns
true if the path was added, false otherwise.
See also
pathListChanged()

◆ addPaths

QStringList ctkPathListWidget::addPaths ( const QStringList &  paths)
slot

Depending on the mode and path constraints, add paths to the entry list and emit signal pathListChanged().

Parameters
pathsThe paths to add.
Returns
The absolute paths of all added entries from paths.
See also
pathListChanged()

◆ clear

void ctkPathListWidget::clear ( )
slot

Remove all paths from the list.

◆ contains()

bool ctkPathListWidget::contains ( const QString &  path) const

Checks if an entry with the given path already exists.

Returns
true if the path has already been added, false otherwise.

◆ count()

int ctkPathListWidget::count ( ) const
Returns
The current entry count.

◆ currentPath()

QString ctkPathListWidget::currentPath ( bool  absolutePath = false) const

Get the currently focused path entry.

Parameters
absolutePathIf true, resolve all entries to absolute paths.
Returns
The focused path entry or a null QString if no entry is focused.

◆ currentPathChanged

void ctkPathListWidget::currentPathChanged ( const QString &  currentAbsolutePath,
const QString &  previousAbsolutePath 
)
signal

This signal is emitted whenever the current item changes.

Parameters
currentAbsolutePathThe new current path entry.
previousAbsolutePathThe path entry that previously had the focus.

◆ directories()

QStringList ctkPathListWidget::directories ( bool  absolutePath = false) const

Get all directory entries.

Parameters
absolutePathIf true, resolve all entries to absolute paths.
Returns
A list of all directory entries.

◆ directoryIcon()

QIcon ctkPathListWidget::directoryIcon ( ) const
Returns
The QIcon used for directory entries.

◆ directoryOptions()

PathOptions ctkPathListWidget::directoryOptions ( ) const
Returns
The directory entry constraints.

◆ editPath() [1/2]

bool ctkPathListWidget::editPath ( const QModelIndex &  index,
const QString &  newPath 
)

Changes the path value of index to newPath.

Parameters
indexThe model index for which the path will be changed.
newPathThe new path replacing the path value of index.
See also
editPath(const QString&, const QString&)

◆ editPath() [2/2]

bool ctkPathListWidget::editPath ( const QString &  oldPath,
const QString &  newPath 
)

Changes oldPath to the new value given by newPath. Does nothing if oldPath is not in the list or newPath does not fullfill the current path options (constraints).

Parameters
oldPathThe path to be edited.
newPathThe new path replacing oldPath.
Returns
true if the old path was successfully changed, false otherwise.

◆ fileIcon()

QIcon ctkPathListWidget::fileIcon ( ) const
Returns
The QIcon used for file entries.

◆ fileOptions()

PathOptions ctkPathListWidget::fileOptions ( ) const
Returns
The file entry constraints.

◆ files()

QStringList ctkPathListWidget::files ( bool  absolutePath = false) const

Get all file entries.

Parameters
absolutePathIf true, resolve all entries to absolute paths.
Returns
A list of all file entries.

◆ isDirectory()

bool ctkPathListWidget::isDirectory ( const QString &  path) const
Returns
Returns true if the given path is treated as a directory, false otherwise.

◆ isFile()

bool ctkPathListWidget::isFile ( const QString &  path) const
Returns
Returns true if the given path is treated as a file, false otherwise.

◆ item() [1/2]

QStandardItem* ctkPathListWidget::item ( const QString &  absolutePath) const
Returns
The item for the given absolute path or NULL if the the path is not known.

◆ item() [2/2]

QStandardItem* ctkPathListWidget::item ( int  row) const
Returns
The item for row or NULL if row is out of range.

◆ itemAt() [1/2]

QStandardItem* ctkPathListWidget::itemAt ( const QPoint &  point) const
Returns
The item for the entry located at the point point (in the widget coordinate system) or NULL if no ite could be found for point.

◆ itemAt() [2/2]

QStandardItem* ctkPathListWidget::itemAt ( int  x,
int  y 
) const
inline
See also
itemAt(const QPoint&)

Definition at line 205 of file ctkPathListWidget.h.

◆ mode()

Mode ctkPathListWidget::mode ( ) const
Returns
The current widget mode.

◆ path()

QString ctkPathListWidget::path ( int  row) const
Returns
The absolute path for row or a null QString if row is out of range.

◆ pathActivated

void ctkPathListWidget::pathActivated ( const QString &  absolutePath)
signal

This signal is emitted when the absolutePath entry is activated. The entry is activated when the user clicks or double clicks on it, depending on the system configuration. It is also activated when the user presses the activation key (on Windows and X11 this is the Return key, on Mac OS X it is Ctrl+0).

◆ pathAt() [1/2]

QString ctkPathListWidget::pathAt ( const QPoint &  point) const
Returns
The absolute path for the entry located at the point point (in the widget coordinate system) or a null QString if no entry could be found for point.

◆ pathAt() [2/2]

QString ctkPathListWidget::pathAt ( int  x,
int  y 
) const
inline
See also
pathAt(const QPoint&)

Definition at line 202 of file ctkPathListWidget.h.

◆ pathClicked

void ctkPathListWidget::pathClicked ( const QString &  absolutePath)
signal

The user clicked on a path entry.

◆ pathDoubleClicked

void ctkPathListWidget::pathDoubleClicked ( const QString &  absolutePath)
signal

The user double-clicked on a path entry.

◆ paths()

QStringList ctkPathListWidget::paths ( bool  absolutePath = false) const

Get all path entries.

Parameters
absolutePathIf true, resolve all entries to absolute paths.
Returns
A list of all entries.

◆ pathsChanged

void ctkPathListWidget::pathsChanged ( const QStringList &  added,
const QStringList &  removed 
)
signal

This signal is emitted when paths are added or removed to the list.

Parameters
addedThe newly added absolute paths.
removedThe removed absolute paths.

◆ removePath

bool ctkPathListWidget::removePath ( const QString &  path)
slot

Remove path from the list. The signal pathListChanged() is emitted if the path was in the list.

Parameters
pathThe path to remove.
Returns
true if path was removed, false otherwise.
See also
pathListChanged()

◆ removePaths

QStringList ctkPathListWidget::removePaths ( const QStringList &  paths)
slot

Remove paths from the list.

Parameters
pathsThe paths to remove.
Returns
The absolute paths of all removed entries from paths.

◆ removeSelectedPaths

void ctkPathListWidget::removeSelectedPaths ( )
slot

Remove all currently selected paths from the list.

◆ row()

int ctkPathListWidget::row ( const QString &  path) const
Returns
The row number for the given path or -1 if path is not in the list of current entries.

◆ selectedPaths()

QStringList ctkPathListWidget::selectedPaths ( bool  absolutePath = false) const

Get all selected path entries.

Parameters
absolutePathIf true, resolve all entries to absolute paths.
Returns
A list of all selected entries.

◆ setDirectoryIcon()

void ctkPathListWidget::setDirectoryIcon ( const QIcon &  icon)

Sets a QIcon to be used for directory entries.

Parameters
iconThe new directory entry icon.

◆ setDirectoryOptions()

void ctkPathListWidget::setDirectoryOptions ( PathOptions  directoryOptions)

Set new directory entry constraints.

Parameters
directoryOptionsThe directory entry constraints.

◆ setFileIcon()

void ctkPathListWidget::setFileIcon ( const QIcon &  icon)

Sets a QIcon to be used for file entries.

Parameters
iconThe new file entry icon.

◆ setFileOptions()

void ctkPathListWidget::setFileOptions ( PathOptions  fileOptions)

Set new file entry constraints.

Parameters
fileOptionsThe file entry constraints.

◆ setMode

void ctkPathListWidget::setMode ( Mode  mode)
slot

Set the mode for controlling the path type.

Parameters
modeThe path mode.

◆ setPaths

void ctkPathListWidget::setPaths ( const QStringList &  paths)
slot

Remove all entries and set all valid entries in paths as the current list. The signal pathListChanged() is emitted if the old list of paths is different from the provided one.

Parameters
pathsThe new path list.
See also
addPaths(), pathListChanged()

◆ unsetDirectoryIcon()

void ctkPathListWidget::unsetDirectoryIcon ( )

Un-set any custom directory icon.

◆ unsetFileIcon()

void ctkPathListWidget::unsetFileIcon ( )

Un-set any custom file icon.

Member Data Documentation

◆ d_ptr

QScopedPointer<ctkPathListWidgetPrivate> ctkPathListWidget::d_ptr
protected

Definition at line 305 of file ctkPathListWidget.h.

Property Documentation

◆ directoryIcon

QIcon ctkPathListWidget::directoryIcon
readwrite

The icon to be shown for a directory entry.

Definition at line 1 of file ctkPathListWidget.h.

◆ directoryOptions

PathOptions ctkPathListWidget::directoryOptions
readwrite

Constraints on the directory type.

Definition at line 1 of file ctkPathListWidget.h.

◆ fileIcon

QIcon ctkPathListWidget::fileIcon
readwrite

The icon to be shown for a file entry.

Definition at line 1 of file ctkPathListWidget.h.

◆ fileOptions

PathOptions ctkPathListWidget::fileOptions
readwrite

Constraints on the file type.

Definition at line 1 of file ctkPathListWidget.h.

◆ mode

Mode ctkPathListWidget::mode
readwrite

The mode for this ctkPathListWidget.

Definition at line 1 of file ctkPathListWidget.h.

◆ paths

QStringList ctkPathListWidget::paths
readwrite

The current list of paths.

Definition at line 1 of file ctkPathListWidget.h.


The documentation for this class was generated from the following file: