[Fix-Warnings] Local variable can be made const

This commit is contained in:
Brübach, Lukas 2025-11-29 15:11:22 +01:00
parent 8abd04dab1
commit f2d3e81331
214 changed files with 1375 additions and 1355 deletions

View file

@ -16,11 +16,11 @@
CardMenu::CardMenu(Player *_player, const CardItem *_card, bool _shortcutsActive)
: player(_player), card(_card), shortcutsActive(_shortcutsActive)
{
auto playerActions = player->getPlayerActions();
const auto playerActions = player->getPlayerActions();
const QList<Player *> &players = player->getGame()->getPlayerManager()->getPlayers().values();
for (auto playerToAdd : players) {
for (const auto playerToAdd : players) {
if (playerToAdd == player) {
continue;
}
@ -95,7 +95,7 @@ CardMenu::CardMenu(Player *_player, const CardItem *_card, bool _shortcutsActive
bool revealedCard = false;
bool writeableCard = player->getPlayerInfo()->getLocalOrJudge();
if (auto *view = qobject_cast<ZoneViewZoneLogic *>(card->getZone())) {
if (const auto *view = qobject_cast<ZoneViewZoneLogic *>(card->getZone())) {
if (view->getRevealZone()) {
if (view->getWriteableRevealZone()) {
writeableCard = true;
@ -155,7 +155,7 @@ void CardMenu::removePlayer(Player *playerToRemove)
void CardMenu::createTableMenu()
{
// Card is on the battlefield
bool canModifyCard = player->getPlayerInfo()->judge || card->getOwner() == player;
const bool canModifyCard = player->getPlayerInfo()->judge || card->getOwner() == player;
if (!canModifyCard) {
addRelatedCardView();
@ -213,7 +213,7 @@ void CardMenu::createTableMenu()
void CardMenu::createStackMenu()
{
bool canModifyCard = player->getPlayerInfo()->judge || card->getOwner() == player;
const bool canModifyCard = player->getPlayerInfo()->judge || card->getOwner() == player;
// Card is on the stack
if (canModifyCard) {
@ -238,7 +238,7 @@ void CardMenu::createStackMenu()
void CardMenu::createGraveyardOrExileMenu()
{
bool canModifyCard = player->getPlayerInfo()->judge || card->getOwner() == player;
const bool canModifyCard = player->getPlayerInfo()->judge || card->getOwner() == player;
// Card is in the graveyard or exile
if (canModifyCard) {
@ -328,7 +328,7 @@ void CardMenu::addRelatedCardView()
if (!card) {
return;
}
auto exactCard = card->getCard();
const auto exactCard = card->getCard();
if (!exactCard) {
return;
}
@ -348,12 +348,12 @@ void CardMenu::addRelatedCardView()
}
addSeparator();
auto viewRelatedCards = new QMenu(tr("View related cards"));
const auto viewRelatedCards = new QMenu(tr("View related cards"));
addMenu(viewRelatedCards);
for (const CardRelation *relatedCard : relatedCards) {
QString relatedCardName = relatedCard->getName();
CardRef cardRef = {relatedCardName, exactCard.getPrinting().getUuid()};
QAction *viewCard = viewRelatedCards->addAction(relatedCardName);
const QAction *viewCard = viewRelatedCards->addAction(relatedCardName);
Q_UNUSED(viewCard);
connect(viewCard, &QAction::triggered, player->getGame(),
@ -366,7 +366,7 @@ void CardMenu::addRelatedCardActions()
if (!card) {
return;
}
auto exactCard = card->getCard();
const auto exactCard = card->getCard();
if (!exactCard) {
return;
}
@ -460,7 +460,7 @@ void CardMenu::retranslateUi()
mCardCounters->setTitle(tr("Ca&rd counters"));
auto &cardCounterSettings = SettingsCache::instance().cardCounters();
const auto &cardCounterSettings = SettingsCache::instance().cardCounters();
for (int i = 0; i < aAddCounter.size(); ++i) {
aAddCounter[i]->setText(tr("&Add counter (%1)").arg(cardCounterSettings.displayName(i)));
@ -475,7 +475,7 @@ void CardMenu::retranslateUi()
void CardMenu::setShortcutsActive()
{
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
const ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aHide->setShortcuts(shortcuts.getShortcut("Player/aHide"));
aPlay->setShortcuts(shortcuts.getShortcut("Player/aPlay"));

View file

@ -19,7 +19,7 @@ void CustomZoneMenu::retranslateUi()
if (player->getPlayerInfo()->getLocalOrJudge()) {
for (auto aViewZone : actions()) {
for (const auto aViewZone : actions()) {
aViewZone->setText(tr("View custom zone '%1'").arg(aViewZone->data().toString()));
}
}

View file

@ -36,7 +36,7 @@ GraveyardMenu::GraveyardMenu(Player *_player, QWidget *parent) : TearOffMenu(par
void GraveyardMenu::createMoveActions()
{
auto grave = player->getGraveZone();
const auto grave = player->getGraveZone();
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aMoveGraveToTopLibrary = new QAction(this);
@ -60,7 +60,7 @@ void GraveyardMenu::createMoveActions()
void GraveyardMenu::createViewActions()
{
PlayerActions *playerActions = player->getPlayerActions();
const PlayerActions *playerActions = player->getPlayerActions();
aViewGraveyard = new QAction(this);
connect(aViewGraveyard, &QAction::triggered, playerActions, &PlayerActions::actViewGraveyard);
@ -77,7 +77,7 @@ void GraveyardMenu::populateRevealRandomMenuWithActivePlayers()
mRevealRandomGraveyardCard->addSeparator();
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
for (auto *other : players) {
for (const auto *other : players) {
if (other == player)
continue;
QAction *a = mRevealRandomGraveyardCard->addAction(other->getPlayerInfo()->getName());
@ -88,7 +88,7 @@ void GraveyardMenu::populateRevealRandomMenuWithActivePlayers()
void GraveyardMenu::onRevealRandomTriggered()
{
if (auto *a = qobject_cast<QAction *>(sender())) {
if (const auto *a = qobject_cast<QAction *>(sender())) {
player->getPlayerActions()->actRevealRandomGraveyardCard(a->data().toInt());
}
}
@ -112,7 +112,7 @@ void GraveyardMenu::retranslateUi()
void GraveyardMenu::setShortcutsActive()
{
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
const ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aViewGraveyard->setShortcuts(shortcuts.getShortcut("Player/aViewGraveyard"));
}

View file

@ -74,7 +74,7 @@ HandMenu::HandMenu(Player *_player, PlayerActions *actions, QWidget *parent) : T
aMoveHandToRfg = new QAction(this);
aMoveHandToRfg->setData(QList<QVariant>() << "rfg" << 0);
auto hand = player->getHandZone();
const auto hand = player->getHandZone();
connect(aMoveHandToTopLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
connect(aMoveHandToBottomLibrary, &QAction::triggered, hand, &HandZoneLogic::moveAllToZone);
@ -122,7 +122,7 @@ void HandMenu::retranslateUi()
void HandMenu::setShortcutsActive()
{
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
const ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aViewHand->setShortcuts(shortcuts.getShortcut("Player/aViewHand"));
aSortHandByName->setShortcuts(shortcuts.getShortcut("Player/aSortHandByName"));
aSortHandByType->setShortcuts(shortcuts.getShortcut("Player/aSortHandByType"));
@ -152,7 +152,7 @@ void HandMenu::populateRevealHandMenuWithActivePlayers()
mRevealHand->addSeparator();
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
for (auto *other : players) {
for (const auto *other : players) {
if (other == player)
continue;
QAction *a = mRevealHand->addAction(other->getPlayerInfo()->getName());
@ -170,7 +170,7 @@ void HandMenu::populateRevealRandomHandCardMenuWithActivePlayers()
mRevealRandomHandCard->addSeparator();
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
for (auto *other : players) {
for (const auto *other : players) {
if (other == player)
continue;
QAction *a = mRevealRandomHandCard->addAction(other->getPlayerInfo()->getName());
@ -181,7 +181,7 @@ void HandMenu::populateRevealRandomHandCardMenuWithActivePlayers()
void HandMenu::onRevealHandTriggered()
{
auto *action = qobject_cast<QAction *>(sender());
const auto *action = qobject_cast<QAction *>(sender());
if (!action)
return;
@ -191,7 +191,7 @@ void HandMenu::onRevealHandTriggered()
void HandMenu::onRevealRandomHandCardTriggered()
{
auto *action = qobject_cast<QAction *>(sender());
const auto *action = qobject_cast<QAction *>(sender());
if (!action)
return;

View file

@ -90,7 +90,7 @@ void LibraryMenu::resetTopCardMenuActions()
void LibraryMenu::createDrawActions()
{
PlayerActions *playerActions = player->getPlayerActions();
const PlayerActions *playerActions = player->getPlayerActions();
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aDrawCard = new QAction(this);
@ -108,7 +108,7 @@ void LibraryMenu::createDrawActions()
void LibraryMenu::createShuffleActions()
{
PlayerActions *playerActions = player->getPlayerActions();
const PlayerActions *playerActions = player->getPlayerActions();
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aShuffle = new QAction(this);
@ -122,7 +122,7 @@ void LibraryMenu::createShuffleActions()
void LibraryMenu::createMoveActions()
{
PlayerActions *playerActions = player->getPlayerActions();
const PlayerActions *playerActions = player->getPlayerActions();
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aMoveTopToPlay = new QAction(this);
@ -165,7 +165,7 @@ void LibraryMenu::createMoveActions()
void LibraryMenu::createViewActions()
{
PlayerActions *playerActions = player->getPlayerActions();
const PlayerActions *playerActions = player->getPlayerActions();
if (player->getPlayerInfo()->local || player->getPlayerInfo()->judge) {
aViewLibrary = new QAction(this);
@ -244,7 +244,7 @@ void LibraryMenu::populateRevealLibraryMenuWithActivePlayers()
mRevealLibrary->addSeparator();
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
for (auto *other : players) {
for (const auto *other : players) {
if (other == player)
continue;
QAction *a = mRevealLibrary->addAction(other->getPlayerInfo()->getName());
@ -258,7 +258,7 @@ void LibraryMenu::populateLendLibraryMenuWithActivePlayers()
mLendLibrary->clear();
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
for (auto *other : players) {
for (const auto *other : players) {
if (other == player)
continue;
QAction *a = mLendLibrary->addAction(other->getPlayerInfo()->getName());
@ -278,7 +278,7 @@ void LibraryMenu::populateRevealTopCardMenuWithActivePlayers()
mRevealTopCard->addSeparator();
const auto &players = player->getGame()->getPlayerManager()->getPlayers().values();
for (auto *other : players) {
for (const auto *other : players) {
if (other == player)
continue;
QAction *a = mRevealTopCard->addAction(other->getPlayerInfo()->getName());
@ -289,26 +289,26 @@ void LibraryMenu::populateRevealTopCardMenuWithActivePlayers()
void LibraryMenu::onRevealLibraryTriggered()
{
if (auto *a = qobject_cast<QAction *>(sender())) {
if (const auto *a = qobject_cast<QAction *>(sender())) {
player->getPlayerActions()->actRevealLibrary(a->data().toInt());
}
}
void LibraryMenu::onLendLibraryTriggered()
{
if (auto *a = qobject_cast<QAction *>(sender())) {
if (const auto *a = qobject_cast<QAction *>(sender())) {
player->getPlayerActions()->actLendLibrary(a->data().toInt());
}
}
void LibraryMenu::onRevealTopCardTriggered()
{
if (auto *a = qobject_cast<QAction *>(sender())) {
int deckSize = player->getDeckZone()->getCards().size();
if (const auto *a = qobject_cast<QAction *>(sender())) {
const int deckSize = player->getDeckZone()->getCards().size();
bool ok;
int number = QInputDialog::getInt(player->getGame()->getTab(), tr("Reveal top cards of library"),
tr("Number of cards: (max. %1)").arg(deckSize), defaultNumberTopCards, 1,
deckSize, 1, &ok);
const int number = QInputDialog::getInt(player->getGame()->getTab(), tr("Reveal top cards of library"),
tr("Number of cards: (max. %1)").arg(deckSize), defaultNumberTopCards,
1, deckSize, 1, &ok);
if (ok) {
player->getPlayerActions()->actRevealTopCards(a->data().toInt(), number);
defaultNumberTopCards = number;
@ -318,7 +318,7 @@ void LibraryMenu::onRevealTopCardTriggered()
void LibraryMenu::setShortcutsActive()
{
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
const ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aViewLibrary->setShortcuts(shortcuts.getShortcut("Player/aViewLibrary"));
aViewTopCards->setShortcuts(shortcuts.getShortcut("Player/aViewTopCards"));

View file

@ -43,7 +43,7 @@ MoveMenu::MoveMenu(Player *player) : QMenu(tr("Move to"))
void MoveMenu::setShortcutsActive()
{
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
const ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aMoveToTopLibrary->setShortcuts(shortcuts.getShortcut("Player/aMoveToTopLibrary"));
aMoveToBottomLibrary->setShortcuts(shortcuts.getShortcut("Player/aMoveToBottomLibrary"));

View file

@ -63,7 +63,7 @@ void PtMenu::retranslateUi()
void PtMenu::setShortcutsActive()
{
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
const ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aIncP->setShortcuts(shortcuts.getShortcut("Player/aIncP"));
aDecP->setShortcuts(shortcuts.getShortcut("Player/aDecP"));

View file

@ -27,7 +27,7 @@ RfgMenu::RfgMenu(Player *_player, QWidget *parent) : TearOffMenu(parent), player
void RfgMenu::createMoveActions()
{
if (player->getPlayerInfo()->getLocalOrJudge()) {
auto rfg = player->getRfgZone();
const auto rfg = player->getRfgZone();
aMoveRfgToTopLibrary = new QAction(this);
aMoveRfgToTopLibrary->setData(QList<QVariant>() << "deck" << 0);
@ -47,7 +47,7 @@ void RfgMenu::createMoveActions()
void RfgMenu::createViewActions()
{
PlayerActions *playerActions = player->getPlayerActions();
const PlayerActions *playerActions = player->getPlayerActions();
aViewRfg = new QAction(this);
connect(aViewRfg, &QAction::triggered, playerActions, &PlayerActions::actViewRfg);

View file

@ -14,7 +14,7 @@ void SayMenu::initSayMenu()
{
clear();
int count = SettingsCache::instance().messages().getCount();
const int count = SettingsCache::instance().messages().getCount();
setEnabled(count > 0);
for (int i = 0; i < count; ++i) {

View file

@ -22,7 +22,7 @@ void SideboardMenu::retranslateUi()
void SideboardMenu::setShortcutsActive()
{
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
const ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
aViewSideboard->setShortcuts(shortcuts.getShortcut("Player/aViewSideboard"));
}

View file

@ -6,7 +6,7 @@
UtilityMenu::UtilityMenu(Player *_player, QMenu *playerMenu) : QMenu(playerMenu), player(_player)
{
PlayerActions *playerActions = player->getPlayerActions();
const PlayerActions *playerActions = player->getPlayerActions();
if (player->getPlayerInfo()->getLocalOrJudge()) {
aUntapAll = new QAction(this);
@ -62,7 +62,7 @@ void UtilityMenu::populatePredefinedTokensMenu()
return;
}
InnerDecklistNode *tokenZone =
const InnerDecklistNode *tokenZone =
dynamic_cast<InnerDecklistNode *>(_deck->getDeckList()->getRoot()->findChild(DECK_ZONE_TOKENS));
if (tokenZone) {
@ -95,7 +95,7 @@ void UtilityMenu::retranslateUi()
void UtilityMenu::setShortcutsActive()
{
ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
const ShortcutsSettings &shortcuts = SettingsCache::instance().shortcuts();
if (player->getPlayerInfo()->getLocalOrJudge()) {
aIncrementAllCardCounters->setShortcuts(shortcuts.getShortcut("Player/aIncrementAllCardCounters"));

View file

@ -18,7 +18,7 @@ void PlayerArea::updateBg()
void PlayerArea::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{
QBrush brush = themeManager->getExtraBgBrush(ThemeManager::Player, playerZoneId);
const QBrush brush = themeManager->getExtraBgBrush(ThemeManager::Player, playerZoneId);
painter->fillRect(boundingRect(), brush);
}

View file

@ -14,7 +14,7 @@ PlayerGraphicsItem::PlayerGraphicsItem(Player *_player) : player(_player)
playerArea = new PlayerArea(this);
playerTarget = new PlayerTarget(player, playerArea);
qreal avatarMargin = (counterAreaWidth + CARD_HEIGHT + 15 - playerTarget->boundingRect().width()) / 2.0;
const qreal avatarMargin = (counterAreaWidth + CARD_HEIGHT + 15 - playerTarget->boundingRect().width()) / 2.0;
playerTarget->setPos(QPointF(avatarMargin, avatarMargin));
initializeZones();
@ -50,18 +50,18 @@ void PlayerGraphicsItem::onPlayerActiveChanged(bool _active)
void PlayerGraphicsItem::initializeZones()
{
deckZoneGraphicsItem = new PileZone(player->getDeckZone(), this);
auto base = QPointF(counterAreaWidth + (CARD_HEIGHT - CARD_WIDTH + 15) / 2.0,
10 + playerTarget->boundingRect().height() + 5 - (CARD_HEIGHT - CARD_WIDTH) / 2.0);
const auto base = QPointF(counterAreaWidth + (CARD_HEIGHT - CARD_WIDTH + 15) / 2.0,
10 + playerTarget->boundingRect().height() + 5 - (CARD_HEIGHT - CARD_WIDTH) / 2.0);
deckZoneGraphicsItem->setPos(base);
qreal h = deckZoneGraphicsItem->boundingRect().width() + 5;
const qreal h = deckZoneGraphicsItem->boundingRect().width() + 5;
sideboardGraphicsItem = new PileZone(player->getSideboardZone(), this);
player->getSideboardZone()->setGraphicsVisibility(false);
auto *handCounter = new HandCounter(playerArea);
handCounter->setPos(base + QPointF(0, h + 10));
qreal h2 = handCounter->boundingRect().height();
const qreal h2 = handCounter->boundingRect().height();
graveyardZoneGraphicsItem = new PileZone(player->getGraveZone(), this);
graveyardZoneGraphicsItem->setPos(base + QPointF(0, h + h2 + 10));
@ -127,7 +127,7 @@ void PlayerGraphicsItem::setMirrored(bool _mirrored)
void PlayerGraphicsItem::rearrangeCounters()
{
qreal marginTop = 80;
const qreal marginTop = 80;
const qreal padding = 5;
qreal ySize = boundingRect().y() + marginTop;
@ -198,9 +198,9 @@ void PlayerGraphicsItem::rearrangeZones()
void PlayerGraphicsItem::updateBoundingRect()
{
prepareGeometryChange();
qreal width = CARD_HEIGHT + 15 + counterAreaWidth + stackZoneGraphicsItem->boundingRect().width();
const qreal width = CARD_HEIGHT + 15 + counterAreaWidth + stackZoneGraphicsItem->boundingRect().width();
if (SettingsCache::instance().getHorizontalHand()) {
qreal handHeight =
const qreal handHeight =
player->getPlayerInfo()->getHandVisible() ? handZoneGraphicsItem->boundingRect().height() : 0;
bRect = QRectF(0, 0, width + tableZoneGraphicsItem->boundingRect().width(),
tableZoneGraphicsItem->boundingRect().height() + handHeight);

View file

@ -14,7 +14,7 @@ PlayerManager::PlayerManager(AbstractGame *_game,
bool PlayerManager::isMainPlayerConceded() const
{
Player *player = players.value(localPlayerId, nullptr);
const Player *player = players.value(localPlayerId, nullptr);
return player && player->getConceded();
}

View file

@ -95,7 +95,7 @@ public:
void removeSpectator(int spectatorId)
{
ServerInfo_User spectatorInfo = spectators.value(spectatorId);
const ServerInfo_User spectatorInfo = spectators.value(spectatorId);
spectators.remove(spectatorId);
emit spectatorRemoved(spectatorId, spectatorInfo);
}

View file

@ -37,8 +37,8 @@ void PlayerCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*
painter->drawPath(path);
QRectF translatedRect = path.controlPointRect();
QSize translatedSize = translatedRect.size().toSize();
const QRectF translatedRect = path.controlPointRect();
const QSize translatedSize = translatedRect.size().toSize();
QFont font("Serif");
font.setWeight(QFont::Bold);
font.setPixelSize(qMax(qRound(translatedSize.height() / 1.3), 9));