Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 1cece365 authored by Laurent Montel's avatar Laurent Montel 😁

Fix clazy warning

parent 4cab2f0b
......@@ -65,7 +65,7 @@ KGoldrunner::KGoldrunner()
/************* FIND WHERE THE GAMES DATA AND HANDBOOK SHOULD BE *************/
/******************************************************************************/
setObjectName ( QLatin1String("KGoldrunner" ));
setObjectName ( QStringLiteral("KGoldrunner" ));
// Avoid "saveOK()" check if an error-exit occurs during the file checks.
startupOK = true;
......@@ -316,14 +316,14 @@ void KGoldrunner::setupActions()
i18n ("&Create Level"),
i18n ("Create level."),
i18n ("Create a completely new level."));
ed->setIcon (QIcon::fromTheme( QLatin1String( "document-new" )));
ed->setIcon (QIcon::fromTheme( QStringLiteral( "document-new" )));
ed->setIconText (i18n ("Create"));
ed = editAction (QStringLiteral("edit_any"), EDIT_ANY,
i18n ("&Edit Level..."),
i18n ("Edit level..."),
i18n ("Edit any level..."));
ed->setIcon (QIcon::fromTheme( QLatin1String( "document-open" )));
ed->setIcon (QIcon::fromTheme( QStringLiteral( "document-open" )));
ed->setIconText (i18n ("Edit"));
// Save Edits...
......@@ -335,7 +335,7 @@ void KGoldrunner::setupActions()
i18n ("&Save Edits..."),
i18n ("Save edits..."),
i18n ("Save your level after editing..."));
saveEdits->setIcon (QIcon::fromTheme( QLatin1String( "document-save" )));
saveEdits->setIcon (QIcon::fromTheme( QStringLiteral( "document-save" )));
saveEdits->setIconText (i18n ("Save"));
saveEdits->setEnabled (false); // Nothing to save, yet.
......@@ -935,7 +935,7 @@ void KGoldrunner::setupEditToolbarActions()
i18n ("Edit level name or hint"),
i18n ("Edit text for the name or hint "
"of a level"));
ed->setIcon (QIcon::fromTheme( QLatin1String( "games-hint" )));
ed->setIcon (QIcon::fromTheme( QStringLiteral( "games-hint" )));
ed->setIconText (i18n ("Name/Hint"));
KToggleAction * free = editToolbarAction (QStringLiteral("freebg"), FREE,
......
......@@ -576,7 +576,7 @@ bool KGrEditor::editGame (int pGameIndex)
rules = 'T';
}
KGrGameData * gameData = 0;
KGrGameData * gameData = nullptr;
if (action == SL_CR_GAME) {
// Create empty game data and add it to the main list in KGrGame.
gameData = new KGrGameData();
......
......@@ -86,24 +86,24 @@ KGrGame::KGrGame (KGrView * theView,
const QString & theSystemDir, const QString & theUserDir)
:
QObject (theView), // Game is destroyed if view closes.
levelPlayer (0),
recording (0),
levelPlayer (nullptr),
recording (nullptr),
playback (false),
view (theView),
scene (view->gameScene()),
systemDataDir (theSystemDir),
userDataDir (theUserDir),
level (0),
mainDemoName (QLatin1String("demo")),
mainDemoName (QStringLiteral("demo")),
// mainDemoName ("CM"), // IDW test.
demoType (DEMO),
startupDemo (false),
programFreeze (false),
effects (0),
effects (nullptr),
fx (NumSounds),
soundOn (false),
stepsOn (false),
editor (0)
editor (nullptr)
{
dbgLevel = 0;
......@@ -320,7 +320,7 @@ void KGrGame::editActions (const int action)
// Edit failed or was cancelled, so close the editor.
emit setEditMenu (false); // Disable edit menu items and toolbar.
delete editor;
editor = 0;
editor = nullptr;
}
freeze (ProgramPause, false);
}
......@@ -1237,7 +1237,7 @@ void KGrGame::toggleSoundsOnOff (const int action)
#ifdef KGAUDIO_BACKEND_OPENAL
if (action == PLAY_SOUNDS) {
if (soundOn && (effects == 0)) {
if (soundOn && (effects == nullptr)) {
loadSounds(); // Sounds were not loaded when the game started.
}
effects->setMuted (! soundOn);
......@@ -1577,7 +1577,7 @@ bool KGrGame::selectSavedGame (int & selectedGame, int & selectedLevel)
}
if (index >= 0) {
selectedGame = index;
selectedLevel = loadedData.mid (28, 3).toInt();
selectedLevel = loadedData.midRef (28, 3).toInt();
result = true;
}
else {
......@@ -1706,7 +1706,7 @@ void KGrGame::checkHighScore()
// Dialog to ask the user to enter their name.
QDialog * hsn = new QDialog (view,
Qt::WindowTitleHint);
hsn->setObjectName ( QLatin1String("hsNameDialog" ));
hsn->setObjectName ( QStringLiteral("hsNameDialog" ));
int margin = 10;
int spacing = 10;
......@@ -1868,7 +1868,7 @@ void KGrGame::showHighScores()
QDialog * hs = new QDialog (view,
Qt::WindowTitleHint);
hs->setObjectName ( QLatin1String("hsDialog" ));
hs->setObjectName ( QStringLiteral("hsDialog" ));
int margin = 10;
int spacing = 10;
......@@ -2047,7 +2047,7 @@ void KGrGame::saveSolution (const QString & prefix, const int levelNo)
{
// Save the game and level data that is currently displayed.
KGrRecording * prevRecording = recording;
recording = 0;
recording = nullptr;
demoType = REPLAY_ANY; // Must load a "rec_" file, not "sol_".
// Proceed as if we are going to replay the selected level.
......
......@@ -39,18 +39,18 @@ KGrLevelPlayer::KGrLevelPlayer (KGrGame * parent, KRandomSequence * pRandomGen)
QObject (parent),
game (parent),
randomGen (pRandomGen),
hero (0),
hero (nullptr),
controlMode (MOUSE),
holdKeyOption (CLICK_KEY),
nuggets (0),
playState (NotReady),
recording (0),
recording (nullptr),
playback (false),
targetI (1),
targetJ (1),
direction (NO_DIRECTION),
newDirection (NO_DIRECTION),
timer (0),
timer (nullptr),
digCycleTime (200), // Milliseconds per dig-timing cycle (default).
digCycleCount (40), // Cycles while hole is fully open (default).
digOpeningCycles (5), // Cycles for brick-opening animation.
......@@ -180,7 +180,7 @@ void KGrLevelPlayer::init (KGrView * view,
for (int i = wall; i < levelWidth + wall; i++) {
char type = grid->cellType (i, j);
if (type == HERO) {
if (hero == 0) {
if (hero == nullptr) {
targetI = i;
targetJ = j;
heroId = emit makeSprite (HERO, i, j);
......@@ -610,7 +610,7 @@ KGrEnemy * KGrLevelPlayer::standOnEnemy (const int spriteId,
{
int minEnemies = (spriteId == heroId) ? 1 : 2;
if (enemies.count() < minEnemies) {
return 0;
return nullptr;
}
int enemyX, enemyY, pointsPerCell;
for (KGrEnemy * enemy : qAsConst(enemies)) {
......@@ -622,7 +622,7 @@ KGrEnemy * KGrLevelPlayer::standOnEnemy (const int spriteId,
return enemy;
}
}
return 0;
return nullptr;
}
bool KGrLevelPlayer::bumpingFriend (const int spriteId, const Direction dirn,
......
......@@ -45,13 +45,13 @@ KGrRenderer::KGrRenderer (KGrScene * scene)
// Find SVG files for the Set, i.e. tiles and backgrounds.
const QMetaObject * setThemeClass = & KGrSetTheme::staticMetaObject;
m_setProvider->discoverThemes ("appdata", QLatin1String ("themes"),
QLatin1String ("egypt"), setThemeClass);
m_setProvider->discoverThemes ("appdata", QStringLiteral ("themes"),
QStringLiteral ("egypt"), setThemeClass);
// Find SVG files for the Actors, i.e. hero and enemies.
const QMetaObject * actorsThemeClass = & KGrActorsTheme::staticMetaObject;
m_actorsProvider->discoverThemes ("appdata", QLatin1String ("themes"),
QLatin1String ("egypt"), actorsThemeClass);
m_actorsProvider->discoverThemes ("appdata", QStringLiteral ("themes"),
QStringLiteral ("egypt"), actorsThemeClass);
// Set up a dialog for selecting themes.
m_themeSelector = new KgThemeSelector (m_setProvider,
......@@ -192,7 +192,7 @@ KGameRenderedItem * KGrRenderer::getBackground
}
KGameRenderedItem * KGrRenderer::getBorderItem
(QString spriteKey, KGameRenderedItem * currentItem)
(const QString &spriteKey, KGameRenderedItem * currentItem)
{
if (currentItem) {
m_scene->removeItem (currentItem);
......
......@@ -105,7 +105,7 @@ public:
* @param currentItem The pre-existing item that is to be replaced, or
* zero if the previous theme had no border.
*/
KGameRenderedItem * getBorderItem (QString spriteKey,
KGameRenderedItem * getBorderItem (const QString &spriteKey,
KGameRenderedItem * currentItem);
/*
......
......@@ -238,7 +238,7 @@ HeroStatus KGrHero::run (const int scaledTime)
if (falling && (interval != enemyFallTime)) {
// qCDebug(KGOLDRUNNER_LOG) << "Calling standOnEnemy() for" << gridX << gridY;
onEnemy = levelPlayer->standOnEnemy (spriteId, gridX, gridY);
if (onEnemy != 0) {
if (onEnemy != nullptr) {
interval = enemyFallTime;
// If MidCell, hero-speed animation overshoots, but looks OK.
}
......@@ -351,14 +351,14 @@ bool KGrHero::dig (const Direction diggingDirection, int & i, int & j)
((currDirection == LEFT) ? (gridI - 1) : (gridI + 1));
Flags OK = grid->heroMoves (nextGridI, gridJ);
bool canStand = (OK & dFlag [STAND]) || (OK == 0);
bool enemyUnder = (onEnemy != 0);
bool enemyUnder = (onEnemy != nullptr);
// Must be on solid ground or on an enemy (standing or riding down).
if ((! canStand) && (nextGridI != gridI)) {
// If cannot move to next cell and stand, is an enemy under it?
// qCDebug(KGOLDRUNNER_LOG) << "Calling standOnEnemy() at gridX" << gridX
// << "for" << (nextGridI * pointsPerCell) << gridY;
enemyUnder = (levelPlayer->standOnEnemy (spriteId,
nextGridI * pointsPerCell, gridY) != 0);
nextGridI * pointsPerCell, gridY) != nullptr);
}
if ((! canStand) && (! enemyUnder)) {
qCDebug(KGOLDRUNNER_LOG) << "INVALID DIG: hero at" << gridI << gridJ
......
......@@ -39,14 +39,14 @@ KGrScene::KGrScene (KGrView * view)
// plus 2 more tile widths all around for text areas, frame and spillover
// for mouse actions (to avoid accidental clicks affecting the desktop).
m_view (view),
m_background (0),
m_background (nullptr),
m_level (1),
m_title (0),
m_replayMessage (0),
m_livesText (0),
m_scoreText (0),
m_hasHintText (0),
m_pauseResumeText (0),
m_title (nullptr),
m_replayMessage (nullptr),
m_livesText (nullptr),
m_scoreText (nullptr),
m_hasHintText (nullptr),
m_pauseResumeText (nullptr),
m_heroId (0),
m_tilesWide (FIELDWIDTH + 2 * 2),
m_tilesHigh (FIELDHEIGHT + 2 * 2),
......@@ -60,7 +60,7 @@ KGrScene::KGrScene (KGrView * view)
{
setItemIndexMethod(NoIndex);
m_tiles.fill (0, m_tilesWide * m_tilesHigh);
m_tiles.fill (nullptr, m_tilesWide * m_tilesHigh);
m_tileTypes.fill (FREE, m_tilesWide * m_tilesHigh);
m_renderer = new KGrRenderer (this);
......@@ -370,7 +370,7 @@ void KGrScene::setTile (KGameRenderedItem * tile, const int tileSize,
tile->setPos (m_topLeftX + (i+1) * tileSize, m_topLeftY + (j+1) * tileSize);
}
void KGrScene::setBorderTile (const QString spriteKey, const int x, const int y)
void KGrScene::setBorderTile (const QString &spriteKey, const int x, const int y)
{
int index = x * m_tilesHigh + y;
KGameRenderedItem * t = m_renderer->getBorderItem (spriteKey,
......@@ -440,8 +440,8 @@ int KGrScene::makeSprite (const char type, int i, int j)
int spriteId;
KGrSprite * sprite = m_renderer->getSpriteItem (type, TickTime);
if (m_sprites.count(0) > 0 &&
((spriteId = m_sprites.lastIndexOf (0)) >= 0)) {
if (m_sprites.count(nullptr) > 0 &&
((spriteId = m_sprites.lastIndexOf (nullptr)) >= 0)) {
// Re-use a slot previously occupied by a transient member of the list.
m_sprites[spriteId] = sprite;
}
......@@ -484,7 +484,7 @@ int KGrScene::makeSprite (const char type, int i, int j)
void KGrScene::animate (bool missed)
{
for (KGrSprite * sprite : qAsConst(m_sprites)) {
if (sprite != 0) {
if (sprite != nullptr) {
sprite->animate (missed);
}
}
......@@ -574,7 +574,7 @@ void KGrScene::deleteSprite (const int spriteId)
bool brick = (m_sprites.at(spriteId)->spriteType() == BRICK);
delete m_sprites.at(spriteId);
m_sprites [spriteId] = 0;
m_sprites [spriteId] = nullptr;
if (brick) {
// Dug-brick sprite erased: restore the tile that was at that location.
......
......@@ -217,7 +217,7 @@ private:
* @param x The item's x coordinate.
* @param y The item's y coordinate.
*/
void setBorderTile (const QString spriteKey, const int x, const int y);
void setBorderTile (const QString &spriteKey, const int x, const int y);
/*
* Resize a game's visual element.
......
......@@ -27,7 +27,7 @@ class KGrActorsTheme : public KgTheme
{
Q_OBJECT
public:
Q_INVOKABLE KGrActorsTheme(const QByteArray &identifier, QObject *parent=0);
Q_INVOKABLE KGrActorsTheme(const QByteArray &identifier, QObject *parent=nullptr);
~KGrActorsTheme() override;
/*
......@@ -46,7 +46,7 @@ class KGrSetTheme : public KgTheme
{
Q_OBJECT
public:
Q_INVOKABLE KGrSetTheme(const QByteArray &identifier, QObject *parent=0);
Q_INVOKABLE KGrSetTheme(const QByteArray &identifier, QObject *parent=nullptr);
~KGrSetTheme() override;
/*
......
......@@ -36,7 +36,7 @@ KGrView::~KGrView ()
void KGrView::resizeEvent (QResizeEvent *)
{
if (scene() != 0) {
if (scene() != nullptr) {
m_scene->changeSize ();
fitInView (scene()->sceneRect(), Qt::KeepAspectRatio);
}
......
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