Merge branch 'master' into tooomm-qt5

This commit is contained in:
tooomm 2026-05-30 14:49:55 +02:00 committed by GitHub
commit 9d4cf57c70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
593 changed files with 12518 additions and 6581 deletions

View file

@ -1,8 +1,8 @@
/**
* @file card_info_comparator.h
* @ingroup Cards
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef CARD_INFO_COMPARATOR_H
#define CARD_INFO_COMPARATOR_H

View file

@ -103,9 +103,11 @@ void CardDatabase::addCard(CardInfoPtr card)
// If a card already exists, just add the new set property.
if (auto existing = cards.value(name)) {
for (const auto &printings : card->getSets())
for (const auto &printing : printings)
for (const auto &printings : card->getSets()) {
for (const auto &printing : printings) {
existing->addToSet(printing.getSet(), printing);
}
}
return;
}
@ -123,14 +125,17 @@ void CardDatabase::removeCard(CardInfoPtr card)
return;
}
for (auto *cardRelation : card->getRelatedCards())
for (auto *cardRelation : card->getRelatedCards()) {
cardRelation->deleteLater();
}
for (auto *cardRelation : card->getReverseRelatedCards())
for (auto *cardRelation : card->getReverseRelatedCards()) {
cardRelation->deleteLater();
}
for (auto *cardRelation : card->getReverseRelatedCards2Me())
for (auto *cardRelation : card->getReverseRelatedCards2Me()) {
cardRelation->deleteLater();
}
QMutexLocker locker(removeCardMutex);
cards.remove(card->getName());

View file

@ -30,27 +30,27 @@ class CardDatabase : public QObject
Q_OBJECT
protected:
/// Controller to determine set priority when choosing preferred printings.
/** @brief Controller to determine set priority when choosing preferred printings. */
ICardSetPriorityController *setPriorityController;
/// Cards indexed by exact name
/** @brief Cards indexed by exact name. */
CardNameMap cards;
/// Cards indexed by simplified name (normalized)
/** @brief Cards indexed by simplified name (normalized). */
CardNameMap simpleNameCards;
/// Sets indexed by short name
/** @brief Sets indexed by short name. */
SetNameMap sets;
FormatRulesNameMap formats;
/// Loader responsible for file discovery and parsing
/** @brief Loader responsible for file discovery and parsing. */
CardDatabaseLoader *loader;
/// Current load status of the database
/** @brief Current load status of the database. */
LoadStatus loadStatus;
/// Querier for higher-level card lookups
/** @brief Querier for higher-level card lookups. */
CardDatabaseQuerier *querier;
private:
@ -64,7 +64,7 @@ private:
*/
void refreshCachedReverseRelatedCards();
/// Mutexes for thread safety
/** @brief Mutexes for thread safety. */
QBasicMutex *clearDatabaseMutex = new QBasicMutex(), *addCardMutex = new QBasicMutex(),
*removeCardMutex = new QBasicMutex();
@ -133,7 +133,7 @@ public:
ICardSetPriorityController *getPriorityController()
{
return setPriorityController;
};
}
public slots:
/**

View file

@ -125,8 +125,9 @@ QStringList CardDatabaseLoader::collectCustomDatabasePaths() const
QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
QStringList paths;
while (it.hasNext())
while (it.hasNext()) {
paths << it.next();
}
paths.sort();
return paths;
}

View file

@ -67,13 +67,13 @@ private:
/** @brief Private destructor. */
~CardDatabaseManager() = default;
/// Static card preference provider pointer (default: Noop)
/** @brief Static card preference provider pointer (default: Noop). */
static ICardPreferenceProvider *cardPreferenceProvider;
/// Static path provider pointer (default: Noop)
/** @brief Static path provider pointer (default: Noop). */
static ICardDatabasePathProvider *pathProvider;
/// Static set priority controller pointer (default: Noop)
/** @brief Static set priority controller pointer (default: Noop). */
static ICardSetPriorityController *setPriorityController;
};

View file

@ -36,8 +36,9 @@ QList<CardInfoPtr> CardDatabaseQuerier::getCardInfos(const QStringList &cardName
QList<CardInfoPtr> cardInfos;
for (const QString &cardName : cardNames) {
CardInfoPtr ptr = db->cards.value(cardName);
if (ptr)
if (ptr) {
cardInfos.append(ptr);
}
}
return cardInfos;
@ -50,10 +51,12 @@ CardInfoPtr CardDatabaseQuerier::getCardBySimpleName(const QString &cardName) co
CardInfoPtr CardDatabaseQuerier::lookupCardByName(const QString &name) const
{
if (auto info = getCardInfo(name))
if (auto info = getCardInfo(name)) {
return info;
if (auto info = getCardBySimpleName(name))
}
if (auto info = getCardBySimpleName(name)) {
return info;
}
return getCardBySimpleName(CardInfo::simplifyName(name));
}
@ -71,8 +74,9 @@ QList<ExactCard> CardDatabaseQuerier::getCards(const QList<CardRef> &cardRefs) c
QList<ExactCard> cards;
for (const auto &cardRef : cardRefs) {
ExactCard card = getCard(cardRef);
if (card)
if (card) {
cards.append(card);
}
}
return cards;
@ -119,8 +123,9 @@ ExactCard CardDatabaseQuerier::guessCard(const CardRef &cardRef) const
ExactCard CardDatabaseQuerier::getRandomCard() const
{
if (db->cards.isEmpty())
if (db->cards.isEmpty()) {
return {};
}
const auto keys = db->cards.keys();
int randomIndex = QRandomGenerator::global()->bounded(keys.size());

View file

@ -306,8 +306,9 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
PrintingInfo printingInfo(set);
for (QXmlStreamAttribute attr : attrs) {
QString attrName = attr.name().toString();
if (attrName == "picURL")
if (attrName == "picURL") {
attrName = "picurl";
}
printingInfo.setProperty(attrName, attr.value().toString());
}

View file

@ -51,16 +51,21 @@ enum class CardMatchType
// convert string to enum
inline CardMatchType matchTypeFromString(const QString &str)
{
if (str == "equals")
if (str == "equals") {
return CardMatchType::Equals;
if (str == "notEquals")
}
if (str == "notEquals") {
return CardMatchType::NotEquals;
if (str == "contains")
}
if (str == "contains") {
return CardMatchType::Contains;
if (str == "notContains")
}
if (str == "notContains") {
return CardMatchType::NotContains;
if (str == "regex")
}
if (str == "regex") {
return CardMatchType::Regex;
}
return CardMatchType::Equals; // fallback default
}

View file

@ -1,8 +1,8 @@
/**
* @file game_specific_terms.h
* @ingroup Cards
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef GAME_SPECIFIC_TERMS_H
#define GAME_SPECIFIC_TERMS_H
@ -31,26 +31,36 @@ QString const ColorIdentity("coloridentity");
inline static const QString getNicePropertyName(QString key)
{
if (key == CardType)
if (key == CardType) {
return QCoreApplication::translate("Mtg", "Card Type");
if (key == ConvertedManaCost)
}
if (key == ConvertedManaCost) {
return QCoreApplication::translate("Mtg", "Mana Value");
if (key == Colors)
}
if (key == Colors) {
return QCoreApplication::translate("Mtg", "Color(s)");
if (key == Loyalty)
}
if (key == Loyalty) {
return QCoreApplication::translate("Mtg", "Loyalty");
if (key == MainCardType)
}
if (key == MainCardType) {
return QCoreApplication::translate("Mtg", "Main Card Type");
if (key == ManaCost)
}
if (key == ManaCost) {
return QCoreApplication::translate("Mtg", "Mana Cost");
if (key == PowTough)
}
if (key == PowTough) {
return QCoreApplication::translate("Mtg", "P/T");
if (key == Side)
}
if (key == Side) {
return QCoreApplication::translate("Mtg", "Side");
if (key == Layout)
}
if (key == Layout) {
return QCoreApplication::translate("Mtg", "Layout");
if (key == ColorIdentity)
}
if (key == ColorIdentity) {
return QCoreApplication::translate("Mtg", "Color Identity");
}
return key;
}
} // namespace Mtg

View file

@ -33,28 +33,9 @@ QString CardSet::getCorrectedShortName() const
{
// For Windows machines.
QSet<QString> invalidFileNames;
invalidFileNames << "CON"
<< "PRN"
<< "AUX"
<< "NUL"
<< "COM1"
<< "COM2"
<< "COM3"
<< "COM4"
<< "COM5"
<< "COM6"
<< "COM7"
<< "COM8"
<< "COM9"
<< "LPT1"
<< "LPT2"
<< "LPT3"
<< "LPT4"
<< "LPT5"
<< "LPT6"
<< "LPT7"
<< "LPT8"
<< "LPT9";
invalidFileNames << "CON" << "PRN" << "AUX" << "NUL" << "COM1" << "COM2" << "COM3" << "COM4" << "COM5" << "COM6"
<< "COM7" << "COM8" << "COM9" << "LPT1" << "LPT2" << "LPT3" << "LPT4" << "LPT5" << "LPT6" << "LPT7"
<< "LPT8" << "LPT9";
return invalidFileNames.contains(shortName) ? shortName + "_" : shortName;
}

View file

@ -107,31 +107,31 @@ public:
*/
[[nodiscard]] QString getCorrectedShortName() const;
/// @return Short identifier of the set.
/** @return Short identifier of the set. */
[[nodiscard]] QString getShortName() const
{
return shortName;
}
/// @return Descriptive name of the set.
/** @return Descriptive name of the set. */
[[nodiscard]] QString getLongName() const
{
return longName;
}
/// @return Type/category string of the set.
/** @return Type/category string of the set. */
[[nodiscard]] QString getSetType() const
{
return setType;
}
/// @return Release date of the set.
/** @return Release date of the set. */
[[nodiscard]] QDate getReleaseDate() const
{
return releaseDate;
}
/// @return Priority level of the set.
/** @return Priority level of the set. */
[[nodiscard]] Priority getPriority() const
{
return priority;
@ -190,7 +190,7 @@ public:
enabled = _enabled;
}
/// @return The sort key assigned to this set.
/** @return The sort key assigned to this set. */
[[nodiscard]] int getSortKey() const
{
return sortKey;
@ -202,7 +202,7 @@ public:
*/
void setSortKey(unsigned int _sortKey);
/// @return True if the set is enabled.
/** @return True if the set is enabled. */
[[nodiscard]] bool getEnabled() const
{
return enabled;
@ -214,7 +214,7 @@ public:
*/
void setEnabled(bool _enabled);
/// @return True if the set is considered known.
/** @return True if the set is considered known. */
[[nodiscard]] bool getIsKnown() const
{
return isknown;

View file

@ -1,8 +1,8 @@
/**
* @file card_set_comparator.h
* @ingroup CardSets
* @brief TODO: Document this.
*/
//! \todo Document this file.
#ifndef SET_PRIORITY_COMPARATOR_H
#define SET_PRIORITY_COMPARATOR_H