add an isEmpty method to printing info (#6805)
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 11 (push) Blocked by required conditions
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Fedora 42 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 11 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 22.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 15 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run

no reason, I just find it easier to understand
This commit is contained in:
ebbit1q 2026-04-21 01:26:08 +02:00 committed by GitHub
parent 6765831b92
commit 6ab947418c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 3 deletions

View file

@ -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();

View file

@ -133,7 +133,7 @@ ExactCard CardDatabaseQuerier::getRandomCard() const
ExactCard CardDatabaseQuerier::getCardFromSameSet(const QString &cardName, const PrintingInfo &otherPrinting) const
{
// The source card does not have a printing defined, which means we can't get a card from the same set.
if (otherPrinting == PrintingInfo()) {
if (otherPrinting.isEmpty()) {
return getCard({cardName});
}
@ -360,4 +360,4 @@ QMap<QString, int> CardDatabaseQuerier::getAllFormatsWithCount() const
}
return formatCounts;
}
}

View file

@ -54,6 +54,16 @@ public:
return this->set == other.set && this->properties == other.properties;
}
/**
* @brief check if the info is empty, as if default constructed.
*
* @return True if both set and properties are empty, otherwise false.
*/
bool isEmpty() const
{
return set == nullptr && properties.isEmpty();
}
private:
CardSetPtr set; ///< The set this variation belongs to.
QVariantHash properties; ///< Key-value store for variation-specific attributes.