mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-23 01:55:10 -07:00
style: Add braces to all control flow statements (#6887)
* style: Add braces to all control flow statements Standardize code style by adding explicit braces to all single-statement control flow blocks (if, else, for, while) across the entire codebase. Also documents the InsertBraces clang-format option (requires v15+) for future automated enforcement. * InsertBraces-check-enabled
This commit is contained in:
parent
7153f7d4c1
commit
aadee34238
173 changed files with 2725 additions and 1461 deletions
|
|
@ -98,55 +98,79 @@ inline static DeckFormat apiNameToFormat(const QString &name)
|
|||
{
|
||||
const QString n = name.trimmed();
|
||||
|
||||
if (n.compare("Standard", Qt::CaseInsensitive) == 0)
|
||||
if (n.compare("Standard", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Standard;
|
||||
if (n.compare("Modern", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Modern", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Modern;
|
||||
if (n.compare("Commander", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Commander", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Commander;
|
||||
if (n.compare("Legacy", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Legacy", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Legacy;
|
||||
if (n.compare("Vintage", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Vintage", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Vintage;
|
||||
if (n.compare("Pauper", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Pauper", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Pauper;
|
||||
if (n.compare("Custom", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Custom", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Custom;
|
||||
if (n.compare("Frontier", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Frontier", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Frontier;
|
||||
if (n.compare("Future Std", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Future Std", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::FutureStandard;
|
||||
if (n.compare("Penny Dreadful", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Penny Dreadful", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::PennyDreadful;
|
||||
if (n.compare("1v1 Commander", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("1v1 Commander", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Commander1v1;
|
||||
if (n.compare("Dual Commander", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Dual Commander", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::DualCommander;
|
||||
if (n.compare("Brawl", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Brawl", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Brawl;
|
||||
}
|
||||
|
||||
if (n.compare("Alchemy", Qt::CaseInsensitive) == 0)
|
||||
if (n.compare("Alchemy", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Alchemy;
|
||||
if (n.compare("Historic", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Historic", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Historic;
|
||||
if (n.compare("Gladiator", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Gladiator", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Gladiator;
|
||||
if (n.compare("Oathbreaker", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Oathbreaker", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Oathbreaker;
|
||||
if (n.compare("Old School", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Old School", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::OldSchool;
|
||||
if (n.compare("Pauper Commander", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Pauper Commander", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::PauperCommander;
|
||||
if (n.compare("Pioneer", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Pioneer", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Pioneer;
|
||||
if (n.compare("PreDH", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("PreDH", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::PreDH;
|
||||
if (n.compare("Premodern", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Premodern", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Premodern;
|
||||
if (n.compare("Standard Brawl", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Standard Brawl", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::StandardBrawl;
|
||||
if (n.compare("Timeless", Qt::CaseInsensitive) == 0)
|
||||
}
|
||||
if (n.compare("Timeless", Qt::CaseInsensitive) == 0) {
|
||||
return DeckFormat::Timeless;
|
||||
}
|
||||
|
||||
return DeckFormat::Unknown;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,21 +20,27 @@ static QString timeAgo(const QString ×tamp)
|
|||
{
|
||||
QDateTime dt = QDateTime::fromString(timestamp, Qt::ISODate);
|
||||
|
||||
if (!dt.isValid())
|
||||
if (!dt.isValid()) {
|
||||
return timestamp; // fallback if parsing fails
|
||||
}
|
||||
|
||||
qint64 secs = dt.secsTo(QDateTime::currentDateTimeUtc());
|
||||
|
||||
if (secs < 60)
|
||||
if (secs < 60) {
|
||||
return QString("%1 seconds ago").arg(secs);
|
||||
if (secs < 3600)
|
||||
}
|
||||
if (secs < 3600) {
|
||||
return QString("%1 minutes ago").arg(secs / 60);
|
||||
if (secs < 86400)
|
||||
}
|
||||
if (secs < 86400) {
|
||||
return QString("%1 hours ago").arg(secs / 3600);
|
||||
if (secs < 30 * 86400)
|
||||
}
|
||||
if (secs < 30 * 86400) {
|
||||
return QString("%1 days ago").arg(secs / 86400);
|
||||
if (secs < 365 * 86400)
|
||||
}
|
||||
if (secs < 365 * 86400) {
|
||||
return QString("%1 months ago").arg(secs / (30 * 86400));
|
||||
}
|
||||
|
||||
return QString("%1 years ago").arg(secs / (365 * 86400));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,10 +93,11 @@ void TabArchidekt::initializeUi()
|
|||
colorLayout->addWidget(manaSymbol);
|
||||
|
||||
connect(manaSymbol, &ManaSymbolWidget::colorToggled, this, [this](QChar c, bool active) {
|
||||
if (active)
|
||||
if (active) {
|
||||
activeColors.insert(c);
|
||||
else
|
||||
} else {
|
||||
activeColors.remove(c);
|
||||
}
|
||||
doSearch();
|
||||
});
|
||||
}
|
||||
|
|
@ -298,16 +299,18 @@ void TabArchidekt::setupFilterWidgets()
|
|||
searchModel->updateSearchResults(text);
|
||||
QString pattern = ".*" + QRegularExpression::escape(text) + ".*";
|
||||
proxyModel->setFilterRegularExpression(QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption));
|
||||
if (!text.isEmpty())
|
||||
if (!text.isEmpty()) {
|
||||
completer->complete();
|
||||
}
|
||||
});
|
||||
|
||||
connect(commandersField, &QLineEdit::textChanged, this, [=](const QString &text) {
|
||||
searchModel->updateSearchResults(text);
|
||||
QString pattern = ".*" + QRegularExpression::escape(text) + ".*";
|
||||
proxyModel->setFilterRegularExpression(QRegularExpression(pattern, QRegularExpression::CaseInsensitiveOption));
|
||||
if (!text.isEmpty())
|
||||
if (!text.isEmpty()) {
|
||||
completer->complete();
|
||||
}
|
||||
});
|
||||
|
||||
// Assemble secondary toolbar
|
||||
|
|
@ -492,12 +495,13 @@ QString TabArchidekt::buildSearchUrl()
|
|||
|
||||
QString logic = "GTE";
|
||||
QString selected = minDeckSizeLogicCombo->currentText();
|
||||
if (selected == "≥")
|
||||
if (selected == "≥") {
|
||||
logic = "GTE";
|
||||
else if (selected == "≤")
|
||||
} else if (selected == "≤") {
|
||||
logic = "LTE";
|
||||
else
|
||||
} else {
|
||||
logic = "";
|
||||
}
|
||||
|
||||
if (!logic.isEmpty()) {
|
||||
query.addQueryItem("sizeLogic", logic);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue