Auto-lint was disabled and my pre-commit hook didn't fire. Oh well.

Took 3 minutes
This commit is contained in:
Lukas Brübach 2025-10-01 00:19:35 +02:00
parent b1a3be681e
commit 66dfa05445
7 changed files with 132 additions and 47 deletions

View file

@ -36,7 +36,6 @@ typedef QHash<QString, CardSetPtr> SetNameMap;
Q_DECLARE_METATYPE(CardInfoPtr) Q_DECLARE_METATYPE(CardInfoPtr)
class CardInfo : public QObject class CardInfo : public QObject
{ {
Q_OBJECT Q_OBJECT

View file

@ -1,9 +1,10 @@
#ifndef COCKATRICE_CARD_RELATION_H #ifndef COCKATRICE_CARD_RELATION_H
#define COCKATRICE_CARD_RELATION_H #define COCKATRICE_CARD_RELATION_H
#include "card_relation_type.h"
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include "card_relation_type.h"
class CardRelation : public QObject class CardRelation : public QObject
{ {
@ -25,19 +26,48 @@ public:
int _defaultCount = 1, int _defaultCount = 1,
bool _isPersistent = false); bool _isPersistent = false);
const QString &getName() const { return name; } const QString &getName() const
CardRelationType getAttachType() const { return attachType; } {
bool getDoesAttach() const { return attachType != CardRelationType::DoesNotAttach; } return name;
bool getDoesTransform() const { return attachType == CardRelationType::TransformInto; } }
CardRelationType getAttachType() const
{
return attachType;
}
bool getDoesAttach() const
{
return attachType != CardRelationType::DoesNotAttach;
}
bool getDoesTransform() const
{
return attachType == CardRelationType::TransformInto;
}
QString getAttachTypeAsString() const { return cardAttachTypeToString(attachType); } QString getAttachTypeAsString() const
{
return cardAttachTypeToString(attachType);
}
bool getCanCreateAnother() const { return !getDoesAttach(); } bool getCanCreateAnother() const
bool getIsCreateAllExclusion() const { return isCreateAllExclusion; } {
bool getIsVariable() const { return isVariableCount; } return !getDoesAttach();
int getDefaultCount() const { return defaultCount; } }
bool getIsPersistent() const { return isPersistent; } bool getIsCreateAllExclusion() const
{
return isCreateAllExclusion;
}
bool getIsVariable() const
{
return isVariableCount;
}
int getDefaultCount() const
{
return defaultCount;
}
bool getIsPersistent() const
{
return isPersistent;
}
}; };
#endif // COCKATRICE_CARD_RELATION_H #endif // COCKATRICE_CARD_RELATION_H

View file

@ -6,20 +6,24 @@
/** /**
* Represents how a card relates to another (attach, transform, etc.). * Represents how a card relates to another (attach, transform, etc.).
*/ */
enum class CardRelationType { enum class CardRelationType
{
DoesNotAttach = 0, DoesNotAttach = 0,
AttachTo = 1, AttachTo = 1,
TransformInto = 2, TransformInto = 2,
}; };
// Optional helper // Optional helper
inline QString cardAttachTypeToString(CardRelationType type) { inline QString cardAttachTypeToString(CardRelationType type)
{
switch (type) { switch (type) {
case CardRelationType::AttachTo: return "attach"; case CardRelationType::AttachTo:
case CardRelationType::TransformInto: return "transform"; return "attach";
default: return ""; case CardRelationType::TransformInto:
return "transform";
default:
return "";
} }
} }
#endif // COCKATRICE_CARD_RELATION_TYPE_H #endif // COCKATRICE_CARD_RELATION_TYPE_H

View file

@ -3,8 +3,8 @@
#include <QDate> #include <QDate>
#include <QList> #include <QList>
#include <QString>
#include <QSharedPointer> #include <QSharedPointer>
#include <QString>
class CardInfo; class CardInfo;
using CardInfoPtr = QSharedPointer<CardInfo>; using CardInfoPtr = QSharedPointer<CardInfo>;
@ -15,7 +15,8 @@ using CardSetPtr = QSharedPointer<CardSet>;
class CardSet : public QList<CardInfoPtr> class CardSet : public QList<CardInfoPtr>
{ {
public: public:
enum Priority { enum Priority
{
PriorityFallback = 0, PriorityFallback = 0,
PriorityPrimary = 10, PriorityPrimary = 10,
PrioritySecondary = 20, PrioritySecondary = 20,
@ -33,6 +34,7 @@ private:
QString setType; QString setType;
Priority priority; Priority priority;
bool enabled, isknown; bool enabled, isknown;
public: public:
explicit CardSet(const QString &_shortName = QString(), explicit CardSet(const QString &_shortName = QString(),
const QString &_longName = QString(), const QString &_longName = QString(),
@ -48,28 +50,65 @@ public:
QString getCorrectedShortName() const; QString getCorrectedShortName() const;
QString getShortName() const { return shortName; } QString getShortName() const
QString getLongName() const { return longName; } {
QString getSetType() const { return setType; } return shortName;
QDate getReleaseDate() const { return releaseDate; } }
Priority getPriority() const { return priority; } QString getLongName() const
{
return longName;
}
QString getSetType() const
{
return setType;
}
QDate getReleaseDate() const
{
return releaseDate;
}
Priority getPriority() const
{
return priority;
}
void setLongName(const QString &_longName) { longName = _longName; } void setLongName(const QString &_longName)
void setSetType(const QString &_setType) { setType = _setType; } {
void setReleaseDate(const QDate &_releaseDate) { releaseDate = _releaseDate; } longName = _longName;
void setPriority(const Priority _priority) { priority = _priority; } }
void setSetType(const QString &_setType)
{
setType = _setType;
}
void setReleaseDate(const QDate &_releaseDate)
{
releaseDate = _releaseDate;
}
void setPriority(const Priority _priority)
{
priority = _priority;
}
void loadSetOptions(); void loadSetOptions();
int getSortKey() const { return sortKey; } int getSortKey() const
{
return sortKey;
}
void setSortKey(unsigned int _sortKey); void setSortKey(unsigned int _sortKey);
bool getEnabled() const { return enabled; } bool getEnabled() const
{
return enabled;
}
void setEnabled(bool _enabled); void setEnabled(bool _enabled);
bool getIsKnown() const { return isknown; } bool getIsKnown() const
{
return isknown;
}
void setIsKnown(bool _isknown); void setIsKnown(bool _isknown);
bool getIsKnownIgnored() const { bool getIsKnownIgnored() const
{
return longName.length() + setType.length() + releaseDate.toString().length() == 0; return longName.length() + setType.length() + releaseDate.toString().length() == 0;
} }
}; };

View file

@ -6,7 +6,7 @@ public:
inline bool operator()(const CardSetPtr &a, const CardSetPtr &b) const inline bool operator()(const CardSetPtr &a, const CardSetPtr &b) const
{ {
if (a.isNull() || b.isNull()) { if (a.isNull() || b.isNull()) {
//qCWarning(CardInfoLog) << "SetList::KeyCompareFunctor a or b is null"; // qCWarning(CardInfoLog) << "SetList::KeyCompareFunctor a or b is null";
return false; return false;
} }
@ -74,7 +74,7 @@ void CardSetList::enableAll()
CardSetPtr set = at(i); CardSetPtr set = at(i);
if (set == nullptr) { if (set == nullptr) {
//qCWarning(CardInfoLog) << "enabledAll has null"; // qCWarning(CardInfoLog) << "enabledAll has null";
continue; continue;
} }
@ -105,7 +105,7 @@ void CardSetList::guessSortKeys()
for (int i = 0; i < size(); ++i) { for (int i = 0; i < size(); ++i) {
CardSetPtr set = at(i); CardSetPtr set = at(i);
if (set.isNull()) { if (set.isNull()) {
//qCWarning(CardInfoLog) << "guessSortKeys set is null"; // qCWarning(CardInfoLog) << "guessSortKeys set is null";
continue; continue;
} }
set->setSortKey(i); set->setSortKey(i);

View file

@ -2,6 +2,7 @@
#define COCKATRICE_CARD_SET_LIST_H #define COCKATRICE_CARD_SET_LIST_H
#include "card_set.h" #include "card_set.h"
#include <QList> #include <QList>
#include <QStringList> #include <QStringList>
@ -22,5 +23,4 @@ public:
void defaultSort(); void defaultSort();
}; };
#endif // COCKATRICE_CARD_SET_LIST_H #endif // COCKATRICE_CARD_SET_LIST_H

View file

@ -2,10 +2,11 @@
#define COCKATRICE_PRINTING_INFO_H #define COCKATRICE_PRINTING_INFO_H
#include "card_set.h" #include "card_set.h"
#include <QVariant>
#include <QStringList>
#include <QMap>
#include <QList> #include <QList>
#include <QMap>
#include <QStringList>
#include <QVariant>
class PrintingInfo; class PrintingInfo;
@ -20,7 +21,8 @@ public:
explicit PrintingInfo(const CardSetPtr &_set = nullptr); explicit PrintingInfo(const CardSetPtr &_set = nullptr);
~PrintingInfo() = default; ~PrintingInfo() = default;
bool operator==(const PrintingInfo &other) const { bool operator==(const PrintingInfo &other) const
{
return this->set == other.set && this->properties == other.properties; return this->set == other.set && this->properties == other.properties;
} }
@ -30,14 +32,25 @@ private:
QVariantHash properties; QVariantHash properties;
public: public:
CardSetPtr getSet() const { return set; } CardSetPtr getSet() const
{
return set;
}
QStringList getProperties() const { return properties.keys(); } QStringList getProperties() const
QString getProperty(const QString &propertyName) const { return properties.value(propertyName).toString(); } {
void setProperty(const QString &_name, const QString &_value) { properties.insert(_name, _value); } return properties.keys();
}
QString getProperty(const QString &propertyName) const
{
return properties.value(propertyName).toString();
}
void setProperty(const QString &_name, const QString &_value)
{
properties.insert(_name, _value);
}
QString getUuid() const; QString getUuid() const;
}; };
#endif // COCKATRICE_PRINTING_INFO_H #endif // COCKATRICE_PRINTING_INFO_H