Krita Source Code Documentation
Loading...
Searching...
No Matches
KisWdgTagSelectionControllerBundleTags Class Reference

#include <wdgtagselection.h>

+ Inheritance diagram for KisWdgTagSelectionControllerBundleTags:

Classes

struct  TagResourceType
 

Public Slots

void slotAddTag (KoID tag)
 
void slotRemoveTag (KoID tag)
 

Signals

void tagAdded (KoID tag)
 
void tagRemoved (KoID tag)
 

Public Member Functions

void addTag (KoID tag)
 
QList< int > getSelectedTagIds () const
 
 KisWdgTagSelectionControllerBundleTags (KisTagSelectionWidget *widget, bool editable)
 
void setResourceType (const QString &resourceType)
 
void updateView ()
 
 ~KisWdgTagSelectionControllerBundleTags () override
 

Private Attributes

bool m_editable {true}
 
QString m_resourceType {""}
 
QList< KoIDm_selectedTags
 
QMap< QString, QList< KoID > > m_selectedTagsByResourceType
 
QSharedPointer< KisTagModelm_tagModel
 
QSharedPointer< KisTagResourceModelm_tagResourceModel
 
KisTagSelectionWidgetm_tagSelectionWidget {0}
 

Detailed Description

Definition at line 49 of file wdgtagselection.h.

Constructor & Destructor Documentation

◆ KisWdgTagSelectionControllerBundleTags()

KisWdgTagSelectionControllerBundleTags::KisWdgTagSelectionControllerBundleTags ( KisTagSelectionWidget * widget,
bool editable )

Definition at line 183 of file wdgtagselection.cpp.

184 : QObject(widget)
185 , m_tagSelectionWidget(widget)
186 , m_editable(editable)
187{
188 connect(widget, SIGNAL(sigAddTagToSelection(KoID)), this, SLOT(slotAddTag(KoID)));
189 connect(widget, SIGNAL(sigRemoveTagFromSelection(KoID)), this, SLOT(slotRemoveTag(KoID)));
190 updateView();
191}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisTagSelectionWidget * m_tagSelectionWidget
Definition KoID.h:30

References connect(), slotAddTag(), slotRemoveTag(), and updateView().

◆ ~KisWdgTagSelectionControllerBundleTags()

KisWdgTagSelectionControllerBundleTags::~KisWdgTagSelectionControllerBundleTags ( )
override

Definition at line 193 of file wdgtagselection.cpp.

194{
195
196}

Member Function Documentation

◆ addTag()

void KisWdgTagSelectionControllerBundleTags::addTag ( KoID tag)

Definition at line 237 of file wdgtagselection.cpp.

238{
241 }
242 if (!m_selectedTagsByResourceType[m_resourceType].contains(custom)) {
244 updateView();
245 }
246
247 Q_EMIT tagAdded(custom);
248}
QMap< QString, QList< KoID > > m_selectedTagsByResourceType

References m_resourceType, m_selectedTagsByResourceType, tagAdded(), and updateView().

◆ getSelectedTagIds()

QList< int > KisWdgTagSelectionControllerBundleTags::getSelectedTagIds ( ) const

Definition at line 198 of file wdgtagselection.cpp.

199{
200 QList<int> selectedTags;
201 Q_FOREACH(QString resourceType, m_selectedTagsByResourceType.keys()) {
203 QList<KoID> tagList = m_selectedTagsByResourceType[resourceType];
204 Q_FOREACH(KoID tag, tagList) {
205 KisTagSP tagSP = model->tagForUrl(tag.id());
206 selectedTags << tagSP->id();
207 }
208 }
209 return selectedTags;
210}
KisTagSP tagForUrl(const QString &url) const override
Retrieve a tag by url.
QString id() const
Definition KoID.cpp:63

References KoID::id(), m_resourceType, m_selectedTagsByResourceType, and KisTagModel::tagForUrl().

◆ setResourceType()

void KisWdgTagSelectionControllerBundleTags::setResourceType ( const QString & resourceType)

Definition at line 296 of file wdgtagselection.cpp.

297{
298 m_resourceType = resourceType;
299 updateView();
300}

References m_resourceType, and updateView().

◆ slotAddTag

void KisWdgTagSelectionControllerBundleTags::slotAddTag ( KoID tag)
slot

Definition at line 224 of file wdgtagselection.cpp.

225{
228 }
229 if (!m_selectedTagsByResourceType[m_resourceType].contains(custom)) {
231 updateView();
232 }
233
234 Q_EMIT tagAdded(custom);
235}

References m_resourceType, m_selectedTagsByResourceType, tagAdded(), and updateView().

◆ slotRemoveTag

void KisWdgTagSelectionControllerBundleTags::slotRemoveTag ( KoID tag)
slot

