![]() |
LeechCraft 0.6.70-17335-ge406ffdcaf
Modular cross-platform feature rich live environment.
|
The CategorySelector widget provides a way to select amongst a group of items. More...
#include "categoryselector.h"
Classes | |
class | SelectorTagsModel |
Public Types | |
enum class | ButtonsMode { NoButtons , Close , AcceptReject } |
Signals | |
void | tagsSelectionChanged (const QStringList &newSelections) |
Indicates that selections have changed. | |
Public Member Functions | |
CategorySelector (QWidget *parent=nullptr) | |
Constructor. | |
void | SetCaption (const QString &caption) |
Sets the caption of this selector. | |
QStringList | GetSelections () const |
Gets selected items. | |
QList< int > | GetSelectedIndexes () const |
Gets the indexes of the selected items. | |
void | SetSelections (const QStringList &subset) |
Selects some of the items. | |
QString | GetSeparator () const |
Returns the separator for the tags. | |
void | SetSeparator (const QString &) |
Sets the separator for the tags. | |
void | SetButtonsMode (ButtonsMode) |
Sets the buttons mode. | |
virtual void | SetPossibleSelections (QStringList selections, bool sort=true) |
Sets possible selections. | |
QStringList | GetPossibleSelections () const |
void | SelectAll () |
Selects all variants. | |
void | SelectNone () |
Deselects all variants. | |
void | SetSelectionsFromString (const QString &newText) |
Notifies CategorySelector about logical selection changes. | |
Protected Member Functions | |
void | moveEvent (QMoveEvent *) override |
Checks whether after the move event the selector won't be beoynd the screen. if it would, moves back. | |
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 function SetSelectionsFromString() which can 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 46 of file categoryselector.h.
|
strong |
Enumerator | |
---|---|
NoButtons | |
Close | |
AcceptReject |
Definition at line 58 of file categoryselector.h.
|
explicit |
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 109 of file categoryselector.cpp.
References CategorySelector(), Close, LC::Util::GetDefaultTagsSeparator(), NoButtons, SelectAll(), SelectNone(), and SetButtonsMode().
Referenced by CategorySelector(), and LC::Util::CategorySelector::SelectorTagsModel::SelectorTagsModel().
QStringList LC::Util::CategorySelector::GetPossibleSelections | ( | ) | const |
Definition at line 161 of file categoryselector.cpp.
QList< int > LC::Util::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 177 of file categoryselector.cpp.
Referenced by GetSelections().
QStringList LC::Util::CategorySelector::GetSelections | ( | ) | const |
Gets selected items.
Returns the selected items - a subset of selection variants passed via SetPossibleSelections.
Definition at line 166 of file categoryselector.cpp.
References GetSelectedIndexes().
QString LC::Util::CategorySelector::GetSeparator | ( | ) | const |
Returns the separator for the tags.
Definition at line 207 of file categoryselector.cpp.
|
overrideprotected |
Checks whether after the move event the selector won't be beoynd the screen. if it would, moves back.
Definition at line 235 of file categoryselector.cpp.
void LC::Util::CategorySelector::SelectAll | ( | ) |
Selects all variants.
Definition at line 251 of file categoryselector.cpp.
Referenced by CategorySelector().
void LC::Util::CategorySelector::SelectNone | ( | ) |
Deselects all variants.
Definition at line 256 of file categoryselector.cpp.
Referenced by CategorySelector().
void LC::Util::CategorySelector::SetButtonsMode | ( | ButtonsMode | mode | ) |
Sets the buttons mode.
Definition at line 217 of file categoryselector.cpp.
References AcceptReject, Close, and NoButtons.
Referenced by CategorySelector().
void LC::Util::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 146 of file categoryselector.cpp.
|
virtual |
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 151 of file categoryselector.cpp.
void LC::Util::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 192 of file categoryselector.cpp.
Referenced by SetSelectionsFromString().
void LC::Util::CategorySelector::SetSelectionsFromString | ( | const QString & | newText | ) |
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 261 of file categoryselector.cpp.
References SetSelections().
Referenced by LC::Util::TagsLineEdit::AddSelector().
void LC::Util::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 212 of file categoryselector.cpp.
Referenced by LC::Util::TagsLineEdit::AddSelector().
|
signal |
Indicates that selections have changed.
[out] | newSelections | Selected items. |
Referenced by LC::Util::TagsLineEdit::AddSelector().