![]() |
LeechCraft
0.6.70-13729-g7046a9d2a7
Modular cross-platform feature rich live environment.
|
The CategorySelector widget provides a way to select amongst a group of items. More...
#include "categoryselector.h"
Public Types | |
enum | ButtonsMode { ButtonsMode::NoButtons, ButtonsMode::Close, ButtonsMode::AcceptReject } |
Public Slots | |
void | selectAll () |
Selects all variants. More... | |
void | selectNone () |
Deselects all variants. More... | |
void | setPossibleSelections (QStringList selections, bool sort=true) |
Sets possible selections. More... | |
void | lineTextChanged (const QString &newText) |
Notifies CategorySelector about logical selection changes. More... | |
Signals | |
void | tagsSelectionChanged (const QStringList &newSelections) |
Indicates that selections have changed. More... | |
Public Member Functions | |
CategorySelector (QWidget *parent=0) | |
Constructor. More... | |
void | SetCaption (const QString &caption) |
Sets the caption of this selector. More... | |
QStringList | GetSelections () const |
Gets selected items. More... | |
QList< int > | GetSelectedIndexes () const |
Gets the indexes of the selected items. More... | |
void | SetSelections (const QStringList &subset) |
Selects some of the items. More... | |
QString | GetSeparator () const |
Returns the separator for the tags. More... | |
void | SetSeparator (const QString &) |
Sets the separator for the tags. More... | |
void | SetButtonsMode (ButtonsMode) |
Sets the buttons mode. More... | |
Protected Member Functions | |
virtual void | moveEvent (QMoveEvent *) |
Checks whether after the move event the selector won't be beoynd the screen. if it would, moves back. More... | |
The CategorySelector widget provides a way to select amongst a group of items.
The CategorySelector is a QWidget having Qt::Tool window hint. That results in representing this widget as a tool window - usually a small window with smaller than usual title bar and decoration. CategorySelector represents the possible selections as a list of check boxes.
Programmer can set the list of possible choice variants using SetPossibleSelections and get selected items with GetSelections.
CategorySelector emits selectionChanged() signal when user changes his selection. CategorySelector's primary purpose is to help user to select tags using a line edit, so there's a convenience slot lineTextChanged() which could be used to notify CategorySelector about changes of possible categories. There are also convenience slots selectAll() and selectNone() which could be used to mark all and no elements in the list respectively.
Definition at line 68 of file categoryselector.h.
|
strong |
Enumerator | |
---|---|
NoButtons | |
Close | |
AcceptReject |
Definition at line 77 of file categoryselector.h.
CategorySelector::CategorySelector | ( | QWidget * | parent = 0 | ) |
Constructor.
Sets the default window title and window flags (Qt::Tool | Qt::WindowStaysOnTopHint), calculates the default geometry.
[in] | parent | Pointer to parent widget. |
Definition at line 46 of file categoryselector.cpp.
References LC::Util::oral::sph::all, Close, NoButtons, selectAll(), selectNone(), and SetButtonsMode().
QList< int > CategorySelector::GetSelectedIndexes | ( | ) | const |
Gets the indexes of the selected items.
Returns the indexes of the selected items in the array passed to setPossibleSelections(). Please note that sorting should be disabled in setPossibleSelections() for this function to be useful.
Definition at line 142 of file categoryselector.cpp.
QStringList CategorySelector::GetSelections | ( | ) | const |
Gets selected items.
Returns the selected items - a subset of selection variants passed via SetPossibleSelections.
Definition at line 128 of file categoryselector.cpp.
References RoleTag.
QString CategorySelector::GetSeparator | ( | ) | const |
Returns the separator for the tags.
The default separator is "; ".
Definition at line 170 of file categoryselector.cpp.
|
slot |
Notifies CategorySelector about logical selection changes.
This slot is usually used to notify CategorySelector about selection changes done via a related widget - for example, a line edit with tags.
[in] | newText | The text of the line edit. |
Definition at line 256 of file categoryselector.cpp.
References SetSelections().
|
protectedvirtual |
Checks whether after the move event the selector won't be beoynd the screen. if it would, moves back.
Definition at line 198 of file categoryselector.cpp.
|
slot |
Selects all variants.
Definition at line 214 of file categoryselector.cpp.
References RoleTag, and tagsSelectionChanged().
Referenced by CategorySelector().
|
slot |
Deselects all variants.
Definition at line 238 of file categoryselector.cpp.
References tagsSelectionChanged().
Referenced by CategorySelector().
void CategorySelector::SetButtonsMode | ( | ButtonsMode | mode | ) |
Sets the buttons mode.
Definition at line 180 of file categoryselector.cpp.
References AcceptReject, LC::Util::Close, Close, and NoButtons.
Referenced by CategorySelector().
void CategorySelector::SetCaption | ( | const QString & | caption | ) |
Sets the caption of this selector.
By default, the selector has no caption.
[in] | caption | The new caption of this selector. |
Definition at line 87 of file categoryselector.cpp.
|
slot |
Sets possible selections.
Clears previous selections list, sets new possible selections according to selections parameter. By default, no items are selected.
The selections list is sorted unless the sort parameter is set to false. Please note that if you plan to call GetSelectedIndexes() you should set sort to false.
[in] | selections | Possible selections. |
[in] | sort | Whether the selections should be sorted (default is true). |
Definition at line 93 of file categoryselector.cpp.
References RoleTag, and tagsSelectionChanged().
void CategorySelector::SetSelections | ( | const QStringList & | subset | ) |
Selects some of the items.
Selects some of the items presented by elements of the subset list.
This function won't emit selectionChanged() signal.
[in] | subset | The list of items to select. |
Definition at line 156 of file categoryselector.cpp.
References RoleTag.
Referenced by lineTextChanged().
void CategorySelector::SetSeparator | ( | const QString & | sep | ) |
Sets the separator for the tags.
This function doesn't update the text in the line edit.
Definition at line 175 of file categoryselector.cpp.
|
signal |
Indicates that selections have changed.
[out] | newSelections | Selected items. |
Referenced by selectAll(), selectNone(), and setPossibleSelections().