mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 00:42:14 -07:00
Give deckList a signal to emit when the tags change and hook up the display widget to that.
This commit is contained in:
parent
55b490ade0
commit
3aa8e91b20
4 changed files with 17 additions and 2 deletions
|
|
@ -21,11 +21,21 @@ DeckPreviewDeckTagsDisplayWidget::DeckPreviewDeckTagsDisplayWidget(DeckPreviewWi
|
||||||
|
|
||||||
setFixedHeight(100);
|
setFixedHeight(100);
|
||||||
|
|
||||||
auto *flowWidget = new FlowWidget(this, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded);
|
connect(deckLoader, &DeckList::deckTagsChanged, this, &DeckPreviewDeckTagsDisplayWidget::refreshTags);
|
||||||
|
|
||||||
|
flowWidget = new FlowWidget(this, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded);
|
||||||
for (const QString &tag : this->deckLoader->getTags()) {
|
for (const QString &tag : this->deckLoader->getTags()) {
|
||||||
flowWidget->addWidget(new DeckPreviewTagDisplayWidget(this, tag));
|
flowWidget->addWidget(new DeckPreviewTagDisplayWidget(this, tag));
|
||||||
}
|
}
|
||||||
flowWidget->addWidget(new DeckPreviewTagAdditionWidget(this, tr("Edit tags ...")));
|
flowWidget->addWidget(new DeckPreviewTagAdditionWidget(this, tr("Edit tags ...")));
|
||||||
layout->addWidget(flowWidget);
|
layout->addWidget(flowWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeckPreviewDeckTagsDisplayWidget::refreshTags()
|
||||||
|
{
|
||||||
|
flowWidget->clearLayout();
|
||||||
|
for (const QString &tag : this->deckLoader->getTags()) {
|
||||||
|
flowWidget->addWidget(new DeckPreviewTagDisplayWidget(this, tag));
|
||||||
|
}
|
||||||
|
flowWidget->addWidget(new DeckPreviewTagAdditionWidget(this, tr("Edit tags ...")));
|
||||||
}
|
}
|
||||||
|
|
@ -13,7 +13,9 @@ class DeckPreviewDeckTagsDisplayWidget : public QWidget
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DeckPreviewDeckTagsDisplayWidget(DeckPreviewWidget *_parent, DeckLoader *_deckLoader);
|
explicit DeckPreviewDeckTagsDisplayWidget(DeckPreviewWidget *_parent, DeckLoader *_deckLoader);
|
||||||
|
void refreshTags();
|
||||||
DeckPreviewWidget *parent;
|
DeckPreviewWidget *parent;
|
||||||
DeckLoader *deckLoader;
|
DeckLoader *deckLoader;
|
||||||
|
FlowWidget *flowWidget;
|
||||||
};
|
};
|
||||||
#endif // DECK_PREVIEW_DECK_TAGS_DISPLAY_WIDGET_H
|
#endif // DECK_PREVIEW_DECK_TAGS_DISPLAY_WIDGET_H
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ void DeckPreviewTagAdditionWidget::mousePressEvent(QMouseEvent *event)
|
||||||
QStringList updatedTags = dialog.getActiveTags();
|
QStringList updatedTags = dialog.getActiveTags();
|
||||||
parent->deckLoader->setTags(updatedTags);
|
parent->deckLoader->setTags(updatedTags);
|
||||||
parent->deckLoader->saveToFile(parent->parent->filePath, DeckLoader::CockatriceFormat);
|
parent->deckLoader->saveToFile(parent->parent->filePath, DeckLoader::CockatriceFormat);
|
||||||
parent->parent->parent->refreshBannerCards();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -272,6 +272,7 @@ protected:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deckHashChanged();
|
void deckHashChanged();
|
||||||
|
void deckTagsChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setName(const QString &_name = QString())
|
void setName(const QString &_name = QString())
|
||||||
|
|
@ -285,14 +286,17 @@ public slots:
|
||||||
void setTags(const QStringList &_tags = QStringList())
|
void setTags(const QStringList &_tags = QStringList())
|
||||||
{
|
{
|
||||||
tags = _tags;
|
tags = _tags;
|
||||||
|
emit deckTagsChanged();
|
||||||
}
|
}
|
||||||
void addTag(const QString &_tag)
|
void addTag(const QString &_tag)
|
||||||
{
|
{
|
||||||
tags.append(_tag);
|
tags.append(_tag);
|
||||||
|
emit deckTagsChanged();
|
||||||
}
|
}
|
||||||
void clearTags()
|
void clearTags()
|
||||||
{
|
{
|
||||||
tags.clear();
|
tags.clear();
|
||||||
|
emit deckTagsChanged();
|
||||||
}
|
}
|
||||||
void setBannerCard(const QPair<QString, QString> &_bannerCard = QPair<QString, QString>())
|
void setBannerCard(const QPair<QString, QString> &_bannerCard = QPair<QString, QString>())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue