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 195 of file wdgtagselection.cpp.

196 : QObject(widget)
197 , m_tagSelectionWidget(widget)
198 , m_editable(editable)
199{
200 connect(widget, SIGNAL(sigAddTagToSelection(KoID)), this, SLOT(slotAddTag(KoID)));
201 connect(widget, SIGNAL(sigRemoveTagFromSelection(KoID)), this, SLOT(slotRemoveTag(KoID)));
202 updateView();
203}
KisTagSelectionWidget * m_tagSelectionWidget
Definition KoID.h:30

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

◆ ~KisWdgTagSelectionControllerBundleTags()

KisWdgTagSelectionControllerBundleTags::~KisWdgTagSelectionControllerBundleTags ( )
override

Definition at line 205 of file wdgtagselection.cpp.

206{
207
208}

Member Function Documentation

◆ addTag()

void KisWdgTagSelectionControllerBundleTags::addTag ( KoID tag)

Definition at line 249 of file wdgtagselection.cpp.

250{
253 }
254 if (!m_selectedTagsByResourceType[m_resourceType].contains(custom)) {
256 updateView();
257 }
258
259 Q_EMIT tagAdded(custom);
260}
QMap< QString, QList< KoID > > m_selectedTagsByResourceType

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

◆ getSelectedTagIds()

QList< int > KisWdgTagSelectionControllerBundleTags::getSelectedTagIds ( ) const

Definition at line 210 of file wdgtagselection.cpp.

211{
212 QList<int> selectedTags;
213 Q_FOREACH(QString resourceType, m_selectedTagsByResourceType.keys()) {
215 QList<KoID> tagList = m_selectedTagsByResourceType[resourceType];
216 Q_FOREACH(KoID tag, tagList) {
217 KisTagSP tagSP = model->tagForUrl(tag.id());
218 selectedTags << tagSP->id();
219 }
220 }
221 return selectedTags;
222}
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 308 of file wdgtagselection.cpp.

309{
310 m_resourceType = resourceType;
311 updateView();
312}

References m_resourceType, and updateView().

◆ slotAddTag

void KisWdgTagSelectionControllerBundleTags::slotAddTag ( KoID tag)
slot

Definition at line 236 of file wdgtagselection.cpp.

237{
240 }
241 if (!m_selectedTagsByResourceType[m_resourceType].contains(custom)) {
243 updateView();
244 }
245
246 Q_EMIT tagAdded(custom);
247}

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

◆ slotRemoveTag

void KisWdgTagSelectionControllerBundleTags::slotRemoveTag ( KoID tag)
slot

Definition at line 224 of file wdgtagselection.cpp.

225{
227 if (m_selectedTagsByResourceType[m_resourceType].contains(custom)) {
229 updateView();
230 }
231 }
232
233 Q_EMIT tagRemoved(custom);
234}

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 262 of file wdgtagselection.cpp.

263{
264 typedef QPair<QString, QString> resourceTypePair;
265 QList<QPair<QString, QString>> resourceTypes = {
266 resourceTypePair(i18n("Brush presets"), ResourceType::PaintOpPresets),
267 resourceTypePair(i18n("Brush tips"), ResourceType::Brushes),
268 resourceTypePair(i18n("Workspaces"), ResourceType::Workspaces),
269 resourceTypePair(i18n("Patterns"), ResourceType::Patterns),
270 resourceTypePair(i18n("Palettes"), ResourceType::Palettes),
271 resourceTypePair(i18n("Layer styles"), ResourceType::LayerStyles),
272 resourceTypePair(i18n("Gradients"), ResourceType::Gradients),
273 resourceTypePair(i18n("Gamut masks"), ResourceType::GamutMasks),
274 resourceTypePair(i18n("SeExpr scripts"), ResourceType::SeExprScripts),
275 };
276
278
280 QList<KoID> notSelected;
281
282
283 for (int i = 0; i < model->rowCount(); i++) {
284 QModelIndex idx = model->index(i, 0);
285 KisTagSP tag = model->data(idx, Qt::UserRole + KisAllTagsModel::KisTagRole).value<KisTagSP>();
286
287 if (tag.isNull() || tag->id() < 0) {
288 continue;
289 }
290
291 KoID custom = KoID(tag->url(), tag->name());
292
294 if (!m_selectedTagsByResourceType[m_resourceType].contains(custom)) {
295 notSelected << custom;
296 }
297 } else { // no tags from this resource type are selected
298 notSelected << custom;
299 }
300 }
301
302 // m_selectedTags is already categorized correctly and is in KoID form
303
304 m_tagSelectionWidget->setTagList(m_editable, selected, notSelected);
305
306}
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: