Updated the web pages
[chessclock] / classes / chessclock.h
index 528b58b..1f8f262 100644 (file)
@@ -36,6 +36,9 @@ class TurnInformation;
 
   Base class of chess clock.
 
+  ChessClock has not GUI itself, but it is subclass of QWidget
+  avoiding polymorphism.
+
   */
 class ChessClock : public QWidget
 {
@@ -52,6 +55,8 @@ public:
 
     bool isLoser() const  { return loser_; }
     int getTurn() const  { return turn_; }
+    bool isWhite() const { return isWhite_; }
+    RunningStatus getStatus() const { return status_ ; }
 
 
     /*! Start new turn */
@@ -80,14 +85,45 @@ public:
       @return Time available in msecs */
     virtual int getTimeAvailable();
 
+    /*! Get total time played
+      @return Time played in msecs */
+    virtual int getTimePlayed();
+
+    /*! Set time available
+
+      @param msecs Time available in msecs */
+    void setTimeAvailable(int msecs);
+
+    /*! Add time
+
+      Add time to timeAvailableBeforeTurn_ total available time
+      counter.
+
+      @param msecs Time to add in msecs */
+    void addTime(int msecs);
+
+    /*! Get time played current turn.
+      @return Time in msecs */
+    int currentTurnPlayed();
+
+
 signals:
-    void timeOut();
+    void timeOutLoser();
+    void turnEnded();
+    /*! Emitted after 30 min played one turn.
+
+      Will cause screen not to keeped lit.
+      @since 1.1.2
+      */
+    void dontEatBattery();
 
 public slots:    
 
     /*! Refresh clock information */
     virtual void repaintClock() = 0;
 
+    /*! Update clock information, check looser state and refresh */
+    virtual void updateClock();
 
 protected:
     ChessClock* another_; /*! Another player's clock */
@@ -96,9 +132,10 @@ protected:
     int turn_;          /*! Current turn */
     RunningStatus status_;
     TurnInformation* currentTurn_;
+    bool dontEatBatteryEmitted_;
 
-    int timePlayed_;    /*! Time played in this game */
-    int timeAvailableBeforeTurn_; /*! Time available for play BEFORE this turn!*/
+    int timePlayedBeforeTurn_;    /*! Time played in this game BEFORE this turn msecs */
+    int timeAvailableBeforeTurn_; /*! Time available for play BEFORE this turn msecs !*/
 
     bool isWhite_;      /*! True if white player */
 
@@ -106,7 +143,7 @@ protected:
     QTimer updateTimer_;
 
     static const int UPDATEINTERVAL = 1000; /** Clock updating interval in msecs */
-
+    static const int DONTEATBATTERYTIME = 30 * 60 * 1000; /*! Time after screen not to keep lit */
 };
 
 #endif // CHESSCLOCK_H