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

The KisResourceTaggingManager class is a helper class for KisResourceItemChooser for tagChooser and tagFilter widgets. More...

#include <KisResourceTaggingManager.h>

+ Inheritance diagram for KisResourceTaggingManager:

Classes

class  Private
 

Public Member Functions

void contextMenuRequested (KoResourceSP currentResource, QPoint pos)
 contextMenuRequested method to get the context menu
 
 KisResourceTaggingManager (QString resourceType, KisTagFilterResourceProxyModel *model, QWidget *parent)
 KisResourceTaggingManager standard constructor of the KisResourceTaggingManager class.
 
void showTaggingBar (bool show)
 showTaggingBar method to show or hide the tag chooser bar and the tag filter
 
KisTagChooserWidgettagChooserWidget ()
 tagChooserWidget method to get the tag chooser widget
 
KisTagFilterWidgettagFilterWidget ()
 tagFilterWidget method to get the tag filter widget
 
 ~KisResourceTaggingManager () override
 ~KisResourceTaggingManager destructor
 

Private Slots

void slotFilterByTagChanged (const bool filterByTag)
 slotFilterByTagChanged slot for the "filter by tag" checkbox being checked or unchecked by the user
 
void tagChooserIndexChanged (const KisTagSP tag)
 tagChooserIndexChanged slot for the signal that the tag chosen in the tags combobox changed
 
void tagSearchLineEditTextChanged (const QString &lineEditText)
 tagSearchLineEditTextChanged slot for the signal that the text in the filter changed
 

Private Attributes

Private *const d
 

Detailed Description

The KisResourceTaggingManager class is a helper class for KisResourceItemChooser for tagChooser and tagFilter widgets.

It takes care of exchanging information about tags between KisTagChooserWidget and KisTagFilterWidget. It makes sure that the correct tag is put in the resource model proxy that is used in the KisResourceItemChooser. Historically it also managed a list of tags; now KisTagModel is taking care of it.

Definition at line 43 of file KisResourceTaggingManager.h.

Constructor & Destructor Documentation

◆ KisResourceTaggingManager()

KisResourceTaggingManager::KisResourceTaggingManager ( QString resourceType,
KisTagFilterResourceProxyModel * model,
QWidget * parent )
explicit

KisResourceTaggingManager standard constructor of the KisResourceTaggingManager class.

Parameters
resourceTyperesource type of the resources that will be dealt with
modelproxy model that is used to show only the resources tagged with a specific tag
parentparent widget

Definition at line 58 of file KisResourceTaggingManager.cpp.

60 : QObject(parent)
61 , d(new Private())
62{
63 d->model = model;
64 d->resourceType = resourceType;
65 d->tagModel = new KisTagModel(resourceType);
66 d->tagChooser = new KisTagChooserWidget(d->tagModel, resourceType, parent);
67 d->tagFilter = new KisTagFilterWidget(d->tagModel, parent);
68
69 d->model->setFilterInCurrentTag(d->tagFilter->isFilterByTagChecked());
70
71 connect(d->tagChooser, SIGNAL(sigTagChosen(KisTagSP)), this, SLOT(tagChooserIndexChanged(KisTagSP)));
72
73 connect(d->tagFilter, SIGNAL(filterByTagChanged(bool)), this, SLOT(slotFilterByTagChanged(bool)));
74 connect(d->tagFilter, SIGNAL(filterTextChanged(QString)), this, SLOT(tagSearchLineEditTextChanged(QString)));
75
76 connect(d->tagChooser, SIGNAL(sigTagChosen(KisTagSP)), d->tagFilter, SLOT(clear()));
77}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
QPointer< KisTagFilterResourceProxyModel > model
model main data model for resources in the item chooser that the Tagging Manager is taking care of
KisTagFilterWidget * tagFilter
tagFilter resources filter widget (resources filter box + "filter by tag" checkbox)
KisTagModel * tagModel
tagModel main tag model for tags in the tags combobox
KisTagChooserWidget * tagChooser
tagChooser tag chooser widget (tags combobox + tag tool button with the popup)
void slotFilterByTagChanged(const bool filterByTag)
slotFilterByTagChanged slot for the "filter by tag" checkbox being checked or unchecked by the user
void tagSearchLineEditTextChanged(const QString &lineEditText)
tagSearchLineEditTextChanged slot for the signal that the text in the filter changed
void tagChooserIndexChanged(const KisTagSP tag)
tagChooserIndexChanged slot for the signal that the tag chosen in the tags combobox changed
The KisTagChooserWidget class is responsible for all the logic that the tags combobox has in various ...
QAction * clear(const QObject *recvr, const char *slot, QObject *parent)

References connect(), d, KisTagFilterWidget::isFilterByTagChecked(), KisResourceTaggingManager::Private::model, KisResourceTaggingManager::Private::resourceType, slotFilterByTagChanged(), KisResourceTaggingManager::Private::tagChooser, tagChooserIndexChanged(), KisResourceTaggingManager::Private::tagFilter, KisResourceTaggingManager::Private::tagModel, and tagSearchLineEditTextChanged().

