mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-10 12:23:58 -07:00
Merge branch 'master' into tooomm-qt5
This commit is contained in:
commit
e0b3edc9b8
488 changed files with 28527 additions and 76214 deletions
|
|
@ -62,7 +62,7 @@ void CardInfoTextWidget::setCard(const ExactCard &exactCard)
|
|||
text += QString("<tr><td>%1</td><td width=\"5\"></td><td>%2</td></tr>")
|
||||
.arg(tr("Name:"), card->getName().toHtmlEscaped());
|
||||
|
||||
if (exactCard.getPrinting() != PrintingInfo()) {
|
||||
if (!exactCard.getPrinting().isEmpty()) {
|
||||
QString setShort = exactCard.getPrinting().getSet()->getShortName().toHtmlEscaped();
|
||||
QString cardNum = exactCard.getPrinting().getProperty("num").toHtmlEscaped();
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,14 @@ DeckAnalyticsWidget::DeckAnalyticsWidget(QWidget *parent, DeckListStatisticsAnal
|
|||
removeButton = new QPushButton(this);
|
||||
saveButton = new QPushButton(this);
|
||||
loadButton = new QPushButton(this);
|
||||
includeSideboardCheckBox = new QCheckBox(this);
|
||||
includeSideboardCheckBox->setChecked(false);
|
||||
|
||||
controlLayout->addWidget(addButton);
|
||||
controlLayout->addWidget(removeButton);
|
||||
controlLayout->addWidget(saveButton);
|
||||
controlLayout->addWidget(loadButton);
|
||||
controlLayout->addWidget(includeSideboardCheckBox);
|
||||
|
||||
layout->addWidget(controlContainer);
|
||||
|
||||
|
|
@ -40,6 +44,7 @@ DeckAnalyticsWidget::DeckAnalyticsWidget(QWidget *parent, DeckListStatisticsAnal
|
|||
connect(removeButton, &QPushButton::clicked, this, &DeckAnalyticsWidget::onRemoveSelected);
|
||||
connect(saveButton, &QPushButton::clicked, this, &DeckAnalyticsWidget::saveLayout);
|
||||
connect(loadButton, &QPushButton::clicked, this, &DeckAnalyticsWidget::loadLayout);
|
||||
connect(includeSideboardCheckBox, &QCheckBox::clicked, this, &DeckAnalyticsWidget::includeSideboardChanged);
|
||||
|
||||
// Scroll area and container
|
||||
scrollArea = new QScrollArea(this);
|
||||
|
|
@ -66,6 +71,13 @@ void DeckAnalyticsWidget::retranslateUi()
|
|||
removeButton->setText(tr("Remove Panel"));
|
||||
saveButton->setText(tr("Save Layout"));
|
||||
loadButton->setText(tr("Load Layout"));
|
||||
includeSideboardCheckBox->setText(tr("Include Sideboard"));
|
||||
}
|
||||
|
||||
void DeckAnalyticsWidget::includeSideboardChanged(bool checked)
|
||||
{
|
||||
statsAnalyzer->getConfig().includeSideboard = checked;
|
||||
updateDisplays();
|
||||
}
|
||||
|
||||
void DeckAnalyticsWidget::updateDisplays()
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "deck_list_statistics_analyzer.h"
|
||||
#include "resizable_panel.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QJsonObject>
|
||||
#include <QScrollArea>
|
||||
#include <QVBoxLayout>
|
||||
|
|
@ -29,6 +30,7 @@ public slots:
|
|||
public:
|
||||
explicit DeckAnalyticsWidget(QWidget *parent, DeckListStatisticsAnalyzer *analyzer);
|
||||
void retranslateUi();
|
||||
void includeSideboardChanged(bool checked);
|
||||
|
||||
private slots:
|
||||
void onAddPanel();
|
||||
|
|
@ -57,6 +59,8 @@ private:
|
|||
QPushButton *saveButton;
|
||||
QPushButton *loadButton;
|
||||
|
||||
QCheckBox *includeSideboardCheckBox;
|
||||
|
||||
QScrollArea *scrollArea;
|
||||
QWidget *panelContainer;
|
||||
QVBoxLayout *panelLayout;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,13 @@ void DeckListStatisticsAnalyzer::analyze()
|
|||
{
|
||||
clearData();
|
||||
|
||||
QList<const DecklistCardNode *> nodes = model->getCardNodes();
|
||||
QList<const DecklistCardNode *> nodes;
|
||||
|
||||
if (config.includeSideboard) {
|
||||
nodes = model->getCardNodes();
|
||||
} else {
|
||||
nodes = model->getCardNodesForZone(DECK_ZONE_MAIN);
|
||||
}
|
||||
|
||||
for (auto node : nodes) {
|
||||
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(node->getName());
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ struct DeckListStatisticsAnalyzerConfig
|
|||
bool computeCategories = true;
|
||||
bool computeCurveBreakdowns = true;
|
||||
bool computeProbabilities = true;
|
||||
bool includeSideboard = false;
|
||||
};
|
||||
|
||||
class DeckListStatisticsAnalyzer : public QObject
|
||||
|
|
@ -133,6 +134,11 @@ public:
|
|||
return model;
|
||||
}
|
||||
|
||||
DeckListStatisticsAnalyzerConfig &getConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
signals:
|
||||
void statsUpdated();
|
||||
|
||||
|
|
|
|||
|
|
@ -22,41 +22,43 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes,
|
|||
{QTime(1, 0), tr("1 hour")},
|
||||
{QTime(2, 0), tr("2 hours")}})
|
||||
{
|
||||
const GameFilterConfigs &filters = gamesProxyModel->getFilters();
|
||||
|
||||
hideBuddiesOnlyGames = new QCheckBox(tr("Hide 'buddies only' games"));
|
||||
hideBuddiesOnlyGames->setChecked(gamesProxyModel->getHideBuddiesOnlyGames());
|
||||
hideBuddiesOnlyGames->setChecked(filters.hideBuddiesOnlyGames);
|
||||
|
||||
hideFullGames = new QCheckBox(tr("Hide full games"));
|
||||
hideFullGames->setChecked(gamesProxyModel->getHideFullGames());
|
||||
hideFullGames->setChecked(filters.hideFullGames);
|
||||
|
||||
hideGamesThatStarted = new QCheckBox(tr("Hide games that have started"));
|
||||
hideGamesThatStarted->setChecked(gamesProxyModel->getHideGamesThatStarted());
|
||||
hideGamesThatStarted->setChecked(filters.hideGamesThatStarted);
|
||||
|
||||
hidePasswordProtectedGames = new QCheckBox(tr("Hide password protected games"));
|
||||
hidePasswordProtectedGames->setChecked(gamesProxyModel->getHidePasswordProtectedGames());
|
||||
hidePasswordProtectedGames->setChecked(filters.hidePasswordProtectedGames);
|
||||
|
||||
hideIgnoredUserGames = new QCheckBox(tr("Hide 'ignored user' games"));
|
||||
hideIgnoredUserGames->setChecked(gamesProxyModel->getHideIgnoredUserGames());
|
||||
hideIgnoredUserGames->setChecked(filters.hideIgnoredUserGames);
|
||||
|
||||
hideNotBuddyCreatedGames = new QCheckBox(tr("Hide games not created by buddies"));
|
||||
hideNotBuddyCreatedGames->setChecked(gamesProxyModel->getHideNotBuddyCreatedGames());
|
||||
hideNotBuddyCreatedGames->setChecked(filters.hideNotBuddyCreatedGames);
|
||||
|
||||
hideOpenDecklistGames = new QCheckBox(tr("Hide games with forced open decklists"));
|
||||
hideOpenDecklistGames->setChecked(gamesProxyModel->getHideOpenDecklistGames());
|
||||
hideOpenDecklistGames->setChecked(filters.hideOpenDecklistGames);
|
||||
|
||||
maxGameAgeComboBox = new QComboBox();
|
||||
maxGameAgeComboBox->setEditable(false);
|
||||
maxGameAgeComboBox->addItems(gameAgeMap.values());
|
||||
QTime gameAge = gamesProxyModel->getMaxGameAge();
|
||||
QTime gameAge = filters.maxGameAge;
|
||||
maxGameAgeComboBox->setCurrentIndex(gameAgeMap.keys().indexOf(gameAge)); // index is -1 if unknown
|
||||
auto *maxGameAgeLabel = new QLabel(tr("&Newer than:"));
|
||||
maxGameAgeLabel->setBuddy(maxGameAgeComboBox);
|
||||
|
||||
gameNameFilterEdit = new QLineEdit;
|
||||
gameNameFilterEdit->setText(gamesProxyModel->getGameNameFilter());
|
||||
gameNameFilterEdit->setText(filters.gameNameFilter);
|
||||
auto *gameNameFilterLabel = new QLabel(tr("Game &description:"));
|
||||
gameNameFilterLabel->setBuddy(gameNameFilterEdit);
|
||||
creatorNameFilterEdit = new QLineEdit;
|
||||
creatorNameFilterEdit->setText(gamesProxyModel->getCreatorNameFilters().join(", "));
|
||||
creatorNameFilterEdit->setText(filters.creatorNameFilters.join(", "));
|
||||
auto *creatorNameFilterLabel = new QLabel(tr("&Creator name:"));
|
||||
creatorNameFilterLabel->setBuddy(creatorNameFilterEdit);
|
||||
|
||||
|
|
@ -76,7 +78,7 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes,
|
|||
gameTypesIterator.next();
|
||||
|
||||
auto *temp = new QCheckBox(gameTypesIterator.value());
|
||||
temp->setChecked(gamesProxyModel->getGameTypeFilter().contains(gameTypesIterator.key()));
|
||||
temp->setChecked(filters.gameTypeFilter.contains(gameTypesIterator.key()));
|
||||
|
||||
gameTypeFilterCheckBoxes.insert(gameTypesIterator.key(), temp);
|
||||
gameTypeFilterLayout->addWidget(temp);
|
||||
|
|
@ -92,14 +94,14 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes,
|
|||
maxPlayersFilterMinSpinBox = new QSpinBox;
|
||||
maxPlayersFilterMinSpinBox->setMinimum(0);
|
||||
maxPlayersFilterMinSpinBox->setMaximum(99);
|
||||
maxPlayersFilterMinSpinBox->setValue(gamesProxyModel->getMaxPlayersFilterMin());
|
||||
maxPlayersFilterMinSpinBox->setValue(filters.maxPlayersFilterMin);
|
||||
maxPlayersFilterMinLabel->setBuddy(maxPlayersFilterMinSpinBox);
|
||||
|
||||
auto *maxPlayersFilterMaxLabel = new QLabel(tr("at &most:"));
|
||||
maxPlayersFilterMaxSpinBox = new QSpinBox;
|
||||
maxPlayersFilterMaxSpinBox->setMinimum(0);
|
||||
maxPlayersFilterMaxSpinBox->setMaximum(99);
|
||||
maxPlayersFilterMaxSpinBox->setValue(gamesProxyModel->getMaxPlayersFilterMax());
|
||||
maxPlayersFilterMaxSpinBox->setValue(filters.maxPlayersFilterMax);
|
||||
maxPlayersFilterMaxLabel->setBuddy(maxPlayersFilterMaxSpinBox);
|
||||
|
||||
auto *maxPlayersFilterLayout = new QGridLayout;
|
||||
|
|
@ -124,17 +126,17 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes,
|
|||
restrictionsGroupBox->setLayout(restrictionsLayout);
|
||||
|
||||
showOnlyIfSpectatorsCanWatch = new QCheckBox(tr("Show games only if &spectators can watch"));
|
||||
showOnlyIfSpectatorsCanWatch->setChecked(gamesProxyModel->getShowOnlyIfSpectatorsCanWatch());
|
||||
showOnlyIfSpectatorsCanWatch->setChecked(filters.showOnlyIfSpectatorsCanWatch);
|
||||
connect(showOnlyIfSpectatorsCanWatch, &QCheckBox::toggled, this,
|
||||
&DlgFilterGames::toggleSpectatorCheckboxEnabledness);
|
||||
|
||||
showSpectatorPasswordProtected = new QCheckBox(tr("Show spectator password p&rotected games"));
|
||||
showSpectatorPasswordProtected->setChecked(gamesProxyModel->getShowSpectatorPasswordProtected());
|
||||
showSpectatorPasswordProtected->setChecked(filters.showSpectatorPasswordProtected);
|
||||
showOnlyIfSpectatorsCanChat = new QCheckBox(tr("Show only if spectators can ch&at"));
|
||||
showOnlyIfSpectatorsCanChat->setChecked(gamesProxyModel->getShowOnlyIfSpectatorsCanChat());
|
||||
showOnlyIfSpectatorsCanChat->setChecked(filters.showOnlyIfSpectatorsCanChat);
|
||||
showOnlyIfSpectatorsCanSeeHands = new QCheckBox(tr("Show only if spectators can see &hands"));
|
||||
showOnlyIfSpectatorsCanSeeHands->setChecked(gamesProxyModel->getShowOnlyIfSpectatorsCanSeeHands());
|
||||
toggleSpectatorCheckboxEnabledness(getShowOnlyIfSpectatorsCanWatch());
|
||||
showOnlyIfSpectatorsCanSeeHands->setChecked(filters.showOnlyIfSpectatorsCanSeeHands);
|
||||
toggleSpectatorCheckboxEnabledness(filters.showOnlyIfSpectatorsCanWatch);
|
||||
|
||||
auto *spectatorsLayout = new QGridLayout;
|
||||
spectatorsLayout->addWidget(showOnlyIfSpectatorsCanWatch, 0, 0);
|
||||
|
|
@ -180,6 +182,27 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes,
|
|||
setFixedHeight(sizeHint().height());
|
||||
}
|
||||
|
||||
GameFilterConfigs DlgFilterGames::getFilters() const
|
||||
{
|
||||
return {hideBuddiesOnlyGames->isChecked(),
|
||||
hideIgnoredUserGames->isChecked(),
|
||||
hideFullGames->isChecked(),
|
||||
hideGamesThatStarted->isChecked(),
|
||||
hidePasswordProtectedGames->isChecked(),
|
||||
hideNotBuddyCreatedGames->isChecked(),
|
||||
hideOpenDecklistGames->isChecked(),
|
||||
gameNameFilterEdit->text(),
|
||||
getCreatorNameFilters(),
|
||||
getGameTypeFilter(),
|
||||
maxPlayersFilterMinSpinBox->value(),
|
||||
maxPlayersFilterMaxSpinBox->value(),
|
||||
getMaxGameAge(),
|
||||
showOnlyIfSpectatorsCanWatch->isChecked(),
|
||||
getShowSpectatorPasswordProtected(),
|
||||
getShowOnlyIfSpectatorsCanChat(),
|
||||
getShowOnlyIfSpectatorsCanSeeHands()};
|
||||
}
|
||||
|
||||
void DlgFilterGames::actOk()
|
||||
{
|
||||
accept();
|
||||
|
|
@ -192,46 +215,6 @@ void DlgFilterGames::toggleSpectatorCheckboxEnabledness(bool spectatorsEnabled)
|
|||
showOnlyIfSpectatorsCanSeeHands->setDisabled(!spectatorsEnabled);
|
||||
}
|
||||
|
||||
bool DlgFilterGames::getHideFullGames() const
|
||||
{
|
||||
return hideFullGames->isChecked();
|
||||
}
|
||||
|
||||
bool DlgFilterGames::getHideGamesThatStarted() const
|
||||
{
|
||||
return hideGamesThatStarted->isChecked();
|
||||
}
|
||||
|
||||
bool DlgFilterGames::getHideBuddiesOnlyGames() const
|
||||
{
|
||||
return hideBuddiesOnlyGames->isChecked();
|
||||
}
|
||||
|
||||
bool DlgFilterGames::getHidePasswordProtectedGames() const
|
||||
{
|
||||
return hidePasswordProtectedGames->isChecked();
|
||||
}
|
||||
|
||||
bool DlgFilterGames::getHideIgnoredUserGames() const
|
||||
{
|
||||
return hideIgnoredUserGames->isChecked();
|
||||
}
|
||||
|
||||
bool DlgFilterGames::getHideNotBuddyCreatedGames() const
|
||||
{
|
||||
return hideNotBuddyCreatedGames->isChecked();
|
||||
}
|
||||
|
||||
bool DlgFilterGames::getHideOpenDecklistGames() const
|
||||
{
|
||||
return hideOpenDecklistGames->isChecked();
|
||||
}
|
||||
|
||||
QString DlgFilterGames::getGameNameFilter() const
|
||||
{
|
||||
return gameNameFilterEdit->text();
|
||||
}
|
||||
|
||||
QStringList DlgFilterGames::getCreatorNameFilters() const
|
||||
{
|
||||
return creatorNameFilterEdit->text().split(",", Qt::SkipEmptyParts);
|
||||
|
|
@ -249,30 +232,15 @@ QSet<int> DlgFilterGames::getGameTypeFilter() const
|
|||
return result;
|
||||
}
|
||||
|
||||
int DlgFilterGames::getMaxPlayersFilterMin() const
|
||||
{
|
||||
return maxPlayersFilterMinSpinBox->value();
|
||||
}
|
||||
|
||||
int DlgFilterGames::getMaxPlayersFilterMax() const
|
||||
{
|
||||
return maxPlayersFilterMaxSpinBox->value();
|
||||
}
|
||||
|
||||
QTime DlgFilterGames::getMaxGameAge() const
|
||||
{
|
||||
int index = maxGameAgeComboBox->currentIndex();
|
||||
if (index < 0 || index >= gameAgeMap.size()) { // index is out of bounds
|
||||
return gamesProxyModel->getMaxGameAge(); // leave the setting unchanged
|
||||
if (index < 0 || index >= gameAgeMap.size()) { // index is out of bounds
|
||||
return gamesProxyModel->getFilters().maxGameAge; // leave the setting unchanged
|
||||
}
|
||||
return gameAgeMap.keys().at(index);
|
||||
}
|
||||
|
||||
bool DlgFilterGames::getShowOnlyIfSpectatorsCanWatch() const
|
||||
{
|
||||
return showOnlyIfSpectatorsCanWatch->isChecked();
|
||||
}
|
||||
|
||||
bool DlgFilterGames::getShowSpectatorPasswordProtected() const
|
||||
{
|
||||
return showSpectatorPasswordProtected->isEnabled() && showSpectatorPasswordProtected->isChecked();
|
||||
|
|
|
|||
|
|
@ -48,6 +48,14 @@ private:
|
|||
|
||||
const QMap<int, QString> &allGameTypes;
|
||||
const GamesProxyModel *gamesProxyModel;
|
||||
const QMap<QTime, QString> gameAgeMap;
|
||||
|
||||
[[nodiscard]] QStringList getCreatorNameFilters() const;
|
||||
[[nodiscard]] QSet<int> getGameTypeFilter() const;
|
||||
[[nodiscard]] QTime getMaxGameAge() const;
|
||||
[[nodiscard]] bool getShowSpectatorPasswordProtected() const;
|
||||
[[nodiscard]] bool getShowOnlyIfSpectatorsCanChat() const;
|
||||
[[nodiscard]] bool getShowOnlyIfSpectatorsCanSeeHands() const;
|
||||
|
||||
private slots:
|
||||
void actOk();
|
||||
|
|
@ -58,32 +66,7 @@ public:
|
|||
const GamesProxyModel *_gamesProxyModel,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
[[nodiscard]] bool getHideFullGames() const;
|
||||
[[nodiscard]] bool getHideGamesThatStarted() const;
|
||||
[[nodiscard]] bool getHidePasswordProtectedGames() const;
|
||||
void setShowPasswordProtectedGames(bool _passwordProtectedGamesHidden);
|
||||
[[nodiscard]] bool getHideBuddiesOnlyGames() const;
|
||||
void setHideBuddiesOnlyGames(bool _hideBuddiesOnlyGames);
|
||||
[[nodiscard]] bool getHideOpenDecklistGames() const;
|
||||
void setHideOpenDecklistGames(bool _hideOpenDecklistGames);
|
||||
[[nodiscard]] bool getHideIgnoredUserGames() const;
|
||||
void setHideIgnoredUserGames(bool _hideIgnoredUserGames);
|
||||
[[nodiscard]] bool getHideNotBuddyCreatedGames() const;
|
||||
[[nodiscard]] QString getGameNameFilter() const;
|
||||
void setGameNameFilter(const QString &_gameNameFilter);
|
||||
[[nodiscard]] QStringList getCreatorNameFilters() const;
|
||||
void setCreatorNameFilter(const QString &_creatorNameFilter);
|
||||
[[nodiscard]] QSet<int> getGameTypeFilter() const;
|
||||
void setGameTypeFilter(const QSet<int> &_gameTypeFilter);
|
||||
[[nodiscard]] int getMaxPlayersFilterMin() const;
|
||||
[[nodiscard]] int getMaxPlayersFilterMax() const;
|
||||
void setMaxPlayersFilter(int _maxPlayersFilterMin, int _maxPlayersFilterMax);
|
||||
[[nodiscard]] QTime getMaxGameAge() const;
|
||||
const QMap<QTime, QString> gameAgeMap;
|
||||
[[nodiscard]] bool getShowOnlyIfSpectatorsCanWatch() const;
|
||||
[[nodiscard]] bool getShowSpectatorPasswordProtected() const;
|
||||
[[nodiscard]] bool getShowOnlyIfSpectatorsCanChat() const;
|
||||
[[nodiscard]] bool getShowOnlyIfSpectatorsCanSeeHands() const;
|
||||
[[nodiscard]] GameFilterConfigs getFilters() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include <QPushButton>
|
||||
#include <QToolBar>
|
||||
#include <QTreeView>
|
||||
#include <QtConcurrentRun>
|
||||
#include <algorithm>
|
||||
#include <libcockatrice/card/database/card_database_manager.h>
|
||||
#include <libcockatrice/models/database/card_set/card_sets_model.h>
|
||||
|
|
@ -253,6 +254,11 @@ void WndSets::actSave()
|
|||
model->save(CardDatabaseManager::getInstance());
|
||||
SettingsCache::instance().setIncludeRebalancedCards(includeRebalancedCards);
|
||||
CardPictureLoader::clearPixmapCache();
|
||||
const auto reloadOk1 = QtConcurrent::run([] {
|
||||
CardDatabaseManager::getInstance()->reloadCardDatabasesAndNotify();
|
||||
|
||||
SettingsCache::instance().downloads().sync();
|
||||
});
|
||||
close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -219,7 +219,9 @@ void DlgUpdate::downloadSuccessful(const QUrl &filepath)
|
|||
{
|
||||
setLabel(tr("Installing..."));
|
||||
// Try to open the installer. If it opens, quit Cockatrice
|
||||
if (QDesktopServices::openUrl(filepath)) {
|
||||
if (QProcess::startDetached(filepath.toLocalFile(),
|
||||
QStringList()
|
||||
<< "/R" << QString("/D=%1").arg(QCoreApplication::applicationDirPath()))) {
|
||||
QMetaObject::invokeMethod(static_cast<MainWindow *>(parent()), "close", Qt::QueuedConnection);
|
||||
qCInfo(DlgUpdateLog) << "Opened downloaded update file successfully - closing Cockatrice";
|
||||
close();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "../../../client/settings/cache_settings.h"
|
||||
#include "../../../interface/widgets/tabs/tab_supervisor.h"
|
||||
#include "../../theme_manager.h"
|
||||
#include "../../window_main.h"
|
||||
#include "background_sources.h"
|
||||
#include "home_styled_button.h"
|
||||
|
|
@ -46,6 +47,8 @@ HomeWidget::HomeWidget(QWidget *parent, TabSupervisor *_tabSupervisor)
|
|||
&HomeWidget::onBackgroundShuffleFrequencyChanged);
|
||||
// Lambda is cleaner to read than overloading this
|
||||
connect(&SettingsCache::instance(), &SettingsCache::homeTabDisplayCardNameChanged, this, [this] { repaint(); });
|
||||
connect(&SettingsCache::instance(), &SettingsCache::themeChanged, this,
|
||||
&HomeWidget::initializeBackgroundFromSource);
|
||||
connect(&SettingsCache::instance(), &SettingsCache::themeChanged, this,
|
||||
&HomeWidget::updateButtonsToBackgroundColor);
|
||||
}
|
||||
|
|
@ -256,7 +259,7 @@ void HomeWidget::updateConnectButton(const ClientStatus status)
|
|||
|
||||
QPair<QColor, QColor> HomeWidget::extractDominantColors(const QPixmap &pixmap)
|
||||
{
|
||||
if (SettingsCache::instance().getThemeName() == "Default" &&
|
||||
if (themeManager->isBuiltInTheme() &&
|
||||
SettingsCache::instance().getHomeTabBackgroundSource() == BackgroundSources::toId(BackgroundSources::Theme)) {
|
||||
return QPair<QColor, QColor>(QColor::fromRgb(20, 140, 60), QColor::fromRgb(120, 200, 80));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
#include "game_filter_configs.h"
|
||||
|
||||
bool GameFilterConfigs::isDefault() const
|
||||
{
|
||||
static const GameFilterConfigs DEFAULT = {};
|
||||
return *this == DEFAULT;
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef COCKATRICE_GAME_FILTER_CONFIGS_H
|
||||
#define COCKATRICE_GAME_FILTER_CONFIGS_H
|
||||
|
||||
#include <QTime>
|
||||
|
||||
/**
|
||||
* @brief The possible game filter configs.
|
||||
*/
|
||||
struct GameFilterConfigs
|
||||
{
|
||||
static constexpr int DEFAULT_MAX_PLAYERS_MIN = 1;
|
||||
static constexpr int DEFAULT_MAX_PLAYERS_MAX = 99;
|
||||
|
||||
bool hideBuddiesOnlyGames = false;
|
||||
bool hideIgnoredUserGames = false;
|
||||
bool hideFullGames = false;
|
||||
bool hideGamesThatStarted = false;
|
||||
bool hidePasswordProtectedGames = false;
|
||||
bool hideNotBuddyCreatedGames = false;
|
||||
bool hideOpenDecklistGames = false;
|
||||
QString gameNameFilter = "";
|
||||
QStringList creatorNameFilters = {};
|
||||
QSet<int> gameTypeFilter = {};
|
||||
int maxPlayersFilterMin = DEFAULT_MAX_PLAYERS_MIN;
|
||||
int maxPlayersFilterMax = DEFAULT_MAX_PLAYERS_MAX;
|
||||
QTime maxGameAge = {};
|
||||
bool showOnlyIfSpectatorsCanWatch = false;
|
||||
bool showSpectatorPasswordProtected = false;
|
||||
bool showOnlyIfSpectatorsCanChat = false;
|
||||
bool showOnlyIfSpectatorsCanSeeHands = false;
|
||||
|
||||
bool operator==(const GameFilterConfigs &) const = default;
|
||||
|
||||
/**
|
||||
* @brief Checks if this config has exactly the default values.
|
||||
*
|
||||
* @return Whether this config has the default values
|
||||
*/
|
||||
bool isDefault() const;
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_GAME_FILTER_CONFIGS_H
|
||||
|
|
@ -37,8 +37,9 @@ GameSelector::GameSelector(AbstractClient *_client,
|
|||
connect(gameListView, &QTreeView::customContextMenuRequested, this, &GameSelector::customContextMenu);
|
||||
|
||||
gameListModel = new GamesModel(_rooms, _gameTypes, this);
|
||||
gameListProxyModel = new GamesProxyModel(this, tabSupervisor->getUserListManager());
|
||||
|
||||
if (showFilters) {
|
||||
gameListProxyModel = new GamesProxyModel(this, tabSupervisor->getUserListManager());
|
||||
gameListProxyModel->setSourceModel(gameListModel);
|
||||
gameListProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
gameListView->setModel(gameListProxyModel);
|
||||
|
|
@ -91,6 +92,7 @@ GameSelector::GameSelector(AbstractClient *_client,
|
|||
bool filtersSetToDefault = showFilters && gameListProxyModel->areFilterParametersSetToDefaults();
|
||||
clearFilterButton->setEnabled(!filtersSetToDefault);
|
||||
connect(clearFilterButton, &QPushButton::clicked, this, &GameSelector::actClearFilter);
|
||||
connect(gameListProxyModel, &GamesProxyModel::filtersChanged, this, &GameSelector::checkClearFilterButtonState);
|
||||
|
||||
if (room) {
|
||||
createButton = new QPushButton;
|
||||
|
|
@ -179,24 +181,19 @@ void GameSelector::actSetFilter()
|
|||
if (!dlg.exec())
|
||||
return;
|
||||
|
||||
gameListProxyModel->setGameFilters(
|
||||
dlg.getHideBuddiesOnlyGames(), dlg.getHideIgnoredUserGames(), dlg.getHideFullGames(),
|
||||
dlg.getHideGamesThatStarted(), dlg.getHidePasswordProtectedGames(), dlg.getHideNotBuddyCreatedGames(),
|
||||
dlg.getHideOpenDecklistGames(), dlg.getGameNameFilter(), dlg.getCreatorNameFilters(), dlg.getGameTypeFilter(),
|
||||
dlg.getMaxPlayersFilterMin(), dlg.getMaxPlayersFilterMax(), dlg.getMaxGameAge(),
|
||||
dlg.getShowOnlyIfSpectatorsCanWatch(), dlg.getShowSpectatorPasswordProtected(),
|
||||
dlg.getShowOnlyIfSpectatorsCanChat(), dlg.getShowOnlyIfSpectatorsCanSeeHands());
|
||||
gameListProxyModel->setGameFilters(dlg.getFilters());
|
||||
gameListProxyModel->saveFilterParameters(gameTypeMap);
|
||||
|
||||
clearFilterButton->setEnabled(!gameListProxyModel->areFilterParametersSetToDefaults());
|
||||
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
void GameSelector::checkClearFilterButtonState()
|
||||
{
|
||||
clearFilterButton->setEnabled(!gameListProxyModel->areFilterParametersSetToDefaults());
|
||||
}
|
||||
|
||||
void GameSelector::actClearFilter()
|
||||
{
|
||||
clearFilterButton->setEnabled(false);
|
||||
|
||||
gameListProxyModel->resetFilterParameters();
|
||||
gameListProxyModel->saveFilterParameters(gameTypeMap);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ private slots:
|
|||
* Updates the proxy model with selected filter parameters and refreshes the displayed game list.
|
||||
*/
|
||||
void actSetFilter();
|
||||
void checkClearFilterButtonState();
|
||||
|
||||
/**
|
||||
* @brief Clears all filters applied to the game list.
|
||||
|
|
|
|||
|
|
@ -18,33 +18,31 @@ GameSelectorQuickFilterToolBar::GameSelectorQuickFilterToolBar(QWidget *parent,
|
|||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
mainLayout->setSpacing(5);
|
||||
|
||||
const GameFilterConfigs &filters = model->getFilters();
|
||||
|
||||
searchBar = new QLineEdit(this);
|
||||
searchBar->setText(model->getCreatorNameFilters().join(", "));
|
||||
connect(searchBar, &QLineEdit::textChanged, this, [this](const QString &text) { model->setGameNameFilter(text); });
|
||||
searchBar->setText(filters.gameNameFilter);
|
||||
connect(searchBar, &QLineEdit::textChanged, this, [this](const QString &text) {
|
||||
applyFilters([&](GameFilterConfigs &configs) { configs.gameNameFilter = text; });
|
||||
});
|
||||
|
||||
hideGamesNotCreatedByBuddiesCheckBox = new QCheckBox(this);
|
||||
hideGamesNotCreatedByBuddiesCheckBox->setChecked(model->getHideBuddiesOnlyGames());
|
||||
hideGamesNotCreatedByBuddiesCheckBox->setChecked(filters.hideNotBuddyCreatedGames);
|
||||
connect(hideGamesNotCreatedByBuddiesCheckBox, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
if (checked) {
|
||||
QStringList buddyNames;
|
||||
for (auto buddy : tabSupervisor->getUserListManager()->getBuddyList().values()) {
|
||||
buddyNames << QString::fromStdString(buddy.name());
|
||||
}
|
||||
model->setCreatorNameFilters(buddyNames);
|
||||
} else {
|
||||
model->setCreatorNameFilters({});
|
||||
}
|
||||
applyFilters([&](GameFilterConfigs &configs) { configs.hideNotBuddyCreatedGames = checked; });
|
||||
});
|
||||
|
||||
hideFullGamesCheckBox = new QCheckBox(this);
|
||||
hideFullGamesCheckBox->setChecked(model->getHideFullGames());
|
||||
connect(hideFullGamesCheckBox, &QCheckBox::toggled, this,
|
||||
[this](bool checked) { model->setHideFullGames(checked); });
|
||||
hideFullGamesCheckBox->setChecked(filters.hideFullGames);
|
||||
connect(hideFullGamesCheckBox, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
applyFilters([&](GameFilterConfigs &configs) { configs.hideFullGames = checked; });
|
||||
});
|
||||
|
||||
hideStartedGamesCheckBox = new QCheckBox(this);
|
||||
hideStartedGamesCheckBox->setChecked(model->getHideGamesThatStarted());
|
||||
connect(hideStartedGamesCheckBox, &QCheckBox::toggled, this,
|
||||
[this](bool checked) { model->setHideGamesThatStarted(checked); });
|
||||
hideStartedGamesCheckBox->setChecked(filters.hideGamesThatStarted);
|
||||
connect(hideStartedGamesCheckBox, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
applyFilters([&](GameFilterConfigs &configs) { configs.hideGamesThatStarted = checked; });
|
||||
});
|
||||
|
||||
filterToFormatComboBox = new QComboBox(this);
|
||||
|
||||
|
|
@ -57,7 +55,7 @@ GameSelectorQuickFilterToolBar::GameSelectorQuickFilterToolBar(QWidget *parent,
|
|||
filterToFormatComboBox->addItem(i.value(), i.key()); // text = name, data = type ID
|
||||
}
|
||||
|
||||
QSet<int> currentTypes = model->getGameTypeFilter();
|
||||
QSet<int> currentTypes = filters.gameTypeFilter;
|
||||
if (currentTypes.size() == 1) {
|
||||
int typeId = *currentTypes.begin();
|
||||
int index = filterToFormatComboBox->findData(typeId);
|
||||
|
|
@ -69,13 +67,14 @@ GameSelectorQuickFilterToolBar::GameSelectorQuickFilterToolBar(QWidget *parent,
|
|||
|
||||
// Update proxy model on selection change
|
||||
connect(filterToFormatComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int index) {
|
||||
QVariant data = filterToFormatComboBox->itemData(index);
|
||||
if (!data.isValid()) {
|
||||
model->setGameTypeFilter({}); // empty = no filter
|
||||
} else {
|
||||
int typeId = data.toInt();
|
||||
model->setGameTypeFilter({typeId});
|
||||
}
|
||||
applyFilters([&](GameFilterConfigs &configs) {
|
||||
QVariant data = filterToFormatComboBox->itemData(index);
|
||||
if (!data.isValid()) {
|
||||
configs.gameTypeFilter.clear();
|
||||
} else {
|
||||
configs.gameTypeFilter = {data.toInt()};
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
hideGamesNotCreatedByBuddiesCheckBox->setMinimumSize(20, 20);
|
||||
|
|
@ -96,9 +95,47 @@ GameSelectorQuickFilterToolBar::GameSelectorQuickFilterToolBar(QWidget *parent,
|
|||
|
||||
setLayout(mainLayout);
|
||||
|
||||
syncFromModel();
|
||||
|
||||
connect(model, &GamesProxyModel::filtersChanged, this, &GameSelectorQuickFilterToolBar::syncFromModel);
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
void GameSelectorQuickFilterToolBar::syncFromModel()
|
||||
{
|
||||
QSignalBlocker b1(searchBar);
|
||||
QSignalBlocker b2(filterToFormatComboBox);
|
||||
QSignalBlocker b3(hideGamesNotCreatedByBuddiesCheckBox);
|
||||
QSignalBlocker b4(hideFullGamesCheckBox);
|
||||
QSignalBlocker b5(hideStartedGamesCheckBox);
|
||||
|
||||
const GameFilterConfigs filters = model->getFilters();
|
||||
|
||||
searchBar->setText(filters.gameNameFilter);
|
||||
|
||||
hideGamesNotCreatedByBuddiesCheckBox->setChecked(filters.hideNotBuddyCreatedGames);
|
||||
hideFullGamesCheckBox->setChecked(filters.hideFullGames);
|
||||
hideStartedGamesCheckBox->setChecked(filters.hideGamesThatStarted);
|
||||
|
||||
QSet<int> types = filters.gameTypeFilter;
|
||||
if (types.size() == 1) {
|
||||
int idx = filterToFormatComboBox->findData(*types.begin());
|
||||
filterToFormatComboBox->setCurrentIndex(idx >= 0 ? idx : 0);
|
||||
} else {
|
||||
filterToFormatComboBox->setCurrentIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
void GameSelectorQuickFilterToolBar::applyFilters(std::function<void(GameFilterConfigs &)> mutator)
|
||||
{
|
||||
GameFilterConfigs configs = model->getFilters();
|
||||
|
||||
mutator(configs);
|
||||
|
||||
model->setGameFilters(configs);
|
||||
}
|
||||
|
||||
void GameSelectorQuickFilterToolBar::retranslateUi()
|
||||
{
|
||||
searchBar->setPlaceholderText(tr("Filter by game name..."));
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ public:
|
|||
TabSupervisor *tabSupervisor,
|
||||
GamesProxyModel *model,
|
||||
const QMap<int, QString> &allGameTypes);
|
||||
void syncFromModel();
|
||||
void applyFilters(std::function<void(GameFilterConfigs &)> mutator);
|
||||
void retranslateUi();
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -23,10 +23,6 @@ enum GameListColumn
|
|||
SPECTATORS
|
||||
};
|
||||
|
||||
const int DEFAULT_MAX_PLAYERS_MIN = 1;
|
||||
const int DEFAULT_MAX_PLAYERS_MAX = 99;
|
||||
constexpr auto DEFAULT_MAX_GAME_AGE = QTime();
|
||||
|
||||
const QString GamesModel::getGameCreatedString(const int secs)
|
||||
{
|
||||
static const QTime zeroTime{0, 0};
|
||||
|
|
@ -283,49 +279,18 @@ GamesProxyModel::GamesProxyModel(QObject *parent, const UserListProxy *_userList
|
|||
setDynamicSortFilter(true);
|
||||
}
|
||||
|
||||
void GamesProxyModel::setGameFilters(bool _hideBuddiesOnlyGames,
|
||||
bool _hideIgnoredUserGames,
|
||||
bool _hideFullGames,
|
||||
bool _hideGamesThatStarted,
|
||||
bool _hidePasswordProtectedGames,
|
||||
bool _hideNotBuddyCreatedGames,
|
||||
bool _hideOpenDecklistGames,
|
||||
const QString &_gameNameFilter,
|
||||
const QStringList &_creatorNameFilters,
|
||||
const QSet<int> &_gameTypeFilter,
|
||||
int _maxPlayersFilterMin,
|
||||
int _maxPlayersFilterMax,
|
||||
const QTime &_maxGameAge,
|
||||
bool _showOnlyIfSpectatorsCanWatch,
|
||||
bool _showSpectatorPasswordProtected,
|
||||
bool _showOnlyIfSpectatorsCanChat,
|
||||
bool _showOnlyIfSpectatorsCanSeeHands)
|
||||
void GamesProxyModel::setGameFilters(const GameFilterConfigs &_filters)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 9, 0))
|
||||
beginFilterChange();
|
||||
#endif
|
||||
hideBuddiesOnlyGames = _hideBuddiesOnlyGames;
|
||||
hideIgnoredUserGames = _hideIgnoredUserGames;
|
||||
hideFullGames = _hideFullGames;
|
||||
hideGamesThatStarted = _hideGamesThatStarted;
|
||||
hidePasswordProtectedGames = _hidePasswordProtectedGames;
|
||||
hideNotBuddyCreatedGames = _hideNotBuddyCreatedGames;
|
||||
hideOpenDecklistGames = _hideOpenDecklistGames;
|
||||
gameNameFilter = _gameNameFilter;
|
||||
creatorNameFilters = _creatorNameFilters;
|
||||
gameTypeFilter = _gameTypeFilter;
|
||||
maxPlayersFilterMin = _maxPlayersFilterMin;
|
||||
maxPlayersFilterMax = _maxPlayersFilterMax;
|
||||
maxGameAge = _maxGameAge;
|
||||
showOnlyIfSpectatorsCanWatch = _showOnlyIfSpectatorsCanWatch;
|
||||
showSpectatorPasswordProtected = _showSpectatorPasswordProtected;
|
||||
showOnlyIfSpectatorsCanChat = _showOnlyIfSpectatorsCanChat;
|
||||
showOnlyIfSpectatorsCanSeeHands = _showOnlyIfSpectatorsCanSeeHands;
|
||||
filters = _filters;
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(6, 10, 0))
|
||||
endFilterChange(QSortFilterProxyModel::Direction::Rows);
|
||||
#else
|
||||
invalidateFilter();
|
||||
#endif
|
||||
emit filtersChanged();
|
||||
}
|
||||
|
||||
int GamesProxyModel::getNumFilteredGames() const
|
||||
|
|
@ -345,18 +310,12 @@ int GamesProxyModel::getNumFilteredGames() const
|
|||
|
||||
void GamesProxyModel::resetFilterParameters()
|
||||
{
|
||||
setGameFilters(false, false, false, false, false, false, false, QString(), QStringList(), {},
|
||||
DEFAULT_MAX_PLAYERS_MIN, DEFAULT_MAX_PLAYERS_MAX, DEFAULT_MAX_GAME_AGE, false, false, false, false);
|
||||
setGameFilters({});
|
||||
}
|
||||
|
||||
bool GamesProxyModel::areFilterParametersSetToDefaults() const
|
||||
{
|
||||
return !hideFullGames && !hideGamesThatStarted && !hidePasswordProtectedGames && !hideBuddiesOnlyGames &&
|
||||
!hideOpenDecklistGames && !hideIgnoredUserGames && !hideNotBuddyCreatedGames && gameNameFilter.isEmpty() &&
|
||||
creatorNameFilters.isEmpty() && gameTypeFilter.isEmpty() && maxPlayersFilterMin == DEFAULT_MAX_PLAYERS_MIN &&
|
||||
maxPlayersFilterMax == DEFAULT_MAX_PLAYERS_MAX && maxGameAge == DEFAULT_MAX_GAME_AGE &&
|
||||
!showOnlyIfSpectatorsCanWatch && !showSpectatorPasswordProtected && !showOnlyIfSpectatorsCanChat &&
|
||||
!showOnlyIfSpectatorsCanSeeHands;
|
||||
return filters.isDefault();
|
||||
}
|
||||
|
||||
void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameTypes)
|
||||
|
|
@ -372,44 +331,44 @@ void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameType
|
|||
}
|
||||
}
|
||||
|
||||
setGameFilters(gameFilters.isHideBuddiesOnlyGames(), gameFilters.isHideIgnoredUserGames(),
|
||||
gameFilters.isHideFullGames(), gameFilters.isHideGamesThatStarted(),
|
||||
gameFilters.isHidePasswordProtectedGames(), gameFilters.isHideNotBuddyCreatedGames(),
|
||||
gameFilters.isHideOpenDecklistGames(), gameFilters.getGameNameFilter(),
|
||||
gameFilters.getCreatorNameFilters(), newGameTypeFilter, gameFilters.getMinPlayers(),
|
||||
gameFilters.getMaxPlayers(), gameFilters.getMaxGameAge(),
|
||||
gameFilters.isShowOnlyIfSpectatorsCanWatch(), gameFilters.isShowSpectatorPasswordProtected(),
|
||||
gameFilters.isShowOnlyIfSpectatorsCanChat(), gameFilters.isShowOnlyIfSpectatorsCanSeeHands());
|
||||
setGameFilters({gameFilters.isHideBuddiesOnlyGames(), gameFilters.isHideIgnoredUserGames(),
|
||||
gameFilters.isHideFullGames(), gameFilters.isHideGamesThatStarted(),
|
||||
gameFilters.isHidePasswordProtectedGames(), gameFilters.isHideNotBuddyCreatedGames(),
|
||||
gameFilters.isHideOpenDecklistGames(), gameFilters.getGameNameFilter(),
|
||||
gameFilters.getCreatorNameFilters(), newGameTypeFilter, gameFilters.getMinPlayers(),
|
||||
gameFilters.getMaxPlayers(), gameFilters.getMaxGameAge(),
|
||||
gameFilters.isShowOnlyIfSpectatorsCanWatch(), gameFilters.isShowSpectatorPasswordProtected(),
|
||||
gameFilters.isShowOnlyIfSpectatorsCanChat(), gameFilters.isShowOnlyIfSpectatorsCanSeeHands()});
|
||||
}
|
||||
|
||||
void GamesProxyModel::saveFilterParameters(const QMap<int, QString> &allGameTypes)
|
||||
{
|
||||
GameFiltersSettings &gameFilters = SettingsCache::instance().gameFilters();
|
||||
gameFilters.setHideBuddiesOnlyGames(hideBuddiesOnlyGames);
|
||||
gameFilters.setHideFullGames(hideFullGames);
|
||||
gameFilters.setHideGamesThatStarted(hideGamesThatStarted);
|
||||
gameFilters.setHidePasswordProtectedGames(hidePasswordProtectedGames);
|
||||
gameFilters.setHideIgnoredUserGames(hideIgnoredUserGames);
|
||||
gameFilters.setHideNotBuddyCreatedGames(hideNotBuddyCreatedGames);
|
||||
gameFilters.setHideOpenDecklistGames(hideOpenDecklistGames);
|
||||
gameFilters.setGameNameFilter(gameNameFilter);
|
||||
gameFilters.setCreatorNameFilters(creatorNameFilters);
|
||||
gameFilters.setHideBuddiesOnlyGames(filters.hideBuddiesOnlyGames);
|
||||
gameFilters.setHideFullGames(filters.hideFullGames);
|
||||
gameFilters.setHideGamesThatStarted(filters.hideGamesThatStarted);
|
||||
gameFilters.setHidePasswordProtectedGames(filters.hidePasswordProtectedGames);
|
||||
gameFilters.setHideIgnoredUserGames(filters.hideIgnoredUserGames);
|
||||
gameFilters.setHideNotBuddyCreatedGames(filters.hideNotBuddyCreatedGames);
|
||||
gameFilters.setHideOpenDecklistGames(filters.hideOpenDecklistGames);
|
||||
gameFilters.setGameNameFilter(filters.gameNameFilter);
|
||||
gameFilters.setCreatorNameFilters(filters.creatorNameFilters);
|
||||
|
||||
QMapIterator<int, QString> gameTypeIterator(allGameTypes);
|
||||
while (gameTypeIterator.hasNext()) {
|
||||
gameTypeIterator.next();
|
||||
bool enabled = gameTypeFilter.contains(gameTypeIterator.key());
|
||||
bool enabled = filters.gameTypeFilter.contains(gameTypeIterator.key());
|
||||
gameFilters.setGameTypeEnabled(gameTypeIterator.value(), enabled);
|
||||
}
|
||||
|
||||
gameFilters.setMinPlayers(maxPlayersFilterMin);
|
||||
gameFilters.setMaxPlayers(maxPlayersFilterMax);
|
||||
gameFilters.setMaxGameAge(maxGameAge);
|
||||
gameFilters.setMinPlayers(filters.maxPlayersFilterMin);
|
||||
gameFilters.setMaxPlayers(filters.maxPlayersFilterMax);
|
||||
gameFilters.setMaxGameAge(filters.maxGameAge);
|
||||
|
||||
gameFilters.setShowOnlyIfSpectatorsCanWatch(showOnlyIfSpectatorsCanWatch);
|
||||
gameFilters.setShowSpectatorPasswordProtected(showSpectatorPasswordProtected);
|
||||
gameFilters.setShowOnlyIfSpectatorsCanChat(showOnlyIfSpectatorsCanChat);
|
||||
gameFilters.setShowOnlyIfSpectatorsCanSeeHands(showOnlyIfSpectatorsCanSeeHands);
|
||||
gameFilters.setShowOnlyIfSpectatorsCanWatch(filters.showOnlyIfSpectatorsCanWatch);
|
||||
gameFilters.setShowSpectatorPasswordProtected(filters.showSpectatorPasswordProtected);
|
||||
gameFilters.setShowOnlyIfSpectatorsCanChat(filters.showOnlyIfSpectatorsCanChat);
|
||||
gameFilters.setShowOnlyIfSpectatorsCanSeeHands(filters.showOnlyIfSpectatorsCanSeeHands);
|
||||
}
|
||||
|
||||
bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
|
||||
|
|
@ -430,33 +389,35 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow) const
|
|||
|
||||
const ServerInfo_Game &game = model->getGame(sourceRow);
|
||||
|
||||
if (hideBuddiesOnlyGames && game.only_buddies()) {
|
||||
if (filters.hideBuddiesOnlyGames && game.only_buddies()) {
|
||||
return false;
|
||||
}
|
||||
if (hideOpenDecklistGames && game.share_decklists_on_load()) {
|
||||
if (filters.hideOpenDecklistGames && game.share_decklists_on_load()) {
|
||||
return false;
|
||||
}
|
||||
if (hideIgnoredUserGames && userListProxy->isUserIgnored(QString::fromStdString(game.creator_info().name()))) {
|
||||
if (filters.hideIgnoredUserGames &&
|
||||
userListProxy->isUserIgnored(QString::fromStdString(game.creator_info().name()))) {
|
||||
return false;
|
||||
}
|
||||
if (hideNotBuddyCreatedGames && !userListProxy->isUserBuddy(QString::fromStdString(game.creator_info().name()))) {
|
||||
if (filters.hideNotBuddyCreatedGames &&
|
||||
!userListProxy->isUserBuddy(QString::fromStdString(game.creator_info().name()))) {
|
||||
return false;
|
||||
}
|
||||
if (hideFullGames && game.player_count() == game.max_players())
|
||||
if (filters.hideFullGames && game.player_count() == game.max_players())
|
||||
return false;
|
||||
if (hideGamesThatStarted && game.started())
|
||||
if (filters.hideGamesThatStarted && game.started())
|
||||
return false;
|
||||
if (!userListProxy->isOwnUserRegistered())
|
||||
if (game.only_registered())
|
||||
return false;
|
||||
if (hidePasswordProtectedGames && game.with_password())
|
||||
if (filters.hidePasswordProtectedGames && game.with_password())
|
||||
return false;
|
||||
if (!gameNameFilter.isEmpty())
|
||||
if (!QString::fromStdString(game.description()).contains(gameNameFilter, Qt::CaseInsensitive))
|
||||
if (!filters.gameNameFilter.isEmpty())
|
||||
if (!QString::fromStdString(game.description()).contains(filters.gameNameFilter, Qt::CaseInsensitive))
|
||||
return false;
|
||||
if (!creatorNameFilters.isEmpty()) {
|
||||
if (!filters.creatorNameFilters.isEmpty()) {
|
||||
bool found = false;
|
||||
for (const auto &createNameFilter : creatorNameFilters) {
|
||||
for (const auto &createNameFilter : filters.creatorNameFilters) {
|
||||
if (QString::fromStdString(game.creator_info().name()).contains(createNameFilter, Qt::CaseInsensitive)) {
|
||||
found = true;
|
||||
}
|
||||
|
|
@ -469,33 +430,34 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow) const
|
|||
QSet<int> gameTypes;
|
||||
for (int i = 0; i < game.game_types_size(); ++i)
|
||||
gameTypes.insert(game.game_types(i));
|
||||
if (!gameTypeFilter.isEmpty() && gameTypes.intersect(gameTypeFilter).isEmpty())
|
||||
if (!filters.gameTypeFilter.isEmpty() && gameTypes.intersect(filters.gameTypeFilter).isEmpty())
|
||||
return false;
|
||||
|
||||
if (game.max_players() < maxPlayersFilterMin)
|
||||
if (static_cast<int>(game.max_players()) < filters.maxPlayersFilterMin)
|
||||
return false;
|
||||
if (game.max_players() > maxPlayersFilterMax)
|
||||
if (static_cast<int>(game.max_players()) > filters.maxPlayersFilterMax)
|
||||
return false;
|
||||
|
||||
if (maxGameAge.isValid()) {
|
||||
if (filters.maxGameAge.isValid()) {
|
||||
QDateTime now = QDateTime::currentDateTimeUtc();
|
||||
qint64 signed_start_time = game.start_time(); // cast to 64 bit value to allow signed value
|
||||
QDateTime total = now.addSecs(-signed_start_time); // a 32 bit value would wrap at 2038-1-19
|
||||
// games shouldn't have negative ages but we'll not filter them
|
||||
// because qtime wraps after a day we consider all games older than a day to be too old
|
||||
if (total.isValid() && total.date() >= epochDate && (total.date() > epochDate || total.time() > maxGameAge)) {
|
||||
if (total.isValid() && total.date() >= epochDate &&
|
||||
(total.date() > epochDate || total.time() > filters.maxGameAge)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (showOnlyIfSpectatorsCanWatch) {
|
||||
if (filters.showOnlyIfSpectatorsCanWatch) {
|
||||
if (!game.spectators_allowed())
|
||||
return false;
|
||||
if (!showSpectatorPasswordProtected && game.spectators_need_password())
|
||||
if (!filters.showSpectatorPasswordProtected && game.spectators_need_password())
|
||||
return false;
|
||||
if (showOnlyIfSpectatorsCanChat && !game.spectators_can_chat())
|
||||
if (filters.showOnlyIfSpectatorsCanChat && !game.spectators_can_chat())
|
||||
return false;
|
||||
if (showOnlyIfSpectatorsCanSeeHands && !game.spectators_omniscient())
|
||||
if (filters.showOnlyIfSpectatorsCanSeeHands && !game.spectators_omniscient())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef GAMESMODEL_H
|
||||
#define GAMESMODEL_H
|
||||
|
||||
#include "game_filter_configs.h"
|
||||
#include "game_type_map.h"
|
||||
|
||||
#include <QList>
|
||||
|
|
@ -121,22 +122,10 @@ private:
|
|||
// - loadFilterParameters()
|
||||
// - saveFilterParameters()
|
||||
// - filterAcceptsRow()
|
||||
bool hideBuddiesOnlyGames;
|
||||
bool hideIgnoredUserGames;
|
||||
bool hideFullGames;
|
||||
bool hideGamesThatStarted;
|
||||
bool hidePasswordProtectedGames;
|
||||
bool hideNotBuddyCreatedGames;
|
||||
bool hideOpenDecklistGames;
|
||||
QString gameNameFilter;
|
||||
QStringList creatorNameFilters;
|
||||
QSet<int> gameTypeFilter;
|
||||
quint32 maxPlayersFilterMin, maxPlayersFilterMax;
|
||||
QTime maxGameAge;
|
||||
bool showOnlyIfSpectatorsCanWatch;
|
||||
bool showSpectatorPasswordProtected;
|
||||
bool showOnlyIfSpectatorsCanChat;
|
||||
bool showOnlyIfSpectatorsCanSeeHands;
|
||||
GameFilterConfigs filters;
|
||||
|
||||
signals:
|
||||
void filtersChanged();
|
||||
|
||||
public:
|
||||
/**
|
||||
|
|
@ -147,182 +136,15 @@ public:
|
|||
explicit GamesProxyModel(QObject *parent = nullptr, const UserListProxy *_userListProxy = nullptr);
|
||||
|
||||
// Getters for filter parameters
|
||||
[[nodiscard]] bool getHideBuddiesOnlyGames() const
|
||||
[[nodiscard]] const GameFilterConfigs &getFilters() const
|
||||
{
|
||||
return hideBuddiesOnlyGames;
|
||||
}
|
||||
[[nodiscard]] bool getHideIgnoredUserGames() const
|
||||
{
|
||||
return hideIgnoredUserGames;
|
||||
}
|
||||
[[nodiscard]] bool getHideFullGames() const
|
||||
{
|
||||
return hideFullGames;
|
||||
}
|
||||
[[nodiscard]] bool getHideGamesThatStarted() const
|
||||
{
|
||||
return hideGamesThatStarted;
|
||||
}
|
||||
[[nodiscard]] bool getHidePasswordProtectedGames() const
|
||||
{
|
||||
return hidePasswordProtectedGames;
|
||||
}
|
||||
[[nodiscard]] bool getHideNotBuddyCreatedGames() const
|
||||
{
|
||||
return hideNotBuddyCreatedGames;
|
||||
}
|
||||
[[nodiscard]] bool getHideOpenDecklistGames() const
|
||||
{
|
||||
return hideOpenDecklistGames;
|
||||
}
|
||||
[[nodiscard]] QString getGameNameFilter() const
|
||||
{
|
||||
return gameNameFilter;
|
||||
}
|
||||
[[nodiscard]] QStringList getCreatorNameFilters() const
|
||||
{
|
||||
return creatorNameFilters;
|
||||
}
|
||||
[[nodiscard]] QSet<int> getGameTypeFilter() const
|
||||
{
|
||||
return gameTypeFilter;
|
||||
}
|
||||
[[nodiscard]] int getMaxPlayersFilterMin() const
|
||||
{
|
||||
return maxPlayersFilterMin;
|
||||
}
|
||||
[[nodiscard]] int getMaxPlayersFilterMax() const
|
||||
{
|
||||
return maxPlayersFilterMax;
|
||||
}
|
||||
[[nodiscard]] const QTime &getMaxGameAge() const
|
||||
{
|
||||
return maxGameAge;
|
||||
}
|
||||
[[nodiscard]] bool getShowOnlyIfSpectatorsCanWatch() const
|
||||
{
|
||||
return showOnlyIfSpectatorsCanWatch;
|
||||
}
|
||||
[[nodiscard]] bool getShowSpectatorPasswordProtected() const
|
||||
{
|
||||
return showSpectatorPasswordProtected;
|
||||
}
|
||||
[[nodiscard]] bool getShowOnlyIfSpectatorsCanChat() const
|
||||
{
|
||||
return showOnlyIfSpectatorsCanChat;
|
||||
}
|
||||
[[nodiscard]] bool getShowOnlyIfSpectatorsCanSeeHands() const
|
||||
{
|
||||
return showOnlyIfSpectatorsCanSeeHands;
|
||||
return filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets all game filters at once.
|
||||
*/
|
||||
void setGameFilters(bool _hideBuddiesOnlyGames,
|
||||
bool _hideIgnoredUserGames,
|
||||
bool _hideFullGames,
|
||||
bool _hideGamesThatStarted,
|
||||
bool _hidePasswordProtectedGames,
|
||||
bool _hideNotBuddyCreatedGames,
|
||||
bool _hideOpenDecklistGames,
|
||||
const QString &_gameNameFilter,
|
||||
const QStringList &_creatorNameFilter,
|
||||
const QSet<int> &_gameTypeFilter,
|
||||
int _maxPlayersFilterMin,
|
||||
int _maxPlayersFilterMax,
|
||||
const QTime &_maxGameAge,
|
||||
bool _showOnlyIfSpectatorsCanWatch,
|
||||
bool _showSpectatorPasswordProtected,
|
||||
bool _showOnlyIfSpectatorsCanChat,
|
||||
bool _showOnlyIfSpectatorsCanSeeHands);
|
||||
|
||||
// Individual setters
|
||||
void setHideBuddiesOnlyGames(bool value)
|
||||
{
|
||||
hideBuddiesOnlyGames = value;
|
||||
refresh();
|
||||
}
|
||||
void setHideIgnoredUserGames(bool value)
|
||||
{
|
||||
hideIgnoredUserGames = value;
|
||||
refresh();
|
||||
}
|
||||
void setHideFullGames(bool value)
|
||||
{
|
||||
hideFullGames = value;
|
||||
refresh();
|
||||
}
|
||||
void setHideGamesThatStarted(bool value)
|
||||
{
|
||||
hideGamesThatStarted = value;
|
||||
refresh();
|
||||
}
|
||||
void setHidePasswordProtectedGames(bool value)
|
||||
{
|
||||
hidePasswordProtectedGames = value;
|
||||
refresh();
|
||||
}
|
||||
void setHideNotBuddyCreatedGames(bool value)
|
||||
{
|
||||
hideNotBuddyCreatedGames = value;
|
||||
refresh();
|
||||
}
|
||||
void setHideOpenDecklistGames(bool value)
|
||||
{
|
||||
hideOpenDecklistGames = value;
|
||||
refresh();
|
||||
}
|
||||
void setGameNameFilter(const QString &value)
|
||||
{
|
||||
gameNameFilter = value;
|
||||
refresh();
|
||||
}
|
||||
void setCreatorNameFilters(const QStringList &values)
|
||||
{
|
||||
creatorNameFilters = values;
|
||||
refresh();
|
||||
}
|
||||
void setGameTypeFilter(const QSet<int> &value)
|
||||
{
|
||||
gameTypeFilter = value;
|
||||
refresh();
|
||||
}
|
||||
void setMaxPlayersFilterMin(int value)
|
||||
{
|
||||
maxPlayersFilterMin = value;
|
||||
refresh();
|
||||
}
|
||||
void setMaxPlayersFilterMax(int value)
|
||||
{
|
||||
maxPlayersFilterMax = value;
|
||||
refresh();
|
||||
}
|
||||
void setMaxGameAge(const QTime &value)
|
||||
{
|
||||
maxGameAge = value;
|
||||
refresh();
|
||||
}
|
||||
void setShowOnlyIfSpectatorsCanWatch(bool value)
|
||||
{
|
||||
showOnlyIfSpectatorsCanWatch = value;
|
||||
refresh();
|
||||
}
|
||||
void setShowSpectatorPasswordProtected(bool value)
|
||||
{
|
||||
showSpectatorPasswordProtected = value;
|
||||
refresh();
|
||||
}
|
||||
void setShowOnlyIfSpectatorsCanChat(bool value)
|
||||
{
|
||||
showOnlyIfSpectatorsCanChat = value;
|
||||
refresh();
|
||||
}
|
||||
void setShowOnlyIfSpectatorsCanSeeHands(bool value)
|
||||
{
|
||||
showOnlyIfSpectatorsCanSeeHands = value;
|
||||
refresh();
|
||||
}
|
||||
void setGameFilters(const GameFilterConfigs &_filters);
|
||||
|
||||
/**
|
||||
* @brief Returns the number of games filtered out by the current filter.
|
||||
|
|
|
|||
|
|
@ -4,10 +4,29 @@ void ArchidektApiResponseCardEntry::fromJson(const QJsonObject &json)
|
|||
{
|
||||
id = json.value("id").toInt();
|
||||
|
||||
categories.clear();
|
||||
|
||||
auto categoriesJson = json.value("categories").toArray();
|
||||
|
||||
for (auto category : categoriesJson) {
|
||||
categories.append(category.toString());
|
||||
for (const auto &categoryValue : categoriesJson) {
|
||||
Category cat;
|
||||
|
||||
if (categoryValue.isObject()) {
|
||||
QJsonObject obj = categoryValue.toObject();
|
||||
|
||||
cat.id = obj.value("id").toInt();
|
||||
cat.name = obj.value("name").toString();
|
||||
cat.isPremier = obj.value("isPremier").toBool();
|
||||
cat.includedInDeck = obj.value("includedInDeck").toBool();
|
||||
cat.includedInPrice = obj.value("includedInPrice").toBool();
|
||||
} else if (categoryValue.isString()) {
|
||||
cat.name = categoryValue.toString();
|
||||
|
||||
// assume mainboard unless known otherwise
|
||||
cat.includedInDeck = true;
|
||||
}
|
||||
|
||||
categories.append(cat);
|
||||
}
|
||||
|
||||
companion = json.value("companion").toBool();
|
||||
|
|
@ -27,7 +46,13 @@ void ArchidektApiResponseCardEntry::fromJson(const QJsonObject &json)
|
|||
void ArchidektApiResponseCardEntry::debugPrint() const
|
||||
{
|
||||
qDebug() << "Id:" << id;
|
||||
qDebug() << "Categories:" << categories;
|
||||
for (auto category : categories) {
|
||||
qDebug() << "Category ID:" << category.id;
|
||||
qDebug() << "Category Name:" << category.name;
|
||||
qDebug() << "Category Premier:" << category.isPremier;
|
||||
qDebug() << "Category Included in Deck:" << category.includedInDeck;
|
||||
qDebug() << "Category Included in Price:" << category.includedInPrice;
|
||||
}
|
||||
qDebug() << "Companion:" << companion;
|
||||
qDebug() << "FlippedDefault:" << flippedDefault;
|
||||
qDebug() << "Label:" << label;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,15 @@
|
|||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
struct Category
|
||||
{
|
||||
int id;
|
||||
QString name;
|
||||
bool isPremier;
|
||||
bool includedInDeck;
|
||||
bool includedInPrice;
|
||||
};
|
||||
|
||||
class ArchidektApiResponseCardEntry
|
||||
{
|
||||
public:
|
||||
|
|
@ -26,7 +35,7 @@ public:
|
|||
return card;
|
||||
};
|
||||
|
||||
QStringList getCategories() const
|
||||
QList<Category> getCategories() const
|
||||
{
|
||||
return categories;
|
||||
}
|
||||
|
|
@ -38,7 +47,7 @@ public:
|
|||
|
||||
private:
|
||||
int id;
|
||||
QStringList categories;
|
||||
QList<Category> categories;
|
||||
bool companion;
|
||||
bool flippedDefault;
|
||||
QString label;
|
||||
|
|
|
|||
|
|
@ -63,16 +63,60 @@ ArchidektApiResponseDeckDisplayWidget::ArchidektApiResponseDeckDisplayWidget(QWi
|
|||
QString tempDeck;
|
||||
QTextStream deckStream(&tempDeck);
|
||||
|
||||
for (auto card : response.getCards()) {
|
||||
QString mainboardText;
|
||||
QString sideboardText;
|
||||
|
||||
QTextStream mainStream(&mainboardText);
|
||||
QTextStream sideStream(&sideboardText);
|
||||
|
||||
for (const auto &card : response.getCards()) {
|
||||
QString fullName = card.getCard().getOracleCard().value("name").toString();
|
||||
// We don't really care about the second card, the card database already has it as a relation
|
||||
QString cleanName = fullName.split("//").first().trimmed();
|
||||
|
||||
tempDeck += QString("%1 %2 (%3) %4\n")
|
||||
.arg(card.getQuantity())
|
||||
.arg(cleanName)
|
||||
.arg(card.getCard().getEdition().getEditionCode().toUpper())
|
||||
.arg(card.getCard().getCollectorNumber());
|
||||
QString line = QString("%1 %2 (%3) %4\n")
|
||||
.arg(card.getQuantity())
|
||||
.arg(cleanName)
|
||||
.arg(card.getCard().getEdition().getEditionCode().toUpper())
|
||||
.arg(card.getCard().getCollectorNumber());
|
||||
|
||||
bool isCommander = false;
|
||||
bool isSideboardCategory = false;
|
||||
bool includedInDeck = false;
|
||||
|
||||
for (const auto &cat : card.getCategories()) {
|
||||
|
||||
if (cat.name.compare("Commander", Qt::CaseInsensitive) == 0) {
|
||||
isCommander = true;
|
||||
}
|
||||
|
||||
if (cat.name.compare("Sideboard", Qt::CaseInsensitive) == 0 ||
|
||||
cat.name.compare("Maybeboard", Qt::CaseInsensitive) == 0) {
|
||||
isSideboardCategory = true;
|
||||
}
|
||||
|
||||
if (cat.includedInDeck) {
|
||||
includedInDeck = true;
|
||||
}
|
||||
}
|
||||
|
||||
QString target;
|
||||
|
||||
if (isCommander || isSideboardCategory) {
|
||||
sideStream << line;
|
||||
} else if (includedInDeck) {
|
||||
mainStream << line;
|
||||
} else {
|
||||
sideStream << line;
|
||||
}
|
||||
}
|
||||
|
||||
// Combine with blank line separator
|
||||
tempDeck = mainboardText;
|
||||
|
||||
if (!sideboardText.isEmpty()) {
|
||||
tempDeck += "\n";
|
||||
tempDeck += sideboardText;
|
||||
}
|
||||
|
||||
model = new DeckListModel(this);
|
||||
|
|
|
|||
|
|
@ -259,6 +259,9 @@ TabGame::~TabGame()
|
|||
if (replayManager) {
|
||||
delete replayManager->replay;
|
||||
}
|
||||
for (auto &player : game->getPlayerManager()->getPlayers()) {
|
||||
player->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void TabGame::updatePlayerListDockTitle()
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ TabDeckEditorVisualTabWidget::TabDeckEditorVisualTabWidget(QWidget *parent,
|
|||
this->addNewTab(visualDatabaseDisplay, tr("Visual Database Display"));
|
||||
this->addNewTab(deckAnalytics, tr("Deck Analytics"));
|
||||
this->addNewTab(sampleHandWidget, tr("Sample Hand"));
|
||||
|
||||
setTabsClosable(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef COCKATRICE_VISUAL_DATABASE_DISPLAY_FILTER_BUTTON_H
|
||||
#define COCKATRICE_VISUAL_DATABASE_DISPLAY_FILTER_BUTTON_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
const QString visualDatabaseDisplayFilterButtonStyle = QString(R"(
|
||||
QPushButton {
|
||||
background-color: palette(button);
|
||||
color: palette(button-text);
|
||||
padding: 5px 10px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid palette(dark);
|
||||
}
|
||||
QPushButton:checked {
|
||||
background-color: palette(highlight);
|
||||
color: palette(highlighted-text);
|
||||
border: 1px solid palette(shadow);
|
||||
}
|
||||
)");
|
||||
|
||||
#endif // COCKATRICE_VISUAL_DATABASE_DISPLAY_FILTER_BUTTON_H
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
#include "visual_database_display_format_legality_filter_widget.h"
|
||||
|
||||
#include "../../../filters/filter_tree_model.h"
|
||||
#include "visual_database_display_filter_button.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
|
|
@ -80,8 +81,7 @@ void VisualDatabaseDisplayFormatLegalityFilterWidget::createFormatButtons()
|
|||
for (auto it = allFormatsWithCount.begin(); it != allFormatsWithCount.end(); ++it) {
|
||||
auto *button = new QPushButton(it.key(), flowWidget);
|
||||
button->setCheckable(true);
|
||||
button->setStyleSheet("QPushButton { background-color: lightgray; border: 1px solid gray; padding: 5px; }"
|
||||
"QPushButton:checked { background-color: green; color: white; }");
|
||||
button->setStyleSheet(visualDatabaseDisplayFilterButtonStyle);
|
||||
|
||||
flowWidget->addWidget(button);
|
||||
formatButtons[it.key()] = button;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "visual_database_display_main_type_filter_widget.h"
|
||||
|
||||
#include "../../../filters/filter_tree_model.h"
|
||||
#include "visual_database_display_filter_button.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
|
|
@ -75,8 +76,8 @@ void VisualDatabaseDisplayMainTypeFilterWidget::createMainTypeButtons()
|
|||
for (auto it = allMainCardTypesWithCount.begin(); it != allMainCardTypesWithCount.end(); ++it) {
|
||||
auto *button = new QPushButton(it.key(), flowWidget);
|
||||
button->setCheckable(true);
|
||||
button->setStyleSheet("QPushButton { background-color: lightgray; border: 1px solid gray; padding: 5px; }"
|
||||
"QPushButton:checked { background-color: green; color: white; }");
|
||||
|
||||
button->setStyleSheet(visualDatabaseDisplayFilterButtonStyle);
|
||||
|
||||
flowWidget->addWidget(button);
|
||||
typeButtons[it.key()] = button;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "../../../interface/widgets/dialogs/dlg_load_deck_from_clipboard.h"
|
||||
#include "../../../interface/widgets/tabs/abstract_tab_deck_editor.h"
|
||||
#include "../deck_editor/deck_state_manager.h"
|
||||
#include "visual_database_display_filter_button.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
|
||||
|
|
@ -95,8 +96,8 @@ void VisualDatabaseDisplayNameFilterWidget::createNameFilter(const QString &name
|
|||
|
||||
// Create a button for the filter
|
||||
auto *button = new QPushButton(name, flowWidget);
|
||||
button->setStyleSheet("QPushButton { background-color: lightgray; border: 1px solid gray; padding: 5px; }"
|
||||
"QPushButton:hover { background-color: red; color: white; }");
|
||||
|
||||
button->setStyleSheet(visualDatabaseDisplayFilterButtonStyle);
|
||||
|
||||
connect(button, &QPushButton::clicked, this, [this, name]() {
|
||||
removeNameFilter(name);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "../../../client/settings/cache_settings.h"
|
||||
#include "../../../filters/filter_tree_model.h"
|
||||
#include "visual_database_display_filter_button.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
|
|
@ -101,8 +102,8 @@ void VisualDatabaseDisplaySetFilterWidget::createSetButtons()
|
|||
|
||||
auto *button = new QPushButton(longName + " (" + shortName + ")", flowWidget);
|
||||
button->setCheckable(true);
|
||||
button->setStyleSheet("QPushButton { background-color: lightgray; border: 1px solid gray; padding: 5px; }"
|
||||
"QPushButton:checked { background-color: green; color: white; }");
|
||||
|
||||
button->setStyleSheet(visualDatabaseDisplayFilterButtonStyle);
|
||||
|
||||
flowWidget->addWidget(button);
|
||||
setButtons[shortName] = button;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "visual_database_display_sub_type_filter_widget.h"
|
||||
|
||||
#include "../../../filters/filter_tree_model.h"
|
||||
#include "visual_database_display_filter_button.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
|
|
@ -80,8 +81,8 @@ void VisualDatabaseDisplaySubTypeFilterWidget::createSubTypeButtons()
|
|||
for (auto it = allSubCardTypesWithCount.begin(); it != allSubCardTypesWithCount.end(); ++it) {
|
||||
auto *button = new QPushButton(it.key(), flowWidget);
|
||||
button->setCheckable(true);
|
||||
button->setStyleSheet("QPushButton { background-color: lightgray; border: 1px solid gray; padding: 5px; }"
|
||||
"QPushButton:checked { background-color: green; color: white; }");
|
||||
|
||||
button->setStyleSheet(visualDatabaseDisplayFilterButtonStyle);
|
||||
|
||||
flowWidget->addWidget(button);
|
||||
typeButtons[it.key()] = button;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@ VisualDatabaseDisplayWidget::VisualDatabaseDisplayWidget(QWidget *parent,
|
|||
: QWidget(parent), deckEditor(_deckEditor), databaseModel(database_model),
|
||||
databaseDisplayModel(database_display_model)
|
||||
{
|
||||
debounceTimer = new QTimer(this);
|
||||
debounceTimer->setSingleShot(true); // Ensure it only fires once after the timeout
|
||||
|
||||
connect(debounceTimer, &QTimer::timeout, this, &VisualDatabaseDisplayWidget::onSearchModelChanged);
|
||||
|
||||
cards = new QList<ExactCard>;
|
||||
connect(databaseDisplayModel, &CardDatabaseDisplayModel::modelDirty, this,
|
||||
&VisualDatabaseDisplayWidget::modelDirty);
|
||||
|
|
@ -140,6 +145,7 @@ void VisualDatabaseDisplayWidget::initialize()
|
|||
databaseLoadIndicator->setVisible(false);
|
||||
|
||||
filterContainer->initialize();
|
||||
filterContainer->setVisible(true);
|
||||
|
||||
searchLayout->addWidget(colorFilterWidget);
|
||||
searchLayout->addWidget(clearFilterWidget);
|
||||
|
|
@ -156,11 +162,6 @@ void VisualDatabaseDisplayWidget::initialize()
|
|||
|
||||
mainLayout->addWidget(cardSizeWidget);
|
||||
|
||||
debounceTimer = new QTimer(this);
|
||||
debounceTimer->setSingleShot(true); // Ensure it only fires once after the timeout
|
||||
|
||||
connect(debounceTimer, &QTimer::timeout, this, &VisualDatabaseDisplayWidget::onSearchModelChanged);
|
||||
|
||||
databaseDisplayModel->setFilterTree(filterModel->filterTree());
|
||||
|
||||
connect(filterModel, &FilterTreeModel::layoutChanged, this, &VisualDatabaseDisplayWidget::onSearchModelChanged);
|
||||
|
|
@ -285,7 +286,9 @@ void VisualDatabaseDisplayWidget::loadNextPage()
|
|||
}
|
||||
|
||||
// Load the next page of cards and add them to the flow widget
|
||||
flowWidget->setUpdatesEnabled(false);
|
||||
loadPage(start, end);
|
||||
flowWidget->setUpdatesEnabled(true);
|
||||
}
|
||||
|
||||
void VisualDatabaseDisplayWidget::loadPage(int start, int end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue