Version: 9.15.0
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 QtxPathListEdit class represents a widget for files or directories paths list preference items editing.

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() [1/2]

QtxPathListEdit::QtxPathListEdit ( const Qtx::PathType  type,
QWidget parent = 0 
)

Constructor.

Parameters
typewidget mode (Qtx::PathType)
parentparent widget
See also
pathType(), setPathType()

References initialize().

◆ QtxPathListEdit() [2/2]

QtxPathListEdit::QtxPathListEdit ( QWidget parent = 0)

Constructor.

Qtx::PT_OpenFile mode is used by default.

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

References initialize().

◆ ~QtxPathListEdit()

QtxPathListEdit::~QtxPathListEdit ( )
virtual

Destructor.

Member Function Documentation

◆ checkDuplicate()

bool QtxPathListEdit::checkDuplicate ( const QString &  str,
const int  row,
const bool  msg = true 
)
private

Check if path already exists in the list and optionally show the warning message box.

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.

◆ checkExistance()

bool QtxPathListEdit::checkExistance ( const QString &  str,
const bool  msg = true 
)
private

Check if path is correct (exists) and optionally show the question message box.

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.

◆ clear()

void QtxPathListEdit::clear ( )

Clear paths list.

References myModel.

◆ contains()

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

Check if the specified path already exists in the paths list.

Parameters
pathpath to be checked
Returns
true if the path is already selected by the user or false otherwise

References myModel.

◆ count()

int QtxPathListEdit::count ( ) const

Get number of currently entered paths.

Returns
current paths number

References myModel.

◆ createEditor()

QWidget * QtxPathListEdit::createEditor ( QWidget parent)
private

Create editor widget.

Parameters
parentparent widget for the editor
Returns
created editor widget

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

◆ eventFilter()

bool QtxPathListEdit::eventFilter ( QObject o,
QEvent e 
)

Customize child widget events processing.

Parameters
oevent receiver object
eevent
Returns
true if the further event processing should be stopped.

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

◆ initialize()

void QtxPathListEdit::initialize ( )
private

Perform internal widget initialization.

References delete_icon, insert_icon, movedown_icon, moveup_icon, myList, myModel, onDelete(), onDown(), onInsert(), and onUp().

◆ insert()

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

Add path to the list of paths.

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.

◆ isDuplicateEnabled()

bool QtxPathListEdit::isDuplicateEnabled ( ) const

Check if the duplication of paths is enabled.

Returns
true if the duplication is enabled

References myDuplicate.

◆ onDelete

void QtxPathListEdit::onDelete ( bool  = false)
protectedslot

Called when <Delete> button is clicked.

Removes currently selected path item.

Parameters
on(not used)

References myList, and myModel.

◆ onDown

void QtxPathListEdit::onDown ( bool  = false)
protectedslot

Called when <Down> button is clicked.

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

Parameters
on(not used)

References myList, and myModel.

◆ onInsert

void QtxPathListEdit::onInsert ( bool  = false)
protectedslot

Called when <Insert> button is clicked.

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

Parameters
on(not used)

References myList, and myModel.

◆ onUp

void QtxPathListEdit::onUp ( bool  = false)
protectedslot

Called when <Up> button is clicked.

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

Parameters
on(not used)

References myList, and myModel.

◆ pathList()

QStringList QtxPathListEdit::pathList ( ) const

Get currently selected paths list.

Returns
files or directories paths list entered by the user
See also
setPathList()

References myModel.

◆ pathType()

Qtx::PathType QtxPathListEdit::pathType ( ) const

Get widget mode.

Returns
currently used widget mode (Qtx::PathType)
See also
setPathType()

References myType.

◆ remove() [1/2]

void QtxPathListEdit::remove ( const int  idx)

Remove path from the paths list.

Parameters
idxpath index in the list

References myModel.

◆ remove() [2/2]

void QtxPathListEdit::remove ( const QString &  path)

Remove path from the paths list.

Parameters
pathpath to be removed

References myModel.

◆ setDuplicateEnabled()

void QtxPathListEdit::setDuplicateEnabled ( const bool  on)

Enable/disable paths duplication.

Parameters
onnew flag value

References myDuplicate.

◆ setEditorData()

void QtxPathListEdit::setEditorData ( QWidget editor,
const QModelIndex &  index 
)
private

Set data to the editor from the list widget when user starts path edition.

Parameters
editoreditor widget
indexdata model index

References myModel, and QtxPathEdit::setPath().

◆ setModelData()

void QtxPathListEdit::setModelData ( QWidget editor,
const QModelIndex &  index 
)
private

Set modified data from the editor to the list widget.

Parameters
editoreditor widget
indexdata model index

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

◆ setPathList()

void QtxPathListEdit::setPathList ( const QStringList &  lst)

Set paths list.

Parameters
lstfiles or directories paths list
See also
pathList()

References myModel.

◆ setPathType()

void QtxPathListEdit::setPathType ( const Qtx::PathType  t)

Set widget mode.

Parameters
tnew widget mode (Qtx::PathType)
See also
pathType()

References myCompleter, and myType.

Friends And Related Function Documentation

◆ QtxPathListEdit::Delegate

friend class QtxPathListEdit::Delegate
friend

Member Data Documentation

◆ myCompleter

QCompleter* QtxPathListEdit::myCompleter
private

◆ myDuplicate

bool QtxPathListEdit::myDuplicate
private

◆ myList

QListView* QtxPathListEdit::myList
private

◆ myModel

QStringListModel* QtxPathListEdit::myModel
private

◆ myType

Qtx::PathType QtxPathListEdit::myType
private

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