ChessClock Class Reference

Clock of a individual player. More...

#include <chessclock.h>

Inheritance diagram for ChessClock:
ChessClockWidget DelayAfterClock DelayClock FischerAfterClock FischerClock HourGlassClock

List of all members.

Public Types

enum  RunningStatus { NotRunning = 0, Running = 1, Paused = 2 }

Public Slots

virtual void repaintClock ()=0
 Refresh clock information.
virtual void updateClock ()
 Update clock information, check looser state and refresh.

Signals

void timeOutLoser ()
void turnEnded ()
void dontEatBattery ()
 Emitted after 30 min played one turn.

Public Member Functions

 ChessClock (bool white, QWidget *parent=0)
bool isLoser () const
int getTurn () const
bool isWhite () const
RunningStatus getStatus () const
virtual void startTurn ()
 Start new turn.
virtual TurnInformationendTurn ()
 End this turn.
virtual void pauseTurn ()
 Pause clock.
virtual void continueTurn ()
 Continue paused game.
void setAnother (ChessClock *another)
 Set another chess clock for connecting.
virtual int getTimeAvailable ()
 Get total time available.
virtual int getTimePlayed ()
 Get total time played.
void setTimeAvailable (int msecs)
 Set time available.
void addTime (int msecs)
 Add time.
int currentTurnPlayed ()
 Get time played current turn.

Protected Attributes

ChessClockanother_
bool loser_
 Another player's clock.
int turn_
 Is player losed because of timeout.
RunningStatus status_
 Current turn.
TurnInformationcurrentTurn_
bool dontEatBatteryEmitted_
int timePlayedBeforeTurn_
int timeAvailableBeforeTurn_
 Time played in this game BEFORE this turn msecs.
bool isWhite_
 Time available for play BEFORE this turn msecs !
QTime clockTime_
 True if white player.
QTimer updateTimer_

Static Protected Attributes

static const int UPDATEINTERVAL = 1000
static const int DONTEATBATTERYTIME = 30 * 60 * 1000

Detailed Description

Clock of a individual player.

Author:
Arto Hyvättinen
Date:
2010-08-13

Base class of chess clock.

ChessClock has not GUI itself, but it is subclass of QWidget avoiding polymorphism.

Definition at line 43 of file chessclock.h.


Member Enumeration Documentation

Enumerator:
NotRunning 

Not turn.

Running 

Turn running.

Paused 

Turn paused.

Definition at line 50 of file chessclock.h.


Constructor & Destructor Documentation

ChessClock::ChessClock ( bool  white,
QWidget *  parent = 0 
)

Definition at line 29 of file chessclock.cpp.


Member Function Documentation

void ChessClock::addTime ( int  msecs  ) 

Add time.

Add time to timeAvailableBeforeTurn_ total available time counter.

Parameters:
msecs Time to add in msecs

Definition at line 138 of file chessclock.cpp.

void ChessClock::continueTurn (  )  [virtual]

Continue paused game.

Definition at line 73 of file chessclock.cpp.

int ChessClock::currentTurnPlayed (  ) 

Get time played current turn.

Returns:
Time in msecs

Definition at line 143 of file chessclock.cpp.

void ChessClock::dontEatBattery (  )  [signal]

Emitted after 30 min played one turn.

Will cause screen not to keeped lit.

Since:
1.1.2
TurnInformation * ChessClock::endTurn (  )  [virtual]

End this turn.

Player has done his move.

Returns:
Locked turn information

Reimplemented in DelayAfterClock, FischerAfterClock, and HourGlassClock.

Definition at line 84 of file chessclock.cpp.

RunningStatus ChessClock::getStatus (  )  const [inline]

Definition at line 59 of file chessclock.h.

int ChessClock::getTimeAvailable (  )  [virtual]

Get total time available.

Time does't contain delays.

Returns:
Time available in msecs

Reimplemented in DelayClock, and HourGlassClock.

Definition at line 112 of file chessclock.cpp.

int ChessClock::getTimePlayed (  )  [virtual]

Get total time played.

Returns:
Time played in msecs

Definition at line 126 of file chessclock.cpp.

int ChessClock::getTurn (  )  const [inline]

Definition at line 57 of file chessclock.h.

bool ChessClock::isLoser (  )  const [inline]

Definition at line 56 of file chessclock.h.

bool ChessClock::isWhite (  )  const [inline]

Definition at line 58 of file chessclock.h.

void ChessClock::pauseTurn (  )  [virtual]

Pause clock.

Definition at line 64 of file chessclock.cpp.

virtual void ChessClock::repaintClock (  )  [pure virtual, slot]

Refresh clock information.

Implemented in ChessClockWidget.

void ChessClock::setAnother ( ChessClock another  ) 

Set another chess clock for connecting.

Parameters:
another Clock of opposite player

Definition at line 107 of file chessclock.cpp.

void ChessClock::setTimeAvailable ( int  msecs  ) 

Set time available.

Parameters:
msecs Time available in msecs

Definition at line 132 of file chessclock.cpp.

void ChessClock::startTurn (  )  [virtual]

Start new turn.

Reimplemented in FischerClock.

Definition at line 49 of file chessclock.cpp.

void ChessClock::timeOutLoser (  )  [signal]
void ChessClock::turnEnded (  )  [signal]
void ChessClock::updateClock (  )  [virtual, slot]

Update clock information, check looser state and refresh.

Reimplemented in HourGlassClock.

Definition at line 169 of file chessclock.cpp.


Member Data Documentation

Definition at line 129 of file chessclock.h.

QTime ChessClock::clockTime_ [protected]

True if white player.

Definition at line 142 of file chessclock.h.

Definition at line 134 of file chessclock.h.

Definition at line 135 of file chessclock.h.

const int ChessClock::DONTEATBATTERYTIME = 30 * 60 * 1000 [static, protected]

Clock updating interval in msecs

Definition at line 146 of file chessclock.h.

bool ChessClock::isWhite_ [protected]

Time available for play BEFORE this turn msecs !

Definition at line 140 of file chessclock.h.

bool ChessClock::loser_ [protected]

Another player's clock.

Definition at line 131 of file chessclock.h.

Current turn.

Definition at line 133 of file chessclock.h.

Time played in this game BEFORE this turn msecs.

Definition at line 138 of file chessclock.h.

Definition at line 137 of file chessclock.h.

int ChessClock::turn_ [protected]

Is player losed because of timeout.

Definition at line 132 of file chessclock.h.

const int ChessClock::UPDATEINTERVAL = 1000 [static, protected]

Definition at line 145 of file chessclock.h.

QTimer ChessClock::updateTimer_ [protected]

Definition at line 143 of file chessclock.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations Enumerator
Generated on Tue Oct 12 20:52:59 2010 for Chess Clock by  doxygen 1.6.3