mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 17:02:15 -07:00
Minor cleanup
This commit is contained in:
parent
900cbed6bb
commit
ea723620ae
5 changed files with 16 additions and 17 deletions
|
|
@ -9,11 +9,12 @@
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
DeckPreviewTagAdditionWidget::DeckPreviewTagAdditionWidget(QWidget *_parent,
|
DeckPreviewTagAdditionWidget::DeckPreviewTagAdditionWidget(QWidget *_parent,
|
||||||
DeckPreviewDeckTagsDisplayWidget *_tagsDisplayWidget,
|
DeckPreviewDeckTagsDisplayWidget *_tagsDisplayWidget,
|
||||||
const QString &_tagName)
|
QString _tagName)
|
||||||
: QWidget(_parent), tagsDisplayWidget(_tagsDisplayWidget), tagName_(_tagName)
|
: QWidget(_parent), tagsDisplayWidget(_tagsDisplayWidget), tagName_(std::move(_tagName))
|
||||||
{
|
{
|
||||||
// Create layout
|
// Create layout
|
||||||
auto *layout = new QHBoxLayout(this);
|
auto *layout = new QHBoxLayout(this);
|
||||||
|
|
@ -32,7 +33,7 @@ QSize DeckPreviewTagAdditionWidget::sizeHint() const
|
||||||
int width = textWidth + 50; // Add extra padding
|
int width = textWidth + 50; // Add extra padding
|
||||||
int height = fm.height() + 10; // Height based on font size + padding
|
int height = fm.height() + 10; // Height based on font size + padding
|
||||||
|
|
||||||
return QSize(width, height);
|
return {width, height};
|
||||||
}
|
}
|
||||||
|
|
||||||
static QStringList getAllFiles(const QString &filePath, bool recursive)
|
static QStringList getAllFiles(const QString &filePath, bool recursive)
|
||||||
|
|
@ -59,7 +60,7 @@ void DeckPreviewTagAdditionWidget::mousePressEvent(QMouseEvent *event)
|
||||||
QWidget::mousePressEvent(event);
|
QWidget::mousePressEvent(event);
|
||||||
|
|
||||||
if (qobject_cast<DeckPreviewWidget *>(tagsDisplayWidget->parentWidget())) {
|
if (qobject_cast<DeckPreviewWidget *>(tagsDisplayWidget->parentWidget())) {
|
||||||
DeckPreviewWidget *deckPreviewWidget = qobject_cast<DeckPreviewWidget *>(tagsDisplayWidget->parentWidget());
|
auto *deckPreviewWidget = qobject_cast<DeckPreviewWidget *>(tagsDisplayWidget->parentWidget());
|
||||||
QStringList knownTags = deckPreviewWidget->visualDeckStorageWidget->tagFilterWidget->getAllKnownTags();
|
QStringList knownTags = deckPreviewWidget->visualDeckStorageWidget->tagFilterWidget->getAllKnownTags();
|
||||||
QStringList activeTags = tagsDisplayWidget->deckList->getTags();
|
QStringList activeTags = tagsDisplayWidget->deckList->getTags();
|
||||||
|
|
||||||
|
|
@ -118,11 +119,11 @@ void DeckPreviewTagAdditionWidget::mousePressEvent(QMouseEvent *event)
|
||||||
currentParent = currentParent->parentWidget();
|
currentParent = currentParent->parentWidget();
|
||||||
}
|
}
|
||||||
if (qobject_cast<TabDeckEditor *>(currentParent)) {
|
if (qobject_cast<TabDeckEditor *>(currentParent)) {
|
||||||
TabDeckEditor *deckEditor = qobject_cast<TabDeckEditor *>(currentParent);
|
auto *deckEditor = qobject_cast<TabDeckEditor *>(currentParent);
|
||||||
QStringList knownTags;
|
QStringList knownTags;
|
||||||
QStringList allFiles = getAllFiles(SettingsCache::instance().getDeckPath(), true);
|
QStringList allFiles = getAllFiles(SettingsCache::instance().getDeckPath(), true);
|
||||||
DeckLoader *loader = new DeckLoader();
|
auto *loader = new DeckLoader();
|
||||||
for (QString file : allFiles) {
|
for (const QString& file : allFiles) {
|
||||||
loader->loadFromFile(file, DeckLoader::getFormatFromName(file), false);
|
loader->loadFromFile(file, DeckLoader::getFormatFromName(file), false);
|
||||||
QStringList tags = loader->getTags();
|
QStringList tags = loader->getTags();
|
||||||
knownTags.append(tags);
|
knownTags.append(tags);
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ class DeckPreviewTagAdditionWidget : public QWidget
|
||||||
public:
|
public:
|
||||||
explicit DeckPreviewTagAdditionWidget(QWidget *_parent,
|
explicit DeckPreviewTagAdditionWidget(QWidget *_parent,
|
||||||
DeckPreviewDeckTagsDisplayWidget *_tagsDisplayWidget,
|
DeckPreviewDeckTagsDisplayWidget *_tagsDisplayWidget,
|
||||||
const QString &_tagName);
|
QString _tagName);
|
||||||
QSize sizeHint() const override;
|
[[nodiscard]] QSize sizeHint() const override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void tagClicked(); // Emitted when the tag is clicked
|
void tagClicked(); // Emitted when the tag is clicked
|
||||||
|
|
@ -28,8 +28,6 @@ protected:
|
||||||
private:
|
private:
|
||||||
DeckPreviewDeckTagsDisplayWidget *tagsDisplayWidget;
|
DeckPreviewDeckTagsDisplayWidget *tagsDisplayWidget;
|
||||||
QString tagName_;
|
QString tagName_;
|
||||||
QLabel *tagLabel_;
|
|
||||||
QPushButton *closeButton_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DECK_PREVIEW_TAG_ADDITION_WIDGET_H
|
#endif // DECK_PREVIEW_TAG_ADDITION_WIDGET_H
|
||||||
|
|
|
||||||
|
|
@ -195,10 +195,10 @@ void DeckPreviewWidget::updateBannerCardComboBox()
|
||||||
// Prepare the new items with deduplication
|
// Prepare the new items with deduplication
|
||||||
QSet<QPair<QString, QString>> bannerCardSet;
|
QSet<QPair<QString, QString>> bannerCardSet;
|
||||||
InnerDecklistNode *listRoot = deckLoader->getRoot();
|
InnerDecklistNode *listRoot = deckLoader->getRoot();
|
||||||
for (int i = 0; i < listRoot->size(); i++) {
|
for (auto i : *listRoot) {
|
||||||
InnerDecklistNode *currentZone = dynamic_cast<InnerDecklistNode *>(listRoot->at(i));
|
auto *currentZone = dynamic_cast<InnerDecklistNode *>(i);
|
||||||
for (int j = 0; j < currentZone->size(); j++) {
|
for (auto j : *currentZone) {
|
||||||
DecklistCardNode *currentCard = dynamic_cast<DecklistCardNode *>(currentZone->at(j));
|
auto *currentCard = dynamic_cast<DecklistCardNode *>(j);
|
||||||
if (!currentCard)
|
if (!currentCard)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <qfilesystemwatcher.h>
|
#include <QFileSystemWatcher>
|
||||||
|
|
||||||
VisualDeckStorageWidget::VisualDeckStorageWidget(QWidget *parent) : QWidget(parent), folderWidget(nullptr)
|
VisualDeckStorageWidget::VisualDeckStorageWidget(QWidget *parent) : QWidget(parent), folderWidget(nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QFileSystemModel>
|
#include <QFileSystemModel>
|
||||||
#include <qfilesystemwatcher.h>
|
#include <QFileSystemWatcher>
|
||||||
|
|
||||||
class VisualDeckStorageSearchWidget;
|
class VisualDeckStorageSearchWidget;
|
||||||
class VisualDeckStorageSortWidget;
|
class VisualDeckStorageSortWidget;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue