Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Games
KNetWalk
Commits
d1cc69f6
Commit
d1cc69f6
authored
Dec 15, 2021
by
Laurent Montel
Browse files
Use std::as_const/Q_EMIT/Q_SLOTS
parent
bdf20bec
Pipeline
#110422
failed with stage
in 49 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
d1cc69f6
...
...
@@ -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.8
3
.0"
)
set
(
KF5_MIN_VERSION
"5.8
9
.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
)
...
...
autotests/abstractgridtest.cpp
View file @
d1cc69f6
...
...
@@ -26,7 +26,7 @@ class AbstractGridTest : public QObject
{
Q_OBJECT
private
slots
:
private
Q_SLOTS
:
void
testCreateGrid
();
};
...
...
src/abstractgrid.cpp
View file @
d1cc69f6
...
...
@@ -374,7 +374,7 @@ int AbstractGrid::solutionCount()
{
MoveList
possibleNextMoves
;
// TODO: put following in external function
for
each
(
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
;
for
each
(
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
()
{
for
each
(
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
()
{
for
each
(
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
()
{
for
each
(
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
for
each
(
AbstractCell
*
cell
,
m_cells
)
{
for
(
AbstractCell
*
cell
:
std
::
as_const
(
m_cells
)
)
{
if
(
cell
->
isTerminal
()
&&
!
cell
->
isConnected
())
{
return
false
;
}
...
...
src/gameview.cpp
View file @
d1cc69f6
...
...
@@ -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
);
for
each
(
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
()
...
...
src/gameview.h
View file @
d1cc69f6
...
...
@@ -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
);
...
...
src/mainwindow.h
View file @
d1cc69f6
...
...
@@ -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
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment