LeechCraft 0.6.70-19424-g027e980fd1
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
LC::Util::TagsEditorAddon Class Reference

Makes a QLineEdit edit a list of tags. More...

#include "tagseditoraddon.h"

Inheritance diagram for LC::Util::TagsEditorAddon:
Collaboration diagram for LC::Util::TagsEditorAddon:

Public Types

enum class  Flag : std::uint8_t {
  None = 0 ,
  NoSelectorButton = 0b1
}

Signals

void tagPicked ()
 Emitted after the text has been updated with a pick made in the selector or the completer, also when the pick leaves the tags intact.
void tagsCommitted (const TagsChange &change)
 Emitted when the user has changed the tags, by a pick or by editing the text and then pressing Enter or moving the focus away.

Public Member Functions

 TagsEditorAddon (QLineEdit &edit, QAbstractItemModel &model, Flags flags=Flag::None)
 Attaches to edit with model as the tags model; model is not owned.
 TagsEditorAddon (QLineEdit &edit, ITagsManager &tm, Flags flags=Flag::None)
 Attaches to edit with the model of tm as the tags model, as the model overload does.
QString GetSeparator () const
 Returns the separator the tags are joined by, GetDefaultTagsSeparator() by default.
void SetSeparator (const QString &)
 Sets the separator. The text is not updated.
void AddSelectorButton (LineEditButtonManager *manager=nullptr)
 Adds a button, to manager or to a new one, opening a popup CategorySelectorWindow bound as via BindSelector().
void BindSelector (CategorySelector &selector)
 Binds selector to the edit.
void SetTags (const QStringList &tags)
 Shows tags: sets the text to them joined by the separator and syncs the bound selector. The subsequent tagsCommitted() signals are relative to these tags.
void UpdateTags (const QStringList &tags)
 Shows tags as via SetTags() unless the text differs from the shown tags.
QStringList GetTags () const
 Returns the tags in the text, split at the separator and trimmed (see SplitTags()).

Protected Member Functions

bool eventFilter (QObject *, QEvent *) override

Detailed Description

Makes a QLineEdit edit a list of tags.

The token under the cursor is completed from the tags model, the bound selector lists that model and follows the text, and the user's changes are reported as set differences via tagsCommitted(). The object is owned by the edit it is attached to.

Definition at line 36 of file tagseditoraddon.h.

Member Enumeration Documentation

◆ Flag

enum class LC::Util::TagsEditorAddon::Flag : std::uint8_t
strong
Enumerator
None 
NoSelectorButton 

Definition at line 48 of file tagseditoraddon.h.

Constructor & Destructor Documentation

◆ TagsEditorAddon() [1/2]

LC::Util::TagsEditorAddon::TagsEditorAddon ( QLineEdit & edit,
QAbstractItemModel & model,
Flags flags = Flag::None )

Attaches to edit with model as the tags model; model is not owned.

Unless flags has Flag::NoSelectorButton, the selector button is added as via AddSelectorButton().

Definition at line 31 of file tagseditoraddon.cpp.

References AddSelectorButton(), LC::Util::GetDefaultTagsSeparator(), GetTags(), NoSelectorButton, and tagPicked().

Referenced by TagsEditorAddon().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TagsEditorAddon() [2/2]

LC::Util::TagsEditorAddon::TagsEditorAddon ( QLineEdit & edit,
ITagsManager & tm,
Flags flags = Flag::None )

Attaches to edit with the model of tm as the tags model, as the model overload does.

Definition at line 79 of file tagseditoraddon.cpp.

References TagsEditorAddon().

Here is the call graph for this function:

Member Function Documentation

◆ AddSelectorButton()

void LC::Util::TagsEditorAddon::AddSelectorButton ( LineEditButtonManager * manager = nullptr)

Adds a button, to manager or to a new one, opening a popup CategorySelectorWindow bound as via BindSelector().

