Skip to content

Commit

Permalink
Pass the new signals on from Picmi
Browse files Browse the repository at this point in the history
Nice to see that connecting signals to signals is also possible.
  • Loading branch information
schuay committed Jul 23, 2012
1 parent 2b737e3 commit ea57b30
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/logic/picmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ Picmi::Picmi()
}

m_timer.start();

setupSlots();
}

Picmi::Picmi(QSharedPointer<BoardMap> board) {
Expand All @@ -128,6 +130,14 @@ Picmi::Picmi(QSharedPointer<BoardMap> board) {
m_streaks = QSharedPointer<Streaks>(new Streaks(m_map, m_state));
m_io_handler = QSharedPointer<IOHandler>(new IOHandlerNoHints(m_map.data(), m_state.data(), &m_timer));
m_timer.start();

setupSlots();
}

void Picmi::setupSlots()
{
connect(m_state.data(), SIGNAL(undoStackSizeChanged(int)), this, SIGNAL(undoStackSizeChanged(int)));
connect(m_state.data(), SIGNAL(saveStackSizeChanged(int)), this, SIGNAL(saveStackSizeChanged(int)));
}

bool Picmi::won() const {
Expand Down
10 changes: 10 additions & 0 deletions src/logic/picmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,23 @@ class Picmi : public QObject

signals:
void gameWon();

/**
* Emitted whenever the board state has changed (i.e. by undoing an action,
* setting a state explicitly, or loading a saved state).
*/
void stateChanged();

void undoStackSizeChanged(int size);
void saveStackSizeChanged(int size);

private:

/* returns true if the game has been won */
bool won() const;

void setupSlots();

private:
QSharedPointer<BoardMap> m_map;
QSharedPointer<BoardState> m_state;
Expand Down

0 comments on commit ea57b30

Please sign in to comment.