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

#include <wdgtagpreview.h>

+ Inheritance diagram for WdgTagPreview:

Public Slots

void onTagAdded (KoID custom)
 
void onTagRemoved (KoID custom)
 

Signals

void tagsAdded (KisTagSP tagSP)
 
void tagsRemoved (KisTagSP tagSP)
 

Public Member Functions

 WdgTagPreview (QString resourceType, KoResourceBundleSP bundle=nullptr, QWidget *parent=nullptr)
 
 ~WdgTagPreview ()
 

Private Attributes

KoResourceBundleSP m_bundle
 
QLayout * m_layout {nullptr}
 
QString m_resourceType
 
KisWdgTagSelectionControllerBundleTagsm_tagsController
 
Ui::WdgTagPreview * m_ui
 
KisTagSelectionWidgetm_wdgResourcesTags
 

Detailed Description

Definition at line 24 of file wdgtagpreview.h.

Constructor & Destructor Documentation

◆ WdgTagPreview()

WdgTagPreview::WdgTagPreview ( QString resourceType,
KoResourceBundleSP bundle = nullptr,
QWidget * parent = nullptr )
explicit

Definition at line 21 of file wdgtagpreview.cpp.

21 :
22 QWidget(parent),
23 m_ui(new Ui::WdgTagPreview),
24 m_resourceType(resourceType),
26 m_bundle(bundle)
27{
28 m_ui->setupUi(this);
29
30 m_resourceType = (resourceType == "presets" ? ResourceType::PaintOpPresets : resourceType);
31
33 m_ui->verticalLayout_2->addWidget(m_wdgResourcesTags);
34
37
38 connect(m_tagsController, SIGNAL(tagAdded(KoID)), this, SLOT(onTagAdded(KoID)));
39 connect(m_tagsController, SIGNAL(tagRemoved(KoID)), this, SLOT(onTagRemoved(KoID)));
40
42
43 m_ui->widget->setLayout(m_layout);
44
46 for (int i = 0; i < model->rowCount(); ++i) {
47 QModelIndex idx = model->index(i, 0);
48 QString name = model->data(idx, Qt::UserRole + KisAbstractResourceModel::Name).toString();
49 if (name == "All" || name == "All Untagged") continue;
50 KisTagLabel *label = new KisTagLabel(name);
51 m_layout->addWidget(label);
52 }
53
54 if (m_bundle) {
55 KisBundleStorage *bundleStorage = new KisBundleStorage(m_bundle->filename());
56
58 while (tagIter->hasNext()) {
59 tagIter->next();
60 KoID custom = KoID(tagIter->tag()->url(), tagIter->tag()->name());
61 m_tagsController->addTag(custom);
62 }
63 }
64}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
QSharedPointer< KisResourceStorage::TagIterator > tags(const QString &resourceType) override
void setResourceType(const QString &resourceType)
Definition KoID.h:30
void onTagAdded(KoID custom)
Ui::WdgTagPreview * m_ui
QString m_resourceType
void onTagRemoved(KoID custom)
KisTagSelectionWidget * m_wdgResourcesTags
KoResourceBundleSP m_bundle
QLayout * m_layout
KisWdgTagSelectionControllerBundleTags * m_tagsController
const char * name(StandardAction id)
const QString PaintOpPresets

References KisWdgTagSelectionControllerBundleTags::addTag(), connect(), m_bundle, m_layout, m_resourceType, m_tagsController, m_ui, m_wdgResourcesTags, KisAbstractResourceModel::Name, onTagAdded(), onTagRemoved(), ResourceType::PaintOpPresets, KisWdgTagSelectionControllerBundleTags::setResourceType(), and KisBundleStorage::tags().

◆ ~WdgTagPreview()

WdgTagPreview::~WdgTagPreview ( )

Definition at line 66 of file wdgtagpreview.cpp.

67{
68 delete m_ui;
69}

References m_ui.

Member Function Documentation

◆ onTagAdded

void WdgTagPreview::onTagAdded ( KoID custom)
slot

Definition at line 71 of file wdgtagpreview.cpp.

72{
74 KisTagSP tagSP = model->tagForUrl(custom.id());
75
76 for (int i = m_layout->count() - 1; i >= 0; --i) {
77 KisTagLabel *label = qobject_cast<KisTagLabel*>(m_layout->itemAt(i)->widget());
78 if (label && label->getText() == tagSP->name()) {
79 m_layout->removeWidget(label);
80 delete label;
81 }
82 }
83
84 Q_EMIT tagsAdded(tagSP);
85}
QString getText()
KisTagSP tagForUrl(const QString &url) const override
Retrieve a tag by url.
QString id() const
Definition KoID.cpp:63
void tagsAdded(KisTagSP tagSP)

References KisTagLabel::getText(), KoID::id(), m_layout, m_resourceType, KisTagModel::tagForUrl(), and tagsAdded().

◆ onTagRemoved

void WdgTagPreview::onTagRemoved ( KoID custom)
slot

Definition at line 86 of file wdgtagpreview.cpp.

87{
89 KisTagSP tagSP = model->tagForUrl(custom.id());
90
91 KisTagLabel *label = new KisTagLabel(tagSP->name());
92 m_layout->addWidget(label);
93
94 Q_EMIT tagsRemoved(tagSP);
95}
void tagsRemoved(KisTagSP tagSP)

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

◆ tagsAdded

void WdgTagPreview::tagsAdded ( KisTagSP tagSP)
signal

◆ tagsRemoved

void WdgTagPreview::tagsRemoved ( KisTagSP tagSP)
signal

Member Data Documentation

◆ m_bundle

KoResourceBundleSP WdgTagPreview::m_bundle
private

Definition at line 48 of file wdgtagpreview.h.

◆ m_layout

QLayout* WdgTagPreview::m_layout {nullptr}
private

Definition at line 47 of file wdgtagpreview.h.

47{nullptr};

◆ m_resourceType

QString WdgTagPreview::m_resourceType
private

Definition at line 44 of file wdgtagpreview.h.

◆ m_tagsController

KisWdgTagSelectionControllerBundleTags* WdgTagPreview::m_tagsController
private

Definition at line 45 of file wdgtagpreview.h.

◆ m_ui

Ui::WdgTagPreview* WdgTagPreview::m_ui
private

Definition at line 42 of file wdgtagpreview.h.

◆ m_wdgResourcesTags

KisTagSelectionWidget* WdgTagPreview::m_wdgResourcesTags
private

Definition at line 46 of file wdgtagpreview.h.


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