Version: 6.3.1
Data Structures | Public Member Functions | Protected Slots | Private Member Functions | Private Attributes | Friends

QtxPathListEdit Class Reference

The QtxPathListEdit class represents a widget for files or directories paths list preference items editing. More...

#include <QtxPathListEdit.h>

Inheritance diagram for QtxPathListEdit:
Inheritance graph

Data Structures

class  Delegate
 Custom item delegate for the paths list widget. More...
class  Editor
 Path editor widget. More...

Public Member Functions

 QtxPathListEdit (const Qtx::PathType, QWidget *=0)
 Constructor.
 QtxPathListEdit (QWidget *=0)
 Constructor.
virtual ~QtxPathListEdit ()
 Destructor.
Qtx::PathType pathType () const
 Get widget mode.
void setPathType (const Qtx::PathType)
 Set widget mode.
QStringList pathList () const
 Get currently selected paths list.
void setPathList (const QStringList &)
 Set paths list.
bool isDuplicateEnabled () const
 Check if the duplication of paths is enabled.
void setDuplicateEnabled (const bool)
 Enable/disable paths duplication.
int count () const
 Get number of currently entered paths.
bool contains (const QString &) const
 Check if the specified path already exists in the paths list.
void clear ()
 Clear paths list.
void remove (const int)
 Remove path from the paths list.
void remove (const QString &)
 Remove path from the paths list.
void insert (const QString &, const int=-1)
 Add path to the list of paths.
bool eventFilter (QObject *, QEvent *)
 Customize child widget events processing.

Protected Slots

void onUp (bool=false)
 Called when <Up> button is clicked.
void onDown (bool=false)
 Called when <Down> button is clicked.
void onInsert (bool=false)
 Called when <Insert> button is clicked.
void onDelete (bool=false)
 Called when <Delete> button is clicked.

Private Member Functions

void initialize ()
 Perform internal widget initialization.
QWidgetcreateEditor (QWidget *)
 Create editor widget.
void setModelData (QWidget *, const QModelIndex &)
 Set modified data from the editor to the list widget.
void setEditorData (QWidget *, const QModelIndex &)
 Set data to the editor from the list widget when user starts path edition.
bool checkExistance (const QString &, const bool=true)
 Check if path is correct (exists) and optionally show the question message box.
bool checkDuplicate (const QString &, const int, const bool=true)
 Check if path already exists in the list and optionally show the warning message box.

Private Attributes

QListView * myList
Qtx::PathType myType
QStringListModel * myModel
QCompleter * myCompleter
bool myDuplicate

Friends

class QtxPathListEdit::Delegate

Detailed Description

The path list preference item is represented as the list box widget. It provides such operations like adding new file/directory path to the list, removing selected paths and modifying of already entered ones.

The widget can be used in two modes: list of files or list of directories. The mode defines the type of the standard browse dialog box which is invoked on the browse button clicking.

Initial path list value can be set with setPathList() method. Chosen path list can be retrieved with the pathList() method. The widget mode can be set with setPathType() and retrieved with pathType() method.

In addition, it is possible to add path items to the list with the insert() method, remove items with the remove() methods, clear all the widget contents with the clear() method. To get the number of entered paths can be retrieved with the count() method. To check if any path already exists in the paths list, use contains() method.


Constructor & Destructor Documentation

QtxPathListEdit::QtxPathListEdit ( const Qtx::PathType  type,
QWidget parent = 0 
)
Parameters:
typewidget mode (Qtx.PathType)
parentparent widget
See also:
pathType(), setPathType()

References initialize().

QtxPathListEdit::QtxPathListEdit ( QWidget parent = 0)

Qtx.PT_OpenFile mode is used by default.

Parameters:
parentparent widget
See also:
pathType(), setPathType()

References initialize().

QtxPathListEdit::~QtxPathListEdit ( ) [virtual]

Member Function Documentation

Qtx::PathType QtxPathListEdit::pathType ( ) const
Returns:
currently used widget mode (Qtx.PathType)
See also:
setPathType()

References myType.

void QtxPathListEdit::setPathType ( const Qtx::PathType  t)
Parameters:
tnew widget mode (Qtx.PathType)
See also:
pathType()

