Commit 04f572e5 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix some clazy warning

parent 56f6d4e2
......@@ -39,6 +39,7 @@
#include <QStatusBar>
#include <QUrl>
#include <KActionCollection>
#include <KConfigDialog>
#include <KLocalizedString>
......@@ -48,6 +49,7 @@
#include <KStandardGameAction>
#include <KTar>
#define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API
#include <libkdegamesprivate/kgamethemeselector.h>
......@@ -70,7 +72,7 @@
using namespace ksudoku;
void KSudoku::onCompleted(bool isCorrect, const QTime& required, bool withHelp) {
void KSudoku::onCompleted(bool isCorrect, QTime required, bool withHelp) {
if(!isCorrect) {
KMessageBox::information(this, i18n("Sorry, your solution contains mistakes.\n\nEnable \"Show errors\" in the settings to highlight them."));
return;
......
......@@ -25,7 +25,7 @@
#define _KSUDOKU_H_
#include <QUrl>
#include <QTime>
#include <KXmlGuiWindow>
#if 0
#include <knewstuff/knewstuff.h>
......@@ -99,7 +99,7 @@ protected:
void dropEvent(QDropEvent *event) override;
public slots:
void onCompleted(bool isCorrect, const QTime& required, bool withHelp = false);
void onCompleted(bool isCorrect, QTime required, bool withHelp = false);
void showWelcomeScreen();
......
......@@ -201,7 +201,6 @@ SKGraph* Serializer::deserializeGraph(const QDomElement &element) {
if(type.isNull())
return 0;
bool d3 = false;
if(type == QLatin1String("sudoku")) {
SKGraph *graph = new SKGraph(order, TypeSudoku);
graph->initSudoku();
......
......@@ -28,16 +28,16 @@ namespace ksudoku {
/// returns the symbol for a value used for loading and saving
QChar Symbols::ioValue2Symbol(int value) {
if (value == VACANT) return '_';
if (value == UNUSABLE) return '.';
if (value == VACANT) return QLatin1Char('_');
if (value == UNUSABLE) return QLatin1Char('.');
return 'a' + value;
}
/// returns the number of the index
int Symbols::ioSymbol2Value(const QChar& symbol) {
int Symbols::ioSymbol2Value(QChar symbol) {
char c = symbol.toLatin1();
if(symbol == '_') return VACANT;
if(symbol == '.') return UNUSABLE;
if(symbol == QLatin1Char('_')) return VACANT;
if(symbol == QLatin1Char('.')) return UNUSABLE;
return c - 'a';
}
......
......@@ -29,7 +29,7 @@ namespace ksudoku {
class Symbols {
public:
static QChar ioValue2Symbol(int value);
static int ioSymbol2Value(const QChar& symbol);
static int ioSymbol2Value(QChar symbol);
};
}
......
......@@ -52,7 +52,7 @@ void GameActions::init() {
a = new QAction(this);
m_collection->addAction(QStringLiteral("val-select%1").arg(i+1,2,10,QChar('0')), a);
a->setText(i18n("Select %1 (%2)", QChar('a'+i), i+1));
connect(a, &QAction::triggered, this, [this, i] { selectValue(i + 1); });
connect(a, &QAction::triggered, this, [this, i] { Q_EMIT selectValue(i + 1); });
m_actions << a;
a = new QAction(this);
......@@ -71,7 +71,7 @@ void GameActions::init() {
shortcuts << QKeySequence(Qt::Key_1 + i);
}
m_collection->setDefaultShortcuts(a, shortcuts);
connect(a, &QAction::triggered, this, [this, i] { enterValue(i + 1); });
connect(a, &QAction::triggered, this, [this, i] { Q_EMIT enterValue(i + 1); });
m_actions << a;
if (i >= 25) {
continue;
......@@ -86,7 +86,7 @@ void GameActions::init() {
shortcuts << QKeySequence(Qt::ShiftModifier | (Qt::Key_1 + i));
}
m_collection->setDefaultShortcuts(a, shortcuts);
connect(a, &QAction::triggered, this, [this, i] { markValue(i + 1); });
connect(a, &QAction::triggered, this, [this, i] { Q_EMIT markValue(i + 1); });
m_actions << a;
}
......
......@@ -102,8 +102,8 @@ public slots:
void settingsChanged();
signals:
void flagsChanged(ViewFlags flags);
void symbolsChanged(SymbolTable* table);
void flagsChanged(ksudoku::ViewFlags flags);
void symbolsChanged(ksudoku::SymbolTable* table);
void valueSelected(int value);
......
......@@ -25,6 +25,7 @@
#include <QPixmap>
#include <QSvgRenderer>
#define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API
#include <libkdegamesprivate/kgametheme.h>
......@@ -69,7 +70,7 @@ bool Renderer::loadTheme(const QString& themeName) {
return false;
discardCache = true;
m_currentTheme = "default";
m_currentTheme = QStringLiteral("default");
}
bool res = m_renderer->load(theme.graphics());
......@@ -89,51 +90,51 @@ bool Renderer::loadTheme(const QString& themeName) {
void Renderer::fillNameHashes() {
m_borderNames = QVector<QString>();
m_borderNames << "";
m_borderNames << "1";
m_borderNames << "2";
m_borderNames << "12";
m_borderNames << "3";
m_borderNames << "13";
m_borderNames << "23";
m_borderNames << "123";
m_borderNames << "4";
m_borderNames << "14";
m_borderNames << "24";
m_borderNames << "124";
m_borderNames << "34";
m_borderNames << "134";
m_borderNames << "234";
m_borderNames << "1234";
m_borderNames << QStringLiteral("1");
m_borderNames << QStringLiteral("2");
m_borderNames << QStringLiteral("12");
m_borderNames << QStringLiteral("3");
m_borderNames << QStringLiteral("13");
m_borderNames << QStringLiteral("23");
m_borderNames << QStringLiteral("123");
m_borderNames << QStringLiteral("4");
m_borderNames << QStringLiteral("14");
m_borderNames << QStringLiteral("24");
m_borderNames << QStringLiteral("124");
m_borderNames << QStringLiteral("34");
m_borderNames << QStringLiteral("134");
m_borderNames << QStringLiteral("234");
m_borderNames << QStringLiteral("1234");
m_borderTypes << QString();
m_borderTypes << "row";
m_borderTypes << "column";
m_borderTypes << "block";
m_borderTypes << "special";
m_borderTypes << "block"; // Use block-type borders for cages.
m_borderTypes << "special";
m_borderTypes << "special";
m_borderTypes << QStringLiteral("row");
m_borderTypes << QStringLiteral("column");
m_borderTypes << QStringLiteral("block");
m_borderTypes << QStringLiteral("special");
m_borderTypes << QStringLiteral("block"); // Use block-type borders for cages.
m_borderTypes << QStringLiteral("special");
m_borderTypes << QStringLiteral("special");
m_borderTypes << QString();
m_borderTypes << "row_h";
m_borderTypes << "column_h";
m_borderTypes << "block_h";
m_borderTypes << "special_h";
m_borderTypes << "block_h"; // Use block-type borders for cages.
m_borderTypes << "special_h";
m_borderTypes << "special_h";
m_specialNames << "cell";
m_specialNames << "cell_preset";
m_specialNames << "cell";
m_specialNames << "cell_mistake";
m_specialNames << "cursor";
m_specialNames << "valuelist_item";
m_specialNames << "valuelist_selector";
m_special3dNames << "cell3d";
m_special3dNames << "cell3d_preset";
m_special3dNames << "cell3d";
m_special3dNames << "cell3d_mistake";
m_special3dNames << "cursor";
m_special3dNames << "valuelist_item";
m_special3dNames << "valuelist_selector";
m_borderTypes << QStringLiteral("row_h");
m_borderTypes << QStringLiteral("column_h");
m_borderTypes << QStringLiteral("block_h");
m_borderTypes << QStringLiteral("special_h");
m_borderTypes << QStringLiteral("block_h"); // Use block-type borders for cages.
m_borderTypes << QStringLiteral("special_h");
m_borderTypes << QStringLiteral("special_h");
m_specialNames << QStringLiteral("cell");
m_specialNames << QStringLiteral("cell_preset");
m_specialNames << QStringLiteral("cell");
m_specialNames << QStringLiteral("cell_mistake");
m_specialNames << QStringLiteral("cursor");
m_specialNames << QStringLiteral("valuelist_item");
m_specialNames << QStringLiteral("valuelist_selector");
m_special3dNames << QStringLiteral("cell3d");
m_special3dNames << QStringLiteral("cell3d_preset");
m_special3dNames << QStringLiteral("cell3d");
m_special3dNames << QStringLiteral("cell3d_mistake");
m_special3dNames << QStringLiteral("cursor");
m_special3dNames << QStringLiteral("valuelist_item");
m_special3dNames << QStringLiteral("valuelist_selector");
// TODO get this hardcoded values from the SVG file
// m_markerName << "markers9" << "markers9" //...
}
......@@ -142,7 +143,7 @@ QPixmap Renderer::renderBackground(const QSize& size) const {
if(!m_renderer->isValid() || size.isEmpty()) return QPixmap();
QPixmap pix;
QString cacheName = QString("background_%1x%2").arg(size.width()).arg(size.height());
QString cacheName = QStringLiteral("background_%1x%2").arg(size.width()).arg(size.height());
if(!m_cache->findPixmap(cacheName, &pix))
{
pix = QPixmap(size);
......@@ -177,7 +178,7 @@ QPixmap Renderer::renderSpecial(SpecialType type, int size) const {
//only show the errors if the option has been set
if(!Settings::showErrors() && type == SpecialCellMistake ) type = SpecialCell;
QString cacheName = QString("special_%1_%2").arg(m_specialNames[type]).arg(size);
QString cacheName = QStringLiteral("special_%1_%2").arg(m_specialNames[type]).arg(size);
QPixmap pix;
if(!m_cache->findPixmap(cacheName, &pix)) {
pix = QPixmap(size, size);
......@@ -204,12 +205,12 @@ QPixmap Renderer::renderSymbol(int symbol, int size, int max, SymbolType type) c
QString set;
if(max <= 9) {
set = "symbol";
set = QStringLiteral("symbol");
} else {
set = "symbol25";
set = QStringLiteral("symbol25");
}
QString cacheName = QString("%1_%2_%3_%4").arg(set).arg(symbol).arg(size).arg(type);
QString cacheName = QStringLiteral("%1_%2_%3_%4").arg(set).arg(symbol).arg(size).arg(type);
QPixmap pix;
if(!m_cache->findPixmap(cacheName, &pix)) {
pix = QPixmap(size, size);
......@@ -227,17 +228,17 @@ QPixmap Renderer::renderSymbol(int symbol, int size, int max, SymbolType type) c
switch(type) {
case SymbolPreset:
if(m_renderer->elementExists(QString("%1_%2_preset").arg(set).arg(symbol))) {
m_renderer->render(&p, QString("%1_%2_preset").arg(set).arg(symbol), r);
if(m_renderer->elementExists(QStringLiteral("%1_%2_preset").arg(set).arg(symbol))) {
m_renderer->render(&p, QStringLiteral("%1_%2_preset").arg(set).arg(symbol), r);
} else {
m_renderer->render(&p, QString("%1_%2").arg(set).arg(symbol), r);
m_renderer->render(&p, QStringLiteral("%1_%2").arg(set).arg(symbol), r);
}
break;
case SymbolEdited:
if(m_renderer->elementExists(QString("%1_%2_edited").arg(set).arg(symbol))) {
m_renderer->render(&p, QString("%1_%2_edited").arg(set).arg(symbol), r);
if(m_renderer->elementExists(QStringLiteral("%1_%2_edited").arg(set).arg(symbol))) {
m_renderer->render(&p, QStringLiteral("%1_%2_edited").arg(set).arg(symbol), r);
} else {
m_renderer->render(&p, QString("%1_%2").arg(set).arg(symbol), r);
m_renderer->render(&p, QStringLiteral("%1_%2").arg(set).arg(symbol), r);
}
break;
}
......@@ -277,9 +278,9 @@ QPixmap Renderer::renderMarker(int symbol, int range, int size) const {
QString set;
if(range <= 9) {
set = "symbol";
set = QStringLiteral("symbol");
} else {
set = "symbol25";
set = QStringLiteral("symbol25");
}
// TODO this is a hardcoded list of possible marker-groupings
......@@ -292,8 +293,8 @@ QPixmap Renderer::renderMarker(int symbol, int range, int size) const {
range = 25;
}
QString groupName = QString("markers%1").arg(range);
QString cacheName = QString("%1_%2_%3").arg(groupName).arg(symbol).arg(size);
QString groupName = QStringLiteral("markers%1").arg(range);
QString cacheName = QStringLiteral("%1_%2_%3").arg(groupName).arg(symbol).arg(size);
QPixmap pix;
if(!m_cache->findPixmap(cacheName, &pix)) {
pix = QPixmap(size, size);
......@@ -301,15 +302,15 @@ QPixmap Renderer::renderMarker(int symbol, int range, int size) const {
QPainter p(&pix);
// NOTE fix for Qt's QSvgRenderer size reporting bug
QRectF r(m_renderer->boundsOnElement(QString("%1_%2").arg(groupName).arg(symbol)));
QRectF from(m_renderer->boundsOnElement(QString("cell_%1").arg(groupName)));
QRectF r(m_renderer->boundsOnElement(QStringLiteral("%1_%2").arg(groupName).arg(symbol)));
QRectF from(m_renderer->boundsOnElement(QStringLiteral("cell_%1").arg(groupName)));
from.adjust(+0.5,+0.5,-0.5,-0.5); // << this is the fix
QRectF to(QRectF(0,0,size,size));
r.setTopLeft(fromRectToRect(r.topLeft(), from, to));
r.setBottomRight(fromRectToRect(r.bottomRight(), from, to));
m_renderer->render(&p, QString("%1_%2").arg(set).arg(symbol), r);
m_renderer->render(&p, QStringLiteral("%1_%2").arg(set).arg(symbol), r);
p.end();
m_cache->insertPixmap(cacheName, pix);
}
......@@ -349,7 +350,7 @@ QPixmap Renderer::renderCageLabelOn(QPixmap pixmap, const QString & cageLabel)
// TODO - Do font setup once during resize? Put 0+-x/ in themes?
int size = pixmap.width();
QPainter p(&pixmap);
p.setPen(QString("white")); // Text is white on a dark rectangle.
p.setPen(QStringLiteral("white")); // Text is white on a dark rectangle.
p.setBrush(Qt::SolidPattern);
// Cage label uses top 1/4 of pixmap and text is 1/6 height of pixmap.
......@@ -362,7 +363,7 @@ QPixmap Renderer::renderCageLabelOn(QPixmap pixmap, const QString & cageLabel)
int w = fm.boundingRect(cageLabel).width(); // Width of text.
int h = fm.height(); // Total height of font.
int a = fm.ascent(); // Height from baseline of font.
int m = fm.boundingRect(QChar('1')).width()/2; // Left-right margin = 1/2 width of '1'.
int m = fm.boundingRect(QLatin1Char('1')).width()/2; // Left-right margin = 1/2 width of '1'.
// Paint background rect: text must be visible in light and dark themes.
p.fillRect(size/6 - m, (size + 3)/4 - a, w + 2*m, h, Qt::darkGray);
......@@ -376,7 +377,7 @@ QPixmap Renderer::renderCageLabelOn(QPixmap pixmap, const QString & cageLabel)
QPixmap Renderer::renderBorder(int border, GroupTypes type, int size) const {
if(!m_renderer->isValid() || size == 0) return QPixmap();
QString cacheName = QString("contour_%1_%2_%3").arg(m_borderTypes[type]).arg(m_borderNames[border]).arg(size);
QString cacheName = QStringLiteral("contour_%1_%2_%3").arg(m_borderTypes[type]).arg(m_borderNames[border]).arg(size);
QPixmap pix;
if(!m_cache->findPixmap(cacheName, &pix)) {
pix = QPixmap(size, size);
......@@ -384,13 +385,13 @@ QPixmap Renderer::renderBorder(int border, GroupTypes type, int size) const {
QPainter p(&pix);
// NOTE fix for Qt's QSvgRenderer size reporting bug
QRectF r(m_renderer->boundsOnElement(QString("%1_%2").arg(m_borderTypes[type]).arg(m_borderNames[border])));
QRectF r(m_renderer->boundsOnElement(QStringLiteral("%1_%2").arg(m_borderTypes[type]).arg(m_borderNames[border])));
QRectF from(r.adjusted(+0.5,+0.5,-0.5,-0.5));
QRectF to(QRectF(0,0,size,size));
r.setTopLeft(fromRectToRect(r.topLeft(), from, to));
r.setBottomRight(fromRectToRect(r.bottomRight(), from, to));
m_renderer->render(&p, QString("%1_%2").arg(m_borderTypes[type]).arg(m_borderNames[border]), r);
m_renderer->render(&p, QStringLiteral("%1_%2").arg(m_borderTypes[type]).arg(m_borderNames[border]), r);
p.end();
m_cache->insertPixmap(cacheName, pix);
}
......@@ -401,7 +402,7 @@ QPixmap Renderer::renderBorder(int border, GroupTypes type, int size) const {
QPixmap Renderer::renderSpecial3D(SpecialType type, int size) const {
if(!m_renderer->isValid() || size == 0) return QPixmap();
QString cacheName = QString("special_%1_%2").arg(m_special3dNames[type]).arg(size);
QString cacheName = QStringLiteral("special_%1_%2").arg(m_special3dNames[type]).arg(size);
QPixmap pix;
if(!m_cache->findPixmap(cacheName, &pix)) {
pix = QPixmap(size, size);
......
......@@ -92,12 +92,12 @@ public:
QPixmap renderBorder(int border, GroupTypes type, int size) const;
QPixmap renderSymbol(int symbol, int size, int max, SymbolType type) const;
QPixmap renderSymbolOn(QPixmap pixmap, int symbol, int color, int max, SymbolType type) const;
QPixmap renderSymbolOn(QPixmap pixmap, int symbol, int color, int max, SymbolType type) const;
QPixmap renderMarker(int symbol, int range, int size) const;
QPixmap renderMarkerOn(QPixmap pixmap, int symbol, int range, int color) const;
QPixmap renderMarkerOn(QPixmap pixmap, int symbol, int range, int color) const;
QPixmap renderCageLabelOn(QPixmap pixmap, const QString & cageLabel);
QPixmap renderCageLabelOn(QPixmap pixmap, const QString & cageLabel);
QPixmap renderSpecial3D(SpecialType type, int size) const;
private:
......
......@@ -663,7 +663,7 @@ void View2DScene::updateCage (int cageNumP1, bool drawLabel) {
}
// Invoke the method in View2DScene that triggers a re-draw.
setSceneSize (views().first()->size());
setSceneSize (views().constFirst()->size());
}
void View2DScene::selectValue(int value) {
......
......@@ -32,8 +32,6 @@ namespace ksudoku {
Puzzle::Puzzle(SKGraph *graph, bool withSolution)
: m_withSolution(withSolution)
, m_graph(graph)
, m_difficulty(0)
, m_symmetry(0)
, m_initialized(false)
{ }
......
......@@ -97,9 +97,6 @@ private:
BoardContents m_solution;
QList<int> m_hintList;
int m_difficulty;
int m_symmetry;
bool m_initialized;
};
......
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