Commit 85c2e121 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use Q_EMIT/Q_SLOTS/Q_SIGNALS

parent 3d20cc53
......@@ -66,7 +66,7 @@ public:
~Ai() override;
virtual void cancelAndWait() = 0;
public slots:
public Q_SLOTS:
virtual void changeBoard(const Move& move) = 0;
virtual void gameOver() = 0;
virtual void setSkill(KgDifficultyLevel::StandardLevel skill) = 0;
......
......@@ -64,7 +64,7 @@ void AiAron::setSkill(KgDifficultyLevel::StandardLevel skill) {
}
void AiAron::slotMove() {
emit move(Move(m_player, m_board->move()));
Q_EMIT move(Move(m_player, m_board->move()));
}
} /* namespace ai */
......
......@@ -45,13 +45,13 @@ public:
~AiAron() override;
void cancelAndWait() Q_DECL_OVERRIDE;
public slots:
public Q_SLOTS:
void changeBoard(const Move& move) Q_DECL_OVERRIDE;
void gameOver() Q_DECL_OVERRIDE;
void setSkill(KgDifficultyLevel::StandardLevel skill) Q_DECL_OVERRIDE;
void slotMove() Q_DECL_OVERRIDE;
signals:
Q_SIGNALS:
void move(const Move& move);
private:
......
......@@ -112,7 +112,7 @@ void AiGabor::slotMoveImpl() {
QThread::yieldCurrentThread();
}
if (!m_canceling) {
emit move(Move(m_player, Coord(f.x, f.y)));
Q_EMIT move(Move(m_player, Coord(f.x, f.y)));
}
}
......
......@@ -46,13 +46,13 @@ public:
void cancelAndWait() Q_DECL_OVERRIDE;
bool isTimeOver() Q_DECL_OVERRIDE;
public slots:
public Q_SLOTS:
void changeBoard(const Move& move) Q_DECL_OVERRIDE;
void gameOver() Q_DECL_OVERRIDE;
void setSkill(KgDifficultyLevel::StandardLevel skill) Q_DECL_OVERRIDE;
void slotMove() Q_DECL_OVERRIDE;
signals:
Q_SIGNALS:
void move(const Move& move);
private:
......
......@@ -171,9 +171,9 @@ void Game::setSkill(KgDifficultyLevel::StandardLevel skill) {
void Game::start() {
if (computerTurn()) {
emit oposerTurn();
Q_EMIT oposerTurn();
} else {
emit playerTurn();
Q_EMIT playerTurn();
}
}
......@@ -181,7 +181,7 @@ void Game::startRestored() {
connect(this, &Game::boardChanged,
m_ai, &Ai::changeBoard);
foreach (const Move &move, m_history) {
emit boardChanged(move);
Q_EMIT boardChanged(move);
}
connect(this, &Game::oposerTurn, m_ai, &Ai::slotMove,
Qt::QueuedConnection);
......@@ -189,13 +189,13 @@ void Game::startRestored() {
this, SLOT(move(Move)));
if (!m_history.isEmpty() && m_history.last().player() == X) {
m_curPlayer = O;
emit oposerTurn();
Q_EMIT oposerTurn();
} else {
m_curPlayer = X;
emit playerTurn();
Q_EMIT playerTurn();
}
if (!m_history.isEmpty()) {
emit undoAble();
Q_EMIT undoAble();
}
}
......@@ -221,7 +221,7 @@ void Game::move(const Move& move) {
}
makeMove(move);
if (tmp_emptyHistory && !m_history.empty() && !m_demoMode) {
emit undoAble();
Q_EMIT undoAble();
}
}
......@@ -232,7 +232,7 @@ void Game::replay() {
m_replayIteratorEnd = m_history.constEnd();
disconnect(this, &Game::replayBegin, this, &Game::replayNext);
connect(this, &Game::replayBegin, this, &Game::replayNext);
emit replayBegin();
Q_EMIT replayBegin();
}
}
......@@ -258,29 +258,29 @@ void Game::undoLatest() {
m_history.removeLast();
m_board->setPlayer(move);
m_stepCount--;
emit boardChanged(move);
Q_EMIT boardChanged(move);
m_curPlayer = m_playerMark;
emit playerTurn();
Q_EMIT playerTurn();
} else if (m_curPlayer == m_playerMark) {
Move move(No, m_history.last().coord());
m_history.removeLast();
m_board->setPlayer(move);
m_stepCount--;
emit boardChanged(move);
Q_EMIT boardChanged(move);
if (m_history.count() == 0) {
m_curPlayer = m_computerMark;
emit oposerTurn();
Q_EMIT oposerTurn();
} else {
Move move2(No, m_history.last().coord());
m_history.removeLast();
m_board->setPlayer(move2);
m_stepCount--;
emit boardChanged(move2);
emit playerTurn();
Q_EMIT boardChanged(move2);
Q_EMIT playerTurn();
}
}
if (m_history.empty() && !m_demoMode) {
emit undoNotAble();
Q_EMIT undoNotAble();
}
m_inUndoState = false;
}
......@@ -290,11 +290,11 @@ void Game::undoLatest() {
void Game::replayNext() {
if (m_replayIterator != m_replayIteratorEnd) {
QTimer::singleShot(m_playTime, this, &Game::replayNext);
emit boardChanged(*m_replayIterator);
Q_EMIT boardChanged(*m_replayIterator);
++m_replayIterator;
} else {
m_replaying = false;
emit replayEnd(winningMoves()); // FIX:!!!!!!!
Q_EMIT replayEnd(winningMoves()); // FIX:!!!!!!!
}
}
......@@ -316,23 +316,23 @@ void Game::makeMove(const Move& move) {
}
m_history << move;
m_curPlayer = (m_curPlayer == X ? O : X );
emit boardChanged(move);
Q_EMIT boardChanged(move);
if (m_gameOver) {
QList<Move> moves = winningMoves();
emit gameOver(moves);
Q_EMIT gameOver(moves);
this->disconnect(m_ai);
} else {
if (computerTurn()) {
if (m_demoMode) {
QTimer::singleShot(m_playTime, this, &Game::oposerTurn);
} else {
emit oposerTurn();
Q_EMIT oposerTurn();
}
} else {
if (m_demoMode) {
QTimer::singleShot(m_playTime, this, &Game::playerTurn);
} else {
emit playerTurn();
Q_EMIT playerTurn();
}
}
}
......
......@@ -230,7 +230,7 @@ public:
*/
void cancelAndWait();
public slots:
public Q_SLOTS:
/**
* @brief make a move
* @param move move to make
......@@ -248,7 +248,7 @@ public slots:
*/
void undoLatest();
signals:
Q_SIGNALS:
/**
* @brief emitted at game over
* @param moves Winning moves (winning line)
......@@ -292,7 +292,7 @@ signals:
*/
void undoNotAble();
private slots:
private Q_SLOTS:
void replayNext();
private:
......
......@@ -93,7 +93,7 @@ void HintItem::killTick() {
update();
if (m_opacity <= 0.05) {
m_ticker->stop();
emit killed();
Q_EMIT killed();
}
}
......
......@@ -47,11 +47,11 @@ public:
void setFill(qreal fill);
QRectF boundingRect() const Q_DECL_OVERRIDE;
public slots:
public Q_SLOTS:
void tick();
void killTick();
signals:
Q_SIGNALS:
void killed();
protected:
......
......@@ -58,7 +58,7 @@ public:
explicit MainWindow(QWidget* parent=0);
~MainWindow() override;
public slots:
public Q_SLOTS:
void hint();
void slotNewGame();
void slotPlayerTurn();
......
......@@ -98,7 +98,7 @@ void Mark::killTick() {
update();
if (m_opacity <= 0.1) {
m_ticker->stop();
emit killed(this);
Q_EMIT killed(this);
}
}
......
......@@ -50,11 +50,11 @@ public:
void setFill(qreal fill);
QRectF boundingRect() const Q_DECL_OVERRIDE;
public slots:
public Q_SLOTS:
void tick();
void killTick();
signals:
Q_SIGNALS:
void killed(Mark* thisMark);
protected:
......
......@@ -262,7 +262,7 @@ void Scene::mousePressEvent( QGraphicsSceneMouseEvent* ev ) {
row = qMin(NUMCOLS-1, row);
col = qMax(col, 0);
col = qMin(NUMCOLS-1, col);
emit move(Move(m_player, Coord(col, row)));
Q_EMIT move(Move(m_player, Coord(col, row)));
}
void Scene::removePaintMarker() {
......
......@@ -58,7 +58,7 @@ public:
QPointF cellCenter( int x, int y ) const;
QPointF cellTopLeft( int x, int y ) const;
public slots:
public Q_SLOTS:
void updateBoard(const Move& move);
void slotPlayerTurn();
void slotOposerTurn();
......@@ -74,7 +74,7 @@ public slots:
protected:
bool event(QEvent *event) Q_DECL_OVERRIDE;
signals:
Q_SIGNALS:
void move(const Move&);
private:
......
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