Changeset View
Changeset View
Standalone View
Standalone View
src/tagwidget.h
Show All 35 Lines | 29 | namespace Baloo { | |||
---|---|---|---|---|---|
36 | * | 36 | * | ||
37 | * TagWidget provides a simple GUI interface to assign tags. | 37 | * TagWidget provides a simple GUI interface to assign tags. | ||
38 | * | 38 | * | ||
39 | * \author Sebastian Trueg <trueg@kde.org> | 39 | * \author Sebastian Trueg <trueg@kde.org> | ||
40 | */ | 40 | */ | ||
41 | class BALOO_WIDGETS_EXPORT TagWidget : public QWidget | 41 | class BALOO_WIDGETS_EXPORT TagWidget : public QWidget | ||
42 | { | 42 | { | ||
43 | Q_OBJECT | 43 | Q_OBJECT | ||
44 | public: | ||||
45 | /** | ||||
46 | * Modify how items are displayed | ||||
47 | */ | ||||
48 | enum DisplayMode : uint { | ||||
49 | Unrestricted = 0, /// Display items as links and add a 'Change' link. | ||||
50 | ReadOnly = 1, /// Display items as links. | ||||
51 | NoLinks = 2, /// Add a 'Change' link. | ||||
52 | ReadOnlyNoLinks = ReadOnly | NoLinks, /// Display as plain text. | ||||
53 | Tags = 0x100 /// Use 'tags://' as base URL. | ||||
54 | }; | ||||
44 | 55 | | |||
45 | public: | 56 | public: | ||
46 | /** | 57 | /** | ||
47 | * Constructor | 58 | * Constructor | ||
48 | */ | 59 | */ | ||
49 | explicit TagWidget(QWidget* parent = 0); | 60 | explicit TagWidget(QWidget* parent = 0); | ||
50 | 61 | | |||
51 | /** | 62 | /** | ||
Show All 23 Lines | |||||
75 | * If the widget is read only | 86 | * If the widget is read only | ||
76 | */ | 87 | */ | ||
77 | bool readOnly() const; | 88 | bool readOnly() const; | ||
78 | 89 | | |||
79 | Q_SIGNALS: | 90 | Q_SIGNALS: | ||
80 | /** | 91 | /** | ||
81 | * This signal is emitted whenever a tag is clicked. | 92 | * This signal is emitted whenever a tag is clicked. | ||
82 | */ | 93 | */ | ||
83 | void tagClicked(const QString&); | 94 | void tagClicked(const QUrl&); | ||
84 | 95 | | |||
85 | /** | 96 | /** | ||
86 | * Emitted whenever the selection of tags changes. | 97 | * Emitted whenever the selection of tags changes. | ||
87 | * | 98 | * | ||
88 | * \since 4.5 | 99 | * \since 4.5 | ||
89 | */ | 100 | */ | ||
90 | void selectionChanged(const QStringList& tags); | 101 | void selectionChanged(const QStringList& tags); | ||
91 | 102 | | |||
92 | public Q_SLOTS: | 103 | public Q_SLOTS: | ||
93 | /** | 104 | /** | ||
94 | * Set the list of selected tags. In case resources have been | 105 | * Set the list of selected tags. In case resources have been | ||
95 | * set via setTaggedResource() or setTaggedResources() their | 106 | * set via setTaggedResource() or setTaggedResources() their | ||
96 | * list of tags is changed automatically. | 107 | * list of tags is changed automatically. | ||
97 | * | 108 | * | ||
98 | * \since 4.5 | 109 | * \since 4.5 | ||
99 | */ | 110 | */ | ||
100 | void setSelectedTags(const QStringList& tags); | 111 | void setSelectedTags(const QStringList& tags); | ||
112 | /** | ||||
113 | * Set the list of tags. | ||||
114 | * | ||||
115 | * \p propertyName - the property the tags belong to. | ||||
116 | * \p tags - list of tags or token-like strings. | ||||
117 | * \since 4.5 | ||||
118 | */ | ||||
119 | | ||||
120 | void setSelectedTags(const QString& propertyName, const QStringList& tags); | ||||
101 | 121 | | |||
102 | /** | 122 | /** | ||
103 | * Set the alignment to use. Only horizontal alignment flags make a | 123 | * Set the alignment to use. Only horizontal alignment flags make a | ||
104 | * difference. | 124 | * difference. | ||
105 | * | 125 | * | ||
106 | * \since 4.5 | 126 | * \since 4.5 | ||
107 | */ | 127 | */ | ||
108 | void setAlignment( Qt::Alignment alignment ); | 128 | void setAlignment( Qt::Alignment alignment ); | ||
109 | 129 | | |||
110 | /** | 130 | /** | ||
111 | * Set the TagWidget as read only | 131 | * Set the TagWidget as read only | ||
112 | */ | 132 | */ | ||
113 | void setReadyOnly(bool readOnly = true); | 133 | void setReadyOnly(bool readOnly = true); | ||
134 | /** | ||||
135 | * Set the name of the property. | ||||
136 | * Default is 'tags' | ||||
137 | */ | ||||
138 | void setPropertyName(const QString& name); | ||||
139 | bool displayAsLinks() const; | ||||
140 | void setDisplayAsLinks(const bool asLinks); | ||||
114 | 141 | | |||
115 | private Q_SLOTS: | 142 | private Q_SLOTS: | ||
116 | void slotShowAll(); | 143 | void slotShowAll(); | ||
117 | void slotTagUpdateDone(); | 144 | void slotTagUpdateDone(); | ||
118 | void slotKEditTagDialogFinished( int result ); | 145 | void slotKEditTagDialogFinished( int result ); | ||
119 | 146 | | |||
120 | private: | 147 | private: | ||
121 | TagWidgetPrivate* const d; | 148 | TagWidgetPrivate* const d; | ||
122 | }; | 149 | }; | ||
123 | } | 150 | } | ||
124 | 151 | | |||
125 | #endif | 152 | #endif |