Commit 25983bcf authored by Laurent Montel's avatar Laurent Montel 😁

Use nullptr/explicit/const

parent f7cf957f
......@@ -29,7 +29,7 @@ include(FeatureSummary)
include(ECMAddAppIcon)
include(ECMInstallIcons)
include(KDEInstallDirs)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
include(ECMQtDeclareLoggingCategory)
......
......@@ -47,7 +47,7 @@
class General : public QWidget, public Ui::General
{
public:
General(QWidget *parent = 0)
explicit General(QWidget *parent = nullptr)
: QWidget(parent)
{
setupUi(this);
......
......@@ -58,10 +58,10 @@ class KTron : public KXmlGuiWindow {
void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE;
void keyReleaseEvent(QKeyEvent *) Q_DECL_OVERRIDE;
public slots:
public Q_SLOTS:
void close();
private slots:
private Q_SLOTS:
void loadSettings();
/** updates players points in statusbar and checks if someone has won */
void changeStatus();
......
......@@ -57,7 +57,7 @@ int main(int argc, char* argv[])
migrate.migrate();
KAboutData aboutData( QStringLiteral("ksnakeduel"), i18n("KSnakeDuel"),
KTRON_VERSION, i18n(description), KAboutLicense::GPL, i18n(notice));
QLatin1String(KTRON_VERSION), i18n(description), KAboutLicense::GPL, i18n(notice));
aboutData.addAuthor(i18n("Matthias Kiefer"), i18n("Original author"), QStringLiteral("matthias.kiefer@gmx.de"));
aboutData.addAuthor(i18n("Benjamin Meyer"), i18n("Various improvements"), QStringLiteral("ben+ktron@meyerhome.net"));
aboutData.addAuthor(i18n("Stas Verberkt"), i18n("KDE 4 Port, interface revision and KSnake mode"), QStringLiteral("legolas@legolasweb.nl"));
......
......@@ -33,20 +33,21 @@ Object::Object(ObjectType::Type t)
m_objectType = t;
}
QString Object::getSVGName() {
QString Object::getSVGName() const
{
return m_svgName;
}
void Object::setSVGName(QString name) {
void Object::setSVGName(const QString &name) {
m_svgName = name;
}
int Object::getX()
int Object::getX() const
{
return m_xCoordinate;
}
int Object::getY()
int Object::getY() const
{
return m_yCoordinate;
}
......@@ -57,7 +58,7 @@ void Object::setCoordinates(int x, int y)
m_yCoordinate = y;
}
ObjectType::Type Object::getObjectType()
ObjectType::Type Object::getObjectType() const
{
return m_objectType;
}
......@@ -43,11 +43,11 @@ class Object
public:
Object();
Object(ObjectType::Type t);
int getX();
int getY();
int getX() const;
int getY() const;
void setCoordinates(int x, int y);
QString getSVGName();
ObjectType::Type getObjectType();
QString getSVGName() const;
ObjectType::Type getObjectType() const;
private:
int m_xCoordinate;
......@@ -56,7 +56,7 @@ class Object
ObjectType::Type m_objectType;
protected:
void setSVGName(QString svgName);
void setSVGName(const QString &svgName);
};
#endif // OBJECT_H
......@@ -88,7 +88,7 @@ int Player::getScore()
// Player name
//
QString Player::getName()
QString Player::getName() const
{
if (isComputer())
{
......@@ -100,7 +100,7 @@ QString Player::getName()
}
}
void Player::setName(QString name)
void Player::setName(const QString &name)
{
if (name.isEmpty())
{
......@@ -427,7 +427,7 @@ void Player::reset()
// Computer powered
//
bool Player::isComputer()
bool Player::isComputer() const
{
return m_computer;
}
......
......@@ -53,7 +53,7 @@ class Player : public QObject
int getPlayerNumber();
void reset();
void setCoordinates(int x, int y);
bool isComputer();
bool isComputer() const;
void setComputer(bool computer);
void setStartPosition();
void movePlayer();
......@@ -72,8 +72,8 @@ class Player : public QObject
void setAccelerated(bool value);
bool hasKeyPressed();
void setKeyPressed(bool value);
QString getName();
void setName(QString name);
QString getName() const;
void setName(const QString &name);
private:
int m_playerNumber;
......@@ -89,7 +89,7 @@ class Player : public QObject
QString m_name;
bool m_blockSwitchDir;
signals:
Q_SIGNALS:
void fetchedItem(int playerNumber, int x, int y);
};
......
......@@ -54,7 +54,7 @@ Object *PlayField::getObjectAt(int x, int y)
if (x < 0 || x >= m_width || y < 0 || y >= m_height) {
qCDebug(KSNAKEDUEL_LOG) << "Inexistent place accessed: (" << x << ", " << y << ")";
return 0;
return nullptr;
}
return &m_playfield[x * m_height + y];
......
......@@ -61,7 +61,7 @@ RendererPrivate::RendererPrivate()
{
QPixmapCache::setCacheLimit(40);
QPixmapCache::clear();
m_playField = 0;
m_playField = nullptr;
}
RendererPrivate::~RendererPrivate()
......
......@@ -54,7 +54,7 @@ int SnakePart::getPlayerNumber()
return this->m_playerNumber;
}
SnakePartType::Types SnakePart::getPartType()
SnakePartType::Types SnakePart::getPartType() const
{
return m_partType;
}
......@@ -64,7 +64,7 @@ void SnakePart::setPartType(SnakePartType::Types type)
m_partType = type;
}
bool SnakePart::getPartTop()
bool SnakePart::getPartTop() const
{
return m_partTop;
}
......@@ -74,7 +74,7 @@ void SnakePart::setPartTop(bool value)
m_partTop = value;
}
bool SnakePart::getPartBottom()
bool SnakePart::getPartBottom() const
{
return m_partBottom;
}
......@@ -84,7 +84,7 @@ void SnakePart::setPartBottom(bool value)
m_partBottom = value;
}
bool SnakePart::getPartLeft()
bool SnakePart::getPartLeft() const
{
return m_partLeft;
}
......@@ -94,7 +94,7 @@ void SnakePart::setPartLeft(bool value)
m_partLeft = value;
}
bool SnakePart::getPartRight()
bool SnakePart::getPartRight() const
{
return m_partRight;
}
......
......@@ -46,15 +46,15 @@ class SnakePart : public Object
public:
SnakePart(int playerNumber);
int getPlayerNumber();
SnakePartType::Types getPartType();
SnakePartType::Types getPartType() const;
void setPartType(SnakePartType::Types type);
bool getPartTop();
bool getPartTop() const;
void setPartTop(bool value);
bool getPartBottom();
bool getPartBottom() const;
void setPartBottom(bool value);
bool getPartLeft();
bool getPartLeft() const;
void setPartLeft(bool value);
bool getPartRight();
bool getPartRight() const;
void setPartRight(bool value);
void generateSVGName();
......
......@@ -57,7 +57,7 @@ class Tron : public QWidget
Q_OBJECT
public:
Tron(QWidget *parent=0);
explicit Tron(QWidget *parent=nullptr);
~Tron();
void updatePixmap();
void setVelocity(int);
......@@ -70,7 +70,7 @@ class Tron : public QWidget
bool hasWinner();
int getWinner();
public slots:
public Q_SLOTS:
/** Starts a new game. The difference to reset is, that the players
* points are set to zero. Emits gameEnds(Nobody).
*/
......@@ -79,7 +79,7 @@ class Tron : public QWidget
void loadSettings();
void itemHit(int playerNumber, int x, int y);
signals:
Q_SIGNALS:
void gameEnds();
void updatedScore();
void gameReset();
......@@ -148,7 +148,7 @@ class Tron : public QWidget
/** Tries to generate a new obstacle */
void newObstacle();
private slots:
private Q_SLOTS:
/**
* This is the main function of KTron.
* It checks if an accelerator is pressed and than moves this player
......
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