Commit 7a48cb9c authored by Laurent Montel's avatar Laurent Montel 😁

GIT_SILENT: minor qstring optimization

parent a8da92d3
......@@ -306,11 +306,11 @@ KGrLGDialog::KGrLGDialog (QFile * savedGames,
// Read the saved games into the list box.
while (! gameText.atEnd()) {
s = gameText.readLine(); // Read in one saved game.
pr = s.left (s.indexOf (QStringLiteral(" "), 0,
pr = s.left (s.indexOf(QLatin1Char(' '), 0,
Qt::CaseInsensitive)); // Get the game prefix.
for (i = 0; i < imax; ++i) { // Get the game name.
if (gameList.at (i)->prefix == pr) {
s = s.insert (0,
s.insert (0,
gameList.at (i)->name.leftJustified (20, QLatin1Char(' '), true) + QLatin1Char(' '));
break;
}
......
......@@ -374,7 +374,7 @@ bool KGrEditor::moveLevelFile (int pGameIndex, int level)
// Save the "fromN" file under a temporary name.
filePath1 = getLevelFilePath (gameList.at (fromC), fromL);
filePath2 = filePath1;
filePath2 = filePath2.append (QStringLiteral(".tmp"));
filePath2.append (QStringLiteral(".tmp"));
if (! KGrGameIO::safeRename (view, filePath1, filePath2)) {
return false;
}
......@@ -858,7 +858,7 @@ QString KGrEditor::getTitle()
QString KGrEditor::getLevelFilePath (KGrGameData * gameData, int lev)
{
QString filePath = userDataDir + QStringLiteral("levels/") + gameData->prefix +
QString filePath = userDataDir + QLatin1String("levels/") + gameData->prefix +
QString::number(lev).rightJustified(3, QLatin1Char('0')) + QStringLiteral(".grl");
return (filePath);
}
......
......@@ -442,7 +442,7 @@ void KGrGame::initGame()
// If he/she has never played before, set it to Tutorial, level 1.
KConfigGroup gameGroup (KSharedConfig::openConfig(), "KDEGame");
QString prevGamePrefix = gameGroup.readEntry ("GamePrefix", "tute");
int prevLevel = gameGroup.readEntry (QStringLiteral("Level_") + prevGamePrefix, 1);
int prevLevel = gameGroup.readEntry (QLatin1String("Level_") + prevGamePrefix, 1);
//qCDebug(KGOLDRUNNER_LOG)<< "Config() Game and Level" << prevGamePrefix << prevLevel;
......@@ -519,14 +519,14 @@ void KGrGame::initGame()
bool KGrGame::getRecordingName (const QString & dir, const QString & pPrefix,
QString & filename)
{
QString recFile = dir + QStringLiteral("rec_") + pPrefix + QStringLiteral(".txt");
QString recFile = dir + QLatin1String("rec_") + pPrefix + QLatin1String(".txt");
QFileInfo fileInfo (recFile);
bool recOK = fileInfo.exists() && fileInfo.isReadable();
filename = QString ();
if (demoType == SOLVE) {
// Look for a solution-file name in User or System area.
QString solFile = dir + QStringLiteral("sol_") + pPrefix + QStringLiteral(".txt");
QString solFile = dir + QLatin1String("sol_") + pPrefix + QLatin1String(".txt");
fileInfo.setFile (solFile);
bool solOK = fileInfo.exists() && fileInfo.isReadable();
if (solOK) {
......@@ -1569,7 +1569,7 @@ bool KGrGame::selectSavedGame (int & selectedGame, int & selectedLevel)
selectedLevel = 0;
if (! loadedData.isEmpty()) {
pr = loadedData.mid (21, 7); // Get the game prefix.
pr = pr.left (pr.indexOf (QStringLiteral(" "), 0, Qt::CaseInsensitive));
pr = pr.left (pr.indexOf(QLatin1Char(' '), 0, Qt::CaseInsensitive));
for (int i = 0; i < gameList.count(); i++) { // Find the game.
if (gameList.at (i)->prefix == pr) {
......
......@@ -274,7 +274,7 @@ QString KGrGameIO::getFilePath
(const QString & dir, const QString & prefix, const int level)
{
QString filePath = ((level == 0) ? QStringLiteral("ende") : prefix);
filePath = dir + QStringLiteral("game_") + filePath + QStringLiteral(".txt");
filePath = dir + QLatin1String("game_") + filePath + QLatin1String(".txt");
QFile test (filePath);
// See if there is a game-file or "ENDE" screen in KGoldrunner 3 format.
......@@ -289,7 +289,7 @@ QString KGrGameIO::getFilePath
}
else {
QString num = QString::number (level).rightJustified (3, QLatin1Char('0'));
filePath = dir + QStringLiteral("levels/") + prefix + num + QStringLiteral(".grl");
filePath = dir + QLatin1String("levels/") + prefix + num + QLatin1String(".grl");
}
return (filePath);
......@@ -300,7 +300,7 @@ char KGrGameIO::getALine (const bool kgr3, QByteArray & line)
char c;
line = "";
while (openFile.getChar (&c)) {
line = line.append (c);
line.append (c);
if (c == '\n') {
break;
}
......
......@@ -587,7 +587,7 @@ Direction KGrLevelPlayer::getEnemyDirection (int enemyI, int enemyJ,
bool KGrLevelPlayer::heroCaught (const int heroX, const int heroY)
{
if (enemies.count() == 0) {
if (enemies.isEmpty()) {
return false;
}
int enemyX, enemyY, pointsPerCell_1;
......
......@@ -213,7 +213,7 @@ bool KGrRenderer::hasBorder() const
{
QString s = m_setRenderer->theme()->customData(QStringLiteral("DrawCanvasBorder"), QStringLiteral("0"));
if (s == QStringLiteral("1"))
if (s == QLatin1Char('1'))
return true;
else
return false;
......@@ -308,7 +308,7 @@ int KGrRenderer::countFrames (const int index)
count++;
}
if ((count == 0) && (QLatin1String(keyTable[index].picKey) != QStringLiteral("brick"))) {
if ((count == 0) && (QLatin1String(keyTable[index].picKey) != QLatin1String("brick"))) {
return count;
}
......
......@@ -448,7 +448,7 @@ void KGrSLDialog::slGame()
}
// Else use the last level played in the selected game (from KConfig).
else {
lev = gameGroup.readEntry (QStringLiteral("Level_") + myGameList.at (n)->prefix, 1);
lev = gameGroup.readEntry (QLatin1String("Level_") + myGameList.at (n)->prefix, 1);
number->setValue (lev); // Else use level 1.
}
break;
......
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