[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/kpresenter/part
From:       Fredy Yanardi <fyanardi () gmail ! com>
Date:       2008-07-27 4:32:35
Message-ID: 1217133155.557056.25433.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 838184 by fyanardi:

Use QTime for the stopwatch to make it simpler


 M  +6 -13     KPrPresenterViewInterface.cpp  
 M  +2 -5      KPrPresenterViewInterface.h  


--- trunk/koffice/kpresenter/part/KPrPresenterViewInterface.cpp #838183:838184
@@ -274,13 +274,10 @@
     setLayout(mainLayout);
     setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
 
+    m_currentTime.start();
     m_clockTimer = new QTimer( this );
     connect( m_clockTimer, SIGNAL( timeout() ), this, SLOT( updateClock() ) );
     m_clockTimer->start( 1000 );
-
-    hour = 0;
-    min = 0;
-    sec = 0;
 }
 
 void KPrPresenterViewToolWidget::toggleSlideThumbnails( bool toggle )
@@ -292,16 +289,12 @@
 {
     QTime time = QTime::currentTime();
     m_clockLabel->setText( time.toString( "hh:mm:ss a" ) );
+    int sec = m_currentTime.elapsed() / 1000;
 
-    sec++;
-    if ( sec == 60 ) {
-        min++;
-        sec = 0;
-    }
-    if ( min == 60 ) {
-        hour++;
-        min = 0;
-    }
+    int hour = sec / 3600;
+    sec -= hour * 3600;
+    int min = sec / 60;
+    sec -= min * 60;
 
     // display the timer, with 0 appended if only 1 digit
     m_timerLabel->setText( QString( "%1:%2:%3").arg( hour, 2, 10, QChar( '0' ) )
--- trunk/koffice/kpresenter/part/KPrPresenterViewInterface.h #838183:838184
@@ -21,12 +21,12 @@
 #define KPRPRESENTERVIEWINTERFACE
 
 #include <QtGui/QFrame>
+#include <QtCore/QTime>
 
 class QLabel;
 class QListView;
 class QModelIndex;
 class QTextEdit;
-class QTimer;
 class QTime;
 class QToolButton;
 
@@ -113,11 +113,8 @@
     QLabel *m_clockLabel;
     QLabel *m_timerLabel;
 
+    QTime m_currentTime;
     QTimer *m_clockTimer;
-
-    int hour;
-    int min;
-    int sec;
 };
 
 #endif
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic