• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

ktimetracker

  • sources
  • kde-4.14
  • kdepim
  • ktimetracker
task.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1997 by Stephan Kulow <coolo@kde.org>
3  * 2007 the ktimetracker developers
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the
17  * Free Software Foundation, Inc.
18  * 51 Franklin Street, Fifth Floor
19  * Boston, MA 02110-1301 USA.
20  *
21  */
22 
23 #include "task.h"
24 
25 #include <QDateTime>
26 #include <QString>
27 #include <QTimer>
28 #include <QPixmap>
29 
30 #include <KDebug>
31 #include <KIconLoader>
32 #include <KComponentData>
33 
34 #include <KCalCore/Event>
35 
36 #include "ktimetrackerutility.h"
37 #include "ktimetracker.h"
38 #include "preferences.h"
39 
40 QVector<QPixmap*> *Task::icons = 0;
41 
42 Task::Task( const QString& taskName, const QString& taskDescription, long minutes, long sessionTime,
43  DesktopList desktops, TaskView *parent, bool konsolemode )
44  : QObject(), QTreeWidgetItem(parent)
45 {
46  init( taskName, taskDescription, minutes, sessionTime, 0, desktops, 0, 0, konsolemode );
47 }
48 
49 Task::Task( const QString& taskName, const QString& taskDescription, long minutes, long sessionTime,
50  DesktopList desktops, Task *parent)
51  : QObject(), QTreeWidgetItem(parent)
52 {
53  init( taskName, taskDescription, minutes, sessionTime, 0, desktops, 0, 0 );
54 }
55 
56 Task::Task( const KCalCore::Todo::Ptr &todo, TaskView* parent, bool konsolemode )
57  : QObject(), QTreeWidgetItem( parent )
58 {
59  long minutes = 0;
60  QString name;
61  QString description;
62  long sessionTime = 0;
63  QString sessionStartTiMe;
64  int percent_complete = 0;
65  int priority = 0;
66  DesktopList desktops;
67 
68  parseIncidence( todo, minutes, sessionTime, sessionStartTiMe, name, description, desktops, percent_complete,
69  priority );
70  init( name, description, minutes, sessionTime, sessionStartTiMe, desktops, percent_complete, priority, konsolemode );
71 }
72 
73 int Task::depth()
74 // Deliver the depth of a task, i.e. how many tasks are supertasks to it.
75 // A toplevel task has the depth 0.
76 {
77  kDebug(5970) << "Entering function";
78  int res=0;
79  Task* t=this;
80  while ( ( t = t->parent() ) ) res++;
81  kDebug(5970) << "Leaving function. depth is:" << res;
82  return res;
83 }
84 
85 void Task::init( const QString& taskName, const QString& taskDescription, long minutes, long sessionTime, QString sessionStartTiMe,
86  DesktopList desktops, int percent_complete, int priority, bool konsolemode )
87 {
88  const TaskView *taskView = qobject_cast<TaskView*>( treeWidget() );
89  // If our parent is the taskview then connect our totalTimesChanged
90  // signal to its receiver
91  if ( ! parent() )
92  connect( this, SIGNAL(totalTimesChanged(long,long)),
93  taskView, SLOT(taskTotalTimesChanged(long,long)));
94 
95  connect( this, SIGNAL(deletingTask(Task*)),
96  taskView, SLOT(deletingTask(Task*)));
97 
98  if (icons == 0)
99  {
100  icons = new QVector<QPixmap*>(8);
101  if (!konsolemode)
102  {
103  KIconLoader kil("ktimetracker");
104  for (int i=0; i<8; ++i)
105  {
106  QPixmap *icon = new QPixmap();
107  QString name;
108  name.sprintf("watch-%d.xpm",i);
109  *icon = kil.loadIcon( name, KIconLoader::User );
110  icons->insert(i,icon);
111  }
112  }
113  }
114 
115  mRemoving = false;
116  mName = taskName.trimmed();
117  mDescription = taskDescription.trimmed();
118  mLastStart = QDateTime::currentDateTime();
119  mTotalTime = mTime = minutes;
120  mTotalSessionTime = mSessionTime = sessionTime;
121  mTimer = new QTimer(this);
122  mDesktops = desktops;
123  connect(mTimer, SIGNAL(timeout()), this, SLOT(updateActiveIcon()));
124  if ( !konsolemode ) setIcon(1, UserIcon(QString::fromLatin1("empty-watch.xpm")));
125  mCurrentPic = 0;
126  mPercentComplete = percent_complete;
127  mPriority = priority;
128  mSessionStartTiMe=KDateTime::fromString(sessionStartTiMe);
129 
130  update();
131  changeParentTotalTimes( mSessionTime, mTime);
132 
133  // alignment of the number items
134  for (int i = 1; i < columnCount(); ++i)
135  {
136  setTextAlignment( i, Qt::AlignRight );
137  }
138 
139  // .. but not the priority column
140  setTextAlignment( 5, Qt::AlignCenter );
141 }
142 
143 Task::~Task()
144 {
145  emit deletingTask(this);
146  delete mTimer;
147 }
148 
149 void Task::delete_recursive()
150 {
151  while ( this->child(0) )
152  {
153  Task* t=(Task*) this->child(0);
154  t->delete_recursive();
155  }
156  delete this;
157 }
158 
159 void Task::setRunning( bool on, timetrackerstorage* storage, const QDateTime &when )
160 // This is the back-end, the front-end is StartTimerFor()
161 {
162  kDebug(5970) << "Entering function";
163  if ( on )
164  {
165  if (!mTimer->isActive())
166  {
167  mTimer->start(1000);
168  storage->startTimer(this);
169  mCurrentPic=7;
170  mLastStart = when;
171  kDebug(5970) << "task has been started for " << when;
172  updateActiveIcon();
173  }
174  }
175  else
176  {
177  if (mTimer->isActive())
178  {
179  mTimer->stop();
180  if ( ! mRemoving )
181  {
182  storage->stopTimer(this, when);
183  setIcon(1, UserIcon(QString::fromLatin1("empty-watch.xpm")));
184  }
185  }
186  }
187 }
188 
189 void Task::resumeRunning()
190 // setRunning is the back-end, the front-end is StartTimerFor().
191 // resumeRunning does the same as setRunning, but not add a new
192 // start date to the storage.
193 {
194  kDebug(5970) << "Entering function";
195  if (!mTimer->isActive())
196  {
197  mTimer->start(1000);
198  mCurrentPic=7;
199  updateActiveIcon();
200  }
201 }
202 
203 void Task::setUid( const QString &uid )
204 {
205  mUid = uid;
206 }
207 
208 bool Task::isRunning() const
209 {
210  return mTimer->isActive();
211 }
212 
213 void Task::setName( const QString& name, timetrackerstorage* storage )
214 {
215  kDebug(5970) << "Entering function, name=" << name;
216 
217  QString oldname = mName;
218  if ( oldname != name )
219  {
220  mName = name;
221  storage->setName(this, oldname);
222  update();
223  }
224 }
225 
226 void Task::setDescription( const QString& description )
227 {
228  kDebug(5970) << "Entering function, description=" << description;
229 
230  QString olddescription = mDescription;
231  if ( olddescription != description )
232  {
233  mDescription = description;
234  update();
235  }
236 }
237 
238 void Task::setPercentComplete(const int percent, timetrackerstorage *storage)
239 {
240  kDebug(5970) << "Entering function(" << percent <<", storage):" << mUid;
241 
242  if (!percent)
243  mPercentComplete = 0;
244  else if (percent > 100)
245  mPercentComplete = 100;
246  else if (percent < 0)
247  mPercentComplete = 0;
248  else
249  mPercentComplete = percent;
250 
251  if (isRunning() && mPercentComplete==100) taskView()->stopTimerFor(this);
252 
253  setPixmapProgress();
254 
255  // When parent marked as complete, mark all children as complete as well.
256  // This behavior is consistent with KOrganizer (as of 2003-09-24).
257  if (mPercentComplete == 100)
258  {
259  for ( int i = 0; i < childCount(); ++i )
260  {
261  Task *task = static_cast< Task* >( child( i ) );
262  task->setPercentComplete(mPercentComplete, storage);
263  }
264  }
265  // maybe there is a column "percent completed", so do a ...
266  update();
267 }
268 
269 void Task::setPriority( int priority )
270 {
271  if ( priority < 0 )
272  {
273  priority = 0;
274  }
275  else if ( priority > 9 )
276  {
277  priority = 9;
278  }
279 
280  mPriority = priority;
281  update();
282 }
283 
284 void Task::setPixmapProgress()
285 {
286  kDebug(5970) << "Entering function";
287  QPixmap icon;
288  KIconLoader* kil = new KIconLoader();
289  if (mPercentComplete >= 100)
290  {
291  const QString iconcomplete=QString("task-complete.xpm");
292  icon = kil->loadIcon( iconcomplete, KIconLoader::User );
293  }
294  else
295  {
296  const QString iconincomplete=QString("task-incomplete.xpm");
297  icon = kil->loadIcon( iconincomplete, KIconLoader::User );
298  }
299  setIcon(0, icon);
300  delete kil;
301  kDebug(5970) << "Leaving function";
302 }
303 
304 bool Task::isComplete() { return mPercentComplete == 100; }
305 
306 void Task::setDesktopList ( DesktopList desktopList )
307 {
308  mDesktops = desktopList;
309 }
310 
311 QString Task::addTime( long minutes )
312 {
313  kDebug(5970) << "Entering function";
314  QString err;
315  mTime+=minutes;
316  this->addTotalTime( minutes );
317  kDebug(5970) << "Leaving function";
318  return err;
319 }
320 
321 QString Task::addTotalTime( long minutes )
322 {
323  kDebug(5970) << "Entering function";
324  QString err;
325  mTotalTime+=minutes;
326  if ( parent() ) parent()->addTotalTime( minutes );
327  kDebug(5970) << "Leaving function";
328  return err;
329 }
330 
331 QString Task::addSessionTime( long minutes )
332 {
333  kDebug(5970) << "Entering function";
334  QString err;
335  mSessionTime+=minutes;
336  this->addTotalSessionTime( minutes );
337  kDebug(5970) << "Leaving function";
338  return err;
339 }
340 
341 QString Task::addTotalSessionTime( long minutes )
342 {
343  kDebug(5970) << "Entering function";
344  QString err;
345  mTotalSessionTime+=minutes;
346  if ( parent() ) parent()->addTotalSessionTime( minutes );
347  kDebug(5970) << "Leaving function";
348  return err;
349 }
350 
351 QString Task::setTime( long minutes )
352 {
353  kDebug(5970) << "Entering function";
354  QString err;
355  mTime=minutes;
356  mTotalTime+=minutes;
357  kDebug(5970) << "Leaving function";
358  return err;
359 }
360 
361 QString Task::recalculatetotaltime()
362 {
363  QString result;
364  setTotalTime(0);
365  Task* child;
366  for (int i=0; i<this->childCount(); ++i)
367  child=(Task*)this->child(i);
368  addTotalTime(time());
369  return result;
370 }
371 
372 QString Task::recalculatetotalsessiontime()
373 {
374  QString result;
375  setTotalSessionTime(0);
376  Task* child;
377  for (int i=0; i<this->childCount(); ++i)
378  child=(Task*)this->child(i);
379  addTotalSessionTime(time());
380  return result;
381 }
382 
383 QString Task::setSessionTime( long minutes )
384 {
385  kDebug(5970) << "Entering function";
386  QString err;
387  mSessionTime=minutes;
388  mTotalSessionTime+=minutes;
389  kDebug(5970) << "Leaving function";
390  return err;
391 }
392 
393 void Task::changeTimes( long minutesSession, long minutes, timetrackerstorage* storage)
394 {
395  kDebug(5970) << "Entering function";
396  kDebug() << "Task's sessionStartTiMe is " << mSessionStartTiMe;
397  if( minutesSession != 0 || minutes != 0)
398  {
399  mSessionTime += minutesSession;
400  mTime += minutes;
401  if ( storage ) storage->changeTime(this, minutes * secsPerMinute);
402  changeTotalTimes( minutesSession, minutes );
403  }
404  kDebug(5970) << "Leaving function";
405 }
406 
407 void Task::changeTime( long minutes, timetrackerstorage* storage )
408 {
409  changeTimes( minutes, minutes, storage);
410 }
411 
412 void Task::changeTotalTimes( long minutesSession, long minutes )
413 {
414  kDebug(5970)
415  << "Task::changeTotalTimes(" << minutesSession << ","
416  << minutes << ") for" << name();
417  mTotalSessionTime += minutesSession;
418  mTotalTime += minutes;
419  update();
420  changeParentTotalTimes( minutesSession, minutes );
421  kDebug(5970) << "Leaving function";
422 }
423 
424 void Task::resetTimes()
425 {
426  kDebug(5970) << "Entering function";
427  mTotalSessionTime -= mSessionTime;
428  mTotalTime -= mTime;
429  changeParentTotalTimes( -mSessionTime, -mTime);
430  mSessionTime = 0;
431  mTime = 0;
432  update();
433  kDebug(5970) << "Leaving function";
434 }
435 
436 void Task::changeParentTotalTimes( long minutesSession, long minutes )
437 {
438  if ( isRoot() )
439  emit totalTimesChanged( minutesSession, minutes );
440  else
441  parent()->changeTotalTimes( minutesSession, minutes );
442 }
443 
444 bool Task::remove( timetrackerstorage* storage)
445 {
446  kDebug(5970) << "entering function" << mName;
447  bool ok = true;
448 
449  mRemoving = true;
450  storage->removeTask(this);
451  if( isRunning() ) setRunning( false, storage );
452 
453  for ( int i = 0; i < childCount(); ++i )
454  {
455  Task *task = static_cast< Task* >( child( i ) );
456  if ( task->isRunning() )
457  task->setRunning( false, storage );
458  task->remove( storage );
459  }
460 
461  changeParentTotalTimes( -mSessionTime, -mTime);
462  mRemoving = false;
463  return ok;
464 }
465 
466 void Task::updateActiveIcon()
467 {
468  mCurrentPic = (mCurrentPic+1) % 8;
469  setIcon(1, *(*icons)[mCurrentPic]);
470 }
471 
472 QString Task::fullName() const
473 {
474  if (isRoot())
475  return name();
476  else
477  return parent()->fullName() + QString::fromLatin1("/") + name();
478 }
479 
480 KCalCore::Todo::Ptr Task::asTodo(const KCalCore::Todo::Ptr &todo) const
481 {
482  Q_ASSERT( todo != NULL );
483 
484  kDebug(5970) <<"Task::asTodo: name() = '" << name() <<"'";
485  todo->setSummary( name() );
486  todo->setDescription( description() );
487 
488  // Note: if the date start is empty, the KOrganizer GUI will have the
489  // checkbox blank, but will prefill the todo's starting datetime to the
490  // time the file is opened.
491  // todo->setDtStart( current );
492 
493  todo->setCustomProperty( KGlobal::mainComponent().componentName().toUtf8(),
494  QByteArray( "totalTaskTime" ), QString::number( mTime ) );
495  todo->setCustomProperty( KGlobal::mainComponent().componentName().toUtf8(),
496  QByteArray( "totalSessionTime" ), QString::number( mSessionTime) );
497  todo->setCustomProperty( KGlobal::mainComponent().componentName().toUtf8(),
498  QByteArray( "sessionStartTiMe" ), mSessionStartTiMe.toString() );
499  kDebug() << "mSessionStartTiMe=" << mSessionStartTiMe.toString() ;
500 
501  if (getDesktopStr().isEmpty())
502  todo->removeCustomProperty(KGlobal::mainComponent().componentName().toUtf8(), QByteArray("desktopList"));
503  else
504  todo->setCustomProperty( KGlobal::mainComponent().componentName().toUtf8(),
505  QByteArray( "desktopList" ), getDesktopStr() );
506 
507  todo->setOrganizer( KTimeTrackerSettings::userRealName() );
508  todo->setPercentComplete(mPercentComplete);
509  todo->setPriority( mPriority );
510  return todo;
511 }
512 
513 bool Task::parseIncidence( const KCalCore::Incidence::Ptr &incident, long& minutes,
514  long& sessionMinutes, QString& sessionStartTiMe, QString& name, QString& description, DesktopList& desktops,
515  int& percent_complete, int& priority )
516 {
517  kDebug(5970) << "Entering function";
518  bool ok;
519  name = incident->summary();
520  description = incident->description();
521  mUid = incident->uid();
522  mComment = incident->description();
523  ok = false;
524 
525  // if a KDE-karm-duration exists and not KDE-ktimetracker-duration, change this
526  if (
527  incident->customProperty( KGlobal::mainComponent().componentName().toUtf8(),
528  QByteArray( "totalTaskTime" )) == QString::null && incident->customProperty( "karm",
529  QByteArray( "totalTaskTime" )) != QString::null )
530  incident->setCustomProperty(
531  KGlobal::mainComponent().componentName().toUtf8(),
532  QByteArray( "totalTaskTime" ), incident->customProperty( "karm",
533  QByteArray( "totalTaskTime" )));
534  minutes = incident->customProperty( KGlobal::mainComponent().componentName().toUtf8(),
535  QByteArray( "totalTaskTime" )).toInt( &ok );
536  if ( !ok )
537  minutes = 0;
538  ok = false;
539 
540  // if a KDE-karm-totalSessionTime exists and not KDE-ktimetracker-totalSessionTime, change this
541  if (
542  incident->customProperty( KGlobal::mainComponent().componentName().toUtf8(),
543  QByteArray( "totalSessionTime" )) == QString::null && incident->customProperty( "karm",
544  QByteArray( "totalSessionTime" )) != QString::null )
545  incident->setCustomProperty(
546  KGlobal::mainComponent().componentName().toUtf8(),
547  QByteArray( "totalSessionTime" ), incident->customProperty( "karm",
548  QByteArray( "totalSessionTime" )));
549  sessionMinutes = incident->customProperty( KGlobal::mainComponent().componentName().toUtf8(),
550  QByteArray( "totalSessionTime" )).toInt( &ok );
551  if ( !ok )
552  sessionMinutes = 0;
553  sessionStartTiMe=incident->customProperty( KGlobal::mainComponent().componentName().toUtf8(), QByteArray( "sessionStartTiMe" ));
554 
555  // if a KDE-karm-deskTopList exists and no KDE-ktimetracker-DeskTopList, change this
556  if (
557  incident->customProperty( KGlobal::mainComponent().componentName().toUtf8(),
558  QByteArray( "desktopList" )) == QString::null && incident->customProperty( "karm",
559  QByteArray( "desktopList" )) != QString::null )
560  incident->setCustomProperty(
561  KGlobal::mainComponent().componentName().toUtf8(),
562  QByteArray( "desktopList" ), incident->customProperty( "karm",
563  QByteArray( "desktopList" )));
564 
565  QString desktopList = incident->customProperty( KGlobal::mainComponent().componentName().toUtf8(),
566  QByteArray( "desktopList" ) );
567  QStringList desktopStrList = desktopList.split( QString::fromLatin1(","),
568  QString::SkipEmptyParts );
569  desktops.clear();
570 
571  for ( QStringList::iterator iter = desktopStrList.begin();
572  iter != desktopStrList.end();
573  ++iter )
574  {
575  int desktopInt = (*iter).toInt( &ok );
576  if ( ok )
577  {
578  desktops.push_back( desktopInt );
579  }
580  }
581  percent_complete = incident.staticCast<KCalCore::Todo>()->percentComplete();
582  priority = incident->priority();
583  return true;
584 }
585 
586 QString Task::getDesktopStr() const
587 {
588  if ( mDesktops.empty() )
589  return QString();
590 
591  QString desktopstr;
592  for ( DesktopList::const_iterator iter = mDesktops.begin();
593  iter != mDesktops.end();
594  ++iter )
595  {
596  desktopstr += QString::number( *iter ) + QString::fromLatin1( "," );
597  }
598  desktopstr.remove( desktopstr.length() - 1, 1 );
599  return desktopstr;
600 }
601 
602 void Task::cut()
603 // This is needed e.g. to move a task under its parent when loading.
604 {
605  kDebug(5970) << "Entering function";
606  changeParentTotalTimes( -mTotalSessionTime, -mTotalTime);
607  if ( ! parent() )
608  treeWidget()->takeTopLevelItem(treeWidget()->indexOfTopLevelItem(this));
609  else
610  parent()->takeChild(indexOfChild(this));
611  kDebug(5970) << "Leaving function";
612 }
613 
614 void Task::paste(Task* destination)
615 // This is needed e.g. to move a task under its parent when loading.
616 {
617  kDebug(5970) << "Entering function";
618  destination->QTreeWidgetItem::insertChild(0,this);
619  changeParentTotalTimes( mTotalSessionTime, mTotalTime);
620  kDebug(5970) << "Leaving function";
621 }
622 
623 void Task::move(Task* destination)
624 // This is used e.g. to move each task under its parent after loading.
625 {
626  kDebug(5970) << "Entering function";
627  cut();
628  paste(destination);
629  kDebug(5970) << "Leaving function";
630 }
631 
632 void Task::update()
633 // Update a row, containing one task
634 {
635  kDebug( 5970 ) << "Entering function";
636  bool b = KTimeTrackerSettings::decimalFormat();
637  setText( 0, mName );
638  setText( 1, formatTime( mSessionTime, b ) );
639  setText( 2, formatTime( mTime, b ) );
640  setText( 3, formatTime( mTotalSessionTime, b ) );
641  setText( 4, formatTime( mTotalTime, b ) );
642  setText( 5, mPriority > 0 ? QString::number( mPriority ) : "--" );
643  setText( 6, QString::number( mPercentComplete ) );
644  kDebug( 5970 ) << "Leaving function";
645 }
646 
647 void Task::addComment( const QString &comment, timetrackerstorage* storage )
648 {
649  mComment = mComment + QString::fromLatin1("\n") + comment;
650  storage->addComment(this, comment);
651 }
652 
653 void Task::startNewSession()
654 {
655  changeTimes( -mSessionTime, 0 );
656  mSessionStartTiMe=KDateTime::currentLocalDateTime();
657 }
658 
659 /* Overriding the < operator in order to sort the names case insensitive and
660  * the progress percentage [coloumn 6] numerically.
661  */
662 bool Task::operator<(const QTreeWidgetItem &other)const {
663  const int column = treeWidget()->sortColumn();
664  if (column == 6){ //progress percent
665  return text(column).toInt() < other.text(column).toInt();
666  } else if (column == 0) { //task name
667  return text(column).toLower() < other.text(column).toLower();
668  }
669  else {
670  return text(column) < other.text(column);
671  }
672 }
673 
674 //BEGIN Properties
675 QString Task::uid() const
676 {
677  return mUid;
678 }
679 
680 QString Task::comment() const
681 {
682  return mComment;
683 }
684 
685 int Task::percentComplete() const
686 {
687  return mPercentComplete;
688 }
689 
690 int Task::priority() const
691 {
692  return mPriority;
693 }
694 
695 QString Task::name() const
696 {
697  return mName;
698 }
699 
700 QString Task::description() const
701 {
702  return mDescription;
703 }
704 
705 QDateTime Task::startTime() const
706 {
707  return mLastStart;
708 }
709 
710 KDateTime Task::sessionStartTiMe() const
711 {
712  return mSessionStartTiMe;
713 }
714 
715 DesktopList Task::desktops() const
716 {
717  return mDesktops;
718 }
719 //END
720 
QObject::child
QObject * child(const char *objName, const char *inheritsClass, bool recursiveSearch) const
Task::setPercentComplete
void setPercentComplete(const int percent, timetrackerstorage *storage)
Update percent complete for this task.
Definition: task.cpp:238
Task::Task
Task(const QString &taskname, const QString &taskdescription, long minutes, long sessionTime, DesktopList desktops, TaskView *parent=0, bool konsolemode=false)
Definition: task.cpp:42
Task::taskView
TaskView * taskView() const
Return task view for this task.
Definition: task.h:74
timetrackerstorage::startTimer
void startTimer(const Task *task, const KDateTime &when=KDateTime::currentLocalDateTime())
Log the event that a timer has started for a task.
Definition: timetrackerstorage.cpp:897
QTreeWidget::sortColumn
int sortColumn() const
timetrackerstorage::setName
void setName(const Task *task, const QString &oldname)
Log a change to a task name.
Definition: timetrackerstorage.h:199
Task::parseIncidence
bool parseIncidence(const KCalCore::Incidence::Ptr &, long &minutes, long &sessionMinutes, QString &sessionStartTiMe, QString &name, QString &description, DesktopList &desktops, int &percent_complete, int &priority)
Parses an incidence.
Definition: task.cpp:513
QVector::begin
iterator begin()
Task::name
QString name() const
returns the name of this task.
Definition: task.cpp:695
QByteArray
timetrackerstorage::addComment
void addComment(const Task *task, const QString &comment)
Log a new comment for this task.
Definition: timetrackerstorage.cpp:558
Task::startNewSession
void startNewSession()
sets session time to zero.
Definition: task.cpp:653
QString::split
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
Task::sessionStartTiMe
KDateTime sessionStartTiMe() const
Definition: task.cpp:710
QTreeWidgetItem::setIcon
void setIcon(int column, const QIcon &icon)
QVector::insert
void insert(int i, const T &value)
Task::updateActiveIcon
void updateActiveIcon()
animate the active icon
Definition: task.cpp:466
Task::isRoot
bool isRoot() const
tells you whether this task is the root of the task tree
Definition: task.h:315
Task::setRunning
void setRunning(bool on, timetrackerstorage *storage, const QDateTime &when=QDateTime::currentDateTime())
starts or stops a task
Definition: task.cpp:159
Task::update
void update()
Update the display of the task (all columns) in the UI.
Definition: task.cpp:632
Task::changeParentTotalTimes
void changeParentTotalTimes(long minutesSession, long minutes)
Definition: task.cpp:436
QString::remove
QString & remove(int position, int n)
formatTime
QString formatTime(double minutes, bool decimal)
Format time for output.
Definition: ktimetrackerutility.cpp:37
Task::setTotalTime
void setTotalTime(long minutes)
Sets the total time, does not change the parent's total time.
Definition: task.h:174
Task::changeTotalTimes
void changeTotalTimes(long minutesSession, long minutes)
adds minutes to total and session time by adding an event
Definition: task.cpp:412
Task::remove
bool remove(timetrackerstorage *storage)
remove Task with all it's children
Definition: task.cpp:444
secsPerMinute
const int secsPerMinute
Definition: ktimetrackerutility.h:53
Task::isComplete
bool isComplete()
Return true if task is complete (percent complete equals 100).
Definition: task.cpp:304
Task::setSessionTime
QString setSessionTime(long minutes)
Sets the session time.
Definition: task.cpp:383
Task::totalTimesChanged
void totalTimesChanged(long minutesSession, long minutes)
QTreeWidgetItem::icon
QIcon icon(int column) const
QVector::clear
void clear()
QString::number
QString number(int n, int base)
Task::setName
void setName(const QString &name, timetrackerstorage *storage)
sets the name of the task
Definition: task.cpp:213
Task::resetTimes
void resetTimes()
Reset all times to 0 and adjust parent task's totalTiMes.
Definition: task.cpp:424
Task::setTime
QString setTime(long minutes)
Sets the time (not session time).
Definition: task.cpp:351
QTimer
Task::comment
QString comment() const
Retrieve the entire comment for the task.
Definition: task.cpp:680
Task::changeTimes
void changeTimes(long minutesSession, long minutes, timetrackerstorage *storage=0)
Add minutes to time and session time by adding an event, and write to storage.
Definition: task.cpp:393
Task::setTotalSessionTime
void setTotalSessionTime(long minutes)
Sets the total session time, does not change the parent's total session time.
Definition: task.h:179
QObject
QString::toInt
int toInt(bool *ok, int base) const
QString::trimmed
QString trimmed() const
Task::depth
int depth()
Definition: task.cpp:73
Task::delete_recursive
void delete_recursive()
Definition: task.cpp:149
Task::addTotalSessionTime
QString addTotalSessionTime(long minutes)
Adds minutes to the task's and its supertasks' total session time.
Definition: task.cpp:341
timetrackerstorage::removeTask
bool removeTask(Task *task)
Remove this task from iCalendar file.
Definition: timetrackerstorage.cpp:510
Task::uid
QString uid() const
Return unique iCalendar Todo ID for this task.
Definition: task.cpp:675
QTreeWidgetItem::columnCount
int columnCount() const
QString
QTreeWidget::takeTopLevelItem
QTreeWidgetItem * takeTopLevelItem(int index)
Task::resumeRunning
void resumeRunning()
Resume the running state of a task.
Definition: task.cpp:189
Task::isRunning
bool isRunning() const
return the state of a task - if it's running or not
Definition: task.cpp:208
QTreeWidgetItem::treeWidget
QTreeWidget * treeWidget() const
QList::iterator
QStringList
TaskView::stopTimerFor
void stopTimerFor(Task *task)
Definition: taskview.cpp:828
QPixmap
Task::sessionTime
long sessionTime() const
Definition: task.h:207
timetrackerstorage::changeTime
void changeTime(const Task *task, const long deltaSeconds)
Log the change in a task's time.
Definition: timetrackerstorage.cpp:955
Task::addTime
QString addTime(long minutes)
Adds minutes to the time of the task and the total time of its supertasks.
Definition: task.cpp:311
QList::end
iterator end()
QString::toLower
QString toLower() const
Task::addSessionTime
QString addSessionTime(long minutes)
Adds minutes to the task's session time and its supertasks' total session time.
Definition: task.cpp:331
preferences.h
QTimer::stop
void stop()
Task::getDesktopStr
QString getDesktopStr() const
Definition: task.cpp:586
Task::description
QString description() const
returns the description of this task.
Definition: task.cpp:700
QTreeWidgetItem::indexOfChild
int indexOfChild(QTreeWidgetItem *child) const
Task::setDesktopList
void setDesktopList(DesktopList dl)
Definition: task.cpp:306
Task::addComment
void addComment(const QString &comment, timetrackerstorage *storage)
Add a comment to this task.
Definition: task.cpp:647
Task::changeTime
void changeTime(long minutes, timetrackerstorage *storage)
Change task time.
Definition: task.cpp:407
task.h
QDateTime::currentDateTime
QDateTime currentDateTime()
QVector< QPixmap * >
Task::percentComplete
int percentComplete() const
Definition: task.cpp:685
Task::setUid
void setUid(const QString &uid)
Set unique id for the task.
Definition: task.cpp:203
QTreeWidgetItem
Task::addTotalTime
QString addTotalTime(long minutes)
Adds minutes to the total time of the task and its supertasks.
Definition: task.cpp:321
QString::sprintf
QString & sprintf(const char *cformat,...)
timetrackerstorage::stopTimer
void stopTimer(const Task *task, const QDateTime &when=QDateTime::currentDateTime())
Log the event that the timer has stopped for this task.
Definition: timetrackerstorage.cpp:929
QTreeWidgetItem::setText
void setText(int column, const QString &text)
Task::cut
void cut()
cut Task out of parent Task or the TaskView
Definition: task.cpp:602
QString::length
int length() const
Task::priority
int priority() const
Definition: task.cpp:690
QVector::push_back
void push_back(const T &value)
Task::parent
Task * parent() const
return parent Task or null in case of TaskView.
Definition: task.h:71
QString::fromLatin1
QString fromLatin1(const char *str, int size)
Task::desktops
DesktopList desktops() const
Definition: task.cpp:715
Task::~Task
~Task()
Definition: task.cpp:143
Task::recalculatetotalsessiontime
QString recalculatetotalsessiontime()
A recursive function to calculate the total session time of a task.
Definition: task.cpp:372
QTimer::start
void start(int msec)
Task::paste
void paste(Task *destination)
insert Task into the destination Task
Definition: task.cpp:614
QTreeWidgetItem::setTextAlignment
void setTextAlignment(int column, int alignment)
Task::move
void move(Task *destination)
cut Task out of parent Task or the TaskView and into the destination Task
Definition: task.cpp:623
QVector::const_iterator
typedef const_iterator
ktimetrackerutility.h
Task::setPriority
void setPriority(int priority)
Update priority for this task.
Definition: task.cpp:269
Task::fullName
QString fullName() const
Returns that task name, prefixed by parent tree up to root.
Definition: task.cpp:472
QTimer::isActive
bool isActive() const
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Task::setPixmapProgress
void setPixmapProgress()
Sets an appropriate icon for this task based on its level of completion.
Definition: task.cpp:284
TaskView
Container and interface for the tasks.
Definition: taskview.h:50
Task
A class representing a task.
Definition: task.h:54
QTreeWidgetItem::childCount
int childCount() const
QVector::empty
bool empty() const
QVector::end
iterator end()
Task::asTodo
KCalCore::Todo::Ptr asTodo(const KCalCore::Todo::Ptr &calendar) const
Load the todo passed in with this tasks info.
Definition: task.cpp:480
QTreeWidgetItem::text
QString text(int column) const
Task::recalculatetotaltime
QString recalculatetotaltime()
A recursive function to calculate the total time of a task.
Definition: task.cpp:361
QList::begin
iterator begin()
Task::startTime
QDateTime startTime() const
Return time the task was started.
Definition: task.cpp:705
Task::deletingTask
void deletingTask(Task *thisTask)
signal that we're about to delete a task
Task::time
long time() const
Definition: task.h:204
QDateTime
timetrackerstorage
Class to store/retrieve KTimeTracker data to/from persistent storage.
Definition: timetrackerstorage.h:57
QTreeWidgetItem::takeChild
QTreeWidgetItem * takeChild(int index)
Task::setDescription
void setDescription(const QString &description)
sets the description of the task
Definition: task.cpp:226
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:31:34 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ktimetracker

Skip menu "ktimetracker"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal