Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

Classes

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

Protected Slots

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

Private Member Functions

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

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

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.

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.

void QtxPathListEdit::clear ( )

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.

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

References myModel.

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

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

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::initialize ( )
private
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::isDuplicateEnabled ( ) const
Returns
true if the duplication is enabled

References myDuplicate.

void QtxPathListEdit::onDelete ( bool  = false)
protectedslot

Removes currently selected path item.

Parameters
on(not used)

References myList, and myModel.

void QtxPathListEdit::onDown ( bool  = false)
protectedslot

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)
protectedslot

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

Parameters
on(not used)

References myList, and myModel.

void QtxPathListEdit::onUp ( bool  = false)
protectedslot

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

Parameters
on(not used)

References myList, and myModel.

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

References myModel.

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

References myType.

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::setDuplicateEnabled ( const bool  on)
Parameters
onnew flag value

References myDuplicate.

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

References myModel, and QtxPathEdit::setPath().

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::setPathList ( const QStringList &  lst)
Parameters
lstfiles or directories paths list
See Also
pathList()

References myModel.

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

References myCompleter, and myType.

Friends And Related Function Documentation

friend class QtxPathListEdit::Delegate
friend

Member Data Documentation

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

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