mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 00:54:53 -07:00
* Have CardDatabase::getPreferredPrintingInfo respect card provider ID overrides (pinned printings)
Took 13 minutes
Took 37 seconds
Took 10 seconds
Took 10 seconds
# Commit time for manual adjustment:
# Took 30 seconds
Took 15 seconds
Took 8 minutes
Took 21 seconds
* Move settings cache and settings card preference provider out of libcockatrice_settings and into cockatrice
Took 52 minutes
Took 9 minutes
Took 1 minute
* Temp cache.
Took 16 minutes
* Dependency Injection for SettingsCache
* Turn SettingsCache into a QSharedPointer.
* Implement interfaces for settings that need it
Took 2 hours 38 minutes
* Adjust oracle.
Took 5 minutes
* Move abstract/noop interfaces to libcockatrice_interfaces so they can be linked against independently.
Took 52 minutes
* Clean up some links.
Took 3 minutes
* Cleanup two includes.
Took 3 minutes
* More fixes.
Took 7 minutes
* More includes that slipped past.
Took 3 minutes
* Stop mocking and start injecting for tests.
Took 15 minutes
* I don't know why remote_client was including main.
Took 4 minutes
* Include.
Took 3 minutes
* Lint.
Took 2 minutes
* Don't use Qt pointers.
Took 1 hour 7 minutes
* Make parser use CardSettingsInterface
Took 13 minutes
* Also adjust constructor lol.
Took 8 minutes
* Lint.
Took 32 minutes
* Revert "Lint."
This reverts commit ecb596c39e.
Took 3 minutes
* Test.
Took 3 minutes
---------
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
108 lines
2.7 KiB
C++
108 lines
2.7 KiB
C++
/**
|
|
* @file card_database.h
|
|
* @ingroup CardDatabase
|
|
* @brief The CardDatabase is responsible for holding the card and set maps.
|
|
*/
|
|
|
|
#ifndef CARDDATABASE_H
|
|
#define CARDDATABASE_H
|
|
|
|
#include "../set/card_set_list.h"
|
|
#include "card_database_loader.h"
|
|
#include "card_database_querier.h"
|
|
|
|
#include <QBasicMutex>
|
|
#include <QDate>
|
|
#include <QHash>
|
|
#include <QList>
|
|
#include <QLoggingCategory>
|
|
#include <QStringList>
|
|
#include <QVector>
|
|
#include <libcockatrice/interfaces/interface_card_database_path_provider.h>
|
|
#include <libcockatrice/utility/card_ref.h>
|
|
#include <utility>
|
|
|
|
inline Q_LOGGING_CATEGORY(CardDatabaseLog, "card_database");
|
|
|
|
class CardDatabase : public QObject
|
|
{
|
|
Q_OBJECT
|
|
protected:
|
|
ICardSetPriorityController *setPriorityController;
|
|
|
|
/*
|
|
* The cards, indexed by name.
|
|
*/
|
|
CardNameMap cards;
|
|
|
|
/**
|
|
* The cards, indexed by their simple name.
|
|
*/
|
|
CardNameMap simpleNameCards;
|
|
|
|
/*
|
|
* The sets, indexed by short name.
|
|
*/
|
|
SetNameMap sets;
|
|
|
|
// loader responsible for file discovery & parsing
|
|
CardDatabaseLoader *loader;
|
|
|
|
LoadStatus loadStatus;
|
|
|
|
CardDatabaseQuerier *querier;
|
|
|
|
private:
|
|
void checkUnknownSets();
|
|
void refreshCachedReverseRelatedCards();
|
|
|
|
QBasicMutex *clearDatabaseMutex = new QBasicMutex(), *addCardMutex = new QBasicMutex(),
|
|
*removeCardMutex = new QBasicMutex();
|
|
|
|
public:
|
|
explicit CardDatabase(QObject *parent = nullptr,
|
|
ICardPreferenceProvider *prefs = nullptr,
|
|
ICardDatabasePathProvider *pathProvider = nullptr,
|
|
ICardSetPriorityController *setPriorityController = nullptr);
|
|
~CardDatabase() override;
|
|
|
|
void removeCard(CardInfoPtr card);
|
|
void clear();
|
|
|
|
const CardNameMap &getCardList() const
|
|
{
|
|
return cards;
|
|
}
|
|
CardSetPtr getSet(const QString &setName);
|
|
CardSetList getSetList() const;
|
|
LoadStatus getLoadStatus() const
|
|
{
|
|
return loadStatus;
|
|
}
|
|
CardDatabaseQuerier *query() const
|
|
{
|
|
return querier;
|
|
}
|
|
void enableAllUnknownSets();
|
|
void markAllSetsAsKnown();
|
|
void notifyEnabledSetsChanged();
|
|
|
|
public slots:
|
|
void addCard(CardInfoPtr card);
|
|
void addSet(CardSetPtr set);
|
|
void loadCardDatabases();
|
|
bool saveCustomTokensToFile();
|
|
signals:
|
|
void cardDatabaseLoadingFinished();
|
|
void cardDatabaseLoadingFailed();
|
|
void cardDatabaseNewSetsFound(int numUnknownSets, QStringList unknownSetsNames);
|
|
void cardDatabaseAllNewSetsEnabled();
|
|
void cardDatabaseEnabledSetsChanged();
|
|
void cardAdded(CardInfoPtr card);
|
|
void cardRemoved(CardInfoPtr card);
|
|
|
|
friend class CardDatabaseLoader;
|
|
friend class CardDatabaseQuerier;
|
|
};
|
|
|
|
#endif
|