References myCompleter, and myType.

QStringList QtxPathListEdit::pathList ( ) const
Returns:
files or directories paths list entered by the user
See also:
setPathList()

References myModel.

void QtxPathListEdit::setPathList ( const QStringList &  lst)
Parameters:
lstfiles or directories paths list
See also:
pathList()

References myModel.

bool QtxPathListEdit::isDuplicateEnabled ( ) const
Returns:
true if the duplication is enabled

References myDuplicate.

void QtxPathListEdit::setDuplicateEnabled ( const bool  on)
Parameters:
onnew flag value

References myDuplicate.

int QtxPathListEdit::count ( ) const
Returns:
current paths number

References myModel.

bool QtxPathListEdit::contains ( const QString &  path) const
Parameters:
pathpath to be checked
Returns:
true if the path is already selected by the user or false otherwise

References myModel.

void QtxPathListEdit::clear ( )

References myModel.

void QtxPathListEdit::remove ( const int  idx)
Parameters:
idxpath index in the list

References myModel.

void QtxPathListEdit::remove ( const QString &  path)
Parameters:
pathpath to be removed

References myModel.

void QtxPathListEdit::insert ( const QString &  path,
const int  idx = -1 
)

If the specified index is out of range, the path is added to the end of the list.

Parameters:
pathpath to be added
idxindex in the list to which the path should be inserted.

References myModel.

bool QtxPathListEdit::eventFilter ( QObject o,
QEvent e 
)
Parameters:
oevent receiver object
eevent
Returns:
true if the further event processing should be stopped.

References onDelete(), onDown(), onInsert(), and onUp().

void QtxPathListEdit::onUp ( bool  = false) [protected, slot]

Move currently selected path item up to one row in the paths list.

Parameters:
on(not used)

References myList, and myModel.

void QtxPathListEdit::onDown ( bool  = false) [protected, slot]

Move currently selected path item down to one row in the paths list.

Parameters:
on(not used)

References myList, and myModel.

void QtxPathListEdit::onInsert ( bool  = false) [protected, slot]

Inserts new empty line to the list and sets input focus to it.

Parameters:
on(not used)

References myList, and myModel.

void QtxPathListEdit::onDelete ( bool  = false) [protected, slot]

Removes currently selected path item.

Parameters:
on(not used)

References myList, and myModel.

void QtxPathListEdit::initialize ( ) [private]
QWidget * QtxPathListEdit::createEditor ( QWidget parent) [private]
Parameters:
parentparent widget for the editor
Returns:
created editor widget

References pathType(), and QtxPathEdit.setPathType().

void QtxPathListEdit::setModelData ( QWidget editor,
const QModelIndex &  index 
) [private]
Parameters:
editoreditor widget
indexdata model index

References checkDuplicate(), checkExistance(), isDuplicateEnabled(), myModel, and QtxPathEdit.path().

void QtxPathListEdit::setEditorData ( QWidget editor,
const QModelIndex &  index 
) [private]
Parameters:
editoreditor widget
indexdata model index

References myModel, and QtxPathEdit.setPath().

bool QtxPathListEdit::checkExistance ( const QString &  str,
const bool  msg = true 
) [private]
Parameters:
strpath to be checked
msgif true and path does not exist, question message box is shown
Returns:
true if the user confirms the path adding

References Qtx.makeEnvVarSubst(), pathType(), Qtx.PT_Directory, Qtx.PT_OpenFile, and Qtx.PT_SaveFile.

bool QtxPathListEdit::checkDuplicate ( const QString &  str,
const int  row,
const bool  msg = true 
) [private]
Parameters:
strpath to be checked
rowrow corresponding to the path checked
msgif true and path does not exist, warning message box is shown
Returns:
true if the user confirms the path adding

References myModel.


Friends And Related Function Documentation

friend class QtxPathListEdit::Delegate [friend]

Field Documentation

QListView* QtxPathListEdit.myList [private]
QStringListModel* QtxPathListEdit.myModel [private]
QCompleter* QtxPathListEdit.myCompleter [private]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS