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

@ -135,12 +135,14 @@ bool DeckList::loadFromXml(QXmlStreamReader *xml)
while (!xml->atEnd()) {
xml->readNext();
if (xml->isStartElement()) {
if (xml->name().toString() != "cockatrice_deck")
if (xml->name().toString() != "cockatrice_deck") {
return false;
}
while (!xml->atEnd()) {
xml->readNext();
if (!readElement(xml))
if (!readElement(xml)) {
break;
}
}
}
}
@ -283,8 +285,9 @@ bool DeckList::loadFromStream_Plain(QTextStream &in,
for (; index < max_line; ++index) {
// check if line is a card
match = reCardLine.match(inputs.at(index));
if (!match.hasMatch())
if (!match.hasMatch()) {
continue;
}
QString cardName = match.captured().simplified();
bool sideboard = false;
@ -297,8 +300,9 @@ bool DeckList::loadFromStream_Plain(QTextStream &in,
cardName = match.captured(1);
}
} else {
if (index == sBStart)
if (index == sBStart) {
continue;
}
sideboard = index > sBStart;
}

View file

@ -89,7 +89,7 @@ private:
mutable QString cachedDeckHash;
public:
/// @name Metadata setters
/** @name Metadata setters */
///@{
void setName(const QString &_name = QString())
{
@ -125,11 +125,11 @@ public:
}
///@}
/// @brief Construct an empty deck.
/** @brief Construct an empty deck. */
explicit DeckList();
/// @brief Construct from a serialized native-format string.
/** @brief Construct from a serialized native-format string. */
explicit DeckList(const QString &nativeString);
/// @brief Construct from components
/** @brief Construct from components. */
DeckList(const Metadata &metadata,
const DecklistNodeTree &tree,
const QMap<QString, SideboardPlan> &sideboardPlans = {});
@ -144,8 +144,10 @@ public:
return &tree;
}
/// @name Metadata getters
/// The individual metadata getters still exist for backwards compatibility.
/**
* @name Metadata getters
* The individual metadata getters still exist for backwards compatibility.
*/
///@{
//! \todo Figure out when we can remove them.
const Metadata &getMetadata() const
@ -183,7 +185,7 @@ public:
return metadata.isEmpty() && getCardList().isEmpty();
}
/// @name Sideboard plans
/** @name Sideboard plans */
///@{
QList<MoveCard_ToZone> getCurrentSideboardPlan() const;
void setCurrentSideboardPlan(const QList<MoveCard_ToZone> &plan);
@ -193,7 +195,7 @@ public:
}
///@}
/// @name Serialization (XML)
/** @name Serialization (XML) */
///@{
bool readElement(QXmlStreamReader *xml);
void write(QXmlStreamWriter *xml) const;
@ -204,7 +206,7 @@ public:
bool saveToFile_Native(QIODevice *device) const;
///@}
/// @name Serialization (Plain text)
/** @name Serialization (Plain text) */
///@{
bool loadFromStream_Plain(QTextStream &stream,
bool preserveMetadata,
@ -216,7 +218,7 @@ public:
QString writeToString_Plain(bool prefixSideboardCards = true, bool slashTappedOutSplitCards = false) const;
///@}
/// @name Deck manipulation
/** @name Deck manipulation */
///@{
void cleanList(bool preserveMetadata = false);
bool isEmpty() const
@ -238,7 +240,7 @@ public:
const bool formatLegal = true);
///@}
/// @name Deck identity
/** @name Deck identity */
///@{
QString getDeckHash() const;
void refreshDeckHash();

View file

@ -16,8 +16,9 @@ void DeckListHistoryManager::clear()
void DeckListHistoryManager::undo(DeckList *deck)
{
if (undoStack.isEmpty())
if (undoStack.isEmpty()) {
return;
}
// Peek at the memento we are going to restore
const DeckListMemento &mementoToRestore = undoStack.top();
@ -35,8 +36,9 @@ void DeckListHistoryManager::undo(DeckList *deck)
void DeckListHistoryManager::redo(DeckList *deck)
{
if (redoStack.isEmpty())
if (redoStack.isEmpty()) {
return;
}
// Peek at the memento we are going to restore
const DeckListMemento &mementoToRestore = redoStack.top();

View file

@ -58,8 +58,9 @@ QList<const InnerDecklistNode *> DecklistNodeTree::getZoneNodes(const QSet<QStri
QList<const InnerDecklistNode *> zones;
for (auto *node : *root) {
InnerDecklistNode *currentZone = dynamic_cast<InnerDecklistNode *>(node);
if (!currentZone)
if (!currentZone) {
continue;
}
if (!restrictToZones.isEmpty() && !restrictToZones.contains(currentZone->getName())) {
continue;
}

View file

@ -12,11 +12,11 @@ class DecklistNodeTree
InnerDecklistNode *root; ///< Root of the deck tree (zones + cards).
public:
/// @brief Constructs an empty DecklistNodeTree
/** @brief Constructs an empty DecklistNodeTree. */
explicit DecklistNodeTree();
/// @brief Copy constructor. Deep copies the tree
/** @brief Copy constructor. Deep copies the tree. */
explicit DecklistNodeTree(const DecklistNodeTree &other);
/// @brief Copy-assignment operator. Deep copies the tree
/** @brief Copy-assignment operator. Deep copies the tree. */
DecklistNodeTree &operator=(const DecklistNodeTree &other);
virtual ~DecklistNodeTree();

View file

@ -18,28 +18,30 @@ bool SideboardPlan::readElement(QXmlStreamReader *xml)
xml->readNext();
const QString childName = xml->name().toString();
if (xml->isStartElement()) {
if (childName == "name")
if (childName == "name") {
name = xml->readElementText();
else if (childName == "move_card_to_zone") {
} else if (childName == "move_card_to_zone") {
MoveCard_ToZone m;
while (!xml->atEnd()) {
xml->readNext();
const QString childName2 = xml->name().toString();
if (xml->isStartElement()) {
if (childName2 == "card_name")
if (childName2 == "card_name") {
m.set_card_name(xml->readElementText().toStdString());
else if (childName2 == "start_zone")
} else if (childName2 == "start_zone") {
m.set_start_zone(xml->readElementText().toStdString());
else if (childName2 == "target_zone")
} else if (childName2 == "target_zone") {
m.set_target_zone(xml->readElementText().toStdString());
}
} else if (xml->isEndElement() && (childName2 == "move_card_to_zone")) {
moveList.append(m);
break;
}
}
}
} else if (xml->isEndElement() && (childName == "sideboard_plan"))
} else if (xml->isEndElement() && (childName == "sideboard_plan")) {
return true;
}
}
return false;
}

View file

@ -51,19 +51,19 @@ public:
*/
void write(QXmlStreamWriter *xml) const;
/// @return The plan name.
/** @return The plan name. */
[[nodiscard]] QString getName() const
{
return name;
}
/// @return Const reference to the move list.
/** @return Const reference to the move list. */
[[nodiscard]] const QList<MoveCard_ToZone> &getMoveList() const
{
return moveList;
}
/// @brief Replace the move list with a new one.
/** @brief Replace the move list with a new one. */
void setMoveList(const QList<MoveCard_ToZone> &_moveList);
};

View file

@ -38,8 +38,9 @@ bool AbstractDecklistCardNode::readElement(QXmlStreamReader *xml)
{
while (!xml->atEnd()) {
xml->readNext();
if (xml->isEndElement() && xml->name().toString() == "card")
if (xml->isEndElement() && xml->name().toString() == "card") {
return false;
}
}
return true;
}

View file

@ -58,40 +58,40 @@ public:
{
}
/// @return The number of copies of this card in the deck.
/** @return The number of copies of this card in the deck. */
[[nodiscard]] virtual int getNumber() const = 0;
/// @param _number Set the number of copies of this card.
/** @param _number Set the number of copies of this card. */
virtual void setNumber(int _number) = 0;
/// @return The display name of this card.
/** @return The display name of this card. */
[[nodiscard]] QString getName() const override = 0;
/// @param _name Set the display name of this card.
/** @param _name Set the display name of this card. */
virtual void setName(const QString &_name) = 0;
/// @return The provider identifier for this card (e.g., UUID).
/** @return The provider identifier for this card (e.g., UUID). */
[[nodiscard]] virtual QString getCardProviderId() const override = 0;
/// @param _cardProviderId Set the provider identifier for this card.
/** @param _cardProviderId Set the provider identifier for this card. */
virtual void setCardProviderId(const QString &_cardProviderId) = 0;
/// @return The abbreviated set code (e.g., "NEO").
/** @return The abbreviated set code (e.g., "NEO"). */
[[nodiscard]] virtual QString getCardSetShortName() const override = 0;
/// @param _cardSetShortName Set the abbreviated set code.
/** @param _cardSetShortName Set the abbreviated set code. */
virtual void setCardSetShortName(const QString &_cardSetShortName) = 0;
/// @return The collector number of the card within its set.
/** @return The collector number of the card within its set. */
[[nodiscard]] virtual QString getCardCollectorNumber() const override = 0;
/// @param _cardSetNumber Set the collector number.
/** @param _cardSetNumber Set the collector number. */
virtual void setCardCollectorNumber(const QString &_cardSetNumber) = 0;
/// @return The format legality of the card
/** @return The format legality of the card. */
virtual bool getFormatLegality() const = 0;
/// @param _formatLegal If the card is considered legal
/** @param _formatLegal If the card is considered legal. */
virtual void setFormatLegality(const bool _formatLegal) = 0;
/**

View file

@ -101,7 +101,7 @@ public:
*/
explicit AbstractDecklistNode(InnerDecklistNode *_parent = nullptr, int position = -1);
/// Virtual destructor. Child classes must clean up their resources.
/** @brief Virtual destructor. Child classes must clean up their resources. */
virtual ~AbstractDecklistNode() = default;
/**
@ -136,7 +136,7 @@ public:
*/
[[nodiscard]] virtual bool isDeckHeader() const = 0;
/// @return The parent node, or nullptr if this is the root.
/** @return The parent node, or nullptr if this is the root. */
[[nodiscard]] InnerDecklistNode *getParent() const
{
return parent;

View file

@ -93,79 +93,79 @@ public:
*/
explicit DecklistCardNode(DecklistCardNode *other, InnerDecklistNode *_parent);
/// @return The quantity of this card.
/** @return The quantity of this card. */
[[nodiscard]] int getNumber() const override
{
return number;
}
/// @param _number Set the quantity of this card.
/** @param _number Set the quantity of this card. */
void setNumber(int _number) override
{
number = _number;
}
/// @return The display name of this card.
/** @return The display name of this card. */
[[nodiscard]] QString getName() const override
{
return name;
}
/// @param _name Set the display name of this card.
/** @param _name Set the display name of this card. */
void setName(const QString &_name) override
{
name = _name;
}
/// @return The provider identifier for this card.
/** @return The provider identifier for this card. */
[[nodiscard]] QString getCardProviderId() const override
{
return cardProviderId;
}
/// @param _providerId Set the provider identifier for this card.
/** @param _providerId Set the provider identifier for this card. */
void setCardProviderId(const QString &_providerId) override
{
cardProviderId = _providerId;
}
/// @return The short set code (e.g., "NEO").
/** @return The short set code (e.g., "NEO"). */
[[nodiscard]] QString getCardSetShortName() const override
{
return cardSetShortName;
}
/// @param _cardSetShortName Set the short set code.
/** @param _cardSetShortName Set the short set code. */
void setCardSetShortName(const QString &_cardSetShortName) override
{
cardSetShortName = _cardSetShortName;
}
/// @return The collector number of this card within its set.
/** @return The collector number of this card within its set. */
[[nodiscard]] QString getCardCollectorNumber() const override
{
return cardSetNumber;
}
/// @param _cardSetNumber Set the collector number.
/** @param _cardSetNumber Set the collector number. */
void setCardCollectorNumber(const QString &_cardSetNumber) override
{
cardSetNumber = _cardSetNumber;
}
/// @return The format legality of the card
/** @return The format legality of the card. */
[[nodiscard]] bool getFormatLegality() const override
{
return formatLegal;
}
/// @param _formatLegal If the card is considered legal
/** @param _formatLegal If the card is considered legal. */
void setFormatLegality(const bool _formatLegal) override
{
formatLegal = _formatLegal;
}
/// @return Always false; card nodes are not deck headers.
/** @return Always false; card nodes are not deck headers. */
[[nodiscard]] bool isDeckHeader() const override
{
return false;

View file

@ -48,8 +48,9 @@ QString InnerDecklistNode::getVisibleName() const
void InnerDecklistNode::clearTree()
{
for (int i = 0; i < size(); i++)
for (int i = 0; i < size(); i++) {
delete at(i);
}
clear();
}
@ -154,8 +155,9 @@ bool InnerDecklistNode::readElement(QXmlStreamReader *xml)
xml->attributes().value("collectorNumber").toString(), xml->attributes().value("uuid").toString());
newCard->readElement(xml);
}
} else if (xml->isEndElement() && (childName == "zone"))
} else if (xml->isEndElement() && (childName == "zone")) {
return false;
}
}
return true;
}
@ -164,8 +166,9 @@ void InnerDecklistNode::writeElement(QXmlStreamWriter *xml)
{
xml->writeStartElement("zone");
xml->writeAttribute("name", name);
for (int i = 0; i < size(); i++)
for (int i = 0; i < size(); i++) {
at(i)->writeElement(xml);
}
xml->writeEndElement(); // zone
}

View file

@ -18,11 +18,11 @@
#include "abstract_deck_list_node.h"
/// Constant for the "main" deck zone name.
/** @brief Constant for the "main" deck zone name. */
#define DECK_ZONE_MAIN "main"
/// Constant for the "sideboard" zone name.
/** @brief Constant for the "sideboard" zone name. */
#define DECK_ZONE_SIDE "side"
/// Constant for the "tokens" zone name.
/** @brief Constant for the "tokens" zone name. */
#define DECK_ZONE_TOKENS "tokens"
/**
@ -93,13 +93,13 @@ public:
*/
void setSortMethod(DeckSortMethod method) override;
/// @return The internal name of this node.
/** @return The internal name of this node. */
[[nodiscard]] QString getName() const override
{
return name;
}
/// @param _name Set the internal name of this node.
/** @param _name Set the internal name of this node. */
void setName(const QString &_name)
{
name = _name;
@ -122,25 +122,25 @@ public:
*/
[[nodiscard]] virtual QString getVisibleName() const;
/// @return Always empty for container nodes.
/** @return Always empty for container nodes. */
[[nodiscard]] QString getCardProviderId() const override
{
return "";
}
/// @return Always empty for container nodes.
/** @return Always empty for container nodes. */
[[nodiscard]] QString getCardSetShortName() const override
{
return "";
}
/// @return Always empty for container nodes.
/** @return Always empty for container nodes. */
[[nodiscard]] QString getCardCollectorNumber() const override
{
return "";
}
/// @return Always true; InnerDecklistNode represents deck structure.
/** @return Always true; InnerDecklistNode represents deck structure. */
[[nodiscard]] bool isDeckHeader() const override
{
return true;
@ -196,10 +196,10 @@ public:
*/
bool compare(AbstractDecklistNode *other) const override;
/// @copydoc compare(AbstractDecklistNode*) const
/** @copydoc compare(AbstractDecklistNode*) const */
bool compareNumber(AbstractDecklistNode *other) const;
/// @copydoc compare(AbstractDecklistNode*) const
/** @copydoc compare(AbstractDecklistNode*) const */
bool compareName(AbstractDecklistNode *other) const;
/**