![]() |
LeechCraft 0.6.70-19424-g027e980fd1
Modular cross-platform feature rich live environment.
|
Makes a QLineEdit edit a list of tags. More...
#include "tagseditoraddon.h"
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 |
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.
|
strong |
| Enumerator | |
|---|---|
| None | |
| NoSelectorButton | |
Definition at line 48 of file tagseditoraddon.h.
| 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().
| 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().
| 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.
| std::logic_error | if 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().
| 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.
| std::logic_error | if 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().
|
overrideprotected |
Definition at line 164 of file tagseditoraddon.cpp.
| 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.
| 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().
| void LC::Util::TagsEditorAddon::SetSeparator | ( | const QString & | separator | ) |
Sets the separator. The text is not updated.
| std::invalid_argument | if the separator is empty. |
Definition at line 89 of file tagseditoraddon.cpp.
| 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().
|
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().
|
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.
| 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().