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

List:       kde-commits
Subject:    KDE/kdepim/ktimetracker
From:       Thorsten Staerk <dev () staerk ! de>
Date:       2010-03-07 14:04:03
Message-ID: 1267970643.876464.9463.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1100411 by tstaerk:

If I changeTime(), I cannot see the enddate() in the editHistoryDialog.
There is something wrong. Making changeTime easier accessible for tests.
CCBUGS:169660


 M  +5 -0      org.kde.ktimetracker.ktimetracker.xml  
 M  +7 -7      timetrackerstorage.h  
 M  +39 -5     timetrackerwidget.cpp  
 M  +5 -2      timetrackerwidget.h  


--- trunk/KDE/kdepim/ktimetracker/org.kde.ktimetracker.ktimetracker.xml #1100410:1100411
@@ -35,6 +35,11 @@
       <arg name="dateTime" type="s" direction="in"/>
       <arg name="minutes" type="i" direction="in"/>
     </method>
+    <method name="changeTime">
+      <arg type="i" direction="out"/>
+      <arg name="taskId" type="s" direction="in"/>
+      <arg name="minutes" type="i" direction="in"/>
+    </method>
     <method name="error">
       <arg type="s" direction="out"/>
       <arg name="errorCode" type="i" direction="in"/>
--- trunk/KDE/kdepim/ktimetracker/timetrackerstorage.h #1100410:1100411
@@ -162,9 +162,9 @@
      * Log the change in a task's time.
      *
      * This is also called when a timer is stopped.
-     * We create an iCalendar event to store each change.  The event start
-     * date is set to the current datetime.  If time is added to the task, the
-     * task end date is set to start time + delta.  If the time is negative,
+     * We create an iCalendar event to store each change. The event start
+     * date is set to the current datetime. If time is added to the task, the
+     * task end date is set to start time + delta. If the time is negative,
      * the end date is set to the start time.
      *
      * In both cases (postive or negative delta), we create a custom iCalendar
@@ -173,7 +173,7 @@
      *
      * Note that the ktimetracker UI allows the user to change both the session and
      * the total task time, and this routine does not account for all posibile
-     * cases.  For example, it is possible for the user to do something crazy
+     * cases. For example, it is possible for the user to do something crazy
      * like add 10 minutes to the session time and subtract 50 minutes from
      * the total time. Although this change violates a basic law of physics,
      * it is allowed.
@@ -188,9 +188,9 @@
     /**
      * Book time to a task.
      *
-     * Creates an iCalendar event and adds it to the calendar.  Does not write
-     * calendar to disk, just adds event to calendar in memory.  However, the
-     * resource framework does try to get a lock on the file.  After a
+     * Creates an iCalendar event and adds it to the calendar. Does not write
+     * calendar to disk, just adds event to calendar in memory. However, the
+     * resource framework does try to get a lock on the file. After a
      * successful lock, the calendar marks this incidence as modified and then
      * releases the lock.
      *
--- trunk/KDE/kdepim/ktimetracker/timetrackerwidget.cpp #1100410:1100411
@@ -839,7 +839,8 @@
 }
 //END
 
-//BEGIN dbus slots
+/** \defgroup dbus slots ‘‘dbus slots'' */
+/* @{ */
 QString TimetrackerWidget::version() const
 {
     return KTIMETRACKER_VERSION;
@@ -984,6 +985,41 @@
     return 0;
 }
 
+int TimetrackerWidget::changeTime( const QString &taskId, int minutes )
+{
+    int result=0;
+    QDate startDate;
+    QTime startTime;
+    QDateTime startDateTime;
+    Task *task = 0, *t = 0;
+
+    if ( minutes <= 0 ) return KTIMETRACKER_ERR_INVALID_DURATION;
+
+    // Find task
+    for ( int i = 0; i < d->mTabWidget->count(); ++i )
+    {
+        TaskView *taskView = qobject_cast< TaskView* >( d->mTabWidget->widget( i ) );
+        if ( !taskView ) continue;
+
+        QTreeWidgetItemIterator it( taskView );
+        while ( *it )
+        {
+            t = static_cast< Task* >( *it );
+            if ( t && t->uid() == taskId )
+            {
+                task = t;
+                break;
+            }
+            ++it;
+        }
+        if ( task ) break;
+    }
+
+    if ( !task ) result=KTIMETRACKER_ERR_UID_NOT_FOUND;
+    else task->changeTime(minutes, task->taskView()->storage());
+    return result;
+}
+
 QString TimetrackerWidget::error( int errorCode ) const
 {
     switch ( errorCode )
@@ -1191,7 +1227,6 @@
   return false;
 }
 
-
 bool TimetrackerWidget::isTaskNameActive( const QString &taskName ) const
 {
     for ( int i = 0; i < d->mTabWidget->count(); ++i )
@@ -1212,7 +1247,6 @@
   return false;
 }
 
-
 QStringList TimetrackerWidget::tasks() const
 {
     QStringList result;
@@ -1283,6 +1317,6 @@
         kapp->quit();
     }
 }
-//END
-
+// END of dbus slots group
+/* @} */
 #include "timetrackerwidget.moc"
--- trunk/KDE/kdepim/ktimetracker/timetrackerwidget.h #1100410:1100411
@@ -176,7 +176,8 @@
     void slotSearchBar();
     //END
 
-    //BEGIN dbus slots
+    /** \defgroup dbus slots ‘‘dbus slots'' */
+    /* @{ */
     QString version() const;
     QStringList taskIdsFromName( const QString &taskName ) const;
     void addTask( const QString &taskName );
@@ -184,6 +185,7 @@
     void deleteTask( const QString &taskId );
     void setPercentComplete( const QString &taskId, int percent );
     int bookTime( const QString &taskId, const QString &dateTime, int minutes );
+    int changeTime( const QString &taskId, int minutes );
     QString error( int errorCode ) const;
     bool isIdleDetectionPossible() const;
     int totalMinutesForTaskId( const QString &taskId ) const;
@@ -206,7 +208,8 @@
     bool isTaskNameActive( const QString &taskId ) const;
     void saveAll();
     void quit();
-    //END
+    // END of dbus slots group
+    /* @} */
 
   protected:
     bool event ( QEvent * event ); // inherited from QWidget
[prev in list] [next in list] [prev in thread] [next in thread] 

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