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

Use std::as_const/Q_EMIT/Q_SLOTS

parent bdf20bec
Pipeline #110422 failed with stage
in 49 seconds
......@@ -9,7 +9,7 @@ set (RELEASE_SERVICE_COMPACT_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}${RELEASE_
project(knetwalk VERSION "3.3.${RELEASE_SERVICE_COMPACT_VERSION}")
set (QT_MIN_VERSION "5.15.0")
set (KF5_MIN_VERSION "5.83.0")
set (KF5_MIN_VERSION "5.89.0")
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} )
......@@ -57,6 +57,12 @@ add_definitions(
-DQT_NO_URL_CAST_FROM_STRING
-DQT_USE_QSTRINGBUILDER
)
add_definitions(
-DQT_DISABLE_DEPRECATED_BEFORE=0x050F00
-DQT_DEPRECATED_WARNINGS_SINCE=0x060000
-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055900
-DKF_DEPRECATED_WARNINGS_SINCE=0x060000
)
add_subdirectory(src)
add_subdirectory(themes)
......
......@@ -26,7 +26,7 @@ class AbstractGridTest : public QObject
{
Q_OBJECT
private slots:
private Q_SLOTS:
void testCreateGrid();
};
......
......@@ -374,7 +374,7 @@ int AbstractGrid::solutionCount()
{
MoveList possibleNextMoves;
// TODO: put following in external function
foreach (AbstractCell *cell, m_cells) {
for (AbstractCell *cell : std::as_const(m_cells)) {
if (!cell->hasBeenMoved()) {
Directions dirs = cell->cables();
Move move;
......@@ -414,7 +414,7 @@ int AbstractGrid::solutionCount()
// else
int solutionsFound = 0;
foreach (const Move &nextMove, possibleNextMoves) {
for (const Move &nextMove : std::as_const(possibleNextMoves)) {
int index = nextMove.index();
switch (nextMove.move()) {
......@@ -444,7 +444,7 @@ int AbstractGrid::solutionCount()
bool AbstractGrid::movesDoneArePossible()
{
foreach (AbstractCell *cell, m_cells) {
for (AbstractCell *cell : std::as_const(m_cells)) {
if (!cell->hasBeenMoved()) continue;
uint x = cell->index() % m_width;
......@@ -496,7 +496,7 @@ bool AbstractGrid::movesDoneArePossible()
bool AbstractGrid::hasUnneededCables()
{
foreach (AbstractCell *cell, m_cells) {
for (AbstractCell *cell : std::as_const(m_cells)) {
if (cell->isTerminal() || cell->isServer() || cell->cables() == None) {
continue;
}
......@@ -518,7 +518,7 @@ bool AbstractGrid::hasUnneededCables()
bool AbstractGrid::isPossibleSolution()
{
foreach (AbstractCell *cell, m_cells) {
for (AbstractCell *cell : std::as_const(m_cells)) {
cell->setConnected(false);
}
updateConnections();
......@@ -528,7 +528,7 @@ bool AbstractGrid::isPossibleSolution()
bool AbstractGrid::allTerminalsConnected() {
// return false if there is a terminal that isn't connected
foreach (AbstractCell *cell, m_cells) {
for (AbstractCell *cell : std::as_const(m_cells)) {
if (cell->isTerminal() && !cell->isConnected()) {
return false;
}
......
......@@ -84,7 +84,7 @@ void GameView::clicked(int index)
{
if (index >= 0) {
rotatingCells.insert(index);
emit rotationStarted();
Q_EMIT rotationStarted();
if (Settings::playSounds()) {
m_soundTurn->start();
}
......@@ -106,11 +106,11 @@ void GameView::rotated(int index, int angle)
case 180: case -180:
grid->cellAt(index)->invert();
}
QList<int> changedCells = grid->updateConnections();
const QList<int> changedCells = grid->updateConnections();
bool newTerminalConnected = false;
rotatingCells.remove(index);
foreach (int i, changedCells) {
for (int i : changedCells) {
if(grid->cellAt(i)->isTerminal()){
newTerminalConnected = true;
}
......@@ -125,7 +125,7 @@ void GameView::rotated(int index, int angle)
}
if (Settings::autolock()) {
emit lock(index);
Q_EMIT lock(index);
}
if (rotatingCells.count() == 0) {
checkCompleted();
......@@ -165,7 +165,7 @@ void GameView::checkCompleted()
return;
}
}
emit gameOver(QLatin1String("won"));
Q_EMIT gameOver(QLatin1String("won"));
}
void GameView::solve()
......@@ -183,7 +183,7 @@ void GameView::solve()
setSprite(i, code, QLatin1String("none"));
}
}
emit gameOver(QLatin1String("solved"));
Q_EMIT gameOver(QLatin1String("solved"));
}
void GameView::updateSettings()
......
......@@ -40,10 +40,10 @@ public:
public slots:
public Q_SLOTS:
void updateSettings();
signals:
Q_SIGNALS:
void newCell(const QVariant &cable, const QVariant &type);
void setSprite(const QVariant &pos, const QVariant &cable, const QVariant &type);
void setSize(const QVariant &width, const QVariant &height);
......@@ -51,7 +51,7 @@ signals:
void lock(const QVariant&);
void gameOver(const QVariant &msg);
private slots:
private Q_SLOTS:
void solve();
void clicked(int index);
void rotated(int index, int angle);
......
......@@ -43,9 +43,9 @@ private:
StatusBarIndexTime = 1
};
QSize boardSize();
signals:
Q_SIGNALS:
void pause(const QVariant &paused);
private slots:
private Q_SLOTS:
void startNewGame();
void gameOver(const QVariant &msg);
void rotationStarted();
......
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