Definition at line 212 of file wdgtagselection.cpp.

213{
215 if (m_selectedTagsByResourceType[m_resourceType].contains(custom)) {
217 updateView();
218 }
219 }
220
221 Q_EMIT tagRemoved(custom);
222}

References m_resourceType, m_selectedTagsByResourceType, tagRemoved(), and updateView().

◆ tagAdded

void KisWdgTagSelectionControllerBundleTags::tagAdded ( KoID tag)
signal

◆ tagRemoved

void KisWdgTagSelectionControllerBundleTags::tagRemoved ( KoID tag)
signal

◆ updateView()

void KisWdgTagSelectionControllerBundleTags::updateView ( )

Definition at line 250 of file wdgtagselection.cpp.

251{
252 typedef QPair<QString, QString> resourceTypePair;
253 QList<QPair<QString, QString>> resourceTypes = {
254 resourceTypePair(i18n("Brush presets"), ResourceType::PaintOpPresets),
255 resourceTypePair(i18n("Brush tips"), ResourceType::Brushes),
256 resourceTypePair(i18n("Workspaces"), ResourceType::Workspaces),
257 resourceTypePair(i18n("Patterns"), ResourceType::Patterns),
258 resourceTypePair(i18n("Palettes"), ResourceType::Palettes),
259 resourceTypePair(i18n("Layer styles"), ResourceType::LayerStyles),
260 resourceTypePair(i18n("Gradients"), ResourceType::Gradients),
261 resourceTypePair(i18n("Gamut masks"), ResourceType::GamutMasks),
262 resourceTypePair(i18n("SeExpr scripts"), ResourceType::SeExprScripts),
263 };
264
266
268 QList<KoID> notSelected;
269
270
271 for (int i = 0; i < model->rowCount(); i++) {
272 QModelIndex idx = model->index(i, 0);
273 KisTagSP tag = model->data(idx, Qt::UserRole + KisAllTagsModel::KisTagRole).value<KisTagSP>();
274
275 if (tag.isNull() || tag->id() < 0) {
276 continue;
277 }
278
279 KoID custom = KoID(tag->url(), tag->name());
280
282 if (!m_selectedTagsByResourceType[m_resourceType].contains(custom)) {
283 notSelected << custom;
284 }
285 } else { // no tags from this resource type are selected
286 notSelected << custom;
287 }
288 }
289
290 // m_selectedTags is already categorized correctly and is in KoID form
291
292 m_tagSelectionWidget->setTagList(m_editable, selected, notSelected);
293
294}
void setTagList(bool editable, QList< KoID > &selected, QList< KoID > &notSelected)
const QString Palettes
const QString LayerStyles
const QString Brushes
const QString GamutMasks
const QString Patterns
const QString SeExprScripts
const QString Gradients
const QString Workspaces
const QString PaintOpPresets

References ResourceType::Brushes, ResourceType::GamutMasks, ResourceType::Gradients, KisAllTagsModel::KisTagRole, ResourceType::LayerStyles, m_editable, m_resourceType, m_selectedTagsByResourceType, m_tagSelectionWidget, ResourceType::PaintOpPresets, ResourceType::Palettes, ResourceType::Patterns, ResourceType::SeExprScripts, KisTagSelectionWidget::setTagList(), and ResourceType::Workspaces.

Member Data Documentation

◆ m_editable

bool KisWdgTagSelectionControllerBundleTags::m_editable {true}
private

Definition at line 80 of file wdgtagselection.h.

80{true};

◆ m_resourceType

QString KisWdgTagSelectionControllerBundleTags::m_resourceType {""}
private

Definition at line 81 of file wdgtagselection.h.

81{""};

◆ m_selectedTags

QList<KoID> KisWdgTagSelectionControllerBundleTags::m_selectedTags
private

Definition at line 83 of file wdgtagselection.h.

◆ m_selectedTagsByResourceType

QMap<QString, QList<KoID> > KisWdgTagSelectionControllerBundleTags::m_selectedTagsByResourceType
private

Definition at line 85 of file wdgtagselection.h.

◆ m_tagModel

QSharedPointer<KisTagModel> KisWdgTagSelectionControllerBundleTags::m_tagModel
private

Definition at line 87 of file wdgtagselection.h.

◆ m_tagResourceModel

QSharedPointer<KisTagResourceModel> KisWdgTagSelectionControllerBundleTags::m_tagResourceModel
private

Definition at line 88 of file wdgtagselection.h.

◆ m_tagSelectionWidget

KisTagSelectionWidget* KisWdgTagSelectionControllerBundleTags::m_tagSelectionWidget {0}
private

Definition at line 79 of file wdgtagselection.h.

79{0};

The documentation for this class was generated from the following files: