LeechCraft
0.6.70-19424-g027e980fd1
Modular cross-platform feature rich live environment.
Toggle main menu visibility
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
16
class
ITagsManager
;
17
class
QAbstractItemModel;
18
class
QAction;
19
class
QCompleter;
20
class
QLineEdit;
21
class
QPoint;
22
23
namespace
LC::Util
24
{
25
class
CategorySelector
;
26
class
LineEditButtonManager
;
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
148
Q_DECLARE_OPERATORS_FOR_FLAGS (LC::Util::TagsEditorAddon::Flags)
ITagsManager
Tags manager's interface.
Definition
itagsmanager.h:91
LC::Util::CategorySelector
A checklist over a model of names.
Definition
categoryselector.h:28
LC::Util::LineEditButtonManager
Manages additional overlay buttons in a QLineEdit.
Definition
lineeditbuttonmanager.h:37
LC::Util::TagsEditorAddon
Makes a QLineEdit edit a list of tags.
Definition
tagseditoraddon.h:37
LC::Util::TagsEditorAddon::tagsCommitted
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 ...
LC::Util::TagsEditorAddon::tagPicked
void tagPicked()
Emitted after the text has been updated with a pick made in the selector or the completer,...
LC::Util::TagsEditorAddon::TagsEditorAddon
TagsEditorAddon(QLineEdit &edit, QAbstractItemModel &model, Flags flags=Flag::None)
Attaches to edit with model as the tags model; model is not owned.
Definition
tagseditoraddon.cpp:31
LC::Util::TagsEditorAddon::Flag
Flag
Definition
tagseditoraddon.h:49
LC::Util
Definition
icoreproxy.h:34
LC::Util::Q_DECLARE_FLAGS
Q_DECLARE_FLAGS(FitFlags, FitFlag)
LC::Util::TagsChange
A change of a tags list, described by its old and new versions.
Definition
tagschange.h:22
tagsconfig.h
UTIL_TAGS_API
#define UTIL_TAGS_API
Definition
tagsconfig.h:16
src
util
tags
tagseditoraddon.h
Generated by
1.18.0