| %1 | | ").arg(tr("Related cards:"));
- for (auto *relatedCard : relatedCards) {
+ for (const auto *relatedCard : relatedCards) {
QString tmp = relatedCard->getName().toHtmlEscaped();
text += "" + tmp + " ";
}
diff --git a/cockatrice/src/interface/widgets/cards/deck_card_zone_display_widget.cpp b/cockatrice/src/interface/widgets/cards/deck_card_zone_display_widget.cpp
index 5529c35b6..518f31628 100644
--- a/cockatrice/src/interface/widgets/cards/deck_card_zone_display_widget.cpp
+++ b/cockatrice/src/interface/widgets/cards/deck_card_zone_display_widget.cpp
@@ -81,7 +81,7 @@ void DeckCardZoneDisplayWidget::cleanupInvalidCardGroup(CardGroupDisplayWidget *
void DeckCardZoneDisplayWidget::constructAppropriateWidget(QPersistentModelIndex index)
{
- auto categoryName = deckListModel->data(index.sibling(index.row(), 1), Qt::EditRole).toString();
+ const auto categoryName = deckListModel->data(index.sibling(index.row(), 1), Qt::EditRole).toString();
if (indexToWidgetMap.contains(index)) {
return;
}
@@ -122,7 +122,7 @@ void DeckCardZoneDisplayWidget::displayCards()
proxy.sort(1, Qt::AscendingOrder);
// 1. trackedIndex is a source index → map it to proxy space
- QModelIndex proxyParent = proxy.mapFromSource(trackedIndex);
+ const QModelIndex proxyParent = proxy.mapFromSource(trackedIndex);
// 2. iterate children under the proxy parent
for (int i = 0; i < proxy.rowCount(proxyParent); ++i) {
@@ -132,7 +132,7 @@ void DeckCardZoneDisplayWidget::displayCards()
QModelIndex sourceIndex = proxy.mapToSource(proxyIndex);
// 4. persist the source index
- QPersistentModelIndex persistent(sourceIndex);
+ const QPersistentModelIndex persistent(sourceIndex);
constructAppropriateWidget(persistent);
}
@@ -146,7 +146,7 @@ void DeckCardZoneDisplayWidget::onCategoryAddition(const QModelIndex &parent, in
}
if (parent == trackedIndex) {
for (int i = first; i <= last; i++) {
- QPersistentModelIndex index = QPersistentModelIndex(deckListModel->index(i, 0, trackedIndex));
+ const QPersistentModelIndex index = QPersistentModelIndex(deckListModel->index(i, 0, trackedIndex));
constructAppropriateWidget(index);
}
@@ -206,7 +206,7 @@ void DeckCardZoneDisplayWidget::refreshDisplayType(const DisplayType &_displayTy
// We gotta wait for all the deleteLater's to finish so we fire after the next event cycle
- auto timer = new QTimer(this);
+ const auto timer = new QTimer(this);
timer->setSingleShot(true);
connect(timer, &QTimer::timeout, this, [this]() { displayCards(); });
timer->start();
diff --git a/cockatrice/src/interface/widgets/deck_analytics/mana_base_widget.cpp b/cockatrice/src/interface/widgets/deck_analytics/mana_base_widget.cpp
index 568583af5..b19db2946 100644
--- a/cockatrice/src/interface/widgets/deck_analytics/mana_base_widget.cpp
+++ b/cockatrice/src/interface/widgets/deck_analytics/mana_base_widget.cpp
@@ -51,7 +51,7 @@ void ManaBaseWidget::updateDisplay()
}
int highestEntry = 0;
- for (auto entry : manaBaseMap) {
+ for (const auto entry : manaBaseMap) {
if (entry > highestEntry) {
highestEntry = entry;
}
@@ -67,7 +67,7 @@ void ManaBaseWidget::updateDisplay()
manaColors.insert("C", QColor(150, 150, 150));
for (auto manaColor : manaBaseMap.keys()) {
- QColor barColor = manaColors.value(manaColor, Qt::gray);
+ const QColor barColor = manaColors.value(manaColor, Qt::gray);
BarWidget *barWidget = new BarWidget(QString(manaColor), manaBaseMap[manaColor], highestEntry, barColor, this);
barLayout->addWidget(barWidget);
}
@@ -80,7 +80,7 @@ QHash ManaBaseWidget::analyzeManaBase()
manaBaseMap.clear();
QList cardsInDeck = deckListModel->getDeckList()->getCardNodes();
- for (auto currentCard : cardsInDeck) {
+ for (const auto currentCard : cardsInDeck) {
for (int k = 0; k < currentCard->getNumber(); ++k) {
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(currentCard->getName());
if (info) {
@@ -98,7 +98,7 @@ QHash ManaBaseWidget::determineManaProduction(const QString &rules
{
QHash manaCounts = {{"W", 0}, {"U", 0}, {"B", 0}, {"R", 0}, {"G", 0}, {"C", 0}};
- QString text = rulesText.toLower(); // Normalize case for matching
+ const QString text = rulesText.toLower(); // Normalize case for matching
// Quick keyword-based checks for any color and colorless mana
if (text.contains("{t}: add one mana of any color") || text.contains("add one mana of any color")) {
@@ -113,7 +113,7 @@ QHash ManaBaseWidget::determineManaProduction(const QString &rules
// Optimized regex for specific mana symbols
static const QRegularExpression specificColorRegex(R"(\{T\}:\s*Add\s*\{([WUBRG])\})");
- QRegularExpressionMatch match = specificColorRegex.match(rulesText);
+ const QRegularExpressionMatch match = specificColorRegex.match(rulesText);
if (match.hasMatch()) {
manaCounts[match.captured(1)]++;
}
diff --git a/cockatrice/src/interface/widgets/deck_analytics/mana_curve_widget.cpp b/cockatrice/src/interface/widgets/deck_analytics/mana_curve_widget.cpp
index 4515b723b..6600d306e 100644
--- a/cockatrice/src/interface/widgets/deck_analytics/mana_curve_widget.cpp
+++ b/cockatrice/src/interface/widgets/deck_analytics/mana_curve_widget.cpp
@@ -47,7 +47,7 @@ std::unordered_map ManaCurveWidget::analyzeManaCurve()
QList cardsInDeck = deckListModel->getDeckList()->getCardNodes();
- for (auto currentCard : cardsInDeck) {
+ for (const auto currentCard : cardsInDeck) {
for (int k = 0; k < currentCard->getNumber(); ++k) {
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(currentCard->getName());
if (info) {
@@ -81,7 +81,7 @@ void ManaCurveWidget::updateDisplay()
}
// Convert unordered_map to ordered map to ensure sorting by CMC
- std::map sortedManaCurve(manaCurveMap.begin(), manaCurveMap.end());
+ const std::map sortedManaCurve(manaCurveMap.begin(), manaCurveMap.end());
// Add new widgets to the layout in sorted order
for (const auto &entry : sortedManaCurve) {
diff --git a/cockatrice/src/interface/widgets/deck_analytics/mana_devotion_widget.cpp b/cockatrice/src/interface/widgets/deck_analytics/mana_devotion_widget.cpp
index 3cafdaeab..be38791f0 100644
--- a/cockatrice/src/interface/widgets/deck_analytics/mana_devotion_widget.cpp
+++ b/cockatrice/src/interface/widgets/deck_analytics/mana_devotion_widget.cpp
@@ -49,7 +49,7 @@ std::unordered_map ManaDevotionWidget::analyzeManaDevotion()
QList cardsInDeck = deckListModel->getDeckList()->getCardNodes();
- for (auto currentCard : cardsInDeck) {
+ for (const auto currentCard : cardsInDeck) {
for (int k = 0; k < currentCard->getNumber(); ++k) {
CardInfoPtr info = CardDatabaseManager::query()->getCardInfo(currentCard->getName());
if (info) {
@@ -73,7 +73,7 @@ void ManaDevotionWidget::updateDisplay()
}
int highestEntry = 0;
- for (auto entry : manaDevotionMap) {
+ for (const auto entry : manaDevotionMap) {
if (highestEntry < entry.second) {
highestEntry = entry.second;
}
@@ -85,7 +85,7 @@ void ManaDevotionWidget::updateDisplay()
{'G', QColor(0, 115, 62)}, {'C', QColor(150, 150, 150)}};
for (auto entry : manaDevotionMap) {
- QColor barColor = manaColors.count(entry.first) ? manaColors[entry.first] : Qt::gray;
+ const QColor barColor = manaColors.count(entry.first) ? manaColors[entry.first] : Qt::gray;
BarWidget *barWidget = new BarWidget(QString(entry.first), entry.second, highestEntry, barColor, this);
barLayout->addWidget(barWidget);
}
@@ -97,7 +97,7 @@ std::unordered_map ManaDevotionWidget::countManaSymbols(const QString
{
std::unordered_map manaCounts = {{'W', 0}, {'U', 0}, {'B', 0}, {'R', 0}, {'G', 0}};
- int len = manaString.length();
+ const int len = manaString.length();
for (int i = 0; i < len; ++i) {
if (manaString[i] == '{') {
++i; // Move past '{'
diff --git a/cockatrice/src/interface/widgets/deck_editor/deck_editor_database_display_widget.cpp b/cockatrice/src/interface/widgets/deck_editor/deck_editor_database_display_widget.cpp
index b5aa007f0..74ec61ceb 100644
--- a/cockatrice/src/interface/widgets/deck_editor/deck_editor_database_display_widget.cpp
+++ b/cockatrice/src/interface/widgets/deck_editor/deck_editor_database_display_widget.cpp
@@ -37,7 +37,7 @@ DeckEditorDatabaseDisplayWidget::DeckEditorDatabaseDisplayWidget(AbstractTabDeck
searchEdit->setPlaceholderText(tr("Search by card name (or search expressions)"));
searchEdit->setClearButtonEnabled(true);
searchEdit->addAction(loadColorAdjustedPixmap("theme:icons/search"), QLineEdit::LeadingPosition);
- auto help = searchEdit->addAction(QPixmap("theme:icons/info"), QLineEdit::TrailingPosition);
+ const auto help = searchEdit->addAction(QPixmap("theme:icons/info"), QLineEdit::TrailingPosition);
searchEdit->installEventFilter(&searchKeySignals);
setFocusProxy(searchEdit);
@@ -83,7 +83,7 @@ DeckEditorDatabaseDisplayWidget::DeckEditorDatabaseDisplayWidget(AbstractTabDeck
&DeckEditorDatabaseDisplayWidget::updateCard);
connect(databaseView, &QTreeView::doubleClicked, this, &DeckEditorDatabaseDisplayWidget::actAddCardToMainDeck);
- QByteArray dbHeaderState = SettingsCache::instance().layouts().getDeckEditorDbHeaderState();
+ const QByteArray dbHeaderState = SettingsCache::instance().layouts().getDeckEditorDbHeaderState();
if (dbHeaderState.isNull()) {
// first run
databaseView->setColumnWidth(0, 200);
@@ -122,7 +122,7 @@ DeckEditorDatabaseDisplayWidget::DeckEditorDatabaseDisplayWidget(AbstractTabDeck
void DeckEditorDatabaseDisplayWidget::updateSearch(const QString &search)
{
databaseDisplayModel->setStringFilter(search);
- QModelIndexList sel = databaseView->selectionModel()->selectedRows();
+ const QModelIndexList sel = databaseView->selectionModel()->selectedRows();
if (sel.isEmpty() && databaseDisplayModel->rowCount())
databaseView->selectionModel()->setCurrentIndex(databaseDisplayModel->index(0, 0),
QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
@@ -214,7 +214,7 @@ void DeckEditorDatabaseDisplayWidget::databaseCustomMenu(QPoint point)
} else {
for (const CardRelation *rel : relatedCards) {
const QString &relatedCardName = rel->getName();
- QAction *relatedCard = relatedMenu->addAction(relatedCardName);
+ const QAction *relatedCard = relatedMenu->addAction(relatedCardName);
connect(
relatedCard, &QAction::triggered, deckEditor->cardInfoDockWidget->cardInfo,
[this, relatedCardName] { deckEditor->cardInfoDockWidget->cardInfo->setCard(relatedCardName); });
@@ -226,7 +226,7 @@ void DeckEditorDatabaseDisplayWidget::databaseCustomMenu(QPoint point)
void DeckEditorDatabaseDisplayWidget::copyDatabaseCellContents()
{
- auto _data = databaseView->selectionModel()->currentIndex().data();
+ const auto _data = databaseView->selectionModel()->currentIndex().data();
QApplication::clipboard()->setText(_data.toString());
}
diff --git a/cockatrice/src/interface/widgets/deck_editor/deck_editor_deck_dock_widget.cpp b/cockatrice/src/interface/widgets/deck_editor/deck_editor_deck_dock_widget.cpp
index 4db7b8774..524f7599f 100644
--- a/cockatrice/src/interface/widgets/deck_editor/deck_editor_deck_dock_widget.cpp
+++ b/cockatrice/src/interface/widgets/deck_editor/deck_editor_deck_dock_widget.cpp
@@ -265,7 +265,7 @@ void DeckEditorDeckDockWidget::createDeckDock()
ExactCard DeckEditorDeckDockWidget::getCurrentCard()
{
- QModelIndex current = deckView->selectionModel()->currentIndex();
+ const QModelIndex current = deckView->selectionModel()->currentIndex();
if (!current.isValid())
return {};
const QString cardName = current.sibling(current.row(), 1).data().toString();
@@ -288,7 +288,7 @@ ExactCard DeckEditorDeckDockWidget::getCurrentCard()
void DeckEditorDeckDockWidget::updateCard(const QModelIndex /*¤t*/, const QModelIndex & /*previous*/)
{
- if (ExactCard card = getCurrentCard()) {
+ if (const ExactCard card = getCurrentCard()) {
emit cardChanged(card);
}
}
@@ -325,10 +325,10 @@ void DeckEditorDeckDockWidget::updateHash()
void DeckEditorDeckDockWidget::updateBannerCardComboBox()
{
// Store current banner card identity
- CardRef wanted = deckModel->getDeckList()->getBannerCard();
+ const CardRef wanted = deckModel->getDeckList()->getBannerCard();
// Block signals temporarily
- bool wasBlocked = bannerCardComboBox->blockSignals(true);
+ const bool wasBlocked = bannerCardComboBox->blockSignals(true);
// Clear the existing items in the combo box
bannerCardComboBox->clear();
@@ -337,7 +337,7 @@ void DeckEditorDeckDockWidget::updateBannerCardComboBox()
QSet> bannerCardSet;
QList cardsInDeck = deckModel->getDeckList()->getCardNodes();
- for (auto currentCard : cardsInDeck) {
+ for (const auto currentCard : cardsInDeck) {
if (!CardDatabaseManager::query()->getCard(currentCard->toCardRef())) {
continue;
}
@@ -359,7 +359,7 @@ void DeckEditorDeckDockWidget::updateBannerCardComboBox()
}
// Try to find an index with a matching card
- int restoreIndex = findRestoreIndex(wanted, bannerCardComboBox);
+ const int restoreIndex = findRestoreIndex(wanted, bannerCardComboBox);
// Handle results
if (restoreIndex != -1) {
@@ -576,9 +576,10 @@ bool DeckEditorDeckDockWidget::swapCard(const QModelIndex ¤tIndex)
offsetCountAtIndex(currentIndex, -1);
const QString otherZoneName = zoneName == DECK_ZONE_MAIN ? DECK_ZONE_SIDE : DECK_ZONE_MAIN;
- ExactCard card = CardDatabaseManager::query()->getCard({cardName, cardProviderID});
- QModelIndex newCardIndex = card ? deckModel->addCard(card, otherZoneName)
- // Third argument (true) says create the card no matter what, even if not in DB
+ const ExactCard card = CardDatabaseManager::query()->getCard({cardName, cardProviderID});
+ const QModelIndex newCardIndex = card
+ ? deckModel->addCard(card, otherZoneName)
+ // Third argument (true) says create the card no matter what, even if not in DB
: deckModel->addPreferredPrintingCard(cardName, otherZoneName, true);
recursiveExpand(proxy->mapToSource(newCardIndex));
@@ -592,10 +593,10 @@ void DeckEditorDeckDockWidget::actDecrementCard(const ExactCard &card, QString z
if (card.getInfo().getIsToken())
zoneName = DECK_ZONE_TOKENS;
- QString providerId = card.getPrinting().getUuid();
- QString collectorNumber = card.getPrinting().getProperty("num");
+ const QString providerId = card.getPrinting().getUuid();
+ const QString collectorNumber = card.getPrinting().getProperty("num");
- QModelIndex idx = deckModel->findCard(card.getName(), zoneName, providerId, collectorNumber);
+ const QModelIndex idx = deckModel->findCard(card.getName(), zoneName, providerId, collectorNumber);
if (!idx.isValid()) {
return;
}
@@ -659,7 +660,7 @@ void DeckEditorDeckDockWidget::offsetCountAtIndex(const QModelIndex &idx, int of
return;
}
- QModelIndex sourceIndex = proxy->mapToSource(idx);
+ const QModelIndex sourceIndex = proxy->mapToSource(idx);
const QModelIndex numberIndex = sourceIndex.sibling(sourceIndex.row(), 0);
const QModelIndex nameIndex = sourceIndex.sibling(sourceIndex.row(), 1);
@@ -691,7 +692,7 @@ void DeckEditorDeckDockWidget::decklistCustomMenu(QPoint point)
if (!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
QMenu menu;
- QAction *selectPrinting = menu.addAction(tr("Select Printing"));
+ const QAction *selectPrinting = menu.addAction(tr("Select Printing"));
connect(selectPrinting, &QAction::triggered, deckEditor, &AbstractTabDeckEditor::showPrintingSelector);
menu.exec(deckView->mapToGlobal(point));
@@ -700,7 +701,7 @@ void DeckEditorDeckDockWidget::decklistCustomMenu(QPoint point)
void DeckEditorDeckDockWidget::refreshShortcuts()
{
- ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
+ const ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aRemoveCard->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aRemoveCard"));
aIncrement->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aIncrement"));
aDecrement->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aDecrement"));
diff --git a/cockatrice/src/interface/widgets/deck_editor/deck_editor_filter_dock_widget.cpp b/cockatrice/src/interface/widgets/deck_editor/deck_editor_filter_dock_widget.cpp
index 4957e24ec..f9cc70b26 100644
--- a/cockatrice/src/interface/widgets/deck_editor/deck_editor_filter_dock_widget.cpp
+++ b/cockatrice/src/interface/widgets/deck_editor/deck_editor_filter_dock_widget.cpp
@@ -128,7 +128,7 @@ void DeckEditorFilterDockWidget::actClearFilterOne()
void DeckEditorFilterDockWidget::refreshShortcuts()
{
- ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
+ const ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aClearFilterAll->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aClearFilterAll"));
aClearFilterOne->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aClearFilterOne"));
diff --git a/cockatrice/src/interface/widgets/deck_editor/deck_list_history_manager_widget.cpp b/cockatrice/src/interface/widgets/deck_editor/deck_list_history_manager_widget.cpp
index c68934ea6..8be0bbfca 100644
--- a/cockatrice/src/interface/widgets/deck_editor/deck_list_history_manager_widget.cpp
+++ b/cockatrice/src/interface/widgets/deck_editor/deck_list_history_manager_widget.cpp
@@ -70,7 +70,7 @@ void DeckListHistoryManagerWidget::refreshList()
// Fill redo section first (oldest redo at top, newest redo closest to divider)
const auto redoStack = historyManager->getRedoStack();
for (int i = 0; i < redoStack.size(); ++i) { // iterate forward
- auto item = new QListWidgetItem(tr("[redo] ") + redoStack[i].getReason(), historyList);
+ const auto item = new QListWidgetItem(tr("[redo] ") + redoStack[i].getReason(), historyList);
item->setData(Qt::UserRole, QVariant("redo"));
item->setData(Qt::UserRole + 1, i); // index in redo stack
item->setForeground(Qt::gray);
@@ -79,7 +79,7 @@ void DeckListHistoryManagerWidget::refreshList()
// Divider
if (!historyManager->getUndoStack().isEmpty() && !historyManager->getRedoStack().isEmpty()) {
- auto divider = new QListWidgetItem("──────────", historyList);
+ const auto divider = new QListWidgetItem("──────────", historyList);
divider->setFlags(Qt::NoItemFlags); // not selectable
historyList->addItem(divider);
}
@@ -87,7 +87,7 @@ void DeckListHistoryManagerWidget::refreshList()
// Fill undo section
const auto undoStack = historyManager->getUndoStack();
for (int i = undoStack.size() - 1; i >= 0; --i) {
- auto item = new QListWidgetItem(tr("[undo] ") + undoStack[i].getReason(), historyList);
+ const auto item = new QListWidgetItem(tr("[undo] ") + undoStack[i].getReason(), historyList);
item->setData(Qt::UserRole, QVariant("undo"));
item->setData(Qt::UserRole + 1, i); // index in undo stack
historyList->addItem(item);
@@ -135,17 +135,17 @@ void DeckListHistoryManagerWidget::onListClicked(QListWidgetItem *item)
}
const QString mode = item->data(Qt::UserRole).toString();
- int index = item->data(Qt::UserRole + 1).toInt();
+ const int index = item->data(Qt::UserRole + 1).toInt();
if (mode == "redo") {
const auto redoStack = historyManager->getRedoStack();
- int steps = redoStack.size() - index;
+ const int steps = redoStack.size() - index;
for (int i = 0; i < steps; ++i) {
historyManager->redo(deckListModel->getDeckList());
}
} else if (mode == "undo") {
const auto undoStack = historyManager->getUndoStack();
- int steps = undoStack.size() - 1 - index;
+ const int steps = undoStack.size() - 1 - index;
for (int i = 0; i < steps + 1; ++i) {
historyManager->undo(deckListModel->getDeckList());
}
diff --git a/cockatrice/src/interface/widgets/deck_editor/deck_list_style_proxy.cpp b/cockatrice/src/interface/widgets/deck_editor/deck_list_style_proxy.cpp
index 9c2265dfd..ccab2581a 100644
--- a/cockatrice/src/interface/widgets/deck_editor/deck_list_style_proxy.cpp
+++ b/cockatrice/src/interface/widgets/deck_editor/deck_list_style_proxy.cpp
@@ -7,13 +7,13 @@
QVariant DeckListStyleProxy::data(const QModelIndex &index, int role) const
{
- QModelIndex src = mapToSource(index);
+ const QModelIndex src = mapToSource(index);
if (!src.isValid())
return {};
QVariant value = QIdentityProxyModel::data(index, role);
- bool isCard = src.data(DeckRoles::IsCardRole).toBool();
+ const bool isCard = src.data(DeckRoles::IsCardRole).toBool();
if (role == Qt::FontRole && !isCard) {
QFont f;
@@ -25,11 +25,11 @@ QVariant DeckListStyleProxy::data(const QModelIndex &index, int role) const
if (isCard) {
const bool legal =
true; // TODO: Not implemented yet. QIdentityProxyModel::data(index, DeckRoles::IsLegalRole).toBool();
- int base = 255 - (index.row() % 2) * 30;
+ const int base = 255 - (index.row() % 2) * 30;
return legal ? QBrush(QColor(base, base, base)) : QBrush(QColor(255, base / 3, base / 3));
} else {
- int depth = src.data(DeckRoles::DepthRole).toInt();
- int color = 90 + 60 * depth;
+ const int depth = src.data(DeckRoles::DepthRole).toInt();
+ const int color = 90 + 60 * depth;
return QBrush(QColor(color, 255, color));
}
}
diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_connect.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_connect.cpp
index ed32b356c..337c2b370 100644
--- a/cockatrice/src/interface/widgets/dialogs/dlg_connect.cpp
+++ b/cockatrice/src/interface/widgets/dialogs/dlg_connect.cpp
@@ -214,9 +214,9 @@ void DlgConnect::rebuildComboBoxList(int failure)
savedHostList = uci.getServerInfo();
auto &servers = SettingsCache::instance().servers();
- bool autoConnectEnabled = servers.getAutoConnect() > 0;
- QString previousHostName = servers.getPrevioushostName();
- QString autoConnectSaveName = servers.getSaveName();
+ const bool autoConnectEnabled = servers.getAutoConnect() > 0;
+ const QString previousHostName = servers.getPrevioushostName();
+ const QString autoConnectSaveName = servers.getSaveName();
int index = 0;
@@ -272,7 +272,7 @@ void DlgConnect::updateDisplayInfo(const QString &saveName)
<< "";
}
- bool savePasswordStatus = (_data.at(5) == "1");
+ const bool savePasswordStatus = (_data.at(5) == "1");
saveEdit->setText(_data.at(0));
hostEdit->setText(_data.at(1));
@@ -285,7 +285,7 @@ void DlgConnect::updateDisplayInfo(const QString &saveName)
}
if (!_data.at(6).isEmpty()) {
- QString formattedLink = "" + _data.at(6) + "";
+ const QString formattedLink = "" + _data.at(6) + "";
serverContactLabel->setText(tr("Webpage") + ":");
serverContactLink->setText(formattedLink);
} else {
diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_default_tags_editor.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_default_tags_editor.cpp
index 5b120b1e2..2af3445b6 100644
--- a/cockatrice/src/interface/widgets/dialogs/dlg_default_tags_editor.cpp
+++ b/cockatrice/src/interface/widgets/dialogs/dlg_default_tags_editor.cpp
@@ -85,7 +85,7 @@ void DlgDefaultTagsEditor::loadStringList()
void DlgDefaultTagsEditor::addItem()
{
- QString newTag = inputField->text().trimmed();
+ const QString newTag = inputField->text().trimmed();
if (newTag.isEmpty()) {
QMessageBox::warning(this, tr("Invalid Input"), tr("Tag name cannot be empty!"));
return;
@@ -93,10 +93,10 @@ void DlgDefaultTagsEditor::addItem()
// Prevent duplicate tags
for (int i = 0; i < listWidget->count(); ++i) {
- QWidget *widget = listWidget->itemWidget(listWidget->item(i));
+ const QWidget *widget = listWidget->itemWidget(listWidget->item(i));
if (!widget)
continue;
- QLineEdit *lineEdit = widget->findChild();
+ const QLineEdit *lineEdit = widget->findChild();
if (lineEdit && lineEdit->text() == newTag) {
QMessageBox::warning(this, tr("Duplicate Tag"), tr("This tag already exists."));
return;
@@ -136,10 +136,10 @@ void DlgDefaultTagsEditor::confirmChanges()
{
QStringList updatedList;
for (int i = 0; i < listWidget->count(); ++i) {
- QWidget *widget = listWidget->itemWidget(listWidget->item(i));
+ const QWidget *widget = listWidget->itemWidget(listWidget->item(i));
if (!widget)
continue;
- QLineEdit *lineEdit = widget->findChild();
+ const QLineEdit *lineEdit = widget->findChild();
if (lineEdit) {
updatedList.append(lineEdit->text());
}
diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_edit_avatar.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_edit_avatar.cpp
index 7330c749b..81c29ea1a 100644
--- a/cockatrice/src/interface/widgets/dialogs/dlg_edit_avatar.cpp
+++ b/cockatrice/src/interface/widgets/dialogs/dlg_edit_avatar.cpp
@@ -49,7 +49,7 @@ void DlgEditAvatar::actOk()
void DlgEditAvatar::actBrowse()
{
- QString fileName =
+ const QString fileName =
QFileDialog::getOpenFileName(this, tr("Open Image"), QDir::homePath(), tr("Image Files (*.png *.jpg *.bmp)"));
if (fileName.isEmpty()) {
imageLabel->setText(tr("No image chosen."));
diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_edit_tokens.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_edit_tokens.cpp
index a47a8221a..4a06b9385 100644
--- a/cockatrice/src/interface/widgets/dialogs/dlg_edit_tokens.cpp
+++ b/cockatrice/src/interface/widgets/dialogs/dlg_edit_tokens.cpp
@@ -162,11 +162,11 @@ void DlgEditTokens::actAddToken()
}
}
- QString setName = CardSet::TOKENS_SETNAME;
+ const QString setName = CardSet::TOKENS_SETNAME;
SetToPrintingsMap sets;
sets[setName].append(PrintingInfo(databaseModel->getDatabase()->getSet(setName)));
- CardInfo::UiAttributes attributes = {.tableRow = -1};
- CardInfoPtr card = CardInfo::newInstance(name, "", true, {}, {}, {}, sets, attributes);
+ const CardInfo::UiAttributes attributes = {.tableRow = -1};
+ const CardInfoPtr card = CardInfo::newInstance(name, "", true, {}, {}, {}, sets, attributes);
card->setCardType("Token");
databaseModel->getDatabase()->addCard(card);
@@ -175,7 +175,7 @@ void DlgEditTokens::actAddToken()
void DlgEditTokens::actRemoveToken()
{
if (currentCard) {
- CardInfoPtr cardToRemove = currentCard; // the currentCard property gets modified during db->removeCard()
+ const CardInfoPtr cardToRemove = currentCard; // the currentCard property gets modified during db->removeCard()
currentCard.clear();
databaseModel->getDatabase()->removeCard(cardToRemove);
}
diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_filter_games.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_filter_games.cpp
index 1bf98822c..d85337ba2 100644
--- a/cockatrice/src/interface/widgets/dialogs/dlg_filter_games.cpp
+++ b/cockatrice/src/interface/widgets/dialogs/dlg_filter_games.cpp
@@ -261,7 +261,7 @@ int DlgFilterGames::getMaxPlayersFilterMax() const
QTime DlgFilterGames::getMaxGameAge() const
{
- int index = maxGameAgeComboBox->currentIndex();
+ const int index = maxGameAgeComboBox->currentIndex();
if (index < 0 || index >= gameAgeMap.size()) { // index is out of bounds
return gamesProxyModel->getMaxGameAge(); // leave the setting unchanged
}
diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_load_deck_from_website.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_load_deck_from_website.cpp
index f29984ab0..af46a9ec5 100644
--- a/cockatrice/src/interface/widgets/dialogs/dlg_load_deck_from_website.cpp
+++ b/cockatrice/src/interface/widgets/dialogs/dlg_load_deck_from_website.cpp
@@ -56,7 +56,7 @@ void DlgLoadDeckFromWebsite::accept()
if (DeckLinkToApiTransformer::parseDeckUrl(urlEdit->text(), info)) {
qCInfo(DlgLoadDeckFromWebsiteLog) << info.baseUrl << info.deckID << info.fullUrl;
- auto jsonParser = createParserForProvider(info.provider);
+ const auto jsonParser = createParserForProvider(info.provider);
if (!jsonParser && info.provider != DeckProvider::Deckstats && info.provider != DeckProvider::TappedOut) {
qCWarning(DlgLoadDeckFromWebsiteLog) << "No parser found for provider";
QMessageBox::warning(this, tr("Load Deck from Website"),
@@ -66,7 +66,7 @@ void DlgLoadDeckFromWebsite::accept()
return;
}
- QNetworkRequest request(QUrl(info.fullUrl));
+ const QNetworkRequest request(QUrl(info.fullUrl));
QNetworkReply *reply = nam->get(request);
QEventLoop loop;
@@ -81,7 +81,7 @@ void DlgLoadDeckFromWebsite::accept()
return;
}
- QByteArray responseData = reply->readAll();
+ const QByteArray responseData = reply->readAll();
reply->deleteLater();
// Special handling for Deckstats and TappedOut .txt
@@ -107,7 +107,7 @@ void DlgLoadDeckFromWebsite::accept()
// Normal JSON parsing for other providers
QJsonParseError parseError;
- QJsonDocument doc = QJsonDocument::fromJson(responseData, &parseError);
+ const QJsonDocument doc = QJsonDocument::fromJson(responseData, &parseError);
if (parseError.error != QJsonParseError::NoError) {
qCWarning(DlgLoadDeckFromWebsiteLog) << "JSON parse error:" << parseError.errorString();
QMessageBox::warning(this, tr("Load Deck from Website"),
diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_manage_sets.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_manage_sets.cpp
index 2d3bc08a4..82fe314b2 100644
--- a/cockatrice/src/interface/widgets/dialogs/dlg_manage_sets.cpp
+++ b/cockatrice/src/interface/widgets/dialogs/dlg_manage_sets.cpp
@@ -326,19 +326,19 @@ void WndSets::actDisableSortButtons(int index)
void WndSets::actToggleButtons(const QItemSelection &selected, const QItemSelection &)
{
- bool emptySelection = selected.empty();
+ const bool emptySelection = selected.empty();
aTop->setDisabled(emptySelection || setOrderIsSorted);
aUp->setDisabled(emptySelection || setOrderIsSorted);
aDown->setDisabled(emptySelection || setOrderIsSorted);
aBottom->setDisabled(emptySelection || setOrderIsSorted);
- int rows = view->selectionModel()->selectedRows().size();
+ const int rows = view->selectionModel()->selectedRows().size();
rebuildMainLayout((rows > 1) ? SOME_SETS_SELECTED : NO_SETS_SELECTED);
}
void WndSets::selectRows(QSet rows)
{
- for (auto i : rows) {
+ for (const auto i : rows) {
QModelIndex idx = model->index(i, 0);
view->selectionModel()->select(idx, QItemSelectionModel::Select | QItemSelectionModel::Rows);
view->scrollTo(idx, QAbstractItemView::EnsureVisible);
@@ -385,7 +385,7 @@ void WndSets::actUp()
for (auto i : rows) {
if (i.row() <= 0)
continue;
- int oldRow = displayModel->mapToSource(i).row();
+ const int oldRow = displayModel->mapToSource(i).row();
int newRow = i.row() - 1;
model->swapRows(oldRow, displayModel->mapToSource(displayModel->index(newRow, 0)).row());
@@ -408,7 +408,7 @@ void WndSets::actDown()
for (auto i : rows) {
if (i.row() >= displayModel->rowCount() - 1)
continue;
- int oldRow = displayModel->mapToSource(i).row();
+ const int oldRow = displayModel->mapToSource(i).row();
int newRow = i.row() + 1;
model->swapRows(oldRow, displayModel->mapToSource(displayModel->index(newRow, 0)).row());
@@ -429,7 +429,7 @@ void WndSets::actTop()
return;
for (int i = 0; i < rows.length(); i++) {
- int oldRow = displayModel->mapToSource(rows.at(i)).row();
+ const int oldRow = displayModel->mapToSource(rows.at(i)).row();
if (oldRow <= 0) {
newRow++;
@@ -455,7 +455,7 @@ void WndSets::actBottom()
return;
for (int i = 0; i < rows.length(); i++) {
- int oldRow = displayModel->mapToSource(rows.at(i)).row();
+ const int oldRow = displayModel->mapToSource(rows.at(i)).row();
if (oldRow >= newRow) {
newRow--;
diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_select_set_for_cards.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_select_set_for_cards.cpp
index 121ce4c86..2f7ec8d7c 100644
--- a/cockatrice/src/interface/widgets/dialogs/dlg_select_set_for_cards.cpp
+++ b/cockatrice/src/interface/widgets/dialogs/dlg_select_set_for_cards.cpp
@@ -144,7 +144,7 @@ void DlgSelectSetForCards::retranslateUi()
void DlgSelectSetForCards::actOK()
{
- QMap modifiedSetsAndCardsMap = getModifiedCards();
+ const QMap modifiedSetsAndCardsMap = getModifiedCards();
for (QString modifiedSet : modifiedSetsAndCardsMap.keys()) {
for (QString card : modifiedSetsAndCardsMap.value(modifiedSet)) {
QModelIndex find_card = model->findCard(card, DECK_ZONE_MAIN);
@@ -205,13 +205,13 @@ QMap DlgSelectSetForCards::getSetsForCards()
if (!model)
return setCounts;
- DeckList *decklist = model->getDeckList();
+ const DeckList *decklist = model->getDeckList();
if (!decklist)
return setCounts;
QList cardsInDeck = decklist->getCardNodes();
- for (auto currentCard : cardsInDeck) {
+ for (const auto currentCard : cardsInDeck) {
CardInfoPtr infoPtr = CardDatabaseManager::query()->getCardInfo(currentCard->getName());
if (!infoPtr)
continue;
@@ -248,13 +248,13 @@ void DlgSelectSetForCards::updateCardLists()
}
}
- DeckList *decklist = model->getDeckList();
+ const DeckList *decklist = model->getDeckList();
if (!decklist)
return;
QList cardsInDeck = decklist->getCardNodes();
- for (auto currentCard : cardsInDeck) {
+ for (const auto currentCard : cardsInDeck) {
bool found = false;
QString foundSetName;
@@ -298,16 +298,16 @@ void DlgSelectSetForCards::dragEnterEvent(QDragEnterEvent *event)
void DlgSelectSetForCards::dropEvent(QDropEvent *event)
{
- QByteArray itemData = event->mimeData()->data("application/x-setentrywidget");
- QString draggedSetName = QString::fromUtf8(itemData);
+ const QByteArray itemData = event->mimeData()->data("application/x-setentrywidget");
+ const QString draggedSetName = QString::fromUtf8(itemData);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- QPoint adjustedPos = event->position().toPoint() + QPoint(0, scrollArea->verticalScrollBar()->value());
+ const QPoint adjustedPos = event->position().toPoint() + QPoint(0, scrollArea->verticalScrollBar()->value());
#else
QPoint adjustedPos = event->pos() + QPoint(0, scrollArea->verticalScrollBar()->value());
#endif
int dropIndex = -1;
for (int i = 0; i < listLayout->count(); ++i) {
- QWidget *widget = listLayout->itemAt(i)->widget();
+ const QWidget *widget = listLayout->itemAt(i)->widget();
if (widget && widget->geometry().contains(adjustedPos)) {
dropIndex = i;
break;
@@ -337,13 +337,13 @@ QMap DlgSelectSetForCards::getCardsForSets()
if (!model)
return setCards;
- DeckList *decklist = model->getDeckList();
+ const DeckList *decklist = model->getDeckList();
if (!decklist)
return setCards;
QList cardsInDeck = decklist->getCardNodes();
- for (auto currentCard : cardsInDeck) {
+ for (const auto currentCard : cardsInDeck) {
CardInfoPtr infoPtr = CardDatabaseManager::query()->getCardInfo(currentCard->getName());
if (!infoPtr)
continue;
@@ -362,7 +362,7 @@ QMap DlgSelectSetForCards::getModifiedCards()
QMap modifiedCards;
for (int i = 0; i < listLayout->count(); ++i) {
QWidget *widget = listLayout->itemAt(i)->widget();
- if (auto entry = qobject_cast(widget)) {
+ if (const auto entry = qobject_cast(widget)) {
if (entry->isChecked()) {
QStringList cardsInSet = entry->getAllCardsForSet();
@@ -388,7 +388,7 @@ void DlgSelectSetForCards::updateLayoutOrder()
entry_widgets.clear();
for (int i = 0; i < listLayout->count(); ++i) {
QWidget *widget = listLayout->itemAt(i)->widget();
- if (auto entry = qobject_cast(widget)) {
+ if (const auto entry = qobject_cast(widget)) {
entry_widgets.append(entry);
}
}
@@ -403,7 +403,7 @@ SetEntryWidget::SetEntryWidget(DlgSelectSetForCards *_parent, const QString &_se
setLayout(layout);
QHBoxLayout *headerLayout = new QHBoxLayout();
- CardSetPtr set = CardDatabaseManager::getInstance()->getSet(setName);
+ const CardSetPtr set = CardDatabaseManager::getInstance()->getSet(setName);
checkBox = new QCheckBox("(" + set->getShortName() + ") - " + set->getLongName(), this);
connect(checkBox, &QCheckBox::toggled, parent, &DlgSelectSetForCards::updateLayoutOrder);
expandButton = new QPushButton("+", this);
@@ -510,7 +510,7 @@ void SetEntryWidget::dragMoveEvent(QDragMoveEvent *event)
// For now, we will just highlight the widget when dragged.
QPainter painter(this);
- QColor highlightColor(255, 255, 255, 128); // Semi-transparent white
+ const QColor highlightColor(255, 255, 255, 128); // Semi-transparent white
painter.setBrush(QBrush(highlightColor));
painter.setPen(Qt::NoPen);
painter.drawRect(this->rect()); // Highlight the widget area
@@ -594,14 +594,16 @@ void SetEntryWidget::updateCardDisplayWidgets()
for (const QString &cardName : possibleCards) {
CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(cardListContainer);
- QString providerId = CardDatabaseManager::query()->getSpecificPrinting(cardName, setName, nullptr).getUuid();
+ const QString providerId =
+ CardDatabaseManager::query()->getSpecificPrinting(cardName, setName, nullptr).getUuid();
picture_widget->setCard(CardDatabaseManager::query()->getCard({cardName, providerId}));
cardListContainer->addWidget(picture_widget);
}
for (const QString &cardName : unusedCards) {
CardInfoPictureWidget *picture_widget = new CardInfoPictureWidget(alreadySelectedCardListContainer);
- QString providerId = CardDatabaseManager::query()->getSpecificPrinting(cardName, setName, nullptr).getUuid();
+ const QString providerId =
+ CardDatabaseManager::query()->getSpecificPrinting(cardName, setName, nullptr).getUuid();
picture_widget->setCard(CardDatabaseManager::query()->getCard({cardName, providerId}));
alreadySelectedCardListContainer->addWidget(picture_widget);
}
diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_settings.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_settings.cpp
index e92593d55..405512f62 100644
--- a/cockatrice/src/interface/widgets/dialogs/dlg_settings.cpp
+++ b/cockatrice/src/interface/widgets/dialogs/dlg_settings.cpp
@@ -68,8 +68,8 @@ GeneralSettingsPage::GeneralSettingsPage()
languageBox.addItem(langName, code);
}
- QString setLanguage = QCoreApplication::translate("i18n", DEFAULT_LANG_NAME);
- int index = languageBox.findText(setLanguage, Qt::MatchExactly);
+ const QString setLanguage = QCoreApplication::translate("i18n", DEFAULT_LANG_NAME);
+ const int index = languageBox.findText(setLanguage, Qt::MatchExactly);
if (index == -1) {
qWarning() << "could not find language" << setLanguage;
} else {
@@ -77,7 +77,7 @@ GeneralSettingsPage::GeneralSettingsPage()
}
// updates
- SettingsCache &settings = SettingsCache::instance();
+ const SettingsCache &settings = SettingsCache::instance();
startupUpdateCheckCheckBox.setChecked(settings.getCheckUpdatesOnStartup());
startupCardUpdateCheckBehaviorSelector.addItem(""); // these will be set in retranslateUI
@@ -178,7 +178,7 @@ GeneralSettingsPage::GeneralSettingsPage()
// Required init here to avoid crashing on Portable builds
resetAllPathsButton = new QPushButton;
- bool isPortable = settings.getIsPortableBuild();
+ const bool isPortable = settings.getIsPortableBuild();
if (isPortable) {
deckPathEdit->setEnabled(false);
filtersPathEdit->setEnabled(false);
@@ -249,7 +249,7 @@ GeneralSettingsPage::GeneralSettingsPage()
QStringList GeneralSettingsPage::findQmFiles()
{
- QDir dir(translationPath);
+ const QDir dir(translationPath);
QStringList fileNames = dir.entryList(QStringList(translationPrefix + "_*.qm"), QDir::Files, QDir::Name);
fileNames.replaceInStrings(QRegularExpression(translationPrefix + "_(.*)\\.qm"), "\\1");
return fileNames;
@@ -259,8 +259,8 @@ QString GeneralSettingsPage::languageName(const QString &lang)
{
QTranslator qTranslator;
- QString appNameHint = translationPrefix + "_" + lang;
- bool appTranslationLoaded = qTranslator.load(appNameHint, translationPath);
+ const QString appNameHint = translationPrefix + "_" + lang;
+ const bool appTranslationLoaded = qTranslator.load(appNameHint, translationPath);
if (!appTranslationLoaded) {
qCWarning(DlgSettingsLog) << "Unable to load" << translationPrefix << "translation" << appNameHint << "at"
<< translationPath;
@@ -271,7 +271,7 @@ QString GeneralSettingsPage::languageName(const QString &lang)
void GeneralSettingsPage::deckPathButtonClicked()
{
- QString path = QFileDialog::getExistingDirectory(this, tr("Choose path"), deckPathEdit->text());
+ const QString path = QFileDialog::getExistingDirectory(this, tr("Choose path"), deckPathEdit->text());
if (path.isEmpty())
return;
@@ -281,7 +281,7 @@ void GeneralSettingsPage::deckPathButtonClicked()
void GeneralSettingsPage::filtersPathButtonClicked()
{
- QString path = QFileDialog::getExistingDirectory(this, tr("Choose path"), filtersPathEdit->text());
+ const QString path = QFileDialog::getExistingDirectory(this, tr("Choose path"), filtersPathEdit->text());
if (path.isEmpty())
return;
@@ -291,7 +291,7 @@ void GeneralSettingsPage::filtersPathButtonClicked()
void GeneralSettingsPage::replaysPathButtonClicked()
{
- QString path = QFileDialog::getExistingDirectory(this, tr("Choose path"), replaysPathEdit->text());
+ const QString path = QFileDialog::getExistingDirectory(this, tr("Choose path"), replaysPathEdit->text());
if (path.isEmpty())
return;
@@ -301,7 +301,7 @@ void GeneralSettingsPage::replaysPathButtonClicked()
void GeneralSettingsPage::picsPathButtonClicked()
{
- QString path = QFileDialog::getExistingDirectory(this, tr("Choose path"), picsPathEdit->text());
+ const QString path = QFileDialog::getExistingDirectory(this, tr("Choose path"), picsPathEdit->text());
if (path.isEmpty())
return;
@@ -311,7 +311,7 @@ void GeneralSettingsPage::picsPathButtonClicked()
void GeneralSettingsPage::cardDatabasePathButtonClicked()
{
- QString path = QFileDialog::getOpenFileName(this, tr("Choose path"), cardDatabasePathEdit->text());
+ const QString path = QFileDialog::getOpenFileName(this, tr("Choose path"), cardDatabasePathEdit->text());
if (path.isEmpty())
return;
@@ -321,7 +321,7 @@ void GeneralSettingsPage::cardDatabasePathButtonClicked()
void GeneralSettingsPage::customCardDatabaseButtonClicked()
{
- QString path = QFileDialog::getExistingDirectory(this, tr("Choose path"), customCardDatabasePathEdit->text());
+ const QString path = QFileDialog::getExistingDirectory(this, tr("Choose path"), customCardDatabasePathEdit->text());
if (path.isEmpty())
return;
@@ -331,7 +331,7 @@ void GeneralSettingsPage::customCardDatabaseButtonClicked()
void GeneralSettingsPage::tokenDatabasePathButtonClicked()
{
- QString path = QFileDialog::getOpenFileName(this, tr("Choose path"), tokenDatabasePathEdit->text());
+ const QString path = QFileDialog::getOpenFileName(this, tr("Choose path"), tokenDatabasePathEdit->text());
if (path.isEmpty())
return;
@@ -393,16 +393,16 @@ void GeneralSettingsPage::retranslateUi()
const auto &settings = SettingsCache::instance();
- QDate lastCheckDate = settings.getLastCardUpdateCheck();
- int daysAgo = lastCheckDate.daysTo(QDate::currentDate());
+ const QDate lastCheckDate = settings.getLastCardUpdateCheck();
+ const int daysAgo = lastCheckDate.daysTo(QDate::currentDate());
lastCardUpdateCheckDateLabel.setText(
tr("Last update check on %1 (%2 days ago)").arg(lastCheckDate.toString()).arg(daysAgo));
// We can't change the strings after they're put into the QComboBox, so this is our workaround
- int oldIndex = updateReleaseChannelBox.currentIndex();
+ const int oldIndex = updateReleaseChannelBox.currentIndex();
updateReleaseChannelBox.clear();
- for (ReleaseChannel *chan : settings.getUpdateReleaseChannels()) {
+ for (const ReleaseChannel *chan : settings.getUpdateReleaseChannels()) {
updateReleaseChannelBox.addItem(tr(chan->getName().toUtf8()));
}
updateReleaseChannelBox.setCurrentIndex(oldIndex);
@@ -410,10 +410,10 @@ void GeneralSettingsPage::retranslateUi()
AppearanceSettingsPage::AppearanceSettingsPage()
{
- SettingsCache &settings = SettingsCache::instance();
+ const SettingsCache &settings = SettingsCache::instance();
// Theme settings
- QString themeName = SettingsCache::instance().getThemeName();
+ const QString themeName = SettingsCache::instance().getThemeName();
QStringList themeDirs = themeManager->getAvailableThemes().keys();
for (int i = 0; i < themeDirs.size(); i++) {
@@ -429,15 +429,15 @@ AppearanceSettingsPage::AppearanceSettingsPage()
homeTabBackgroundSourceBox.addItem(QObject::tr(entry.trKey), QVariant::fromValue(entry.type));
}
- QString homeTabBackgroundSource = SettingsCache::instance().getHomeTabBackgroundSource();
- int homeTabBackgroundSourceId =
+ const QString homeTabBackgroundSource = SettingsCache::instance().getHomeTabBackgroundSource();
+ const int homeTabBackgroundSourceId =
homeTabBackgroundSourceBox.findData(BackgroundSources::fromId(homeTabBackgroundSource));
if (homeTabBackgroundSourceId != -1) {
homeTabBackgroundSourceBox.setCurrentIndex(homeTabBackgroundSourceId);
}
connect(&homeTabBackgroundSourceBox, QOverload::of(&QComboBox::currentIndexChanged), this, [this]() {
- auto type = homeTabBackgroundSourceBox.currentData().value();
+ const auto type = homeTabBackgroundSourceBox.currentData().value();
SettingsCache::instance().setHomeTabBackgroundSource(BackgroundSources::toId(type));
});
@@ -545,7 +545,7 @@ AppearanceSettingsPage::AppearanceSettingsPage()
connect(pushButton, &QPushButton::clicked, this, [index, this]() {
auto &cardCounterSettings = SettingsCache::instance().cardCounters();
- auto newColor = QColorDialog::getColor(cardCounterSettings.color(index), this);
+ const auto newColor = QColorDialog::getColor(cardCounterSettings.color(index), this);
if (!newColor.isValid())
return;
@@ -555,8 +555,8 @@ AppearanceSettingsPage::AppearanceSettingsPage()
auto *colorName = new QLabel;
cardCounterNames.append(colorName);
- int row = index / 3;
- int column = 2 * (index % 3);
+ const int row = index / 3;
+ const int column = 2 * (index % 3);
cardCounterColorsLayout->addWidget(pushButton, row, column);
cardCounterColorsLayout->addWidget(colorName, row, column + 1);
@@ -628,14 +628,14 @@ AppearanceSettingsPage::AppearanceSettingsPage()
void AppearanceSettingsPage::themeBoxChanged(int index)
{
- QStringList themeDirs = themeManager->getAvailableThemes().keys();
+ const QStringList themeDirs = themeManager->getAvailableThemes().keys();
if (index >= 0 && index < themeDirs.count())
SettingsCache::instance().setThemeName(themeDirs.at(index));
}
void AppearanceSettingsPage::openThemeLocation()
{
- QString dir = SettingsCache::instance().getThemesPath();
+ const QString dir = SettingsCache::instance().getThemesPath();
QDir dirDir = dir;
dirDir.cdUp();
// open if dir exists, create if parent dir does exist
@@ -673,7 +673,7 @@ void AppearanceSettingsPage::overrideAllCardArtWithPersonalPreferenceToggled(QT_
"Are you sure you would like to disable this feature?");
}
- QMessageBox::StandardButton result =
+ const QMessageBox::StandardButton result =
QMessageBox::question(this, tr("Confirm Change"), message, QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::Yes) {
@@ -747,7 +747,7 @@ void AppearanceSettingsPage::retranslateUi()
cardCountersGroupBox->setTitle(tr("Card counters"));
- auto &cardCounterSettings = SettingsCache::instance().cardCounters();
+ const auto &cardCounterSettings = SettingsCache::instance().cardCounters();
for (int index = 0; index < cardCounterNames.size(); ++index) {
cardCounterNames[index]->setText(tr("Counter %1").arg(cardCounterSettings.displayName(index)));
}
@@ -1059,17 +1059,17 @@ DeckEditorSettingsPage::DeckEditorSettingsPage()
networkRedirectCacheTtlEdit.setSingleStep(1);
networkRedirectCacheTtlEdit.setValue(SettingsCache::instance().getRedirectCacheTtl());
- auto networkCacheLayout = new QHBoxLayout;
+ const auto networkCacheLayout = new QHBoxLayout;
networkCacheLayout->addStretch();
networkCacheLayout->addWidget(&networkCacheLabel);
networkCacheLayout->addWidget(&networkCacheEdit);
- auto networkRedirectCacheLayout = new QHBoxLayout;
+ const auto networkRedirectCacheLayout = new QHBoxLayout;
networkRedirectCacheLayout->addStretch();
networkRedirectCacheLayout->addWidget(&networkRedirectCacheTtlLabel);
networkRedirectCacheLayout->addWidget(&networkRedirectCacheTtlEdit);
- auto pixmapCacheLayout = new QHBoxLayout;
+ const auto pixmapCacheLayout = new QHBoxLayout;
pixmapCacheLayout->addStretch();
pixmapCacheLayout->addWidget(&pixmapCacheLabel);
pixmapCacheLayout->addWidget(&pixmapCacheEdit);
@@ -1135,7 +1135,7 @@ void DeckEditorSettingsPage::clearDownloadedPicsButtonClicked()
// These are not used anymore, but we don't delete them automatically, so
// we should do it here lest we leave pictures hanging around on users'
// machines.
- QString picsPath = SettingsCache::instance().getPicsPath() + "/downloadedPics/";
+ const QString picsPath = SettingsCache::instance().getPicsPath() + "/downloadedPics/";
QStringList dirs = QDir(picsPath).entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
bool outerSuccessRemove = true;
for (const auto &dir : dirs) {
@@ -1152,7 +1152,7 @@ void DeckEditorSettingsPage::clearDownloadedPicsButtonClicked()
}
if (innerSuccessRemove) {
- bool success = QDir(picsPath).rmdir(dir);
+ const bool success = QDir(picsPath).rmdir(dir);
if (!success) {
qInfo() << "Failed to remove inner directory" << picsPath;
} else {
@@ -1171,7 +1171,7 @@ void DeckEditorSettingsPage::clearDownloadedPicsButtonClicked()
void DeckEditorSettingsPage::actAddURL()
{
bool ok;
- QString msg = QInputDialog::getText(this, tr("Add URL"), tr("URL:"), QLineEdit::Normal, QString(), &ok);
+ const QString msg = QInputDialog::getText(this, tr("Add URL"), tr("URL:"), QLineEdit::Normal, QString(), &ok);
if (ok) {
urlList->addItem(msg);
storeSettings();
@@ -1189,9 +1189,9 @@ void DeckEditorSettingsPage::actRemoveURL()
void DeckEditorSettingsPage::actEditURL()
{
if (urlList->currentItem()) {
- QString oldText = urlList->currentItem()->text();
+ const QString oldText = urlList->currentItem()->text();
bool ok;
- QString msg = QInputDialog::getText(this, tr("Edit URL"), tr("URL:"), QLineEdit::Normal, oldText, &ok);
+ const QString msg = QInputDialog::getText(this, tr("Edit URL"), tr("URL:"), QLineEdit::Normal, oldText, &ok);
if (ok) {
urlList->currentItem()->setText(msg);
storeSettings();
@@ -1223,7 +1223,7 @@ void DeckEditorSettingsPage::updateSpoilers()
updateNowButton->setText(tr("Updating..."));
// Create a new SBU that will act as if the client was just reloaded
- auto *sbu = new SpoilerBackgroundUpdater();
+ const auto *sbu = new SpoilerBackgroundUpdater();
connect(sbu, &SpoilerBackgroundUpdater::spoilerCheckerDone, this, &DeckEditorSettingsPage::unlockSettings);
connect(sbu, &SpoilerBackgroundUpdater::spoilersUpdatedSuccessfully, this, &DeckEditorSettingsPage::unlockSettings);
}
@@ -1236,10 +1236,10 @@ void DeckEditorSettingsPage::unlockSettings()
QString DeckEditorSettingsPage::getLastUpdateTime()
{
- QString fileName = SettingsCache::instance().getSpoilerCardDatabasePath();
- QFileInfo fi(fileName);
+ const QString fileName = SettingsCache::instance().getSpoilerCardDatabasePath();
+ const QFileInfo fi(fileName);
QDir fileDir(fi.path());
- QFile file(fileName);
+ const QFile file(fileName);
if (file.exists()) {
return fi.lastModified().toString("MMM d, hh:mm");
@@ -1250,7 +1250,8 @@ QString DeckEditorSettingsPage::getLastUpdateTime()
void DeckEditorSettingsPage::spoilerPathButtonClicked()
{
- QString lsPath = QFileDialog::getExistingDirectory(this, tr("Choose path"), mpSpoilerSavePathLineEdit->text());
+ const QString lsPath =
+ QFileDialog::getExistingDirectory(this, tr("Choose path"), mpSpoilerSavePathLineEdit->text());
if (lsPath.isEmpty()) {
return;
}
@@ -1378,7 +1379,7 @@ MessagesSettingsPage::MessagesSettingsPage()
messageList = new QListWidget;
- int count = SettingsCache::instance().messages().getCount();
+ const int count = SettingsCache::instance().messages().getCount();
for (int i = 0; i < count; i++)
messageList->addItem(SettingsCache::instance().messages().getMessageAt(i));
@@ -1426,7 +1427,7 @@ MessagesSettingsPage::MessagesSettingsPage()
void MessagesSettingsPage::updateColor(const QString &value)
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
- QColor colorToSet = QColor::fromString("#" + value);
+ const QColor colorToSet = QColor::fromString("#" + value);
#else
QColor colorToSet;
colorToSet.setNamedColor("#" + value);
@@ -1440,7 +1441,7 @@ void MessagesSettingsPage::updateColor(const QString &value)
void MessagesSettingsPage::updateHighlightColor(const QString &value)
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
- QColor colorToSet = QColor::fromString("#" + value);
+ const QColor colorToSet = QColor::fromString("#" + value);
#else
QColor colorToSet;
colorToSet.setNamedColor("#" + value);
@@ -1488,7 +1489,7 @@ void MessagesSettingsPage::storeSettings()
void MessagesSettingsPage::actAdd()
{
bool ok;
- QString msg =
+ const QString msg =
getTextWithMax(this, tr("Add message"), tr("Message:"), QLineEdit::Normal, QString(), &ok, MAX_TEXT_LENGTH);
if (ok) {
messageList->addItem(msg);
@@ -1499,9 +1500,9 @@ void MessagesSettingsPage::actAdd()
void MessagesSettingsPage::actEdit()
{
if (messageList->currentItem()) {
- QString oldText = messageList->currentItem()->text();
+ const QString oldText = messageList->currentItem()->text();
bool ok;
- QString msg =
+ const QString msg =
getTextWithMax(this, tr("Edit message"), tr("Message:"), QLineEdit::Normal, oldText, &ok, MAX_TEXT_LENGTH);
if (ok) {
messageList->currentItem()->setText(msg);
@@ -1549,7 +1550,7 @@ SoundSettingsPage::SoundSettingsPage()
connect(&soundEnabledCheckBox, &QCheckBox::QT_STATE_CHANGED, &SettingsCache::instance(),
&SettingsCache::setSoundEnabled);
- QString themeName = SettingsCache::instance().getSoundThemeName();
+ const QString themeName = SettingsCache::instance().getSoundThemeName();
QStringList themeDirs = soundEngine->getAvailableThemes().keys();
for (int i = 0; i < themeDirs.size(); i++) {
@@ -1602,7 +1603,7 @@ SoundSettingsPage::SoundSettingsPage()
void SoundSettingsPage::themeBoxChanged(int index)
{
- QStringList themeDirs = soundEngine->getAvailableThemes().keys();
+ const QStringList themeDirs = soundEngine->getAvailableThemes().keys();
if (index >= 0 && index < themeDirs.count())
SettingsCache::instance().setSoundThemeName(themeDirs.at(index));
}
@@ -1702,8 +1703,8 @@ void ShortcutSettingsPage::currentItemChanged(const QString &key)
currentActionName->setText("");
editTextBox->setShortcutName("");
} else {
- QString group = SettingsCache::instance().shortcuts().getShortcut(key).getGroupName();
- QString action = SettingsCache::instance().shortcuts().getShortcut(key).getName();
+ const QString group = SettingsCache::instance().shortcuts().getShortcut(key).getGroupName();
+ const QString action = SettingsCache::instance().shortcuts().getShortcut(key).getName();
currentActionGroupName->setText(group);
currentActionName->setText(action);
editTextBox->setShortcutName(key);
@@ -1755,7 +1756,7 @@ static QScrollArea *makeScrollable(QWidget *widget)
DlgSettings::DlgSettings(QWidget *parent) : QDialog(parent)
{
- auto rec = QGuiApplication::primaryScreen()->availableGeometry();
+ const auto rec = QGuiApplication::primaryScreen()->availableGeometry();
this->setMinimumSize(qMin(700, rec.width()), qMin(700, rec.height()));
connect(&SettingsCache::instance(), &SettingsCache::langChanged, this, &DlgSettings::updateLanguage);
@@ -1865,7 +1866,7 @@ void DlgSettings::closeEvent(QCloseEvent *event)
{
bool showLoadError = true;
QString loadErrorMessage = tr("Unknown Error loading card database");
- LoadStatus loadStatus = CardDatabaseManager::getInstance()->getLoadStatus();
+ const LoadStatus loadStatus = CardDatabaseManager::getInstance()->getLoadStatus();
qCInfo(DlgSettingsLog) << "Card Database load status: " << loadStatus;
switch (loadStatus) {
case Ok:
diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_startup_card_check.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_startup_card_check.cpp
index ac1922a9d..40abb7fb1 100644
--- a/cockatrice/src/interface/widgets/dialogs/dlg_startup_card_check.cpp
+++ b/cockatrice/src/interface/widgets/dialogs/dlg_startup_card_check.cpp
@@ -10,8 +10,8 @@ DlgStartupCardCheck::DlgStartupCardCheck(QWidget *parent) : QDialog(parent)
layout = new QVBoxLayout(this);
- QDate lastCheckDate = SettingsCache::instance().getLastCardUpdateCheck();
- int daysAgo = lastCheckDate.daysTo(QDate::currentDate());
+ const QDate lastCheckDate = SettingsCache::instance().getLastCardUpdateCheck();
+ const int daysAgo = lastCheckDate.daysTo(QDate::currentDate());
instructionLabel = new QLabel(
tr("It has been more than %2 days since you last checked your card database for updates.\nChoose how you would "
diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_tip_of_the_day.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_tip_of_the_day.cpp
index 0197d3dbf..9f6005933 100644
--- a/cockatrice/src/interface/widgets/dialogs/dlg_tip_of_the_day.cpp
+++ b/cockatrice/src/interface/widgets/dialogs/dlg_tip_of_the_day.cpp
@@ -19,7 +19,7 @@
DlgTipOfTheDay::DlgTipOfTheDay(QWidget *parent) : QDialog(parent)
{
successfulInit = false;
- QString xmlPath = "theme:tips/tips_of_the_day.xml";
+ const QString xmlPath = "theme:tips/tips_of_the_day.xml";
tipDatabase = new TipsOfTheDay(xmlPath, this);
if (tipDatabase->rowCount() == 0) {
@@ -42,7 +42,7 @@ DlgTipOfTheDay::DlgTipOfTheDay(QWidget *parent) : QDialog(parent)
tipNumber = new QLabel();
tipNumber->setAlignment(Qt::AlignCenter);
- QList seenTips = SettingsCache::instance().getSeenTips();
+ const QList seenTips = SettingsCache::instance().getSeenTips();
newTipsAvailable = false;
currentTip = 0;
for (int i = 0; i < tipDatabase->rowCount(); i++) {
@@ -137,7 +137,7 @@ void DlgTipOfTheDay::updateTip(int tipId)
SettingsCache::instance().setSeenTips(seenTips);
}
- TipOfTheDay tip = tipDatabase->getTip(tipId);
+ const TipOfTheDay tip = tipDatabase->getTip(tipId);
titleText = tip.getTitle();
contentText = tip.getContent();
imagePath = tip.getImagePath();
@@ -150,8 +150,8 @@ void DlgTipOfTheDay::updateTip(int tipId)
qCWarning(DlgTipOfTheDayLog) << "Image failed to load from" << imagePath;
imageLabel->clear();
} else {
- int h = std::min(std::max(imageLabel->height(), MIN_TIP_IMAGE_HEIGHT), MAX_TIP_IMAGE_HEIGHT);
- int w = std::min(std::max(imageLabel->width(), MIN_TIP_IMAGE_WIDTH), MAX_TIP_IMAGE_WIDTH);
+ const int h = std::min(std::max(imageLabel->height(), MIN_TIP_IMAGE_HEIGHT), MAX_TIP_IMAGE_HEIGHT);
+ const int w = std::min(std::max(imageLabel->width(), MIN_TIP_IMAGE_WIDTH), MAX_TIP_IMAGE_WIDTH);
imageLabel->setPixmap(image->scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation));
}
diff --git a/cockatrice/src/interface/widgets/dialogs/dlg_update.cpp b/cockatrice/src/interface/widgets/dialogs/dlg_update.cpp
index 19182c55b..c4ae147a3 100644
--- a/cockatrice/src/interface/widgets/dialogs/dlg_update.cpp
+++ b/cockatrice/src/interface/widgets/dialogs/dlg_update.cpp
@@ -108,7 +108,7 @@ void DlgUpdate::beginUpdateCheck()
progress->setMaximum(0);
setLabel(tr("Checking for updates..."));
- auto checker = new ClientUpdateChecker(this);
+ const auto checker = new ClientUpdateChecker(this);
connect(checker, &ClientUpdateChecker::finishedCheck, this, &DlgUpdate::finishedUpdateCheck);
connect(checker, &ClientUpdateChecker::error, this, &DlgUpdate::updateCheckError);
checker->check();
diff --git a/cockatrice/src/interface/widgets/dialogs/tip_of_the_day.cpp b/cockatrice/src/interface/widgets/dialogs/tip_of_the_day.cpp
index 94996e975..9289a4cdc 100644
--- a/cockatrice/src/interface/widgets/dialogs/tip_of_the_day.cpp
+++ b/cockatrice/src/interface/widgets/dialogs/tip_of_the_day.cpp
@@ -76,7 +76,7 @@ QVariant TipsOfTheDay::data(const QModelIndex &index, int /*role*/) const
if (!index.isValid() || index.row() >= tipList->size() || index.column() >= TIPDDBMODEL_COLUMNS)
return QVariant();
- TipOfTheDay tip = tipList->at(index.row());
+ const TipOfTheDay tip = tipList->at(index.row());
switch (index.column()) {
case TitleColumn:
return tip.getTitle();
diff --git a/cockatrice/src/interface/widgets/general/display/banner_widget.cpp b/cockatrice/src/interface/widgets/general/display/banner_widget.cpp
index f03869a4d..beef0c80b 100644
--- a/cockatrice/src/interface/widgets/general/display/banner_widget.cpp
+++ b/cockatrice/src/interface/widgets/general/display/banner_widget.cpp
@@ -10,7 +10,7 @@
BannerWidget::BannerWidget(QWidget *parent, const QString &text, Qt::Orientation orientation, int transparency)
: QWidget(parent), gradientOrientation(orientation), transparency(qBound(0, transparency, 100))
{
- auto layout = new QHBoxLayout(this);
+ const auto layout = new QHBoxLayout(this);
iconLabel = new QLabel(this);
iconLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
@@ -82,7 +82,7 @@ void BannerWidget::paintEvent(QPaintEvent *event)
QPainter painter(this);
// Calculate alpha based on transparency percentage
- int alpha = (255 * transparency) / 100;
+ const int alpha = (255 * transparency) / 100;
// Determine gradient direction
QLinearGradient gradient;
diff --git a/cockatrice/src/interface/widgets/general/display/bar_widget.cpp b/cockatrice/src/interface/widgets/general/display/bar_widget.cpp
index 2194b6b03..6f37c1424 100644
--- a/cockatrice/src/interface/widgets/general/display/bar_widget.cpp
+++ b/cockatrice/src/interface/widgets/general/display/bar_widget.cpp
@@ -11,14 +11,14 @@ BarWidget::BarWidget(QString label, int value, int total, QColor barColor, QWidg
QSize BarWidget::sizeHint() const
{
- QFontMetrics metrics(font());
- int labelHeight = metrics.height();
- int valueHeight = metrics.height();
+ const QFontMetrics metrics(font());
+ const int labelHeight = metrics.height();
+ const int valueHeight = metrics.height();
// Calculate the height dynamically based on the total
- int barHeight = (total > 0) ? (value * 200 / total) : 20; // Scale height proportionally
- int totalHeight = barHeight + labelHeight + valueHeight + 30; // Extra space for text
- return QSize(60, totalHeight); // Allow width to expand
+ const int barHeight = (total > 0) ? (value * 200 / total) : 20; // Scale height proportionally
+ const int totalHeight = barHeight + labelHeight + valueHeight + 30; // Extra space for text
+ return QSize(60, totalHeight); // Allow width to expand
}
void BarWidget::paintEvent(QPaintEvent *event)
@@ -26,13 +26,13 @@ void BarWidget::paintEvent(QPaintEvent *event)
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
- int widgetWidth = width();
- int widgetHeight = height();
+ const int widgetWidth = width();
+ const int widgetHeight = height();
// Calculate bar dimensions
- int barWidth = widgetWidth * 0.8; // Use 80% of the available width
- int fullBarHeight = widgetHeight - 40; // Leave space for labels
- int valueBarHeight = (total > 0) ? (value * fullBarHeight / total) : 0;
+ const int barWidth = widgetWidth * 0.8; // Use 80% of the available width
+ const int fullBarHeight = widgetHeight - 40; // Leave space for labels
+ const int valueBarHeight = (total > 0) ? (value * fullBarHeight / total) : 0;
// Draw full bar background (gray)
painter.setBrush(QColor(200, 200, 200));
@@ -44,12 +44,12 @@ void BarWidget::paintEvent(QPaintEvent *event)
// Draw the CMC label
painter.setPen(Qt::white);
- QRect textRect(0, widgetHeight - 30, widgetWidth, 20);
+ const QRect textRect(0, widgetHeight - 30, widgetWidth, 20);
painter.drawText(textRect, Qt::AlignCenter, label);
// Draw the value count
painter.setPen(Qt::black);
- QRect valueRect(0, 10, widgetWidth, 20);
+ const QRect valueRect(0, 10, widgetWidth, 20);
painter.drawText(valueRect, Qt::AlignCenter, QString::number(value));
(void)event; // Suppress unused parameter warning
diff --git a/cockatrice/src/interface/widgets/general/display/dynamic_font_size_label.cpp b/cockatrice/src/interface/widgets/general/display/dynamic_font_size_label.cpp
index ed4db1fd3..f76e0ed45 100644
--- a/cockatrice/src/interface/widgets/general/display/dynamic_font_size_label.cpp
+++ b/cockatrice/src/interface/widgets/general/display/dynamic_font_size_label.cpp
@@ -21,7 +21,7 @@ void DynamicFontSizeLabel::paintEvent(QPaintEvent *event)
// timer.start();
QFont newFont = font();
- float fontSize = getWidgetMaximumFontSize(this, this->text());
+ const float fontSize = getWidgetMaximumFontSize(this, this->text());
newFont.setPointSizeF(fontSize);
setFont(newFont);
// qDebug() << "Font size set to" << fontSize;
@@ -70,7 +70,7 @@ float DynamicFontSizeLabel::getWidgetMaximumFontSize(QWidget *widget, const QStr
QFontMetricsF fm(font);
/* Check if widget is QLabel */
- QLabel *label = qobject_cast(widget);
+ const QLabel *label = qobject_cast(widget);
if (label) {
newFontSizeRect =
fm.boundingRect(widgetRect, (label->wordWrap() ? Qt::TextWordWrap : 0) | label->alignment(), text);
diff --git a/cockatrice/src/interface/widgets/general/display/dynamic_font_size_push_button.cpp b/cockatrice/src/interface/widgets/general/display/dynamic_font_size_push_button.cpp
index fce4512e8..d80af10b1 100644
--- a/cockatrice/src/interface/widgets/general/display/dynamic_font_size_push_button.cpp
+++ b/cockatrice/src/interface/widgets/general/display/dynamic_font_size_push_button.cpp
@@ -16,7 +16,7 @@ void DynamicFontSizePushButton::paintEvent(QPaintEvent *event)
// Adjust the font size dynamically based on the text
QFont newFont = font();
- float fontSize = DynamicFontSizeLabel::getWidgetMaximumFontSize(this, this->text());
+ const float fontSize = DynamicFontSizeLabel::getWidgetMaximumFontSize(this, this->text());
newFont.setPointSizeF(fontSize);
setFont(newFont);
diff --git a/cockatrice/src/interface/widgets/general/display/percent_bar_widget.cpp b/cockatrice/src/interface/widgets/general/display/percent_bar_widget.cpp
index 3726dd061..5d6db211c 100644
--- a/cockatrice/src/interface/widgets/general/display/percent_bar_widget.cpp
+++ b/cockatrice/src/interface/widgets/general/display/percent_bar_widget.cpp
@@ -10,7 +10,7 @@ void PercentBarWidget::paintEvent(QPaintEvent *event)
Q_UNUSED(event);
QPainter painter(this);
- QRect rect = this->rect();
+ const QRect rect = this->rect();
const int midX = rect.width() / 2;
const int height = rect.height();
@@ -40,7 +40,7 @@ void PercentBarWidget::paintEvent(QPaintEvent *event)
const int tickHeight = 4;
for (int percent = -100; percent <= 100; percent += 10) {
- int x = midX + static_cast((percent / 100.0) * halfWidth);
+ const int x = midX + static_cast((percent / 100.0) * halfWidth);
painter.drawLine(x, height - tickHeight, x, height);
}
}
diff --git a/cockatrice/src/interface/widgets/general/display/shadow_background_label.cpp b/cockatrice/src/interface/widgets/general/display/shadow_background_label.cpp
index fbca8df8d..933ca1662 100644
--- a/cockatrice/src/interface/widgets/general/display/shadow_background_label.cpp
+++ b/cockatrice/src/interface/widgets/general/display/shadow_background_label.cpp
@@ -52,7 +52,7 @@ void ShadowBackgroundLabel::paintEvent(QPaintEvent *event)
// Adjust the rectangle to account for margins.
QRect adjustedRect = this->rect();
- int margin = contentsMargins().left(); // Assuming equal margins.
+ const int margin = contentsMargins().left(); // Assuming equal margins.
adjustedRect.adjust(margin, margin, -margin, -margin);
// Draw a rounded rectangle with a corner radius of 5.
diff --git a/cockatrice/src/interface/widgets/general/home_styled_button.cpp b/cockatrice/src/interface/widgets/general/home_styled_button.cpp
index 07c9894c1..455dff220 100644
--- a/cockatrice/src/interface/widgets/general/home_styled_button.cpp
+++ b/cockatrice/src/interface/widgets/general/home_styled_button.cpp
@@ -92,9 +92,9 @@ void HomeStyledButton::paintEvent(QPaintEvent *event)
font.setBold(true);
painter.setFont(font);
- QFontMetrics fm(font);
- QSize textSize = fm.size(Qt::TextSingleLine, this->text());
- QPointF center((width() - textSize.width()) / 2.0, (height() + textSize.height() / 2.0) / 2.0);
+ const QFontMetrics fm(font);
+ const QSize textSize = fm.size(Qt::TextSingleLine, this->text());
+ const QPointF center((width() - textSize.width()) / 2.0, (height() + textSize.height() / 2.0) / 2.0);
QPainterPath path;
path.addText(center, font, this->text());
diff --git a/cockatrice/src/interface/widgets/general/home_widget.cpp b/cockatrice/src/interface/widgets/general/home_widget.cpp
index cbf53ee4f..ac7caf30e 100644
--- a/cockatrice/src/interface/widgets/general/home_widget.cpp
+++ b/cockatrice/src/interface/widgets/general/home_widget.cpp
@@ -57,7 +57,7 @@ void HomeWidget::initializeBackgroundFromSource()
return;
}
- auto backgroundSourceType = BackgroundSources::fromId(SettingsCache::instance().getHomeTabBackgroundSource());
+ const auto backgroundSourceType = BackgroundSources::fromId(SettingsCache::instance().getHomeTabBackgroundSource());
cardChangeTimer->stop();
@@ -80,7 +80,7 @@ void HomeWidget::initializeBackgroundFromSource()
void HomeWidget::updateRandomCard()
{
- auto backgroundSourceType = BackgroundSources::fromId(SettingsCache::instance().getHomeTabBackgroundSource());
+ const auto backgroundSourceType = BackgroundSources::fromId(SettingsCache::instance().getHomeTabBackgroundSource());
ExactCard newCard;
@@ -95,7 +95,7 @@ void HomeWidget::updateRandomCard()
break;
case BackgroundSources::DeckFileArt:
QList cardRefs = backgroundSourceDeck->getDeckList()->getCardRefList();
- ExactCard oldCard = backgroundSourceCard->getCard();
+ const ExactCard oldCard = backgroundSourceCard->getCard();
if (!cardRefs.empty()) {
if (cardRefs.size() == 1) {
@@ -103,7 +103,7 @@ void HomeWidget::updateRandomCard()
} else {
// Keep picking until different
do {
- int idx = QRandomGenerator::global()->bounded(cardRefs.size());
+ const int idx = QRandomGenerator::global()->bounded(cardRefs.size());
newCard = CardDatabaseManager::query()->getCard(cardRefs.at(idx));
} while (newCard == oldCard);
}
@@ -180,26 +180,26 @@ QGroupBox *HomeWidget::createButtons()
connectButton = new HomeStyledButton("Connect/Play", gradientColors);
boxLayout->addWidget(connectButton);
- auto visualDeckEditorButton = new HomeStyledButton(tr("Create New Deck"), gradientColors);
+ const auto visualDeckEditorButton = new HomeStyledButton(tr("Create New Deck"), gradientColors);
connect(visualDeckEditorButton, &QPushButton::clicked, tabSupervisor,
[this] { tabSupervisor->openDeckInNewTab(nullptr); });
boxLayout->addWidget(visualDeckEditorButton);
- auto visualDeckStorageButton = new HomeStyledButton(tr("Browse Decks"), gradientColors);
+ const auto visualDeckStorageButton = new HomeStyledButton(tr("Browse Decks"), gradientColors);
connect(visualDeckStorageButton, &QPushButton::clicked, tabSupervisor,
[this] { tabSupervisor->actTabVisualDeckStorage(true); });
boxLayout->addWidget(visualDeckStorageButton);
- auto visualDatabaseDisplayButton = new HomeStyledButton(tr("Browse Card Database"), gradientColors);
+ const auto visualDatabaseDisplayButton = new HomeStyledButton(tr("Browse Card Database"), gradientColors);
connect(visualDatabaseDisplayButton, &QPushButton::clicked, tabSupervisor,
&TabSupervisor::addVisualDatabaseDisplayTab);
boxLayout->addWidget(visualDatabaseDisplayButton);
- auto edhrecButton = new HomeStyledButton(tr("Browse EDHRec"), gradientColors);
+ const auto edhrecButton = new HomeStyledButton(tr("Browse EDHRec"), gradientColors);
connect(edhrecButton, &QPushButton::clicked, tabSupervisor, &TabSupervisor::addEdhrecMainTab);
boxLayout->addWidget(edhrecButton);
- auto replaybutton = new HomeStyledButton(tr("View Replays"), gradientColors);
+ const auto replaybutton = new HomeStyledButton(tr("View Replays"), gradientColors);
connect(replaybutton, &QPushButton::clicked, tabSupervisor, [this] { tabSupervisor->actTabReplays(true); });
boxLayout->addWidget(replaybutton);
if (qobject_cast(tabSupervisor->parentWidget())) {
- auto exitButton = new HomeStyledButton(tr("Quit"), gradientColors);
+ const auto exitButton = new HomeStyledButton(tr("Quit"), gradientColors);
connect(exitButton, &QPushButton::clicked, qobject_cast(tabSupervisor->parentWidget()),
&MainWindow::actExit);
boxLayout->addWidget(exitButton);
@@ -294,18 +294,18 @@ void HomeWidget::paintEvent(QPaintEvent *event)
background = background.scaled(size(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
// Draw already-scaled background centered
- QSize widgetSize = size();
- QSize bgSize = background.size();
- QPoint topLeft((widgetSize.width() - bgSize.width()) / 2, (widgetSize.height() - bgSize.height()) / 2);
+ const QSize widgetSize = size();
+ const QSize bgSize = background.size();
+ const QPoint topLeft((widgetSize.width() - bgSize.width()) / 2, (widgetSize.height() - bgSize.height()) / 2);
painter.drawPixmap(topLeft, background);
// Draw translucent black overlay with rounded corners
- QRectF overlayRect(5, 5, width() - 10, height() - 10); // 5px inset
+ const QRectF overlayRect(5, 5, width() - 10, height() - 10); // 5px inset
QPainterPath roundedRectPath;
roundedRectPath.addRoundedRect(overlayRect, 20, 20); // 20px corner radius
- QColor semiTransparentBlack(0, 0, 0, static_cast(255 * 0.33)); // 33% opacity
+ const QColor semiTransparentBlack(0, 0, 0, static_cast(255 * 0.33)); // 33% opacity
painter.setRenderHint(QPainter::Antialiasing);
painter.fillPath(roundedRectPath, semiTransparentBlack);
diff --git a/cockatrice/src/interface/widgets/general/layout_containers/flow_widget.cpp b/cockatrice/src/interface/widgets/general/layout_containers/flow_widget.cpp
index 75ab56b34..62a3e4939 100644
--- a/cockatrice/src/interface/widgets/general/layout_containers/flow_widget.cpp
+++ b/cockatrice/src/interface/widgets/general/layout_containers/flow_widget.cpp
@@ -155,8 +155,8 @@ void FlowWidget::setMinimumSizeToMaxSizeHint()
// Iterate over all widgets in the flow layout to find the maximum sizeHint
for (int i = 0; i < flowLayout->count(); ++i) {
- if (QLayoutItem *item = flowLayout->itemAt(i)) {
- if (QWidget *widget = item->widget()) {
+ if (const QLayoutItem *item = flowLayout->itemAt(i)) {
+ if (const QWidget *widget = item->widget()) {
// Update the max size based on the sizeHint of each widget
QSize widgetSizeHint = widget->sizeHint();
maxSize.setWidth(qMax(maxSize.width(), widgetSizeHint.width()));
@@ -167,7 +167,7 @@ void FlowWidget::setMinimumSizeToMaxSizeHint()
// Set the minimum size for all widgets to the max sizeHint
for (int i = 0; i < flowLayout->count(); ++i) {
- if (QLayoutItem *item = flowLayout->itemAt(i)) {
+ if (const QLayoutItem *item = flowLayout->itemAt(i)) {
if (QWidget *widget = item->widget()) {
widget->setMinimumSize(maxSize);
}
diff --git a/cockatrice/src/interface/widgets/menus/deck_editor_menu.cpp b/cockatrice/src/interface/widgets/menus/deck_editor_menu.cpp
index 775efafbd..043baafb5 100644
--- a/cockatrice/src/interface/widgets/menus/deck_editor_menu.cpp
+++ b/cockatrice/src/interface/widgets/menus/deck_editor_menu.cpp
@@ -182,7 +182,7 @@ void DeckEditorMenu::retranslateUi()
void DeckEditorMenu::refreshShortcuts()
{
- ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
+ const ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aNewDeck->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aNewDeck"));
aLoadDeck->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aLoadDeck"));
aSaveDeck->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aSaveDeck"));
diff --git a/cockatrice/src/interface/widgets/printing_selector/card_amount_widget.cpp b/cockatrice/src/interface/widgets/printing_selector/card_amount_widget.cpp
index 416de18dc..e9fc31adf 100644
--- a/cockatrice/src/interface/widgets/printing_selector/card_amount_widget.cpp
+++ b/cockatrice/src/interface/widgets/printing_selector/card_amount_widget.cpp
@@ -89,8 +89,8 @@ void CardAmountWidget::showEvent(QShowEvent *event)
updateCardCount();
if (parentWidget()) {
- int width = parentWidget()->size().width();
- int height = parentWidget()->size().height();
+ const int width = parentWidget()->size().width();
+ const int height = parentWidget()->size().height();
incrementButton->setFixedSize(width / 3, height / 9);
decrementButton->setFixedSize(width / 3, height / 9);
@@ -145,10 +145,10 @@ void CardAmountWidget::addPrinting(const QString &zone)
recursiveExpand(newCardIndex);
// Check if a card without a providerId already exists in the deckModel and replace it, if so.
- QModelIndex find_card = deckModel->findCard(rootCard.getName(), zone);
- QString foundProviderId = deckModel->data(find_card.sibling(find_card.row(), 4), Qt::DisplayRole).toString();
+ const QModelIndex find_card = deckModel->findCard(rootCard.getName(), zone);
+ const QString foundProviderId = deckModel->data(find_card.sibling(find_card.row(), 4), Qt::DisplayRole).toString();
if (find_card.isValid() && find_card != newCardIndex && foundProviderId == "") {
- auto amount = deckModel->data(find_card, Qt::DisplayRole);
+ const auto amount = deckModel->data(find_card, Qt::DisplayRole);
for (int i = 0; i < amount.toInt() - 1; i++) {
deckModel->addCard(rootCard, zone);
}
@@ -239,8 +239,8 @@ void CardAmountWidget::offsetCountAtIndex(const QModelIndex &idx, int offset)
*/
void CardAmountWidget::decrementCardHelper(const QString &zone)
{
- QModelIndex idx = deckModel->findCard(rootCard.getName(), zone, rootCard.getPrinting().getUuid(),
- rootCard.getPrinting().getProperty("num"));
+ const QModelIndex idx = deckModel->findCard(rootCard.getName(), zone, rootCard.getPrinting().getUuid(),
+ rootCard.getPrinting().getProperty("num"));
offsetCountAtIndex(idx, -1);
deckEditor->setModified(true);
}
@@ -261,7 +261,7 @@ int CardAmountWidget::countCardsInZone(const QString &deckZone)
return -1;
}
- DeckList *decklist = deckModel->getDeckList();
+ const DeckList *decklist = deckModel->getDeckList();
if (!decklist) {
return -1;
}
@@ -269,7 +269,7 @@ int CardAmountWidget::countCardsInZone(const QString &deckZone)
QList cardsInDeck = decklist->getCardNodes({deckZone});
int count = 0;
- for (auto currentCard : cardsInDeck) {
+ for (const auto currentCard : cardsInDeck) {
for (int k = 0; k < currentCard->getNumber(); ++k) {
if (currentCard->getCardProviderId() == rootCard.getPrinting().getProperty("uuid")) {
count++;
diff --git a/cockatrice/src/interface/widgets/printing_selector/printing_selector.cpp b/cockatrice/src/interface/widgets/printing_selector/printing_selector.cpp
index a551ac290..73a17b371 100644
--- a/cockatrice/src/interface/widgets/printing_selector/printing_selector.cpp
+++ b/cockatrice/src/interface/widgets/printing_selector/printing_selector.cpp
@@ -167,7 +167,7 @@ void PrintingSelector::selectCard(const int changeBy)
}
// Get the current index of the selected item
- auto deckViewCurrentIndex = deckView->currentIndex();
+ const auto deckViewCurrentIndex = deckView->currentIndex();
auto nextIndex = deckViewCurrentIndex.siblingAtRow(deckViewCurrentIndex.row() + changeBy);
if (!nextIndex.isValid()) {
@@ -200,7 +200,7 @@ void PrintingSelector::getAllSetsForCurrentCard()
return;
}
- SetToPrintingsMap setMap = selectedCard->getSets();
+ const SetToPrintingsMap setMap = selectedCard->getSets();
const QList sortedPrintings = sortToolBar->sortSets(setMap);
const QList filteredPrintings =
sortToolBar->filterSets(sortedPrintings, searchBar->getSearchText().trimmed().toLower());
diff --git a/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_display_widget.cpp b/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_display_widget.cpp
index 0da80b522..c2aebbe1b 100644
--- a/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_display_widget.cpp
+++ b/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_display_widget.cpp
@@ -46,10 +46,10 @@ PrintingSelectorCardDisplayWidget::PrintingSelectorCardDisplayWidget(QWidget *pa
connect(overlayWidget, &PrintingSelectorCardOverlayWidget::cardPreferenceChanged, this,
[this]() { emit cardPreferenceChanged(); });
- CardSetPtr set = rootCard.getPrinting().getSet();
+ const CardSetPtr set = rootCard.getPrinting().getSet();
// Create the widget to display the set name and collector's number
- QString combinedSetName = QString(set->getLongName() + " (" + set->getShortName() + ")");
+ const QString combinedSetName = QString(set->getLongName() + " (" + set->getShortName() + ")");
setNameAndCollectorsNumberDisplayWidget = new SetNameAndCollectorsNumberDisplayWidget(
this, combinedSetName, rootCard.getPrinting().getProperty("num"), cardSizeSlider);
diff --git a/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_overlay_widget.cpp b/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_overlay_widget.cpp
index 5f3a44b30..f4b4aa077 100644
--- a/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_overlay_widget.cpp
+++ b/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_overlay_widget.cpp
@@ -168,8 +168,8 @@ void PrintingSelectorCardOverlayWidget::updatePinBadgeVisibility()
if (isPinned) {
// Keep a small margin that scales with the card size to avoid obscuring stuff.
const int margin = qMax(3, int(cardInfoPicture->width() * 0.03));
- int x = qMax(0, cardInfoPicture->width() - pinBadge->width() - margin);
- int y = margin * 3;
+ const int x = qMax(0, cardInfoPicture->width() - pinBadge->width() - margin);
+ const int y = margin * 3;
pinBadge->move(x, y);
pinBadge->raise();
}
@@ -218,14 +218,14 @@ void PrintingSelectorCardOverlayWidget::customMenu(QPoint point)
const auto &cardProviderId = rootCard.getPrinting().getUuid();
if (preferredProviderId.isEmpty() || preferredProviderId != cardProviderId) {
- auto *pinAction = preferenceMenu->addAction(tr("Pin Printing"));
+ const auto *pinAction = preferenceMenu->addAction(tr("Pin Printing"));
connect(pinAction, &QAction::triggered, this, [this] {
SettingsCache::instance().cardOverrides().setCardPreferenceOverride(
{rootCard.getName(), rootCard.getPrinting().getUuid()});
emit cardPreferenceChanged();
});
} else {
- auto *unpinAction = preferenceMenu->addAction(tr("Unpin Printing"));
+ const auto *unpinAction = preferenceMenu->addAction(tr("Unpin Printing"));
connect(unpinAction, &QAction::triggered, this, [this] {
SettingsCache::instance().cardOverrides().deleteCardPreferenceOverride(rootCard.getName());
emit cardPreferenceChanged();
@@ -241,7 +241,7 @@ void PrintingSelectorCardOverlayWidget::customMenu(QPoint point)
} else {
for (const CardRelation *rel : relatedCards) {
const QString &relatedCardName = rel->getName();
- QAction *relatedCard = relatedMenu->addAction(relatedCardName);
+ const QAction *relatedCard = relatedMenu->addAction(relatedCardName);
connect(relatedCard, &QAction::triggered, deckEditor, [this, relatedCardName] {
deckEditor->updateCard(CardDatabaseManager::query()->getCard({relatedCardName}));
deckEditor->showPrintingSelector();
diff --git a/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_sorting_widget.cpp b/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_sorting_widget.cpp
index af7cedbeb..3a6cdbc15 100644
--- a/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_sorting_widget.cpp
+++ b/cockatrice/src/interface/widgets/printing_selector/printing_selector_card_sorting_widget.cpp
@@ -219,8 +219,9 @@ QList PrintingSelectorCardSortingWidget::prependPrintingsInDeck(co
// Prepend sorted sets and remove them from the original list
for (const auto &pair : countList) {
- auto it = std::find_if(result.begin(), result.end(),
- [&pair](const PrintingInfo &item) { return item.getUuid() == pair.first.getUuid(); });
+ const auto it = std::find_if(result.begin(), result.end(), [&pair](const PrintingInfo &item) {
+ return item.getUuid() == pair.first.getUuid();
+ });
if (it != result.end()) {
result.erase(it); // Remove the matching entry
}
diff --git a/cockatrice/src/interface/widgets/printing_selector/set_name_and_collectors_number_display_widget.cpp b/cockatrice/src/interface/widgets/printing_selector/set_name_and_collectors_number_display_widget.cpp
index b1a6a61c1..791ac177d 100644
--- a/cockatrice/src/interface/widgets/printing_selector/set_name_and_collectors_number_display_widget.cpp
+++ b/cockatrice/src/interface/widgets/printing_selector/set_name_and_collectors_number_display_widget.cpp
@@ -90,12 +90,12 @@ void SetNameAndCollectorsNumberDisplayWidget::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event); // Ensure the parent class handles the event first
- QFontMetrics fm(setName->font());
- int labelWidth = setName->width(); // Get the current width of the QLabel
- QString text = setName->text(); // The text to be rendered
+ const QFontMetrics fm(setName->font());
+ const int labelWidth = setName->width(); // Get the current width of the QLabel
+ const QString text = setName->text(); // The text to be rendered
// Calculate the height required to render the text with word wrapping
- int textHeight = fm.boundingRect(0, 0, labelWidth, 0, Qt::TextWordWrap, text).height();
+ const int textHeight = fm.boundingRect(0, 0, labelWidth, 0, Qt::TextWordWrap, text).height();
// Set the minimum height to accommodate the required text height
setName->setMinimumHeight(textHeight);
diff --git a/cockatrice/src/interface/widgets/quick_settings/settings_button_widget.cpp b/cockatrice/src/interface/widgets/quick_settings/settings_button_widget.cpp
index 17087c8bc..4e3adae54 100644
--- a/cockatrice/src/interface/widgets/quick_settings/settings_button_widget.cpp
+++ b/cockatrice/src/interface/widgets/quick_settings/settings_button_widget.cpp
@@ -43,11 +43,12 @@ void SettingsButtonWidget::togglePopup()
} else {
popup->adjustSizeToFitScreen(); // Ensure proper size
- QSize popupSize = popup->size();
- QPoint buttonGlobalPos = button->mapToGlobal(QPoint(0, button->height()));
+ const QSize popupSize = popup->size();
+ const QPoint buttonGlobalPos = button->mapToGlobal(QPoint(0, button->height()));
- QScreen *screen = QApplication::screenAt(buttonGlobalPos);
- QRect screenGeom = screen ? screen->availableGeometry() : QApplication::primaryScreen()->availableGeometry();
+ const QScreen *screen = QApplication::screenAt(buttonGlobalPos);
+ const QRect screenGeom =
+ screen ? screen->availableGeometry() : QApplication::primaryScreen()->availableGeometry();
int x = buttonGlobalPos.x();
int y = buttonGlobalPos.y();
diff --git a/cockatrice/src/interface/widgets/quick_settings/settings_popup_widget.cpp b/cockatrice/src/interface/widgets/quick_settings/settings_popup_widget.cpp
index 9b2e55e0f..e065f6cb8 100644
--- a/cockatrice/src/interface/widgets/quick_settings/settings_popup_widget.cpp
+++ b/cockatrice/src/interface/widgets/quick_settings/settings_popup_widget.cpp
@@ -37,13 +37,13 @@ void SettingsPopupWidget::removeSettingsWidget(QWidget *toRemove) const
void SettingsPopupWidget::adjustSizeToFitScreen()
{
- QScreen *screen = QApplication::screenAt(this->pos());
- QRect screenGeom = screen ? screen->availableGeometry() : QApplication::primaryScreen()->availableGeometry();
- int maxHeight = screenGeom.height() / 2; // Limit height to 50% of screen
+ const QScreen *screen = QApplication::screenAt(this->pos());
+ const QRect screenGeom = screen ? screen->availableGeometry() : QApplication::primaryScreen()->availableGeometry();
+ const int maxHeight = screenGeom.height() / 2; // Limit height to 50% of screen
// Adjust the container widget's size hint to get the actual size of content
containerWidget->adjustSize();
- int contentHeight = containerWidget->sizeHint().height();
+ const int contentHeight = containerWidget->sizeHint().height();
// If content height exceeds maxHeight, we need to scroll
if (contentHeight > maxHeight) {
diff --git a/cockatrice/src/interface/widgets/replay/replay_timeline_widget.cpp b/cockatrice/src/interface/widgets/replay/replay_timeline_widget.cpp
index fb5936cae..416e81933 100644
--- a/cockatrice/src/interface/widgets/replay/replay_timeline_widget.cpp
+++ b/cockatrice/src/interface/widgets/replay/replay_timeline_widget.cpp
@@ -25,7 +25,7 @@ void ReplayTimelineWidget::setTimeline(const QList &_replayTimeline)
histogram.clear();
int binEndTime = BIN_LENGTH - 1;
int binValue = 0;
- for (int i : replayTimeline) {
+ for (const int i : replayTimeline) {
if (i > binEndTime) {
histogram.append(binValue);
if (binValue > maxBinValue)
@@ -51,7 +51,7 @@ void ReplayTimelineWidget::paintEvent(QPaintEvent * /* event */)
QPainter painter(this);
painter.drawRect(0, 0, width() - 1, height() - 1);
- qreal binWidth = (qreal)width() / histogram.size();
+ const qreal binWidth = (qreal)width() / histogram.size();
QPainterPath path;
path.moveTo(0, height() - 1);
for (int i = 0; i < histogram.size(); ++i)
@@ -61,14 +61,14 @@ void ReplayTimelineWidget::paintEvent(QPaintEvent * /* event */)
painter.fillPath(path, Qt::black);
const QColor barColor = QColor::fromHsv(120, 255, 255, 100);
- quint64 w = (quint64)(width() - 1) * (quint64)currentVisualTime / maxTime;
+ const quint64 w = (quint64)(width() - 1) * (quint64)currentVisualTime / maxTime;
painter.fillRect(0, 0, static_cast(w), height() - 1, barColor);
}
void ReplayTimelineWidget::mousePressEvent(QMouseEvent *event)
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
- int newTime = static_cast((qint64)maxTime * (qint64)event->position().x() / width());
+ const int newTime = static_cast((qint64)maxTime * (qint64)event->position().x() / width());
#else
int newTime = static_cast((qint64)maxTime * (qint64)event->x() / width());
#endif
diff --git a/cockatrice/src/interface/widgets/server/chat_view/chat_view.cpp b/cockatrice/src/interface/widgets/server/chat_view/chat_view.cpp
index c97d32d44..01e74fa5c 100644
--- a/cockatrice/src/interface/widgets/server/chat_view/chat_view.cpp
+++ b/cockatrice/src/interface/widgets/server/chat_view/chat_view.cpp
@@ -93,7 +93,7 @@ QTextCursor ChatView::prepareBlock(bool same)
void ChatView::appendHtml(const QString &html)
{
- bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
+ const bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
prepareBlock().insertHtml(html);
if (atBottom)
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
@@ -101,7 +101,7 @@ void ChatView::appendHtml(const QString &html)
void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold, QString optionalFontColor)
{
- bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
+ const bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
QString htmlText =
"" +
@@ -117,7 +117,7 @@ void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold,
void ChatView::appendCardTag(QTextCursor &cursor, const QString &cardName)
{
- QTextCharFormat oldFormat = cursor.charFormat();
+ const QTextCharFormat oldFormat = cursor.charFormat();
QTextCharFormat anchorFormat = oldFormat;
anchorFormat.setForeground(linkColor);
anchorFormat.setAnchor(true);
@@ -134,7 +134,7 @@ void ChatView::appendUrlTag(QTextCursor &cursor, QString url)
if (!url.contains("://"))
url.prepend("https://");
- QTextCharFormat oldFormat = cursor.charFormat();
+ const QTextCharFormat oldFormat = cursor.charFormat();
QTextCharFormat anchorFormat = oldFormat;
anchorFormat.setForeground(linkColor);
anchorFormat.setAnchor(true);
@@ -155,10 +155,10 @@ void ChatView::appendMessage(QString message,
const QString userName = QString::fromStdString(userInfo.name());
const UserLevelFlags userLevel = UserLevelFlags(userInfo.user_level());
- bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
+ const bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
// messageType should be Event_RoomSay::UserMessage though we don't actually check
- bool isUserMessage = !(userName.toLower() == "servatrice" || userName.isEmpty());
- bool sameSender = isUserMessage && userName == lastSender;
+ const bool isUserMessage = !(userName.toLower() == "servatrice" || userName.isEmpty());
+ const bool sameSender = isUserMessage && userName == lastSender;
QTextCursor cursor = prepareBlock(sameSender);
lastSender = userName;
@@ -189,7 +189,7 @@ void ChatView::appendMessage(QString message,
cursor.insertText(" ");
} else {
const int pixelSize = QFontInfo(cursor.charFormat().font()).pixelSize();
- bool isBuddy = userListProxy->isUserBuddy(userName);
+ const bool isBuddy = userListProxy->isUserBuddy(userName);
const QString privLevel = userInfo.has_privlevel() ? QString::fromStdString(userInfo.privlevel()) : "NONE";
cursor.insertImage(UserLevelPixmapGenerator::generatePixmap(pixelSize, userLevel, userInfo.pawn_colors(),
isBuddy, privLevel)
@@ -210,13 +210,13 @@ void ChatView::appendMessage(QString message,
defaultFormat.setFontWeight(QFont::Light);
defaultFormat.setFontItalic(true);
static const QRegularExpression userNameRegex("^(\\[[^\\]]*\\]\\s)(\\S+):\\s");
- auto match = userNameRegex.match(message);
+ const auto match = userNameRegex.match(message);
if (match.hasMatch()) {
cursor.setCharFormat(defaultFormat);
UserMessagePosition pos(cursor);
pos.relativePosition = match.captured(0).length(); // set message start
- auto before = match.captured(1);
- auto sentBy = match.captured(2);
+ const auto before = match.captured(1);
+ const auto sentBy = match.captured(2);
cursor.insertText(before); // add message timestamp
QTextCharFormat senderFormat(defaultFormat);
senderFormat.setAnchor(true);
@@ -235,7 +235,7 @@ void ChatView::appendMessage(QString message,
}
cursor.setCharFormat(defaultFormat);
- bool mentionEnabled = SettingsCache::instance().getChatMention();
+ const bool mentionEnabled = SettingsCache::instance().getChatMention();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
highlightedWords = SettingsCache::instance().getHighlightWords().split(' ', Qt::SkipEmptyParts);
#else
@@ -280,8 +280,8 @@ void ChatView::checkTag(QTextCursor &cursor, QString &message)
{
if (message.startsWith("[card]")) {
message = message.mid(6);
- int closeTagIndex = message.indexOf("[/card]");
- QString cardName = message.left(closeTagIndex);
+ const int closeTagIndex = message.indexOf("[/card]");
+ const QString cardName = message.left(closeTagIndex);
if (closeTagIndex == -1)
message.clear();
else
@@ -293,8 +293,8 @@ void ChatView::checkTag(QTextCursor &cursor, QString &message)
if (message.startsWith("[[")) {
message = message.mid(2);
- int closeTagIndex = message.indexOf("]]");
- QString cardName = message.left(closeTagIndex);
+ const int closeTagIndex = message.indexOf("]]");
+ const QString cardName = message.left(closeTagIndex);
if (closeTagIndex == -1)
message.clear();
else
@@ -306,8 +306,8 @@ void ChatView::checkTag(QTextCursor &cursor, QString &message)
if (message.startsWith("[url]")) {
message = message.mid(5);
- int closeTagIndex = message.indexOf("[/url]");
- QString url = message.left(closeTagIndex);
+ const int closeTagIndex = message.indexOf("[/url]");
+ const QString url = message.left(closeTagIndex);
if (closeTagIndex == -1)
message.clear();
else
@@ -325,9 +325,9 @@ void ChatView::checkMention(QTextCursor &cursor, QString &message, const QString
{
const static auto notALetterOrNumber = QRegularExpression("[^a-zA-Z0-9]");
- int firstSpace = message.indexOf(' ');
+ const int firstSpace = message.indexOf(' ');
QString fullMentionUpToSpaceOrEnd = (firstSpace == -1) ? message.mid(1) : message.mid(1, firstSpace - 1);
- QString mentionIntact = fullMentionUpToSpaceOrEnd;
+ const QString mentionIntact = fullMentionUpToSpaceOrEnd;
while (fullMentionUpToSpaceOrEnd.size()) {
const ServerInfo_User *onlineUser = userListProxy->getOnlineUser(fullMentionUpToSpaceOrEnd);
@@ -344,7 +344,7 @@ void ChatView::checkMention(QTextCursor &cursor, QString &message, const QString
message = message.mid(mention.size());
showSystemPopup(userName);
} else {
- QString correctUserName = QString::fromStdString(onlineUser->name());
+ const QString correctUserName = QString::fromStdString(onlineUser->name());
mentionFormatOtherUser.setAnchorHref("user://" + QString::number(onlineUser->user_level()) + "_" +
correctUserName);
cursor.insertText("@" + correctUserName, mentionFormatOtherUser);
@@ -389,13 +389,13 @@ void ChatView::checkWord(QTextCursor &cursor, QString &message)
{
// extract the first word
QString rest;
- QString fullWordUpToSpaceOrEnd = extractNextWord(message, rest);
+ const QString fullWordUpToSpaceOrEnd = extractNextWord(message, rest);
// check urls
if (fullWordUpToSpaceOrEnd.startsWith("http://", Qt::CaseInsensitive) ||
fullWordUpToSpaceOrEnd.startsWith("https://", Qt::CaseInsensitive) ||
fullWordUpToSpaceOrEnd.startsWith("www.", Qt::CaseInsensitive)) {
- QUrl qUrl(fullWordUpToSpaceOrEnd);
+ const QUrl qUrl(fullWordUpToSpaceOrEnd);
if (qUrl.isValid()) {
appendUrlTag(cursor, fullWordUpToSpaceOrEnd);
cursor.insertText(rest, defaultFormat);
@@ -425,7 +425,7 @@ QString ChatView::extractNextWord(QString &message, QString &rest)
{
// get the first next space and extract the word
QString word;
- int firstSpace = message.indexOf(' ');
+ const int firstSpace = message.indexOf(' ');
if (firstSpace == -1) {
word = message;
message.clear();
@@ -448,7 +448,7 @@ QString ChatView::extractNextWord(QString &message, QString &rest)
bool ChatView::isModeratorSendingGlobal(QFlags userLevelFlag, QString message)
{
- int userLevel = QString::number(userLevelFlag).toInt();
+ const int userLevel = QString::number(userLevelFlag).toInt();
QStringList getAttentionList;
getAttentionList << "/all"; // Send a message to all users
@@ -473,7 +473,7 @@ void ChatView::showSystemPopup(const QString &userName)
QColor ChatView::getCustomMentionColor()
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
- QColor customColor = QColor::fromString("#" + SettingsCache::instance().getChatMentionColor());
+ const QColor customColor = QColor::fromString("#" + SettingsCache::instance().getChatMentionColor());
#else
QColor customColor;
customColor.setNamedColor("#" + SettingsCache::instance().getChatMentionColor());
@@ -484,7 +484,7 @@ QColor ChatView::getCustomMentionColor()
QColor ChatView::getCustomHighlightColor()
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0))
- QColor customColor = QColor::fromString("#" + SettingsCache::instance().getChatMentionColor());
+ const QColor customColor = QColor::fromString("#" + SettingsCache::instance().getChatMentionColor());
#else
QColor customColor;
customColor.setNamedColor("#" + SettingsCache::instance().getChatMentionColor());
@@ -537,8 +537,8 @@ void ChatView::leaveEvent(QEvent * /*event*/)
QTextFragment ChatView::getFragmentUnderMouse(const QPoint &pos) const
{
- QTextCursor cursor(cursorForPosition(pos));
- QTextBlock block(cursor.block());
+ const QTextCursor cursor(cursorForPosition(pos));
+ const QTextBlock block(cursor.block());
QTextBlock::iterator it;
for (it = block.begin(); !(it.atEnd()); ++it) {
QTextFragment frag = it.fragment();
@@ -550,7 +550,7 @@ QTextFragment ChatView::getFragmentUnderMouse(const QPoint &pos) const
void ChatView::mouseMoveEvent(QMouseEvent *event)
{
- QString anchorHref = getFragmentUnderMouse(event->pos()).charFormat().anchorHref();
+ const QString anchorHref = getFragmentUnderMouse(event->pos()).charFormat().anchorHref();
if (!anchorHref.isEmpty()) {
const int delimiterIndex = anchorHref.indexOf("://");
if (delimiterIndex != -1) {
@@ -594,7 +594,7 @@ void ChatView::mousePressEvent(QMouseEvent *event)
const QString userName = hoveredContent.mid(delimiterIndex + 1);
switch (event->button()) {
case Qt::RightButton: {
- UserLevelFlags userLevel(hoveredContent.left(delimiterIndex).toInt());
+ const UserLevelFlags userLevel(hoveredContent.left(delimiterIndex).toInt());
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
userContextMenu->showContextMenu(event->globalPosition().toPoint(), userName, userLevel, this);
#else
diff --git a/cockatrice/src/interface/widgets/server/game_selector_quick_filter_toolbar.cpp b/cockatrice/src/interface/widgets/server/game_selector_quick_filter_toolbar.cpp
index c63b52450..1e94ca378 100644
--- a/cockatrice/src/interface/widgets/server/game_selector_quick_filter_toolbar.cpp
+++ b/cockatrice/src/interface/widgets/server/game_selector_quick_filter_toolbar.cpp
@@ -60,8 +60,8 @@ GameSelectorQuickFilterToolBar::GameSelectorQuickFilterToolBar(QWidget *parent,
QSet currentTypes = model->getGameTypeFilter();
if (currentTypes.size() == 1) {
- int typeId = *currentTypes.begin();
- int index = filterToFormatComboBox->findData(typeId);
+ const int typeId = *currentTypes.begin();
+ const int index = filterToFormatComboBox->findData(typeId);
if (index >= 0)
filterToFormatComboBox->setCurrentIndex(index);
} else {
@@ -70,7 +70,7 @@ GameSelectorQuickFilterToolBar::GameSelectorQuickFilterToolBar(QWidget *parent,
// Update proxy model on selection change
connect(filterToFormatComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, [this](int index) {
- QVariant data = filterToFormatComboBox->itemData(index);
+ const QVariant data = filterToFormatComboBox->itemData(index);
if (!data.isValid()) {
model->setGameTypeFilter({}); // empty = no filter
} else {
diff --git a/cockatrice/src/interface/widgets/server/games_model.cpp b/cockatrice/src/interface/widgets/server/games_model.cpp
index dfb41fd29..f0c484082 100644
--- a/cockatrice/src/interface/widgets/server/games_model.cpp
+++ b/cockatrice/src/interface/widgets/server/games_model.cpp
@@ -41,8 +41,8 @@ const QString GamesModel::getGameCreatedString(const int secs)
return tr(">1 day");
}
- QTime total = zeroTime.addSecs(secs);
- QTime totalRounded = total.addSecs(halfMinSecs); // round up
+ const QTime total = zeroTime.addSecs(secs);
+ const QTime totalRounded = total.addSecs(halfMinSecs); // round up
QString form;
int amount;
if (totalRounded.hour()) {
@@ -55,7 +55,7 @@ const QString GamesModel::getGameCreatedString(const int secs)
form = tr("%1%2 min", "short age in minutes", amount);
}
- for (int aggregate : {40, 20, 10, 5}) { // floor to values in this list
+ for (const int aggregate : {40, 20, 10, 5}) { // floor to values in this list
if (amount >= aggregate) {
return form.arg(">").arg(aggregate);
}
@@ -87,11 +87,11 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
switch (role) {
case Qt::DisplayRole: {
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
- auto then = QDateTime::fromSecsSinceEpoch(gameentry.start_time(), QTimeZone::UTC);
+ const auto then = QDateTime::fromSecsSinceEpoch(gameentry.start_time(), QTimeZone::UTC);
#else
auto then = QDateTime::fromSecsSinceEpoch(gameentry.start_time(), Qt::UTC);
#endif
- int secs = then.secsTo(QDateTime::currentDateTimeUtc());
+ const int secs = then.secsTo(QDateTime::currentDateTimeUtc());
return getGameCreatedString(secs);
}
case SORT_ROLE:
@@ -132,7 +132,7 @@ QVariant GamesModel::data(const QModelIndex &index, int role) const
case SORT_ROLE:
case Qt::DisplayRole: {
QStringList result;
- GameTypeMap gameTypeMap = gameTypes.value(gameentry.room_id());
+ const GameTypeMap gameTypeMap = gameTypes.value(gameentry.room_id());
for (int i = gameentry.game_types_size() - 1; i >= 0; --i)
result.append(gameTypeMap.value(gameentry.game_types(i)));
return result.join(", ");
@@ -333,7 +333,7 @@ void GamesProxyModel::setGameFilters(bool _hideBuddiesOnlyGames,
int GamesProxyModel::getNumFilteredGames() const
{
- auto *model = qobject_cast(sourceModel());
+ const auto *model = qobject_cast(sourceModel());
if (!model)
return 0;
@@ -401,7 +401,7 @@ void GamesProxyModel::saveFilterParameters(const QMap &allGameType
QMapIterator gameTypeIterator(allGameTypes);
while (gameTypeIterator.hasNext()) {
gameTypeIterator.next();
- bool enabled = gameTypeFilter.contains(gameTypeIterator.key());
+ const bool enabled = gameTypeFilter.contains(gameTypeIterator.key());
gameFilters.setGameTypeEnabled(gameTypeIterator.value(), enabled);
}
@@ -483,9 +483,9 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow) const
return false;
if (maxGameAge.isValid()) {
- QDateTime now = QDateTime::currentDateTimeUtc();
- qint64 signed_start_time = game.start_time(); // cast to 64 bit value to allow signed value
- QDateTime total = now.addSecs(-signed_start_time); // a 32 bit value would wrap at 2038-1-19
+ const QDateTime now = QDateTime::currentDateTimeUtc();
+ const qint64 signed_start_time = game.start_time(); // cast to 64 bit value to allow signed value
+ const QDateTime total = now.addSecs(-signed_start_time); // a 32 bit value would wrap at 2038-1-19
// games shouldn't have negative ages but we'll not filter them
// because qtime wraps after a day we consider all games older than a day to be too old
if (total.isValid() && total.date() >= epochDate && (total.date() > epochDate || total.time() > maxGameAge)) {
diff --git a/cockatrice/src/interface/widgets/server/handle_public_servers.cpp b/cockatrice/src/interface/widgets/server/handle_public_servers.cpp
index 6a8754a79..c970ab136 100644
--- a/cockatrice/src/interface/widgets/server/handle_public_servers.cpp
+++ b/cockatrice/src/interface/widgets/server/handle_public_servers.cpp
@@ -17,7 +17,7 @@ HandlePublicServers::HandlePublicServers(QObject *parent)
void HandlePublicServers::downloadPublicServers()
{
- QUrl url(QString(PUBLIC_SERVERS_JSON));
+ const QUrl url(QString(PUBLIC_SERVERS_JSON));
reply = nam->get(QNetworkRequest(url));
connect(reply, &QNetworkReply::finished, this, &HandlePublicServers::actFinishParsingDownloadedData);
}
@@ -25,7 +25,7 @@ void HandlePublicServers::downloadPublicServers()
void HandlePublicServers::actFinishParsingDownloadedData()
{
reply = dynamic_cast(sender());
- QNetworkReply::NetworkError errorCode = reply->error();
+ const QNetworkReply::NetworkError errorCode = reply->error();
if (errorCode == QNetworkReply::NoError) {
// Get current saved hosts
@@ -34,9 +34,9 @@ void HandlePublicServers::actFinishParsingDownloadedData()
// Downloaded data from GitHub
QJsonParseError parseError{};
- QJsonDocument jsonResponse = QJsonDocument::fromJson(reply->readAll(), &parseError);
+ const QJsonDocument jsonResponse = QJsonDocument::fromJson(reply->readAll(), &parseError);
if (parseError.error == QJsonParseError::NoError) {
- QVariantMap jsonMap = jsonResponse.toVariant().toMap();
+ const QVariantMap jsonMap = jsonResponse.toVariant().toMap();
updateServerINISettings(jsonMap);
} else {
qDebug() << "[PUBLIC SERVER HANDLER]"
diff --git a/cockatrice/src/interface/widgets/server/remote/remote_decklist_tree_widget.cpp b/cockatrice/src/interface/widgets/server/remote/remote_decklist_tree_widget.cpp
index 6ca680c3f..0f772b63a 100644
--- a/cockatrice/src/interface/widgets/server/remote/remote_decklist_tree_widget.cpp
+++ b/cockatrice/src/interface/widgets/server/remote/remote_decklist_tree_widget.cpp
@@ -30,7 +30,7 @@ void RemoteDeckList_TreeModel::DirectoryNode::clearTree()
QString RemoteDeckList_TreeModel::DirectoryNode::getPath() const
{
if (parent) {
- QString parentPath = parent->getPath();
+ const QString parentPath = parent->getPath();
if (parentPath.isEmpty())
return name;
else
@@ -63,7 +63,7 @@ RemoteDeckList_TreeModel::DirectoryNode *RemoteDeckList_TreeModel::DirectoryNode
RemoteDeckList_TreeModel::FileNode *RemoteDeckList_TreeModel::DirectoryNode::getNodeById(int id) const
{
for (int i = 0; i < size(); ++i) {
- DirectoryNode *node = dynamic_cast(at(i));
+ const DirectoryNode *node = dynamic_cast(at(i));
if (node) {
FileNode *result = node->getNodeById(id);
if (result)
@@ -80,7 +80,7 @@ RemoteDeckList_TreeModel::FileNode *RemoteDeckList_TreeModel::DirectoryNode::get
RemoteDeckList_TreeModel::RemoteDeckList_TreeModel(AbstractClient *_client, QObject *parent)
: QAbstractItemModel(parent), client(_client)
{
- QFileIconProvider fip;
+ const QFileIconProvider fip;
dirIcon = fip.icon(QFileIconProvider::Folder);
fileIcon = fip.icon(QFileIconProvider::File);
@@ -94,7 +94,7 @@ RemoteDeckList_TreeModel::~RemoteDeckList_TreeModel()
int RemoteDeckList_TreeModel::rowCount(const QModelIndex &parent) const
{
- DirectoryNode *node = getNode(parent);
+ const DirectoryNode *node = getNode(parent);
if (node)
return node->size();
else
@@ -114,9 +114,9 @@ QVariant RemoteDeckList_TreeModel::data(const QModelIndex &index, int role) cons
return QVariant();
Node *temp = static_cast(index.internalPointer());
- FileNode *file = dynamic_cast(temp);
+ const FileNode *file = dynamic_cast(temp);
if (!file) {
- DirectoryNode *node = dynamic_cast(temp);
+ const DirectoryNode *node = dynamic_cast(temp);
switch (role) {
case Qt::DisplayRole: {
switch (index.column()) {
@@ -184,7 +184,7 @@ QModelIndex RemoteDeckList_TreeModel::index(int row, int column, const QModelInd
if (!hasIndex(row, column, parent))
return QModelIndex();
- DirectoryNode *parentNode = getNode(parent);
+ const DirectoryNode *parentNode = getNode(parent);
if (row >= parentNode->size())
return QModelIndex();
@@ -252,7 +252,7 @@ RemoteDeckList_TreeModel::DirectoryNode *RemoteDeckList_TreeModel::addNamedFolde
void RemoteDeckList_TreeModel::removeNode(RemoteDeckList_TreeModel::Node *node)
{
- int ind = node->getParent()->indexOf(node);
+ const int ind = node->getParent()->indexOf(node);
beginRemoveRows(nodeToIndex(node->getParent()), ind, ind);
node->getParent()->removeAt(ind);
endRemoveRows();
diff --git a/cockatrice/src/interface/widgets/server/remote/remote_replay_list_tree_widget.cpp b/cockatrice/src/interface/widgets/server/remote/remote_replay_list_tree_widget.cpp
index 5152880d9..6df90e57d 100644
--- a/cockatrice/src/interface/widgets/server/remote/remote_replay_list_tree_widget.cpp
+++ b/cockatrice/src/interface/widgets/server/remote/remote_replay_list_tree_widget.cpp
@@ -32,7 +32,7 @@ void RemoteReplayList_TreeModel::MatchNode::updateMatchInfo(const ServerInfo_Rep
RemoteReplayList_TreeModel::RemoteReplayList_TreeModel(AbstractClient *_client, QObject *parent)
: QAbstractItemModel(parent), client(_client)
{
- QFileIconProvider fip;
+ const QFileIconProvider fip;
dirIcon = fip.icon(QFileIconProvider::Folder);
fileIcon = fip.icon(QFileIconProvider::File);
lockIcon = QPixmap("theme:icons/lock");
@@ -48,7 +48,7 @@ int RemoteReplayList_TreeModel::rowCount(const QModelIndex &parent) const
if (!parent.isValid())
return replayMatches.size();
- auto *matchNode = dynamic_cast(static_cast(parent.internalPointer()));
+ const auto *matchNode = dynamic_cast(static_cast(parent.internalPointer()));
if (matchNode)
return matchNode->size();
else
@@ -170,7 +170,7 @@ QModelIndex RemoteReplayList_TreeModel::index(int row, int column, const QModelI
if (!hasIndex(row, column, parent))
return QModelIndex();
- auto *matchNode = dynamic_cast(static_cast(parent.internalPointer()));
+ const auto *matchNode = dynamic_cast(static_cast(parent.internalPointer()));
if (matchNode) {
if (row >= matchNode->size())
return QModelIndex();
@@ -231,7 +231,7 @@ ServerInfo_ReplayMatch const *RemoteReplayList_TreeModel::getEnclosingReplayMatc
auto *node = dynamic_cast(static_cast(index.internalPointer()));
if (!node) {
- auto *_node = dynamic_cast(static_cast(index.internalPointer()));
+ const auto *_node = dynamic_cast(static_cast(index.internalPointer()));
if (!_node)
return nullptr;
return &_node->getParent()->getMatchInfo();
diff --git a/cockatrice/src/interface/widgets/server/user/user_context_menu.cpp b/cockatrice/src/interface/widgets/server/user/user_context_menu.cpp
index cb7d2eca9..22b06ac10 100644
--- a/cockatrice/src/interface/widgets/server/user/user_context_menu.cpp
+++ b/cockatrice/src/interface/widgets/server/user/user_context_menu.cpp
@@ -137,8 +137,8 @@ void UserContextMenu::warnUser_processGetWarningsListResponse(const Response &r)
{
const Response_WarnList &response = r.GetExtension(Response_WarnList::ext);
- QString user = QString::fromStdString(response.user_name()).simplified();
- QString clientid = QString::fromStdString(response.user_clientid()).simplified();
+ const QString user = QString::fromStdString(response.user_name()).simplified();
+ const QString clientid = QString::fromStdString(response.user_clientid()).simplified();
// The dialog needs to be non-modal in order to not block the event queue of the client.
auto *dlg = new WarningDialog(user, clientid, static_cast(parent()));
@@ -155,7 +155,7 @@ void UserContextMenu::warnUser_processGetWarningsListResponse(const Response &r)
void UserContextMenu::warnUser_processUserInfoResponse(const Response &resp)
{
const Response_GetUserInfo &response = resp.GetExtension(Response_GetUserInfo::ext);
- ServerInfo_User userInfo = response.user_info();
+ const ServerInfo_User userInfo = response.user_info();
Command_GetWarnList cmd;
cmd.set_user_name(userInfo.name());
@@ -278,7 +278,7 @@ void UserContextMenu::adjustMod_processUserResponse(const Response &resp, const
void UserContextMenu::banUser_dialogFinished()
{
- auto *dlg = static_cast(sender());
+ const auto *dlg = static_cast(sender());
Command_BanFromServer cmd;
cmd.set_user_name(dlg->getBanName().toStdString());
@@ -287,7 +287,7 @@ void UserContextMenu::banUser_dialogFinished()
cmd.set_reason(dlg->getReason().toStdString());
cmd.set_visible_reason(dlg->getVisibleReason().toStdString());
cmd.set_clientid(dlg->getBanId().toStdString());
- int removeAmount = dlg->getDeleteMessages();
+ const int removeAmount = dlg->getDeleteMessages();
if (removeAmount != 0) {
cmd.set_remove_messages(removeAmount);
}
@@ -297,7 +297,7 @@ void UserContextMenu::banUser_dialogFinished()
void UserContextMenu::warnUser_dialogFinished()
{
- auto *dlg = static_cast(sender());
+ const auto *dlg = static_cast(sender());
if (dlg->getName().isEmpty() || userListProxy->getOwnUsername().simplified().isEmpty())
return;
@@ -306,7 +306,7 @@ void UserContextMenu::warnUser_dialogFinished()
cmd.set_user_name(dlg->getName().toStdString());
cmd.set_reason(dlg->getReason().toStdString());
cmd.set_clientid(dlg->getWarnID().toStdString());
- int removeAmount = dlg->getDeleteMessages();
+ const int removeAmount = dlg->getDeleteMessages();
if (removeAmount != 0) {
cmd.set_remove_messages(removeAmount);
}
@@ -316,7 +316,7 @@ void UserContextMenu::warnUser_dialogFinished()
void UserContextMenu::updateAdminNotes_dialogFinished()
{
- auto *dlg = static_cast(sender());
+ const auto *dlg = static_cast(sender());
Command_UpdateAdminNotes cmd;
cmd.set_user_name(dlg->getName().toStdString());
diff --git a/cockatrice/src/interface/widgets/server/user/user_info_box.cpp b/cockatrice/src/interface/widgets/server/user/user_info_box.cpp
index 9ae4a42c2..87dd1c09b 100644
--- a/cockatrice/src/interface/widgets/server/user/user_info_box.cpp
+++ b/cockatrice/src/interface/widgets/server/user/user_info_box.cpp
@@ -110,7 +110,7 @@ void UserInfoBox::updateInfo(const ServerInfo_User &user)
nameLabel.setText(QString::fromStdString(user.name()));
realNameLabel2.setText(QString::fromStdString(user.real_name()));
- QString country = QString::fromStdString(user.country());
+ const QString country = QString::fromStdString(user.country());
if (country.length() != 0) {
countryLabel2.setPixmap(CountryPixmapGenerator::generatePixmap(13, country));
@@ -156,17 +156,17 @@ QString UserInfoBox::getAgeString(int ageSeconds)
return accountAgeString;
// secsSinceEpoch is in utc
- auto secsSinceEpoch = QDateTime::currentSecsSinceEpoch() - ageSeconds;
+ const auto secsSinceEpoch = QDateTime::currentSecsSinceEpoch() - ageSeconds;
// the date is in local time, fromSecsSinceEpoch expects a timestamp from utc and converts it to local time
- auto date = QDateTime::fromSecsSinceEpoch(secsSinceEpoch).date();
+ const auto date = QDateTime::fromSecsSinceEpoch(secsSinceEpoch).date();
if (!date.isValid())
return accountAgeString;
// now can be local time as the date is also local time
- auto now = QDate::currentDate();
- auto daysAndYears = getDaysAndYearsBetween(date, now);
+ const auto now = QDate::currentDate();
+ const auto daysAndYears = getDaysAndYearsBetween(date, now);
- QString dateString = QLocale().toString(date, QLocale::ShortFormat);
+ const QString dateString = QLocale().toString(date, QLocale::ShortFormat);
QString yearString;
if (daysAndYears.second > 0) {
yearString = tr("%n Year(s), ", "amount of years (only shown if more than 0)", daysAndYears.second);
@@ -200,7 +200,7 @@ void UserInfoBox::processResponse(const Response &r)
void UserInfoBox::actEdit()
{
- Command_GetUserInfo cmd;
+ const Command_GetUserInfo cmd;
PendingCommand *pend = client->prepareSessionCommand(cmd);
connect(pend, &PendingCommand::finished, this, &UserInfoBox::actEditInternal);
@@ -213,9 +213,9 @@ void UserInfoBox::actEditInternal(const Response &r)
const Response_GetUserInfo &response = r.GetExtension(Response_GetUserInfo::ext);
const ServerInfo_User &user = response.user_info();
- QString email = QString::fromStdString(user.email());
- QString country = QString::fromStdString(user.country());
- QString realName = QString::fromStdString(user.real_name());
+ const QString email = QString::fromStdString(user.email());
+ const QString country = QString::fromStdString(user.country());
+ const QString realName = QString::fromStdString(user.real_name());
DlgEditUser dlg(this, email, country, realName);
if (!dlg.exec())
@@ -227,7 +227,7 @@ void UserInfoBox::actEditInternal(const Response &r)
if (email != dlg.getEmail()) {
// real password is required to change email
bool ok = false;
- QString password =
+ const QString password =
getTextWithMax(this, tr("Enter Password"),
tr("Password verification is required in order to change your email address"),
QLineEdit::Password, "", &ok);
@@ -253,8 +253,8 @@ void UserInfoBox::actPassword()
if (!dlg.exec())
return;
- auto oldPassword = dlg.getOldPassword();
- auto newPassword = dlg.getNewPassword();
+ const auto oldPassword = dlg.getOldPassword();
+ const auto newPassword = dlg.getNewPassword();
if (client->getServerSupportsPasswordHash()) {
Command_RequestPasswordSalt cmd;
@@ -280,8 +280,8 @@ void UserInfoBox::changePassword(const QString &oldPassword, const QString &newP
Command_AccountPassword cmd;
cmd.set_old_password(oldPassword.toStdString());
if (client->getServerSupportsPasswordHash()) {
- auto passwordSalt = PasswordHasher::generateRandomSalt();
- QString hashedPassword = PasswordHasher::computeHash(newPassword, passwordSalt);
+ const auto passwordSalt = PasswordHasher::generateRandomSalt();
+ const QString hashedPassword = PasswordHasher::computeHash(newPassword, passwordSalt);
cmd.set_hashed_new_password(hashedPassword.toStdString());
} else {
cmd.set_new_password(newPassword.toStdString());
@@ -376,7 +376,7 @@ void UserInfoBox::resizeEvent(QResizeEvent *event)
if (hasAvatar) {
resizedPixmap = avatarPixmap.scaled(avatarPic.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
} else {
- int height = qMin(avatarPic.size().width(), avatarPic.size().height());
+ const int height = qMin(avatarPic.size().width(), avatarPic.size().height());
resizedPixmap = createDefaultAvatar(height, *currentUserInfo);
}
avatarPic.setPixmap(resizedPixmap);
diff --git a/cockatrice/src/interface/widgets/server/user/user_info_connection.cpp b/cockatrice/src/interface/widgets/server/user/user_info_connection.cpp
index 069e438a9..7392f5b65 100644
--- a/cockatrice/src/interface/widgets/server/user/user_info_connection.cpp
+++ b/cockatrice/src/interface/widgets/server/user/user_info_connection.cpp
@@ -25,16 +25,16 @@ QMap> UserConnection_Inf
ServersSettings &servers = SettingsCache::instance().servers();
- int size = servers.getValue("totalServers", "server", "server_details").toInt() + 1;
+ const int size = servers.getValue("totalServers", "server", "server_details").toInt() + 1;
for (int i = 0; i < size; i++) {
QString _saveName = servers.getValue(QString("saveName%1").arg(i), "server", "server_details").toString();
QString serverName = servers.getValue(QString("server%1").arg(i), "server", "server_details").toString();
- QString portNum = servers.getValue(QString("port%1").arg(i), "server", "server_details").toString();
- QString userName = servers.getValue(QString("username%1").arg(i), "server", "server_details").toString();
- QString pass = servers.getValue(QString("password%1").arg(i), "server", "server_details").toString();
- bool savePass = servers.getValue(QString("savePassword%1").arg(i), "server", "server_details").toBool();
- QString _site = servers.getValue(QString("site%1").arg(i), "server", "server_details").toString();
+ const QString portNum = servers.getValue(QString("port%1").arg(i), "server", "server_details").toString();
+ const QString userName = servers.getValue(QString("username%1").arg(i), "server", "server_details").toString();
+ const QString pass = servers.getValue(QString("password%1").arg(i), "server", "server_details").toString();
+ const bool savePass = servers.getValue(QString("savePassword%1").arg(i), "server", "server_details").toBool();
+ const QString _site = servers.getValue(QString("site%1").arg(i), "server", "server_details").toString();
UserConnection_Information userInfo(_saveName, serverName, portNum, userName, pass, savePass, _site);
serverList.insert(_saveName, std::make_pair(serverName, userInfo));
@@ -49,19 +49,19 @@ QStringList UserConnection_Information::getServerInfo(const QString &find)
ServersSettings &servers = SettingsCache::instance().servers();
- int size = servers.getValue("totalServers", "server", "server_details").toInt() + 1;
+ const int size = servers.getValue("totalServers", "server", "server_details").toInt() + 1;
for (int i = 0; i < size; i++) {
QString _saveName = servers.getValue(QString("saveName%1").arg(i), "server", "server_details").toString();
if (find != _saveName)
continue;
- QString serverName = servers.getValue(QString("server%1").arg(i), "server", "server_details").toString();
- QString portNum = servers.getValue(QString("port%1").arg(i), "server", "server_details").toString();
- QString userName = servers.getValue(QString("username%1").arg(i), "server", "server_details").toString();
- QString pass = servers.getValue(QString("password%1").arg(i), "server", "server_details").toString();
- bool savePass = servers.getValue(QString("savePassword%1").arg(i), "server", "server_details").toBool();
- QString _site = servers.getValue(QString("site%1").arg(i), "server", "server_details").toString();
+ const QString serverName = servers.getValue(QString("server%1").arg(i), "server", "server_details").toString();
+ const QString portNum = servers.getValue(QString("port%1").arg(i), "server", "server_details").toString();
+ const QString userName = servers.getValue(QString("username%1").arg(i), "server", "server_details").toString();
+ const QString pass = servers.getValue(QString("password%1").arg(i), "server", "server_details").toString();
+ const bool savePass = servers.getValue(QString("savePassword%1").arg(i), "server", "server_details").toBool();
+ const QString _site = servers.getValue(QString("site%1").arg(i), "server", "server_details").toString();
_server.append(_saveName);
_server.append(serverName);
diff --git a/cockatrice/src/interface/widgets/server/user/user_list_widget.cpp b/cockatrice/src/interface/widgets/server/user/user_list_widget.cpp
index b6d65c5fa..4a7a027f8 100644
--- a/cockatrice/src/interface/widgets/server/user/user_list_widget.cpp
+++ b/cockatrice/src/interface/widgets/server/user/user_list_widget.cpp
@@ -321,7 +321,7 @@ bool UserListItemDelegate::editorEvent(QEvent *event,
const QModelIndex &index)
{
if ((event->type() == QEvent::MouseButtonPress) && index.isValid()) {
- QMouseEvent *const mouseEvent = static_cast |