◆ ~KisResourceTaggingManager()

KisResourceTaggingManager::~KisResourceTaggingManager ( )
override

~KisResourceTaggingManager destructor

Definition at line 79 of file KisResourceTaggingManager.cpp.

80{
81 delete d->tagModel;
82 delete d;
83}

References d, and KisResourceTaggingManager::Private::tagModel.

Member Function Documentation

◆ contextMenuRequested()

void KisResourceTaggingManager::contextMenuRequested ( KoResourceSP currentResource,
QPoint pos )

contextMenuRequested method to get the context menu

Parameters
currentResourcecurrent selected resource
posposition of the mouse cursor where the context menu should be created

Definition at line 110 of file KisResourceTaggingManager.cpp.

111{
112 // No visible tag chooser usually means no intended tag interaction,
113 // context menu makes no sense then either
114 if (!resource || !d->tagChooser->isVisible())
115 return;
116
118 menu.exec(pos);
119
120}
The KisResourceItemChooserContextMenu class is responsible for the context menu in ResourceItemChoose...
KisTagSP currentlySelectedTag()
currentlySelectedTag returns the current tag from combobox

References KisTagChooserWidget::currentlySelectedTag(), d, and KisResourceTaggingManager::Private::tagChooser.

◆ showTaggingBar()

void KisResourceTaggingManager::showTaggingBar ( bool show)

showTaggingBar method to show or hide the tag chooser bar and the tag filter

Parameters
showif true, the bars should be shown; if false, they should be hidden

Definition at line 85 of file KisResourceTaggingManager.cpp.

86{
87 show ? d->tagFilter->show() : d->tagFilter->hide();
88 show ? d->tagChooser->show() : d->tagChooser->hide();
89
90 KConfigGroup group = KSharedConfig::openConfig()->group("SelectedTags");
91 QString tag = group.readEntry<QString>(d->resourceType, "All");
93}
void setCurrentItem(const QString &tag)
setCurrentItem sets the tag from the param as the current tag in the combobox

References d, KisResourceTaggingManager::Private::resourceType, KisTagChooserWidget::setCurrentItem(), KisResourceTaggingManager::Private::tagChooser, and KisResourceTaggingManager::Private::tagFilter.

◆ slotFilterByTagChanged

void KisResourceTaggingManager::slotFilterByTagChanged ( const bool filterByTag)
privateslot

slotFilterByTagChanged slot for the "filter by tag" checkbox being checked or unchecked by the user

Parameters
filterByTagcurrent state of the checkbox

It updates the filter in the filter proxy model to honor the "filter by tag" setting correctly.

Definition at line 105 of file KisResourceTaggingManager.cpp.

106{
107 d->model->setFilterInCurrentTag(filterByTag);
108}

References d, and KisResourceTaggingManager::Private::model.

◆ tagChooserIndexChanged

void KisResourceTaggingManager::tagChooserIndexChanged ( const KisTagSP tag)
privateslot

tagChooserIndexChanged slot for the signal that the tag chosen in the tags combobox changed

Parameters
tagthe currently chosen tag

It puts the current tag in the filter proxy model to get only the resources filtered out by the tag.

Definition at line 95 of file KisResourceTaggingManager.cpp.

96{
97 d->model->setTagFilter(tag);
98}

References d, and KisResourceTaggingManager::Private::model.

◆ tagChooserWidget()

KisTagChooserWidget * KisResourceTaggingManager::tagChooserWidget ( )

tagChooserWidget method to get the tag chooser widget

Returns
tag chooser widget

Definition at line 122 of file KisResourceTaggingManager.cpp.

123{
124 return d->tagChooser;
125}

References d, and KisResourceTaggingManager::Private::tagChooser.

◆ tagFilterWidget()

KisTagFilterWidget * KisResourceTaggingManager::tagFilterWidget ( )

tagFilterWidget method to get the tag filter widget

Returns
tag filter widget

Definition at line 127 of file KisResourceTaggingManager.cpp.

128{
129 return d->tagFilter;
130}

References d, and KisResourceTaggingManager::Private::tagFilter.

◆ tagSearchLineEditTextChanged

void KisResourceTaggingManager::tagSearchLineEditTextChanged ( const QString & lineEditText)
privateslot

tagSearchLineEditTextChanged slot for the signal that the text in the filter changed

Parameters
lineEditTextthe current text in the filter box

It updates the filter in the filter proxy model.

Definition at line 100 of file KisResourceTaggingManager.cpp.

101{
102 d->model->setSearchText(lineEditText);
103}

References d, and KisResourceTaggingManager::Private::model.

Member Data Documentation

◆ d

Private* const KisResourceTaggingManager::d
private

Definition at line 108 of file KisResourceTaggingManager.h.


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