LeechCraft 0.6.70-19424-g027e980fd1
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
tagseditoraddon.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <QObject>
12#include <QPointer>
13#include <QStringList>
14#include "tagsconfig.h"
15
16class ITagsManager;
17class QAbstractItemModel;
18class QAction;
19class QCompleter;
20class QLineEdit;
21class QPoint;
22
23namespace LC::Util
24{
25 class CategorySelector;
27 struct TagsChange;
28
36 class UTIL_TAGS_API TagsEditorAddon : public QObject
37 {
38 Q_OBJECT
39
40 QLineEdit& Edit_;
41 QCompleter& Completer_;
42 QString Separator_;
43 QString CompletionPrefix_;
44 QStringList ShownTags_;
45 QPointer<CategorySelector> Selector_;
46 QPointer<QAction> SelectorAction_;
47 public:
48 enum class Flag : std::uint8_t
49 {
50 None = 0,
51 NoSelectorButton = 0b1
52 };
53 Q_DECLARE_FLAGS (Flags, Flag)
54
55
60 TagsEditorAddon (QLineEdit& edit, QAbstractItemModel& model, Flags flags = Flag::None);
61
64 TagsEditorAddon (QLineEdit& edit, ITagsManager& tm, Flags flags = Flag::None);
65
68 QString GetSeparator () const;
69
74 void SetSeparator (const QString&);
75
87 void AddSelectorButton (LineEditButtonManager *manager = nullptr);
88
98 void BindSelector (CategorySelector& selector);
99
104 void SetTags (const QStringList& tags);
105
108 void UpdateTags (const QStringList& tags);
109
112 QStringList GetTags () const;
113 protected:
114 bool eventFilter (QObject*, QEvent*) override;
115 private:
116 struct TokenRange
117 {
118 qsizetype Begin_;
119 qsizetype End_;
120 };
121 TokenRange TokenUnderCursor () const;
122 QString PrefixUnderCursor () const;
123
124 void Complete ();
125 void InsertTag (const QString& completion);
126 void ApplyChoice (const QStringList& chosen);
127 void ShowContextMenu (const QPoint& pos);
128
129 bool IsEdited () const;
130 void ReportEdit ();
131 signals:
135 void tagPicked ();
136
144 void tagsCommitted (const TagsChange& change);
145 };
146}
147
148Q_DECLARE_OPERATORS_FOR_FLAGS (LC::Util::TagsEditorAddon::Flags)
Tags manager's interface.
A checklist over a model of names.
Manages additional overlay buttons in a QLineEdit.
Makes a QLineEdit edit a list of tags.
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 ...
void tagPicked()
Emitted after the text has been updated with a pick made in the selector or the completer,...
TagsEditorAddon(QLineEdit &edit, QAbstractItemModel &model, Flags flags=Flag::None)
Attaches to edit with model as the tags model; model is not owned.
Q_DECLARE_FLAGS(FitFlags, FitFlag)
A change of a tags list, described by its old and new versions.
Definition tagschange.h:22
#define UTIL_TAGS_API
Definition tagsconfig.h:16