LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
LC::Util::CategorySelector Class Reference

The CategorySelector widget provides a way to select amongst a group of items. More...

#include "categoryselector.h"

+ Inheritance diagram for LC::Util::CategorySelector:
+ Collaboration diagram for LC::Util::CategorySelector:

Public Types

enum  ButtonsMode {
  ButtonsMode::NoButtons,
  ButtonsMode::Close,
  ButtonsMode::AcceptReject
}
 

Signals

void tagsSelectionChanged (const QStringList &newSelections)
 Indicates that selections have changed. More...
 

Public Member Functions

 CategorySelector (QWidget *parent=nullptr)
 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...
 
void SetPossibleSelections (QStringList selections, bool sort=true)
 Sets possible selections. More...
 
void SelectAll ()
 Selects all variants. More...
 
void SelectNone ()
 Deselects all variants. More...
 
void SetSelectionsFromString (const QString &newText)
 Notifies CategorySelector about logical selection changes. More...
 

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. More...
 

Detailed Description

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.

Member Enumeration Documentation

◆ ButtonsMode

Enumerator
NoButtons 
Close 
AcceptReject 

Definition at line 56 of file categoryselector.h.

Constructor & Destructor Documentation

◆ CategorySelector()

LC::Util::CategorySelector::CategorySelector ( QWidget *  parent = nullptr)
explicit

Constructor.

Sets the default window title and window flags (Qt::Tool | Qt::WindowStaysOnTopHint), calculates the default geometry.

Parameters
[in]parentPointer to parent widget.

Definition at line 33 of file categoryselector.cpp.

Member Function Documentation

◆ GetSelectedIndexes()

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.

See also
GetSelections()

Definition at line 119 of file categoryselector.cpp.

◆ GetSelections()

QStringList LC::Util::CategorySelector::GetSelections ( ) const

Gets selected items.

Returns the selected items - a subset of selection variants passed via SetPossibleSelections.

Returns
Selected items.
See also
SetPossibleSelections()
GetSelectedIndexes()

Definition at line 105 of file categoryselector.cpp.

Referenced by SetSelectionsFromString().

+ Here is the caller graph for this function:

◆ GetSeparator()

QString LC::Util::CategorySelector::GetSeparator ( ) const

Returns the separator for the tags.

See also
SetSeparator()
GetDefaultTagsSeparator()

Definition at line 147 of file categoryselector.cpp.

◆ moveEvent()

void LC::Util::CategorySelector::moveEvent ( QMoveEvent *  e)
overrideprotected

Checks whether after the move event the selector won't be beoynd the screen. if it would, moves back.

Definition at line 175 of file categoryselector.cpp.

◆ SelectAll()

void LC::Util::CategorySelector::SelectAll ( )

Selects all variants.

Definition at line 191 of file categoryselector.cpp.

◆ SelectNone()

void LC::Util::CategorySelector::SelectNone ( )

Deselects all variants.

Definition at line 199 of file categoryselector.cpp.

◆ SetButtonsMode()

void LC::Util::CategorySelector::SetButtonsMode ( ButtonsMode  mode)

Sets the buttons mode.

Definition at line 157 of file categoryselector.cpp.

◆ SetCaption()

void LC::Util::CategorySelector::SetCaption ( const QString &  caption)

Sets the caption of this selector.

By default, the selector has no caption.

Parameters
[in]captionThe new caption of this selector.

Definition at line 74 of file categoryselector.cpp.

◆ SetPossibleSelections()

void LC::Util::CategorySelector::SetPossibleSelections ( QStringList  selections,
bool  sort = true 
)

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.

Parameters
[in]selectionsPossible selections.
[in]sortWhether the selections should be sorted (default is true).
See also
GetSelections()
GetSelectedIndexes()

Definition at line 80 of file categoryselector.cpp.

References LC::Util::RoleTag.

◆ SetSelections()

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.

Parameters
[in]subsetThe list of items to select.

Definition at line 133 of file categoryselector.cpp.

◆ 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.

Parameters
[in]newTextThe text of the line edit.

Definition at line 207 of file categoryselector.cpp.

References GetSelections(), and tagsSelectionChanged().

+ Here is the call graph for this function:

◆ SetSeparator()

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.

See also
GetSeparator()

Definition at line 152 of file categoryselector.cpp.

References NoButtons.

Referenced by LC::Util::TagsLineEdit::GetSeparator().

+ Here is the caller graph for this function:

◆ tagsSelectionChanged

void LC::Util::CategorySelector::tagsSelectionChanged ( const QStringList &  newSelections)
signal

Indicates that selections have changed.

Parameters
[out]newSelectionsSelected items.

Referenced by SetSelectionsFromString().

+ Here is the caller graph for this function:

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