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
KSudoku
Commits
5341ac76
Commit
5341ac76
authored
Sep 10, 2021
by
Laurent Montel
Browse files
Use Q_SIGNALS/Q_SLOTS/Q_EMIT
parent
6fe6bb17
Changes
17
Hide whitespace changes
Inline
Side-by-side
src/gui/gamevariants.cpp
View file @
5341ac76
...
...
@@ -76,7 +76,7 @@ void GameVariantCollection::addVariant(GameVariant* variant) {
beginInsertRows
(
QModelIndex
(),
count
,
count
);
m_variants
.
append
(
variant
);
endInsertRows
();
emit
newVariant
(
variant
);
Q_EMIT
newVariant
(
variant
);
}
int
GameVariantCollection
::
rowCount
(
const
QModelIndex
&
parent
)
const
{
...
...
src/gui/gamevariants.h
View file @
5341ac76
...
...
@@ -86,7 +86,7 @@ public:
QModelIndex
index
(
int
row
,
int
column
,
const
QModelIndex
&
parent
=
QModelIndex
())
const
override
;
GameVariant
*
variant
(
const
QModelIndex
&
)
const
;
signals
:
Q_SIGNALS
:
void
newVariant
(
GameVariant
*
variant
);
public:
...
...
src/gui/ksudoku.cpp
View file @
5341ac76
...
...
@@ -803,7 +803,7 @@ void KSudoku::updateSettings() {
view
->
settingsChanged
();
}
emit
settingsChanged
();
Q_EMIT
settingsChanged
();
}
void
KSudoku
::
difficultyChanged
(
KGameDifficulty
::
standardLevel
difficulty
)
...
...
src/gui/ksudoku.h
View file @
5341ac76
...
...
@@ -97,7 +97,7 @@ protected:
void
dragEnterEvent
(
QDragEnterEvent
*
event
)
override
;
void
dropEvent
(
QDropEvent
*
event
)
override
;
public
slots
:
public
Q_SLOTS
:
void
onCompleted
(
bool
isCorrect
,
QTime
required
,
bool
withHelp
=
false
);
void
showWelcomeScreen
();
...
...
@@ -107,7 +107,7 @@ public slots:
bool
queryClose
()
override
;
private
slots
:
private
Q_SLOTS
:
void
difficultyChanged
(
KGameDifficulty
::
standardLevel
difficulty
);
void
difficultyChanged
(
int
difficulty
);
// IDW test.
void
symmetryChanged
(
int
symmetry
);
...
...
@@ -140,7 +140,7 @@ private slots:
void
enableMessages
();
signals
:
Q_SIGNALS
:
void
settingsChanged
();
private:
...
...
src/gui/ksudokugame.cpp
View file @
5341ac76
...
...
@@ -61,14 +61,14 @@ public: // The slots of GameIFace
void
undo2Checkpoint
()
override
;
public:
inline
void
emitModified
(
bool
isModified
)
{
emit
modified
(
isModified
);
}
inline
void
emitModified
(
bool
isModified
)
{
Q_EMIT
modified
(
isModified
);
}
inline
void
emitCompleted
(
bool
isCorrect
,
const
QTime
&
required
,
bool
withHelp
)
{
emit
completed
(
isCorrect
,
required
,
withHelp
);
Q_EMIT
completed
(
isCorrect
,
required
,
withHelp
);
}
inline
void
emitCellChange
(
int
index
)
{
emit
cellChange
(
index
);
}
inline
void
emitFullChange
()
{
emit
fullChange
();
}
inline
void
emitCellChange
(
int
index
)
{
Q_EMIT
cellChange
(
index
);
}
inline
void
emitFullChange
()
{
Q_EMIT
fullChange
();
}
inline
void
emitCageChange
(
int
cageNumP1
,
bool
showLabel
)
{
emit
cageChange
(
cageNumP1
,
showLabel
);
}
{
Q_EMIT
cageChange
(
cageNumP1
,
showLabel
);
}
public:
PuzzleState
state
;
...
...
@@ -98,12 +98,12 @@ void Game::Private::undo() {
const
QVector
<
int
>&
indices
=
event
.
cellIndices
();
if
(
indices
.
count
()
>
10
)
{
emit
fullChange
();
Q_EMIT
fullChange
();
}
else
{
for
(
int
i
=
0
;
i
<
indices
.
count
();
++
i
)
emit
cellChange
(
indices
[
i
]);
Q_EMIT
cellChange
(
indices
[
i
]);
}
emit
modified
(
true
);
Q_EMIT
modified
(
true
);
}
void
Game
::
Private
::
redo
()
{
...
...
@@ -114,12 +114,12 @@ void Game::Private::redo() {
const
QVector
<
int
>&
indices
=
event
.
cellIndices
();
if
(
indices
.
count
()
>
10
)
{
emit
fullChange
();
Q_EMIT
fullChange
();
}
else
{
for
(
int
i
=
0
;
i
<
indices
.
count
();
++
i
)
emit
cellChange
(
indices
[
i
]);
Q_EMIT
cellChange
(
indices
[
i
]);
}
emit
modified
(
true
);
Q_EMIT
modified
(
true
);
}
void
Game
::
Private
::
addCheckpoint
()
{
...
...
src/gui/ksudokugame.h
View file @
5341ac76
...
...
@@ -43,13 +43,13 @@ class Puzzle ;
class
GameIFace
:
public
QObject
{
Q_OBJECT
public
slots
:
public
Q_SLOTS
:
virtual
void
undo
()
=
0
;
virtual
void
redo
()
=
0
;
virtual
void
addCheckpoint
()
=
0
;
virtual
void
undo2Checkpoint
()
=
0
;
signals
:
Q_SIGNALS
:
void
modified
(
bool
isModified
);
void
completed
(
bool
isCorrect
,
const
QTime
&
required
,
bool
withHelp
);
void
cellChange
(
int
index
);
...
...
src/gui/views/gameactions.cpp
View file @
5341ac76
...
...
@@ -136,23 +136,23 @@ void GameActions::associateWidget(QWidget* widget) {
}
void
GameActions
::
clearValue
()
{
emit
enterValue
(
32
);
// Delete: not always the same as Qt::Key_0.
Q_EMIT
enterValue
(
32
);
// Delete: not always the same as Qt::Key_0.
}
void
GameActions
::
moveUp
()
{
emit
move
(
0
,
-
1
);
Q_EMIT
move
(
0
,
-
1
);
}
void
GameActions
::
moveDown
()
{
emit
move
(
0
,
+
1
);
Q_EMIT
move
(
0
,
+
1
);
}
void
GameActions
::
moveLeft
()
{
emit
move
(
-
1
,
0
);
Q_EMIT
move
(
-
1
,
0
);
}
void
GameActions
::
moveRight
()
{
emit
move
(
+
1
,
0
);
Q_EMIT
move
(
+
1
,
0
);
}
}
...
...
src/gui/views/gameactions.h
View file @
5341ac76
...
...
@@ -34,12 +34,12 @@ public:
explicit
GameActions
(
KActionCollection
*
collection
,
QObject
*
parent
);
void
init
();
void
associateWidget
(
QWidget
*
widget
);
signals
:
Q_SIGNALS
:
void
selectValue
(
int
value
);
void
enterValue
(
int
value
=
-
1
);
void
markValue
(
int
value
=
-
1
);
void
move
(
int
dx
,
int
dy
);
private
slots
:
private
Q_SLOTS
:
void
clearValue
();
void
moveUp
();
void
moveDown
();
...
...
src/gui/views/ksview.cpp
View file @
5341ac76
...
...
@@ -95,7 +95,7 @@ void KsView::createView() {
void
KsView
::
selectValue
(
int
value
)
{
if
(
value
==
m_currentValue
)
return
;
m_currentValue
=
value
;
emit
valueSelected
(
value
);
Q_EMIT
valueSelected
(
value
);
}
SymbolTable
*
KsView
::
symbolTable
()
const
{
...
...
@@ -104,13 +104,13 @@ SymbolTable* KsView::symbolTable() const {
void
KsView
::
setSymbolTable
(
SymbolTable
*
table
)
{
m_symbolTable
=
table
;
emit
symbolsChanged
(
table
);
Q_EMIT
symbolsChanged
(
table
);
}
void
KsView
::
setWidget
(
QWidget
*
widget
)
{
m_viewWidget
=
widget
;
emit
flagsChanged
(
m_flags
);
emit
symbolsChanged
(
m_symbolTable
);
Q_EMIT
flagsChanged
(
m_flags
);
Q_EMIT
symbolsChanged
(
m_symbolTable
);
m_view
=
dynamic_cast
<
ViewInterface
*>
(
widget
);
}
...
...
src/gui/views/ksview.h
View file @
5341ac76
...
...
@@ -90,18 +90,18 @@ public:
ViewFlags
flags
()
const
{
return
m_flags
;
}
void
setFlags
(
ViewFlags
flags
)
{
m_flags
=
flags
;
emit
flagsChanged
(
flags
);
Q_EMIT
flagsChanged
(
flags
);
}
public:
void
createView
();
public
slots
:
public
Q_SLOTS
:
void
selectValue
(
int
value
);
void
settingsChanged
();
signals
:
Q_SIGNALS
:
void
flagsChanged
(
ksudoku
::
ViewFlags
flags
);
void
symbolsChanged
(
ksudoku
::
SymbolTable
*
table
);
void
valueSelected
(
int
value
);
...
...
src/gui/views/roxdokuview.h
View file @
5341ac76
...
...
@@ -58,12 +58,12 @@ public:
QWidget
*
widget
()
override
{
return
this
;
}
public
slots
:
public
Q_SLOTS
:
void
selectValue
(
int
value
)
override
;
void
settingsChanged
();
void
enterValue
(
int
value
);
signals
:
Q_SIGNALS
:
void
valueSelected
(
int
value
);
// Never used but connected to
protected:
...
...
@@ -87,7 +87,7 @@ protected:
updateGL
();
}
private
slots
:
private
Q_SLOTS
:
void
delayOver
();
private:
...
...
src/gui/views/valuelistwidget.cpp
View file @
5341ac76
...
...
@@ -177,7 +177,7 @@ void ValueListWidget::selectValue(int value) {
void
ValueListWidget
::
selectValueItem
(
int
value
)
{
selectValue
(
value
);
emit
valueSelected
(
value
);
Q_EMIT
valueSelected
(
value
);
}
void
ValueListWidget
::
wheelEvent
(
QWheelEvent
*
e
)
{
...
...
src/gui/views/valuelistwidget.h
View file @
5341ac76
...
...
@@ -45,13 +45,13 @@ public:
void
resizeEvent
(
QResizeEvent
*
)
override
;
public
slots
:
public
Q_SLOTS
:
void
selectValue
(
int
value
);
signals
:
Q_SIGNALS
:
/**
* This signal gets emitted when the ValueListWidget itself changed the
* selected value. A call of selectValue(int) will not cause an
emit
.
* selected value. A call of selectValue(int) will not cause an
Q_EMIT
.
*/
void
valueSelected
(
int
value
);
...
...
src/gui/views/view2d.cpp
View file @
5341ac76
...
...
@@ -668,7 +668,7 @@ void View2DScene::updateCage (int cageNumP1, bool drawLabel) {
void
View2DScene
::
selectValue
(
int
value
)
{
m_selectedValue
=
value
;
emit
valueSelected
(
value
);
Q_EMIT
valueSelected
(
value
);
}
void
View2DScene
::
enterValue
(
int
value
,
int
cell
)
{
...
...
@@ -762,7 +762,7 @@ void View2DScene::wheelEvent(QGraphicsSceneWheelEvent* event) {
if
(
m_selectedValue
<
1
)
m_selectedValue
=
m_game
.
order
();
}
emit
valueSelected
(
m_selectedValue
);
Q_EMIT
valueSelected
(
m_selectedValue
);
}
...
...
src/gui/views/view2d.h
View file @
5341ac76
...
...
@@ -67,7 +67,7 @@ public:
inline
int
maxValue
()
const
{
return
m_game
.
order
();
}
public
slots
:
public
Q_SLOTS
:
void
selectValue
(
int
val
);
void
enterValue
(
int
val
,
int
cell
=-
1
);
void
markValue
(
int
val
,
int
cell
=-
1
,
bool
set
=
true
);
...
...
@@ -83,7 +83,7 @@ public slots:
* Value 0: invalid.
*/
void
updateCage
(
int
cageNumP1
,
bool
drawLabel
);
signals
:
Q_SIGNALS
:
void
valueSelected
(
int
val
);
protected:
void
wheelEvent
(
QGraphicsSceneWheelEvent
*
event
)
override
;
...
...
@@ -111,10 +111,10 @@ public:
public:
QWidget
*
widget
()
override
{
return
this
;
}
public
slots
:
public
Q_SLOTS
:
void
selectValue
(
int
value
)
override
;
void
settingsChanged
();
signals
:
Q_SIGNALS
:
void
valueSelected
(
int
value
);
protected:
void
resizeEvent
(
QResizeEvent
*
e
)
override
;
...
...
src/gui/welcomescreen.cpp
View file @
5341ac76
...
...
@@ -153,7 +153,7 @@ void WelcomeScreen::startEmptyGame() {
return
;
}
emit
newGameStarted
(
game
,
variant
);
Q_EMIT
newGameStarted
(
game
,
variant
);
}
void
WelcomeScreen
::
playVariant
()
{
...
...
@@ -170,7 +170,7 @@ void WelcomeScreen::playVariant() {
return
;
}
emit
newGameStarted
(
game
,
variant
);
Q_EMIT
newGameStarted
(
game
,
variant
);
}
void
WelcomeScreen
::
generatePuzzle
()
{
...
...
@@ -199,7 +199,7 @@ void WelcomeScreen::generatePuzzle() {
// If the user abandoned puzzle-generation, stay on the Welcome Screen
// and allow the user to change the Difficulty, etc. of the puzzle.
if
(
game
.
puzzle
()
->
hasSolution
())
{
emit
newGameStarted
(
game
,
variant
);
// OK, start playing.
Q_EMIT
newGameStarted
(
game
,
variant
);
// OK, start playing.
}
}
...
...
src/gui/welcomescreen.h
View file @
5341ac76
...
...
@@ -41,7 +41,7 @@ public:
int
symmetry
()
const
;
void
setSymmetry
(
int
symmetry
);
private
slots
:
private
Q_SLOTS
:
void
onCurrentVariantChange
();
void
getNewVariant
();
...
...
@@ -57,7 +57,7 @@ private slots:
// otherwise selection fails and no selection is shown.
void
setSelectedVariant
(
int
row
);
signals
:
Q_SIGNALS
:
void
newGameStarted
(
const
::
ksudoku
::
Game
&
game
,
GameVariant
*
variant
);
private:
...
...
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