Krita Source Code Documentation
Loading...
Searching...
No Matches
KisResourceTaggingManager.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the KDE project
3 * SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org>
4 * SPDX-FileCopyrightText: 2007 Jan Hambrecht <jaham@gmx.net>
5 * SPDX-FileCopyrightText: 2007 Sven Langkamp <sven.langkamp@gmail.com>
6 * SPDX-FileCopyrightText: 2011 Srikanth Tiyyagura <srikanth.tulasiram@gmail.com>
7 * SPDX-FileCopyrightText: 2011 José Luis Vergara <pentalis@gmail.com>
8 * SPDX-FileCopyrightText: 2013 Sascha Suelzer <s.suelzer@gmail.com>
9 * SPDX-FileCopyrightText: 2020 Agata Cacko <cacko.azh@gmail.com>
10 * SPDX-License-Identifier: LGPL-2.0-or-later
11 */
12
14
15#include <QInputDialog>
16#include <QMessageBox>
17#include <QPointer>
18
19#include <klocalizedstring.h>
20#include <ksharedconfig.h>
21#include <kconfiggroup.h>
22
23#include <KoResource.h>
24
25#include <KisResourceModel.h>
27#include <KisTagModel.h>
28
29#include "KisTagFilterWidget.h"
30#include "KisTagChooserWidget.h"
32#include "kis_debug.h"
33#include "KisTag.h"
34
53
54
55
56
57
59
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}
78
84
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}
94
96{
97 d->model->setTagFilter(tag);
98}
99
101{
102 d->model->setSearchText(lineEditText);
103}
104
106{
107 d->model->setFilterInCurrentTag(filterByTag);
108}
109
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}
121
126
131
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
The KisResourceItemChooserContextMenu class is responsible for the context menu in ResourceItemChoose...
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)
KisTagFilterWidget * tagFilterWidget()
tagFilterWidget method to get the tag filter widget
KisResourceTaggingManager(QString resourceType, KisTagFilterResourceProxyModel *model, QWidget *parent)
KisResourceTaggingManager standard constructor of the KisResourceTaggingManager class.
void slotFilterByTagChanged(const bool filterByTag)
slotFilterByTagChanged slot for the "filter by tag" checkbox being checked or unchecked by the user
~KisResourceTaggingManager() override
~KisResourceTaggingManager destructor
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
KisTagChooserWidget * tagChooserWidget()
tagChooserWidget method to get the tag chooser widget
void showTaggingBar(bool show)
showTaggingBar method to show or hide the tag chooser bar and the tag filter
void contextMenuRequested(KoResourceSP currentResource, QPoint pos)
contextMenuRequested method to get the context menu
The KisTagChooserWidget class is responsible for all the logic that the tags combobox has in various ...
void setCurrentItem(const QString &tag)
setCurrentItem sets the tag from the param as the current tag in the combobox
KisTagSP currentlySelectedTag()
currentlySelectedTag returns the current tag from combobox
The KisTagFilterResourceProxyModel class filters the resources by tag or resource name.