Commit dbce2e8c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix clazy warning

parent 3ce6990f
......@@ -29,7 +29,6 @@ BombExplosionItem::BombExplosionItem(Bomb* p_model, Granatier::Direction::Type d
m_svgScaleFactor = svgScaleFactor;
QString strElemetId;
int width = 1;
int height = 1;
switch(m_direction)
......@@ -126,7 +125,6 @@ void BombExplosionItem::setPosition(qreal p_x, qreal p_y)
void BombExplosionItem::updateAnimationn(int nFrame)
{
QString strElemetId;
switch(m_direction)
{
case Granatier::Direction::NORTH:
......
......@@ -27,7 +27,7 @@
* @brief This class represents a Bonus for the Player.
*/
class Bonus : public Element {
Q_OBJECT
public:
/**
* Creates a new Bonus instance.
......
......@@ -52,12 +52,12 @@ void Character::move()
// Move the Character
m_x += m_xSpeed;
m_y += m_ySpeed;
emit(moved(m_x, m_y));
Q_EMIT moved(m_x, m_y);
}
void Character::die()
{
emit(dead());
Q_EMIT dead();
}
qreal Character::getXSpeed() const
......
......@@ -123,7 +123,7 @@ void ArenaSelector::Private::setupData(KConfigSkeleton * aconfig)
//setup KNS button
if (m_options & EnableNewStuffDownload)
{
ui.getNewButton->setIcon(QIcon::fromTheme( QLatin1String( "get-hot-new-stuff" )));
ui.getNewButton->setIcon(QIcon::fromTheme( QStringLiteral( "get-hot-new-stuff" )));
connect(ui.getNewButton, SIGNAL(clicked()), q, SLOT(_k_openKNewStuffDialog()));
}
else
......@@ -233,7 +233,7 @@ void ArenaSelector::Private::findArenas(const QString &initialSelection)
{
// TODO change this if we ever change ArenaSettings::loadDefault
QLatin1String defaultPath("arenas/granatier.desktop");
for(auto arenaSettings: arenaMap)
for(auto arenaSettings: qAsConst(arenaMap))
{
if (arenaSettings->path().endsWith(defaultPath))
{
......@@ -333,15 +333,15 @@ void ArenaSelector::Private::_k_updatePreview(QListWidgetItem* currentItem)
QTransform transform;
transform.scale(1/svgScaleFactor, 1/svgScaleFactor);
m_graphicsScene->views().first()->setTransform(transform);
m_graphicsScene->views().first()->centerOn( ui.arenaPreview->sceneRect().center());
m_graphicsScene->views().constFirst()->setTransform(transform);
m_graphicsScene->views().constFirst()->centerOn( ui.arenaPreview->sceneRect().center());
if(currentItem == nullptr)
{
if(m_svgScaleFactor != svgScaleFactor)
{
m_svgScaleFactor = svgScaleFactor;
for(auto arenaItem: m_arenaItems)
for(auto arenaItem: qAsConst(m_arenaItems))
{
arenaItem->setRenderSize(calculateSvgSize());
arenaItem->setScale(m_svgScaleFactor);
......@@ -356,7 +356,7 @@ void ArenaSelector::Private::_k_updatePreview(QListWidgetItem* currentItem)
for (int j = 0; j < m_arena->getNbColumns(); ++j)
{
// Create the ArenaItem and set the image
ArenaItem* arenaItem = new ArenaItem(j * Granatier::CellSize, i * Granatier::CellSize, m_renderer, QStringLiteral(""));
ArenaItem* arenaItem = new ArenaItem(j * Granatier::CellSize, i * Granatier::CellSize, m_renderer, QLatin1String(""));
switch(m_arena->getCell(i,j).getType())
{
......
......@@ -66,7 +66,7 @@ public:
* @param directory subdirectory (of share/apps/appname) to search in
* @return true if the arena files and properties could be loaded
*/
ArenaSelector(QWidget* parent, KConfigSkeleton* aconfig, QStringList* randomArenaModeArenaList, Options options = DefaultBehavior, const QString& groupName = QLatin1String("Arena"), const QString& directory = QLatin1String("arenas"));
ArenaSelector(QWidget* parent, KConfigSkeleton* aconfig, QStringList* randomArenaModeArenaList, Options options = DefaultBehavior, const QString& groupName = QStringLiteral("Arena"), const QString& directory = QStringLiteral("arenas"));
~ArenaSelector() override;
protected:
......
......@@ -163,7 +163,7 @@ void PlayerSelectorItem::setPlayerAuthor(const QString& name, const QString& mai
{
mailString = QStringLiteral("<br />") + mail;
}
m_playerAuthor->setText(QStringLiteral("<i>%1</i>%2").arg(i18nc("Author attribution, e.g. \"by Jack\"", "by %1", name)).arg(mailString));
m_playerAuthor->setText(QStringLiteral("<i>%1</i>%2").arg(i18nc("Author attribution, e.g. \"by Jack\"", "by %1", name), mailString));
}
void PlayerSelectorItem::selectionChanged(bool selectionState)
......
......@@ -46,8 +46,8 @@ PlayerSettings::PlayerSettings()
KConfig desktopFile(QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("players/") + settings.strPlayerID), KConfig::SimpleConfig);
settings.strPlayerDesktopFilePath = desktopFile.name();
settings.strPlayerName = desktopFile.group("KGameTheme").readEntry<QString>("Name", QStringLiteral(""));
settings.strPlayerGraphicsFile = desktopFile.group("KGameTheme").readEntry<QString>("FileName", QStringLiteral(""));
settings.strPlayerName = desktopFile.group("KGameTheme").readEntry<QString>("Name", QLatin1String(""));
settings.strPlayerGraphicsFile = desktopFile.group("KGameTheme").readEntry<QString>("FileName", QLatin1String(""));
settings.enabled = false;
m_playerSettings.insert(settings.strPlayerID, settings);
......@@ -188,7 +188,7 @@ void PlayerSettings::savePlayerSettings()
{
playersGroupList = granatierConfig.group("Player").groupList();
playersGroupList.sort();
for(const auto& player: playersGroupList)
for(const auto& player: qAsConst(playersGroupList))
{
strPlayerIDList.append(granatierConfig.group("Player").group(player).readEntry<QString>("PlayerID", QStringLiteral("")));
}
......
......@@ -56,13 +56,13 @@ qreal Element::getY() const
void Element::setX(qreal p_x)
{
m_x = p_x;
emit(moved(m_x, m_y));
Q_EMIT moved(m_x, m_y);
}
void Element::setY(qreal p_y)
{
m_y = p_y;
emit(moved(m_x, m_y));
Q_EMIT moved(m_x, m_y);
}
Granatier::Element::Type Element::getType() const
......
......@@ -242,7 +242,7 @@ void Game::start()
m_timer->start();
m_state = RUNNING;
m_roundTimer->start();
emit(pauseChanged(false, false));
Q_EMIT pauseChanged(false, false);
}
void Game::pause(bool p_locked)
......@@ -258,7 +258,7 @@ void Game::pause(bool p_locked)
{
m_state = PAUSED_UNLOCKED;
}
emit(pauseChanged(true, false));
Q_EMIT pauseChanged(true, false);
}
void Game::switchPause()
......@@ -268,14 +268,14 @@ void Game::switchPause()
{
// Pause the Game
pause();
emit(pauseChanged(true, true));
Q_EMIT pauseChanged(true, true);
}
// If the Game is already paused
else
{
// Resume the Game
start();
emit(pauseChanged(false, true));
Q_EMIT pauseChanged(false, true);
}
}
......@@ -472,14 +472,14 @@ void Game::keyPressEvent(QKeyEvent* p_event)
// Start the game
m_timer->start();
m_roundTimer->start();
emit(gameStarted());
Q_EMIT gameStarted();
}
else if (m_state == PAUSED_LOCKED)
{
// if the game is over, start a new game
if (m_gameOver)
{
emit(gameOver());
Q_EMIT gameOver();
return;
}
else
......@@ -549,7 +549,7 @@ void Game::decrementRemainingRoundTime()
m_remainingTime--;
if(m_remainingTime >= 0)
{
emit(infoChanged(Granatier::Info::TimeInfo));
Q_EMIT infoChanged(Granatier::Info::TimeInfo);
}
else
{
......
......@@ -343,7 +343,7 @@ void GameScene::initItemsWithGraphicsFromTheme()
if (!blockElements.isEmpty())
{
// Create the element item and set the image
for(const auto& element: blockElements)
for(const auto& element: qAsConst(blockElements))
{
Block* block = dynamic_cast <Block*> (element);
BlockItem* blockItem = new BlockItem(block, m_rendererArenaItems);
......@@ -668,8 +668,8 @@ void GameScene::resizeSprites(int delayForBackground)
}
//calculate the scaling factor for the SVGs
int horizontalPixelsPerCell = static_cast<int>(views().first()->size().width() / (m_minSize.width()/Granatier::CellSize));
int verticalPixelsPerCell = static_cast<int>(views().first()->size().height() / (m_minSize.height()/Granatier::CellSize));
int horizontalPixelsPerCell = static_cast<int>(views().constFirst()->size().width() / (m_minSize.width()/Granatier::CellSize));
int verticalPixelsPerCell = static_cast<int>(views().constFirst()->size().height() / (m_minSize.height()/Granatier::CellSize));
if(horizontalPixelsPerCell < verticalPixelsPerCell)
{
m_SvgScaleFactor = Granatier::CellSize / horizontalPixelsPerCell;
......@@ -680,20 +680,20 @@ void GameScene::resizeSprites(int delayForBackground)
}
QTransform transform;
transform.scale(1/m_SvgScaleFactor, 1/m_SvgScaleFactor);
views().first()->setTransform(transform);
views().first()->centerOn(sceneRect().center());
views().first()->updateSceneRect(m_minSize);;
views().constFirst()->setTransform(transform);
views().constFirst()->centerOn(sceneRect().center());
views().constFirst()->updateSceneRect(m_minSize);;
//update pixmaps
emit resizeGraphics(m_SvgScaleFactor);
//update overlay
QRect viewRect = views().first()->rect();
QRectF viewRectToScene = QRectF(views().first()->mapToScene(viewRect.topLeft()), views().first()->mapToScene(viewRect.bottomRight()));
QRect viewRect = views().constFirst()->rect();
QRectF viewRectToScene = QRectF(views().constFirst()->mapToScene(viewRect.topLeft()), views().constFirst()->mapToScene(viewRect.bottomRight()));
m_infoOverlay->resizeDimmOverlay(viewRectToScene.x(), viewRectToScene.y(), viewRectToScene.width(), viewRectToScene.height());
//update background pixmap
m_arenaBackground->setPos(views().first()->mapToScene(viewRect.topLeft()));
m_arenaBackground->setPos(views().constFirst()->mapToScene(viewRect.topLeft()));
m_arenaBackground->setScale(m_SvgScaleFactor);
m_arenaBackground->setPixmap(m_arenaBackground->pixmap().scaled(viewRect.size()));
......@@ -708,7 +708,7 @@ void GameScene::resizeBackground()
{
return;
}
QRect viewRect = views().first()->rect();
QRect viewRect = views().constFirst()->rect();
m_arenaBackground->setRenderSize(viewRect.size());
}
......@@ -919,7 +919,7 @@ void GameScene::bombDetonated(Bomb* bomb)
{
bombElements = m_game->getArena()->getCell(nRow, nColumn).getElements(Granatier::Element::BOMB);
int tempBombDetonationCountdown = nDetonationCountdown;
for(const auto& element: bombElements)
for(const auto& element: qAsConst(bombElements))
{
if(dynamic_cast <Bomb*> (element) != bomb && !(dynamic_cast <Bomb*> (element)->isDetonated()))
{
......@@ -931,7 +931,7 @@ void GameScene::bombDetonated(Bomb* bomb)
blockElements = m_game->getArena()->getCell(nRow, nColumn).getElements(Granatier::Element::BLOCK);
if(!blockElements.isEmpty())
{
for(const auto& element: blockElements)
for(const auto& element: qAsConst(blockElements))
{
dynamic_cast <Block*> (element)->startDestruction();
if (m_blockItems[nRow][nColumn] != nullptr)
......@@ -986,7 +986,7 @@ void GameScene::bombDetonated(Bomb* bomb)
{
int tempBombDetonationCountdown = anDirectionDetonationCountdown[direction];
bool increaseDetonationTimeout = false;
for(const auto& element: bombElements)
for(const auto& element: qAsConst(bombElements))
{
if(dynamic_cast <Bomb*> (element) != bomb && !(dynamic_cast <Bomb*> (element)->isDetonated()))
{
......@@ -1003,7 +1003,7 @@ void GameScene::bombDetonated(Bomb* bomb)
if(!blockElements.isEmpty())
{
abDirectionsDone[direction] = true;
for(const auto& element: blockElements)
for(const auto& element: qAsConst(blockElements))
{
dynamic_cast <Block*> (element)->startDestruction();
if (m_blockItems[nRow][nColumn] != nullptr)
......
......@@ -35,7 +35,7 @@ InfoOverlay::InfoOverlay (Game* p_game, GameScene* p_scene) : QObject()
m_svgScaleFactor = 1;
int nWinPoints = m_game->getWinPoints();
QList <Player*> playerList = m_game->getPlayers();
const QList <Player*> playerList = m_game->getPlayers();
KGameRenderer* renderer;
renderer = m_gameScene->renderer(Granatier::Element::SCORE);
......@@ -113,7 +113,7 @@ InfoOverlay::~InfoOverlay()
hideItems();
// Find the score items and remove them
for(const auto& scoreItems: m_mapScore)
for(const auto& scoreItems: qAsConst(m_mapScore))
{
qDeleteAll(scoreItems);
}
......@@ -340,7 +340,7 @@ void InfoOverlay::updateGraphics(qreal svgScaleFactor)
QSize svgSize;
QPoint topLeft(0, 0);
topLeft = m_gameScene->views().first()->mapFromScene(topLeft);
topLeft = m_gameScene->views().constFirst()->mapFromScene(topLeft);
KGameRenderedItem* score;
for(int i = 0; i < playerList.count(); i++)
......@@ -353,7 +353,7 @@ void InfoOverlay::updateGraphics(qreal svgScaleFactor)
score = m_mapScore.value(playerList.at(i)).at(j);
QPoint bottomRight(static_cast<int>(Granatier::CellSize * 0.6), static_cast<int>(Granatier::CellSize * 0.6));
bottomRight = m_gameScene->views().first()->mapFromScene(bottomRight);
bottomRight = m_gameScene->views().constFirst()->mapFromScene(bottomRight);
svgSize.setHeight(bottomRight.y() - topLeft.y());
svgSize.setWidth(bottomRight.x() - topLeft.x());
......
......@@ -399,11 +399,11 @@ void InfoSidebar::bonusInfoChanged(Player* player, Granatier::Bonus::Type bonusT
//calculate graphics size
QSize renderSize;
QPoint topLeft(0, 0);
topLeft = m_gameScene->views().first()->mapFromScene(topLeft);
topLeft = m_gameScene->views().constFirst()->mapFromScene(topLeft);
QRectF rect;
QPoint bottomRight(static_cast<int>(Granatier::CellSize * 0.5), static_cast<int>(Granatier::CellSize * 0.5));
bottomRight = m_gameScene->views().first()->mapFromScene(bottomRight);
bottomRight = m_gameScene->views().constFirst()->mapFromScene(bottomRight);
renderSize.setHeight(bottomRight.y() - topLeft.y());
renderSize.setWidth(bottomRight.x() - topLeft.x());
......@@ -437,7 +437,7 @@ void InfoSidebar::updateGraphics(qreal svgScaleFactor)
QSize renderSize;
QPoint topLeft(0, 0);
topLeft = m_gameScene->views().first()->mapFromScene(topLeft);
topLeft = m_gameScene->views().constFirst()->mapFromScene(topLeft);
QPoint bottomRight;
QRectF rect;
......@@ -449,7 +449,7 @@ void InfoSidebar::updateGraphics(qreal svgScaleFactor)
{
bottomRight.setX(static_cast<int>(Granatier::CellSize * 0.45));
bottomRight.setY(static_cast<int>(Granatier::CellSize * 0.45));
bottomRight = m_gameScene->views().first()->mapFromScene(bottomRight);
bottomRight = m_gameScene->views().constFirst()->mapFromScene(bottomRight);
renderSize.setHeight(bottomRight.y() - topLeft.y());
renderSize.setWidth(bottomRight.x() - topLeft.x());
......@@ -458,7 +458,7 @@ void InfoSidebar::updateGraphics(qreal svgScaleFactor)
bottomRight.setX(static_cast<int>(Granatier::CellSize * 0.5));
bottomRight.setY(static_cast<int>(Granatier::CellSize * 0.5));
bottomRight = m_gameScene->views().first()->mapFromScene(bottomRight);
bottomRight = m_gameScene->views().constFirst()->mapFromScene(bottomRight);
renderSize.setHeight(bottomRight.y() - topLeft.y());
renderSize.setWidth(bottomRight.x() - topLeft.x());
......
......@@ -58,7 +58,7 @@ int main(int argc, char** argv)
{
QDir sourceDir(sourceBasePath + dataDir);
if(!sourceDir.exists()) continue;
QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
const QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
QDir().mkpath(targetBasePath + dataDir);
for(const auto& fileName: fileNames)
{
......@@ -74,7 +74,7 @@ int main(int argc, char** argv)
KSharedConfig::openConfig()->reparseConfiguration();
}
app.setWindowIcon(QIcon::fromTheme(QLatin1String("granatier")));
app.setWindowIcon(QIcon::fromTheme(QStringLiteral("granatier")));
KLocalizedString::setApplicationDomain("granatier");
// About Granatier
......
......@@ -68,7 +68,7 @@ MainWindow::MainWindow()
KStandardGameAction::quit(this, SLOT(close()), actionCollection());
KToggleAction* soundAction = new KToggleAction(i18n("&Play sounds"), this);
soundAction->setChecked(Settings::sounds());
actionCollection()->addAction( QLatin1String( "sounds" ), soundAction);
actionCollection()->addAction( QStringLiteral( "sounds" ), soundAction);
connect(soundAction, &KToggleAction::triggered, this, &MainWindow::setSoundsEnabled);
// init game
initGame();
......@@ -212,7 +212,7 @@ void MainWindow::settingsDialogCanceled()
m_tempRandomArenaModeArenaList.clear();
if(m_currentThemeIdentifier != QString::fromLatin1(m_themeProvider->currentTheme()->identifier()))
{
QList<const KgTheme*> themeList = m_themeProvider->themes();
const QList<const KgTheme*> themeList = m_themeProvider->themes();
for(const auto& theme: themeList)
{
if(QString::fromLatin1(theme->identifier()) == m_currentThemeIdentifier)
......
......@@ -655,7 +655,7 @@ void Player::addBonus(Bonus* p_bonus)
break;
}
bonusUpdated(this, bonusType, 0);
Q_EMIT bonusUpdated(this, bonusType, 0);
}
bool Player::shield(int nExplosionID)
......@@ -925,7 +925,7 @@ void Player::slot_removeBadBonus()
break;
}
bonusUpdated(this, m_badBonusType, 100);
Q_EMIT bonusUpdated(this, m_badBonusType, 100);
}
void Player::stopMoving()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment