13#include <QContextMenuEvent>
17#include <QAbstractItemView>
43 button->setIconSize ({ 16, 16 });
45 button->setCursor (Qt::ArrowCursor);
51 &QToolButton::clicked,
65 QAbstractItemModel *
model = Completer_->model ();
68 for (
int i = 0;
i <
model->rowCount (); ++
i)
82 &QLineEdit::textChanged,
95 if (CategorySelector_)
101 if (Completer_->widget () !=
this)
107 int pos =
wtext.lastIndexOf (Separator_);
122 if (CategorySelector_)
128 if (Completer_ && Completer_->popup ()->isVisible ())
135 case Qt::Key_Backtab:
142 QLineEdit::keyPressEvent (
e);
144 bool cos =
e->modifiers () & (Qt::ControlModifier |
148 bool isShortcut =
e->modifiers () & (Qt::ControlModifier |
152 (
cos &&
e->text ().isEmpty ()) ||
158 Completer_->popup ()->
160 Completer_->complete ();
166 Completer_->setWidget (
this);
167 QLineEdit::focusInEvent (
e);
172 if (!CategorySelector_ || CategorySelector_->parentWidget () !=
this)
174 QLineEdit::contextMenuEvent (
e);
178 CategorySelector_->move (
e->globalPos ());
179 CategorySelector_->show ();
195 Completer_->setWidget (
this);
196 Completer_->setCompletionMode (QCompleter::PopupCompletion);
200 &TagsLineEdit::InsertTag);
203 QString TagsLineEdit::textUnderCursor ()
const
205 auto rxStr = Separator_;
217 last =
wtext.size ();
The CategorySelector widget provides a way to select amongst a group of items.
void SetSelections(const QStringList &subset)
Selects some of the items.
void SetSeparator(const QString &)
Sets the separator for the tags.
virtual void SetPossibleSelections(QStringList selections, bool sort=true)
Sets possible selections.
void SetSelectionsFromString(const QString &newText)
Notifies CategorySelector about logical selection changes.
void tagsSelectionChanged(const QStringList &newSelections)
Indicates that selections have changed.
Container< T > Filter(const Container< T > &c, F f)
QString GetDefaultTagsSeparator()