The popup also opens from the Select tags... entry added at the top of the edit's context menu and by Alt+Down while the edit has focus. The popup counts as the bound selector. The constructor does this unless given Flag::NoSelectorButton; call it directly to use a shared manager.

Exceptions
std::logic_errorif a selector is bound already.

Definition at line 97 of file tagseditoraddon.cpp.

References LC::Util::LineEditButtonManager::Add(), BindSelector(), and LC::Util::CategorySelectorWindow::Close.

Referenced by TagsEditorAddon().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BindSelector()

void LC::Util::TagsEditorAddon::BindSelector ( CategorySelector & selector)

Binds selector to the edit.

The selector lists the tags model and shows the tags in the text selected. A choice made in it replaces the tags from the model in the text, keeps the other tokens, and emits tagPicked(). At most one selector is bound, the popup of AddSelectorButton() included.

Exceptions
std::logic_errorif a selector is bound already.

Definition at line 128 of file tagseditoraddon.cpp.

References GetTags(), LC::Util::CategorySelector::selectionEdited(), LC::Util::CategorySelector::SetModel(), and LC::Util::CategorySelector::SetSelections().

Referenced by AddSelectorButton().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eventFilter()

bool LC::Util::TagsEditorAddon::eventFilter ( QObject * obj,
QEvent * event )
overrideprotected

Definition at line 164 of file tagseditoraddon.cpp.

◆ GetSeparator()

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

Returns the separator the tags are joined by, GetDefaultTagsSeparator() by default.

Definition at line 84 of file tagseditoraddon.cpp.

◆ GetTags()

QStringList LC::Util::TagsEditorAddon::GetTags ( ) const

Returns the tags in the text, split at the separator and trimmed (see SplitTags()).

Definition at line 159 of file tagseditoraddon.cpp.

References LC::Util::SplitTags().

Referenced by TagsEditorAddon(), and BindSelector().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetSeparator()

void LC::Util::TagsEditorAddon::SetSeparator ( const QString & separator)

Sets the separator. The text is not updated.

Exceptions
std::invalid_argumentif the separator is empty.

Definition at line 89 of file tagseditoraddon.cpp.

◆ SetTags()

void LC::Util::TagsEditorAddon::SetTags ( const QStringList & tags)

Shows tags: sets the text to them joined by the separator and syncs the bound selector. The subsequent tagsCommitted() signals are relative to these tags.

Definition at line 143 of file tagseditoraddon.cpp.

Referenced by UpdateTags().

Here is the caller graph for this function:

◆ tagPicked

void LC::Util::TagsEditorAddon::tagPicked ( )
signal

Emitted after the text has been updated with a pick made in the selector or the completer, also when the pick leaves the tags intact.

Referenced by TagsEditorAddon().

Here is the caller graph for this function:

◆ tagsCommitted

void LC::Util::TagsEditorAddon::tagsCommitted ( const TagsChange & change)
signal

Emitted when the user has changed the tags, by a pick or by editing the text and then pressing Enter or moving the focus away.

The change is relative to the tags last shown via SetTags() or UpdateTags(), or reported by the previous emission, whichever happened last. Edits keeping the set of the tags intact are not reported.

◆ UpdateTags()

void LC::Util::TagsEditorAddon::UpdateTags ( const QStringList & tags)

Shows tags as via SetTags() unless the text differs from the shown tags.

Definition at line 151 of file tagseditoraddon.cpp.

References LC::Util::TagsChange::IsEmpty(), and SetTags().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
  • /home/abuild/rpmbuild/BUILD/leechcraft-doc-0.6.70+git.19424.g027e980fd1-build/leechcraft-0.6.70-19424-g027e980fd1/src/util/tags/tagseditoraddon.h
  • /home/abuild/rpmbuild/BUILD/leechcraft-doc-0.6.70+git.19424.g027e980fd1-build/leechcraft-0.6.70-19424-g027e980fd1/src/util/tags/tagseditoraddon.cpp