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

ktimetracker

  • sources
  • kde-4.12
  • kdepim
  • ktimetracker
taskview.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003 by Scott Monachello <smonach@cox.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the
16  * Free Software Foundation, Inc.
17  * 51 Franklin Street, Fifth Floor
18  * Boston, MA 02110-1301 USA.
19  *
20  */
21 
22 #include "taskview.h"
23 
24 #include <cassert>
25 
26 #include <QFile>
27 #include <QStyledItemDelegate>
28 #include <QMenu>
29 #include <QPainter>
30 #include <QString>
31 #include <QTimer>
32 #include <QMouseEvent>
33 #include <QList>
34 #include <QClipboard>
35 
36 #include <KApplication> // kapp
37 #include <KDebug>
38 #include <KFileDialog>
39 #include <KLocale> // i18n
40 #include <KMessageBox>
41 #include <KProgressDialog>
42 #include <KUrlRequester>
43 
44 #include "csvexportdialog.h"
45 #include "desktoptracker.h"
46 #include "edittaskdialog.h"
47 #include "idletimedetector.h"
48 #include "plannerparser.h"
49 #include "preferences.h"
50 #include "ktimetracker.h"
51 #include "task.h"
52 #include "timekard.h"
53 #include "treeviewheadercontextmenu.h"
54 #include "focusdetector.h"
55 #include "focusdetectornotifier.h"
56 #include "storageadaptor.h"
57 
58 #define T_LINESIZE 1023
59 
60 class DesktopTracker;
61 
62 //BEGIN TaskViewDelegate (custom painting of the progress column)
63 class TaskViewDelegate : public QStyledItemDelegate {
64 public:
65  TaskViewDelegate( QObject *parent = 0 ) : QStyledItemDelegate( parent ) {}
66 
67  void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
68  {
69  if (index.column () == 6)
70  {
71  QApplication::style()->drawControl( QStyle::CE_ItemViewItem, &option, painter );
72  int rX = option.rect.x() + 2;
73  int rY = option.rect.y() + 2;
74  int rWidth = option.rect.width() - 4;
75  int rHeight = option.rect.height() - 4;
76  int value = index.model()->data( index ).toInt();
77  int newWidth = (int)(rWidth * (value / 100.));
78 
79  if(QApplication::isLeftToRight())
80  {
81  int mid = rY + rHeight / 2;
82  int width = rWidth / 2;
83  QLinearGradient gradient1( rX, mid, rX + width, mid);
84  gradient1.setColorAt( 0, Qt::red );
85  gradient1.setColorAt( 1, Qt::yellow );
86  painter->fillRect( rX, rY, (newWidth < width) ? newWidth : width, rHeight, gradient1 );
87 
88  if (newWidth > width)
89  {
90  QLinearGradient gradient2( rX + width, mid, rX + 2 * width, mid);
91  gradient2.setColorAt( 0, Qt::yellow );
92  gradient2.setColorAt( 1, Qt::green );
93  painter->fillRect( rX + width, rY, newWidth - width, rHeight, gradient2 );
94  }
95 
96  painter->setPen( option.state & QStyle::State_Selected ? option.palette.highlight().color() : option.palette.background().color() );
97  for (int x = rHeight; x < newWidth; x += rHeight)
98  {
99  painter->drawLine( rX + x, rY, rX + x, rY + rHeight - 1 );
100  }
101  }
102  else
103  {
104  int mid = option.rect.height() - rHeight / 2;
105  int width = rWidth / 2;
106  QLinearGradient gradient1( rX, mid, rX + width, mid);
107  gradient1.setColorAt( 0, Qt::red );
108  gradient1.setColorAt( 1, Qt::yellow );
109  painter->fillRect( option.rect.height(), rY, (newWidth < width) ? newWidth : width, rHeight, gradient1 );
110 
111  if (newWidth > width)
112  {
113  QLinearGradient gradient2( rX + width, mid, rX + 2 * width, mid);
114  gradient2.setColorAt( 0, Qt::yellow );
115  gradient2.setColorAt( 1, Qt::green );
116  painter->fillRect( rX + width, rY, newWidth - width, rHeight, gradient2 );
117  }
118 
119  painter->setPen( option.state & QStyle::State_Selected ? option.palette.highlight().color() : option.palette.background().color() );
120  for (int x = rWidth- rHeight; x > newWidth; x -= rHeight)
121  {
122  painter->drawLine( rWidth - x, rY, rWidth - x, rY + rHeight - 1 );
123  }
124 
125  }
126  painter->setPen( Qt::black );
127  painter->drawText( option.rect, Qt::AlignCenter | Qt::AlignVCenter, QString::number(value) + " %" );
128  }
129  else
130  {
131  QStyledItemDelegate::paint( painter, option, index );
132  }
133  }
134 };
135 //END
136 
137 //BEGIN Private Data
138 //@cond PRIVATE
139 class TaskView::Private
140 {
141 public:
142 Private() :
143  mStorage( new timetrackerstorage() ),
144  mFocusTrackingActive( false ) {}
145 
146  ~Private()
147  {
148  delete mStorage;
149  }
150  timetrackerstorage *mStorage;
151  bool mFocusTrackingActive;
152  Task* mLastTaskWithFocus;
153  QList<Task*> mActiveTasks;
154 
155  QMenu *mPopupPercentageMenu;
156  QMap<QAction*, int> mPercentage;
157  QMenu *mPopupPriorityMenu;
158  QMap<QAction*, int> mPriority;
159 };
160 //@endcond
161 //END
162 
163 TaskView::TaskView( QWidget *parent ) : QTreeWidget(parent), d( new Private() )
164 {
165  _preferences = Preferences::instance();
166  new StorageAdaptor( this );
167  QDBusConnection::sessionBus().registerObject( "/ktimetrackerstorage", this );
168 
169  connect( this, SIGNAL(itemExpanded(QTreeWidgetItem*)),
170  this, SLOT(itemStateChanged(QTreeWidgetItem*)) );
171  connect( this, SIGNAL(itemCollapsed(QTreeWidgetItem*)),
172  this, SLOT(itemStateChanged(QTreeWidgetItem*)) );
173  connect( this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
174  this, SLOT(slotItemDoubleClicked(QTreeWidgetItem*,int)) );
175  connect( FocusDetectorNotifier::instance()->focusDetector(),
176  SIGNAL(newFocus(QString)),
177  this, SLOT(newFocusWindowDetected(QString)) );
178 
179  QStringList labels;
180  setWindowFlags( windowFlags() | Qt::WindowContextHelpButtonHint );
181  labels << i18n( "Task Name" ) << i18n( "Session Time" ) << i18n( "Time" )
182  << i18n( "Total Session Time" ) << i18n( "Total Time" )
183  << i18n( "Priority" ) << i18n( "Percent Complete" );
184  setHeaderLabels( labels );
185  headerItem()->setWhatsThis(0,i18n("The task name is what you call the task, it can be chosen freely."));
186  headerItem()->setWhatsThis(1,i18n("The session time is the time since you last chose \"start new session.\""));
187  headerItem()->setWhatsThis(3,i18n("The total session time is the session time of this task and all its subtasks."));
188  headerItem()->setWhatsThis(4,i18n("The total time is the time of this task and all its subtasks."));
189  setAllColumnsShowFocus( true );
190  setSortingEnabled( true );
191  setAlternatingRowColors( true );
192  setDragDropMode( QAbstractItemView::InternalMove );
193  setItemDelegateForColumn( 6, new TaskViewDelegate(this) );
194 
195  // set up the minuteTimer
196  _minuteTimer = new QTimer(this);
197  connect( _minuteTimer, SIGNAL(timeout()), this, SLOT(minuteUpdate()));
198  _minuteTimer->start(1000 * secsPerMinute);
199 
200  // Set up the idle detection.
201  _idleTimeDetector = new IdleTimeDetector( KTimeTrackerSettings::period() );
202  connect( _idleTimeDetector, SIGNAL(subtractTime(int)),
203  this, SLOT(subtractTime(int)));
204  connect( _idleTimeDetector, SIGNAL(stopAllTimers(QDateTime)),
205  this, SLOT(stopAllTimers(QDateTime)));
206  if (!_idleTimeDetector->isIdleDetectionPossible())
207  KTimeTrackerSettings::setEnabled( false );
208 
209  // Setup auto save timer
210  _autoSaveTimer = new QTimer(this);
211  connect( _autoSaveTimer, SIGNAL(timeout()), this, SLOT(save()));
212 
213  // Setup manual save timer (to save changes a little while after they happen)
214  _manualSaveTimer = new QTimer(this);
215  _manualSaveTimer->setSingleShot( true );
216  connect( _manualSaveTimer, SIGNAL(timeout()), this, SLOT(save()));
217 
218  // Connect desktop tracker events to task starting/stopping
219  _desktopTracker = new DesktopTracker();
220  connect( _desktopTracker, SIGNAL(reachedActiveDesktop(Task*)),
221  this, SLOT(startTimerFor(Task*)));
222  connect( _desktopTracker, SIGNAL(leftActiveDesktop(Task*)),
223  this, SLOT(stopTimerFor(Task*)));
224 
225  // Header context menu
226  TreeViewHeaderContextMenu *headerContextMenu = new TreeViewHeaderContextMenu( this, this, TreeViewHeaderContextMenu::AlwaysCheckBox, QVector<int>() << 0 );
227  connect( headerContextMenu, SIGNAL(columnToggled(int)), this, SLOT(slotColumnToggled(int)) );
228 
229  // Context Menu
230  d->mPopupPercentageMenu = new QMenu( this );
231  for ( int i = 0; i <= 100; i += 10 )
232  {
233  QString label = i18n( "%1 %" , i );
234  d->mPercentage[ d->mPopupPercentageMenu->addAction( label ) ] = i;
235  }
236  connect( d->mPopupPercentageMenu, SIGNAL(triggered(QAction*)),
237  this, SLOT(slotSetPercentage(QAction*)) );
238 
239  d->mPopupPriorityMenu = new QMenu( this );
240  for ( int i = 0; i <= 9; ++i )
241  {
242  QString label;
243  switch ( i )
244  {
245  case 0:
246  label = i18n( "unspecified" );
247  break;
248  case 1:
249  label = i18nc( "combox entry for highest priority", "1 (highest)" );
250  break;
251  case 5:
252  label = i18nc( "combox entry for medium priority", "5 (medium)" );
253  break;
254  case 9:
255  label = i18nc( "combox entry for lowest priority", "9 (lowest)" );
256  break;
257  default:
258  label = QString( "%1" ).arg( i );
259  break;
260  }
261  d->mPriority[ d->mPopupPriorityMenu->addAction( label ) ] = i;
262  }
263  connect( d->mPopupPriorityMenu, SIGNAL(triggered(QAction*)),
264  this, SLOT(slotSetPriority(QAction*)) );
265 
266  setContextMenuPolicy( Qt::CustomContextMenu );
267  connect( this, SIGNAL(customContextMenuRequested(QPoint)),
268  this, SLOT(slotCustomContextMenuRequested(QPoint)) );
269 
270  reconfigure();
271  sortByColumn( 0, Qt::AscendingOrder );
272  for (int i=0; i<=columnCount(); ++i) resizeColumnToContents(i);
273 }
274 
275 void TaskView::newFocusWindowDetected( const QString &taskName )
276 {
277  QString newTaskName = taskName;
278  newTaskName.remove( '\n' );
279 
280  if ( d->mFocusTrackingActive )
281  {
282  bool found = false; // has taskName been found in our tasks
283  stopTimerFor( d->mLastTaskWithFocus );
284  int i = 0;
285  for ( Task* task = itemAt( i ); task; task = itemAt( ++i ) )
286  {
287  if ( task->name() == newTaskName )
288  {
289  found = true;
290  startTimerFor( task );
291  d->mLastTaskWithFocus = task;
292  }
293  }
294  if ( !found )
295  {
296  QString taskuid = addTask( newTaskName );
297  if ( taskuid.isNull() )
298  {
299  KMessageBox::error( 0, i18n(
300  "Error storing new task. Your changes were not saved. Make sure you can edit your iCalendar file. Also quit all applications using this file and remove any lock file related to its name from ~/.kde/share/apps/kabc/lock/ " ) );
301  }
302  i = 0;
303  for ( Task* task = itemAt( i ); task; task = itemAt( ++i ) )
304  {
305  if (task->name() == newTaskName)
306  {
307  startTimerFor( task );
308  d->mLastTaskWithFocus = task;
309  }
310  }
311  }
312  emit updateButtons();
313  } // focustrackingactive
314 }
315 
316 void TaskView::mouseMoveEvent( QMouseEvent *event )
317 {
318  QModelIndex index = indexAt( event->pos() );
319 
320  if (index.isValid() && index.column() == 6)
321  {
322  int newValue = (int)((event->pos().x() - visualRect(index).x()) / (double)(visualRect(index).width()) * 100);
323  if ( event->modifiers() & Qt::ShiftModifier )
324  {
325  int delta = newValue % 10;
326  if ( delta >= 5 )
327  {
328  newValue += (10 - delta);
329  } else
330  {
331  newValue -= delta;
332  }
333  }
334  QTreeWidgetItem *item = itemFromIndex( index );
335  if (item && item->isSelected())
336  {
337  Task *task = static_cast<Task*>(item);
338  if (task)
339  {
340  task->setPercentComplete( newValue, d->mStorage );
341  emit updateButtons();
342  }
343  }
344  }
345  else
346  {
347  QTreeWidget::mouseMoveEvent( event );
348  }
349 }
350 
351 void TaskView::mousePressEvent( QMouseEvent *event )
352 {
353  kDebug(5970) << "Entering function, event->button()=" << event->button();
354  QModelIndex index = indexAt( event->pos() );
355 
356  // if the user toggles a task as complete/incomplete
357  if ( index.isValid() && index.column() == 0 && visualRect( index ).x() <= event->pos().x()
358  && event->pos().x() < visualRect( index ).x() + 19)
359  {
360  QTreeWidgetItem *item = itemFromIndex( index );
361  if (item)
362  {
363  Task *task = static_cast<Task*>(item);
364  if (task)
365  {
366  if (task->isComplete()) task->setPercentComplete( 0, d->mStorage );
367  else
368  {
369  task->setPercentComplete( 100, d->mStorage );
370  }
371  emit updateButtons();
372  }
373  }
374  }
375  else // the user did not mark a task as complete/incomplete
376  {
377  if ( KTimeTrackerSettings::configPDA() )
378  // if you have a touchscreen, you cannot right-click. So, display context menu on any click.
379  {
380  QPoint newPos = viewport()->mapToGlobal( event->pos() );
381  emit contextMenuRequested( newPos );
382  }
383  QTreeWidget::mousePressEvent( event );
384  }
385 }
386 
387 timetrackerstorage* TaskView::storage()
388 {
389  return d->mStorage;
390 }
391 
392 TaskView::~TaskView()
393 {
394  FocusDetectorNotifier::instance()->detach( this );
395  delete d;
396  KTimeTrackerSettings::self()->writeConfig();
397 }
398 
399 Task* TaskView::currentItem() const
400 {
401  kDebug(5970) << "Entering function";
402  return static_cast< Task* >( QTreeWidget::currentItem() );
403 }
404 
405 Task* TaskView::itemAt(int i)
406 /* This procedure delivers the item at the position i in the KTreeWidget.
407 Every item is a task. The items are counted linearily. The uppermost item
408 has the number i=0. */
409 {
410  if ( topLevelItemCount() == 0 ) return 0;
411 
412  QTreeWidgetItemIterator item( this );
413  while( *item && i-- ) ++item;
414 
415  kDebug( 5970 ) << "Leaving TaskView::itemAt" << "returning " << (*item==0);
416  if ( !( *item ) )
417  return 0;
418  else
419  return (Task*)*item;
420 }
421 
422 void TaskView::load( const QString &fileName )
423 {
424  assert( !( fileName.isEmpty() ) );
425 
426  // if the program is used as an embedded plugin for konqueror, there may be a need
427  // to load from a file without touching the preferences.
428  kDebug(5970) << "Entering function";
429  _isloading = true;
430  QString err = d->mStorage->load(this, fileName);
431 
432  if (!err.isEmpty())
433  {
434  KMessageBox::error(this, err);
435  _isloading = false;
436  kDebug(5970) << "Leaving TaskView::load";
437  return;
438  }
439 
440  // Register tasks with desktop tracker
441  int i = 0;
442  for ( Task* t = itemAt(i); t; t = itemAt(++i) )
443  _desktopTracker->registerForDesktops( t, t->desktops() );
444  // till here
445  // Start all tasks that have an event without endtime
446  i = 0;
447  for ( Task* t = itemAt(i); t; t = itemAt(++i) )
448  {
449  if ( !d->mStorage->allEventsHaveEndTiMe( t ) )
450  {
451  t->resumeRunning();
452  d->mActiveTasks.append(t);
453  emit updateButtons();
454  if ( d->mActiveTasks.count() == 1 )
455  emit timersActive();
456  emit tasksChanged( d->mActiveTasks );
457  }
458  }
459  // till here
460 
461  if ( topLevelItemCount() > 0 )
462  {
463  restoreItemState();
464  setCurrentItem(topLevelItem( 0 ));
465  if ( !_desktopTracker->startTracking().isEmpty() )
466  KMessageBox::error( 0, i18n( "Your virtual desktop number is too high, desktop tracking will not work" ) );
467  _isloading = false;
468  refresh();
469  }
470  for (int i=0; i<=columnCount(); ++i) resizeColumnToContents(i);
471  kDebug(5970) << "Leaving function";
472 }
473 
474 void TaskView::restoreItemState()
475 /* Restores the item state of every item. An item is a task in the list.
476 Its state is whether it is expanded or not. If a task shall be expanded
477 is stored in the _preferences object. */
478 {
479  kDebug(5970) << "Entering function";
480 
481  if ( topLevelItemCount() > 0 )
482  {
483  QTreeWidgetItemIterator item( this );
484  while( *item )
485  {
486  Task *t = (Task *) *item;
487  t->setExpanded( _preferences->readBoolEntry( t->uid() ) );
488  ++item;
489  }
490  }
491  kDebug(5970) << "Leaving function";
492 }
493 
494 void TaskView::itemStateChanged( QTreeWidgetItem *item )
495 {
496  kDebug() << "Entering function";
497  if ( !item || _isloading ) return;
498  Task *t = (Task *)item;
499  kDebug(5970) <<"TaskView::itemStateChanged()" <<" uid=" << t->uid() <<" state=" << t->isExpanded();
500  if( _preferences ) _preferences->writeEntry( t->uid(), t->isExpanded() );
501 }
502 
503 void TaskView::closeStorage()
504 {
505  d->mStorage->closeStorage();
506 }
507 
508 bool TaskView::allEventsHaveEndTiMe()
509 {
510  return d->mStorage->allEventsHaveEndTiMe();
511 }
512 
513 void TaskView::iCalFileModified()
514 {
515  KTimeTracker::KTTCalendar *calendar = qobject_cast<KTimeTracker::KTTCalendar*>( sender() );
516  if ( !calendar || !calendar->weakPointer() ) {
517  kWarning() << "TaskView::iCalFileModified(): calendar or weakPointer is null: " << calendar;
518  } else {
519  kDebug(5970) << "entering function";
520  calendar->reload();
521  d->mStorage->buildTaskView( calendar->weakPointer().toStrongRef(), this );
522  kDebug(5970) << "exiting iCalFileModified";
523  }
524 }
525 
526 void TaskView::refresh()
527 {
528  kDebug(5970) << "entering function";
529  int i = 0;
530  for ( Task* t = itemAt(i); t; t = itemAt(++i) )
531  {
532  t->setPixmapProgress();
533  t->update(); // maybe there was a change in the times's format
534  }
535 
536  // remove root decoration if there is no more child.
537  i = 0;
538  while ( itemAt( ++i ) && ( itemAt( i )->depth() == 0 ) ){};
539  //setRootIsDecorated( itemAt( i ) && ( itemAt( i )->depth() != 0 ) );
540  // FIXME workaround? seems that the QItemDelegate for the procent column only
541  // works properly if rootIsDecorated == true.
542  setRootIsDecorated( true );
543 
544  emit updateButtons();
545  kDebug(5970) << "exiting TaskView::refresh()";
546 }
547 
548 QString TaskView::reFreshTimes()
550 {
551  kDebug(5970) << "Entering function";
552  QString err;
553  // re-calculate the time for every task based on events in the history
554  KCalCore::Event::List eventList = storage()->rawevents(); // get all events (!= tasks)
555  int n=-1;
556  resetDisplayTimeForAllTasks();
557  emit reSetTimes();
558  while (itemAt(++n)) // loop over all tasks
559  {
560  for( KCalCore::Event::List::iterator i = eventList.begin(); i != eventList.end(); ++i ) // loop over all events
561  {
562  if ( (*i)->relatedTo() == itemAt(n)->uid() ) // if event i belongs to task n
563  {
564  KDateTime kdatetimestart = (*i)->dtStart();
565  KDateTime kdatetimeend = (*i)->dtEnd();
566  KDateTime eventstart = KDateTime::fromString(kdatetimestart.toString().remove("Z"));
567  KDateTime eventend = KDateTime::fromString(kdatetimeend.toString().remove("Z"));
568  int duration=eventstart.secsTo( eventend )/60;
569  itemAt(n)->addTime( duration );
570  emit totalTimesChanged( 0, duration );
571  kDebug(5970) << "duration is " << duration;
572 
573  if ( itemAt(n)->sessionStartTiMe().isValid() )
574  {
575  // if there is a session
576  if ((itemAt(n)->sessionStartTiMe().secsTo( eventstart )>0) &&
577  (itemAt(n)->sessionStartTiMe().secsTo( eventend )>0))
578  // if the event is after the session start
579  {
580  int sessionTime=eventstart.secsTo( eventend )/60;
581  itemAt(n)->setSessionTime( itemAt(n)->sessionTime()+sessionTime );
582  }
583  }
584  else
585  // so there is no session at all
586  {
587  itemAt(n)->addSessionTime( duration );
588  emit totalTimesChanged( duration, 0 );
589  };
590  }
591  }
592  }
593 
594  for (int i=0; i<count(); ++i) itemAt(i)->recalculatetotaltime();
595  for (int i=0; i<count(); ++i) itemAt(i)->recalculatetotalsessiontime();
596 
597  refresh();
598  kDebug(5970) << "Leaving TaskView::reFreshTimes()";
599  return err;
600 }
601 
602 void TaskView::importPlanner( const QString &fileName )
603 {
604  kDebug( 5970 ) << "entering importPlanner";
605  PlannerParser *handler = new PlannerParser( this );
606  QString lFileName = fileName;
607  if ( lFileName.isEmpty() )
608  lFileName = KFileDialog::getOpenFileName( QString(), QString(), 0 );
609  QFile xmlFile( lFileName );
610  QXmlInputSource source( &xmlFile );
611  QXmlSimpleReader reader;
612  reader.setContentHandler( handler );
613  reader.parse( source );
614  refresh();
615 }
616 
617 QString TaskView::report( const ReportCriteria& rc )
618 {
619  return d->mStorage->report( this, rc );
620 }
621 
622 void TaskView::exportcsvFile()
623 {
624  kDebug(5970) << "TaskView::exportcsvFile()";
625 
626  CSVExportDialog dialog( ReportCriteria::CSVTotalsExport, this );
627  if ( currentItem() && currentItem()->isRoot() )
628  dialog.enableTasksToExportQuestion();
629  dialog.urlExportTo->KUrlRequester::setMode(KFile::File);
630  if ( dialog.exec() )
631  {
632  QString err = d->mStorage->report( this, dialog.reportCriteria() );
633  if ( !err.isEmpty() ) KMessageBox::error( this, i18n(err.toLatin1()) );
634  }
635 }
636 
637 QString TaskView::exportcsvHistory()
638 {
639  kDebug(5970) << "TaskView::exportcsvHistory()";
640  QString err;
641 
642  CSVExportDialog dialog( ReportCriteria::CSVHistoryExport, this );
643  if ( currentItem() && currentItem()->isRoot() )
644  dialog.enableTasksToExportQuestion();
645  dialog.urlExportTo->KUrlRequester::setMode(KFile::File);
646  if ( dialog.exec() )
647  {
648  err = d->mStorage->report( this, dialog.reportCriteria() );
649  }
650  return err;
651 }
652 
653 long TaskView::count()
654 {
655  long n = 0;
656  QTreeWidgetItemIterator item( this );
657  while( *item )
658  {
659  ++item;
660  ++n;
661  }
662  return n;
663 }
664 
665 QStringList TaskView::tasks()
666 {
667  QStringList result;
668  int i=0;
669  while ( itemAt(i) )
670  {
671  result << itemAt(i)->name();
672  ++i;
673  }
674  return result;
675 }
676 
677 Task* TaskView::task( const QString& taskId )
678 {
679  Task* result=0;
680  int i=-1;
681  while ( itemAt(++i) )
682  if ( itemAt( i ) )
683  if ( itemAt( i )->uid() == taskId ) result=itemAt( i );
684  return result;
685 }
686 
687 void TaskView::dropEvent ( QDropEvent * event )
688 {
689  QTreeWidget::dropEvent(event);
690  reFreshTimes();
691 }
692 
693 void TaskView::scheduleSave()
694 {
695  _manualSaveTimer->start( 10 );
696 }
697 
698 void TaskView::save()
699 {
700  kDebug(5970) <<"Entering TaskView::save()";
701  QString err=d->mStorage->save(this);
702 
703  if (!err.isNull())
704  {
705  QString errMsg = d->mStorage->icalfile() + ":\n";
706 
707  if (err==QString("Could not save. Could not lock file."))
708  errMsg += i18n("Could not save. Disk full?");
709  else
710  errMsg += i18n("Could not save.");
711 
712  KMessageBox::error(this, errMsg);
713  }
714 }
715 
716 void TaskView::startCurrentTimer()
717 {
718  startTimerFor( currentItem() );
719 }
720 
721 void TaskView::startTimerFor( Task* task, const QDateTime &startTime )
722 {
723  kDebug(5970) << "Entering function";
724  if (task != 0 && d->mActiveTasks.indexOf(task) == -1)
725  {
726  if (!task->isComplete())
727  {
728  if ( KTimeTrackerSettings::uniTasking() ) stopAllTimers();
729  _idleTimeDetector->startIdleDetection();
730  task->setRunning(true, d->mStorage, startTime);
731  d->mActiveTasks.append(task);
732  emit updateButtons();
733  if ( d->mActiveTasks.count() == 1 )
734  emit timersActive();
735  emit tasksChanged( d->mActiveTasks );
736  }
737  }
738 }
739 
740 void TaskView::clearActiveTasks()
741 {
742  d->mActiveTasks.clear();
743 }
744 
745 void TaskView::stopAllTimers( const QDateTime &when )
746 {
747  kDebug(5970) << "Entering function";
748  KProgressDialog dialog( this, 0, QString("Progress") );
749  dialog.progressBar()->setMaximum( d->mActiveTasks.count() );
750  if ( d->mActiveTasks.count() > 1 ) dialog.show();
751 
752  foreach ( Task *task, d->mActiveTasks )
753  {
754  kapp->processEvents();
755  task->setRunning( false, d->mStorage, when );
756  dialog.progressBar()->setValue( dialog.progressBar()->value() + 1 );
757  }
758  _idleTimeDetector->stopIdleDetection();
759  FocusDetectorNotifier::instance()->detach( this );
760  d->mActiveTasks.clear();
761  emit updateButtons();
762  emit timersInactive();
763  emit tasksChanged( d->mActiveTasks );
764 }
765 
766 void TaskView::toggleFocusTracking()
767 {
768  d->mFocusTrackingActive = !d->mFocusTrackingActive;
769 
770  if ( d->mFocusTrackingActive )
771  {
772  FocusDetectorNotifier::instance()->attach( this );
773  }
774  else
775  {
776  stopTimerFor( d->mLastTaskWithFocus );
777  FocusDetectorNotifier::instance()->detach( this );
778  }
779 
780  emit updateButtons();
781 }
782 
783 void TaskView::startNewSession()
784 /* This procedure starts a new session. We speak of session times,
785 overalltimes (comprising all sessions) and total times (comprising all subtasks).
786 That is why there is also a total session time. */
787 {
788  kDebug(5970) <<"Entering TaskView::startNewSession";
789  QTreeWidgetItemIterator item( this );
790  while ( *item )
791  {
792  Task * task = (Task *) *item;
793  task->startNewSession();
794  ++item;
795  }
796  kDebug(5970) << "Leaving TaskView::startNewSession";
797 }
798 
799 void TaskView::resetTimeForAllTasks()
800 /* This procedure resets all times (session and overall) for all tasks and subtasks. */
801 {
802  kDebug(5970) << "Entering function";
803  QTreeWidgetItemIterator item( this );
804  while ( *item )
805  {
806  Task * task = (Task *) *item;
807  task->resetTimes();
808  ++item;
809  }
810  storage()->deleteAllEvents();
811  kDebug(5970) << "Leaving function";
812 }
813 
814 void TaskView::resetDisplayTimeForAllTasks()
815 /* This procedure resets all times (session and overall) for all tasks and subtasks. */
816 {
817  kDebug(5970) << "Entering function";
818  QTreeWidgetItemIterator item( this );
819  while ( *item )
820  {
821  Task * task = (Task *) *item;
822  task->resetTimes();
823  ++item;
824  }
825  kDebug(5970) << "Leaving function";
826 }
827 
828 void TaskView::stopTimerFor(Task* task)
829 {
830  kDebug(5970) << "Entering function";
831  if ( task != 0 && d->mActiveTasks.indexOf(task) != -1 )
832  {
833  d->mActiveTasks.removeAll(task);
834  task->setRunning(false, d->mStorage);
835  if ( d->mActiveTasks.count() == 0 )
836  {
837  _idleTimeDetector->stopIdleDetection();
838  emit timersInactive();
839  }
840  emit updateButtons();
841  }
842  emit tasksChanged( d->mActiveTasks );
843 }
844 
845 void TaskView::stopCurrentTimer()
846 {
847  stopTimerFor( currentItem() );
848  if ( d->mFocusTrackingActive && d->mLastTaskWithFocus == currentItem() )
849  {
850  toggleFocusTracking();
851  }
852 }
853 
854 void TaskView::minuteUpdate()
855 {
856  addTimeToActiveTasks(1, false);
857 }
858 
859 void TaskView::addTimeToActiveTasks(int minutes, bool save_data)
860 {
861  foreach ( Task *task, d->mActiveTasks )
862  task->changeTime( minutes, ( save_data ? d->mStorage : 0 ) );
863 }
864 
865 void TaskView::newTask()
866 {
867  newTask(i18n("New Task"), 0);
868 }
869 
870 void TaskView::newTask( const QString &caption, Task *parent )
871 {
872  EditTaskDialog *dialog = new EditTaskDialog( this, caption, 0 );
873  long total, totalDiff, session, sessionDiff;
874  DesktopList desktopList;
875 
876  int result = dialog->exec();
877  if ( result == QDialog::Accepted )
878  {
879  QString taskName = i18n( "Unnamed Task" );
880  if ( !dialog->taskName().isEmpty()) taskName = dialog->taskName();
881  QString taskDescription = dialog->taskDescription();
882 
883  total = totalDiff = session = sessionDiff = 0;
884  dialog->status( &desktopList );
885 
886  // If all available desktops are checked, disable auto tracking,
887  // since it makes no sense to track for every desktop.
888  if ( desktopList.size() == _desktopTracker->desktopCount() )
889  desktopList.clear();
890 
891  QString uid = addTask( taskName, taskDescription, total, session, desktopList, parent );
892  if ( uid.isNull() )
893  {
894  KMessageBox::error( 0, i18n(
895  "Error storing new task. Your changes were not saved. Make sure you can edit your iCalendar file. Also quit all applications using this file and remove any lock file related to its name from ~/.kde/share/apps/kabc/lock/ " ) );
896  }
897  }
898  emit updateButtons();
899 }
900 
901 QString TaskView::addTask
902 ( const QString& taskname, const QString& taskdescription, long total, long session,
903  const DesktopList& desktops, Task* parent )
904 {
905  kDebug(5970) << "Entering function; taskname =" << taskname;
906  setSortingEnabled(false);
907  Task *task;
908  if ( parent ) task = new Task( taskname, taskdescription, total, session, desktops, parent );
909  else task = new Task( taskname, taskdescription, total, session, desktops, this );
910 
911  task->setUid( d->mStorage->addTask( task, parent ) );
912  QString taskuid=task->uid();
913  if ( ! taskuid.isNull() )
914  {
915  _desktopTracker->registerForDesktops( task, desktops );
916  setCurrentItem( task );
917  task->setSelected( true );
918  task->setPixmapProgress();
919  save();
920  }
921  else
922  {
923  delete task;
924  }
925  setSortingEnabled(true);
926  return taskuid;
927 }
928 
929 void TaskView::newSubTask()
930 {
931  Task* task = currentItem();
932  if(!task)
933  return;
934  newTask(i18n("New Sub Task"), task);
935  task->setExpanded(true);
936  refresh();
937 }
938 
939 void TaskView::editTask()
940 {
941  kDebug(5970) <<"Entering editTask";
942  Task *task = currentItem();
943  if (!task) return;
944 
945  DesktopList desktopList = task->desktops();
946  DesktopList oldDeskTopList = desktopList;
947  EditTaskDialog *dialog = new EditTaskDialog( this, i18n("Edit Task"), &desktopList );
948  dialog->setTask( task->name() );
949  dialog->setDescription( task->description() );
950  int result = dialog->exec();
951  if (result == QDialog::Accepted)
952  {
953  QString taskName = i18n("Unnamed Task");
954  if (!dialog->taskName().isEmpty())
955  {
956  taskName = dialog->taskName();
957  }
958  // setName only does something if the new name is different
959  task->setName(taskName, d->mStorage);
960  task->setDescription(dialog->taskDescription());
961  // update session time as well if the time was changed
962  if (!dialog->timeChange().isEmpty())
963  {
964  task->changeTime(dialog->timeChange().toInt(),d->mStorage);
965  }
966  dialog->status( &desktopList );
967  // If all available desktops are checked, disable auto tracking,
968  // since it makes no sense to track for every desktop.
969  if (desktopList.size() == _desktopTracker->desktopCount())
970  desktopList.clear();
971  // only do something for autotracking if the new setting is different
972  if ( oldDeskTopList != desktopList )
973  {
974  task->setDesktopList(desktopList);
975  _desktopTracker->registerForDesktops( task, desktopList );
976  }
977  emit updateButtons();
978  }
979 }
980 
981 void TaskView::setPerCentComplete(int completion)
982 {
983  Task* task = currentItem();
984  if (task == 0)
985  {
986  KMessageBox::information(0,i18n("No task selected."));
987  return;
988  }
989 
990  if (completion<0) completion=0;
991  if (completion<100)
992  {
993  task->setPercentComplete(completion, d->mStorage);
994  task->setPixmapProgress();
995  save();
996  emit updateButtons();
997  }
998 }
999 
1000 void TaskView::deleteTaskBatch( Task* task )
1001 {
1002  QString uid=task->uid();
1003  task->remove(d->mStorage);
1004  _preferences->deleteEntry( uid ); // forget if the item was expanded or collapsed
1005  save();
1006 
1007  // Stop idle detection if no more counters are running
1008  if (d->mActiveTasks.count() == 0)
1009  {
1010  _idleTimeDetector->stopIdleDetection();
1011  emit timersInactive();
1012  }
1013  task->delete_recursive();
1014  emit tasksChanged( d->mActiveTasks );
1015 }
1016 
1017 
1018 void TaskView::deleteTask( Task* task )
1019 /* Attention when popping up a window asking for confirmation.
1020 If you have "Track active applications" on, this window will create a new task and
1021 make this task running and selected. */
1022 {
1023  kDebug(5970) << "Entering function";
1024  if (task == 0) task = currentItem();
1025  if (currentItem() == 0)
1026  {
1027  KMessageBox::information(0,i18n("No task selected."));
1028  }
1029  else
1030  {
1031  int response = KMessageBox::Continue;
1032  if (KTimeTrackerSettings::promptDelete())
1033  {
1034  response = KMessageBox::warningContinueCancel( 0,
1035  i18n( "Are you sure you want to delete the selected"
1036  " task and its entire history?\n"
1037  "NOTE: all subtasks and their history will also "
1038  "be deleted."),
1039  i18n( "Deleting Task"), KStandardGuiItem::del());
1040  }
1041  if (response == KMessageBox::Continue) deleteTaskBatch(task);
1042  }
1043 }
1044 
1045 void TaskView::markTaskAsComplete()
1046 {
1047  if (currentItem() == 0)
1048  {
1049  KMessageBox::information(0,i18n("No task selected."));
1050  return;
1051  }
1052  currentItem()->setPercentComplete(100, d->mStorage);
1053  currentItem()->setPixmapProgress();
1054  save();
1055  emit updateButtons();
1056 }
1057 
1058 void TaskView::subtractTime(int minutes)
1059 {
1060  addTimeToActiveTasks(-minutes,false); // subtract time in memory, but do not store it
1061 }
1062 
1063 void TaskView::deletingTask(Task* deletedTask)
1064 {
1065  kDebug(5970) << "Entering function";
1066  DesktopList desktopList;
1067 
1068  _desktopTracker->registerForDesktops( deletedTask, desktopList );
1069  d->mActiveTasks.removeAll( deletedTask );
1070 
1071  emit tasksChanged( d->mActiveTasks );
1072 }
1073 
1074 void TaskView::markTaskAsIncomplete()
1075 {
1076  setPerCentComplete(50); // if it has been reopened, assume half-done
1077 }
1078 
1079 QString TaskView::clipTotals( const ReportCriteria &rc )
1080 // This function stores the user's tasks into the clipboard.
1081 // rc tells how the user wants his report, e.g. all times or session times
1082 {
1083  kDebug(5970) << "Entering function";
1084  QString err;
1085  TimeKard t;
1086  KApplication::clipboard()->setText(t.totalsAsText(this, rc));
1087  return err;
1088 }
1089 
1090 QString TaskView::setClipBoardText(const QString& s)
1091 {
1092  QString err; // maybe we find possible errors later
1093  KApplication::clipboard()->setText(s);
1094  return err;
1095 }
1096 
1097 void TaskView::slotItemDoubleClicked( QTreeWidgetItem *item, int )
1098 {
1099  if (item)
1100  {
1101  Task *task = static_cast<Task*>( item );
1102  if ( task )
1103  {
1104  if ( task->isRunning() )
1105  {
1106  stopCurrentTimer();
1107  }
1108  else if ( !task->isComplete() )
1109  {
1110  stopAllTimers();
1111  startCurrentTimer();
1112  }
1113  }
1114  }
1115 }
1116 
1117 void TaskView::slotColumnToggled( int column )
1118 {
1119  switch ( column )
1120  {
1121  case 1:
1122  KTimeTrackerSettings::setDisplaySessionTime( !isColumnHidden( 1 ) );
1123  break;
1124  case 2:
1125  KTimeTrackerSettings::setDisplayTime( !isColumnHidden( 2 ) );
1126  break;
1127  case 3:
1128  KTimeTrackerSettings::setDisplayTotalSessionTime( !isColumnHidden( 3 ) );
1129  break;
1130  case 4:
1131  KTimeTrackerSettings::setDisplayTotalTime( !isColumnHidden( 4 ) );
1132  break;
1133  case 5:
1134  KTimeTrackerSettings::setDisplayPriority( !isColumnHidden( 5 ) );
1135  break;
1136  case 6:
1137  KTimeTrackerSettings::setDisplayPercentComplete( !isColumnHidden( 6 ) );
1138  break;
1139  }
1140  KTimeTrackerSettings::self()->writeConfig();
1141 }
1142 
1143 void TaskView::slotCustomContextMenuRequested( const QPoint &pos )
1144 {
1145  QPoint newPos = viewport()->mapToGlobal( pos );
1146  int column = columnAt( pos.x() );
1147 
1148  switch (column)
1149  {
1150  case 6: /* percentage */
1151  d->mPopupPercentageMenu->popup( newPos );
1152  break;
1153 
1154  case 5: /* priority */
1155  d->mPopupPriorityMenu->popup( newPos );
1156  break;
1157 
1158  default:
1159  emit contextMenuRequested( newPos );
1160  break;
1161  }
1162 }
1163 
1164 void TaskView::slotSetPercentage( QAction *action )
1165 {
1166  if ( currentItem() )
1167  {
1168  currentItem()->setPercentComplete( d->mPercentage[ action ], storage() );
1169  emit updateButtons();
1170  }
1171 }
1172 
1173 void TaskView::slotSetPriority( QAction *action )
1174 {
1175  if ( currentItem() )
1176  {
1177  currentItem()->setPriority( d->mPriority[ action ] );
1178  }
1179 }
1180 
1181 bool TaskView::isFocusTrackingActive() const
1182 {
1183  return d->mFocusTrackingActive;
1184 }
1185 
1186 QList< Task* > TaskView::activeTasks() const
1187 {
1188  return d->mActiveTasks;
1189 }
1190 
1191 void TaskView::reconfigure()
1192 {
1193  kDebug(5970) << "Entering function";
1194  /* Adapt columns */
1195  setColumnHidden( 1, !KTimeTrackerSettings::displaySessionTime() );
1196  setColumnHidden( 2, !KTimeTrackerSettings::displayTime() );
1197  setColumnHidden( 3, !KTimeTrackerSettings::displayTotalSessionTime() );
1198  setColumnHidden( 4, !KTimeTrackerSettings::displayTotalTime() );
1199  setColumnHidden( 5, !KTimeTrackerSettings::displayPriority() );
1200  setColumnHidden( 6, !KTimeTrackerSettings::displayPercentComplete() );
1201 
1202  /* idleness */
1203  _idleTimeDetector->setMaxIdle( KTimeTrackerSettings::period() );
1204  _idleTimeDetector->toggleOverAllIdleDetection( KTimeTrackerSettings::enabled() );
1205 
1206  /* auto save */
1207  if ( KTimeTrackerSettings::autoSave() )
1208  {
1209  _autoSaveTimer->start(
1210  KTimeTrackerSettings::autoSavePeriod() * 1000 * secsPerMinute
1211  );
1212  }
1213  else if ( _autoSaveTimer->isActive() )
1214  {
1215  _autoSaveTimer->stop();
1216  }
1217 
1218  refresh();
1219 }
1220 
1221 #include "taskview.moc"
Task::setPercentComplete
void setPercentComplete(const int percent, timetrackerstorage *storage)
Update percent complete for this task.
Definition: task.cpp:238
Preferences::instance
static Preferences * instance()
Definition: preferences.cpp:34
KTimeTrackerSettings::period
static uint period()
Get period.
Definition: ktimetracker.h:88
TaskView::dropEvent
void dropEvent(QDropEvent *event)
Definition: taskview.cpp:687
desktoptracker.h
IdleTimeDetector::stopIdleDetection
void stopIdleDetection()
Stops detecting idle time.
Definition: idletimedetector.cpp:139
IdleTimeDetector::isIdleDetectionPossible
bool isIdleDetectionPossible()
Returns true if it is possible to do idle detection.
Definition: idletimedetector.cpp:57
TaskView::slotSetPriority
void slotSetPriority(QAction *)
Definition: taskview.cpp:1173
edittaskdialog.h
KTimeTracker::KTTCalendar
Definition: kttcalendar.h:29
KTimeTracker::KTTCalendar::reload
bool reload()
reimp
Definition: kttcalendar.cpp:62
IdleTimeDetector::startIdleDetection
void startIdleDetection()
Starts detecting idle time.
Definition: idletimedetector.cpp:131
TaskView::toggleFocusTracking
void toggleFocusTracking()
Toggles the automatic tracking of focused windows.
Definition: taskview.cpp:766
timetrackerstorage::deleteAllEvents
QString deleteAllEvents()
Definition: timetrackerstorage.cpp:358
FocusDetectorNotifier::instance
static FocusDetectorNotifier * instance()
Definition: focusdetectornotifier.cpp:51
FocusDetectorNotifier::detach
void detach(TaskView *view)
Definition: focusdetectornotifier.cpp:74
Preferences::readBoolEntry
bool readBoolEntry(const QString &uid)
Definition: preferences.cpp:43
QTreeWidget
Task::name
QString name() const
returns the name of this task.
Definition: task.cpp:680
TaskView::editTask
void editTask()
Calls editTask dialog for the current task.
Definition: taskview.cpp:939
TaskView::importPlanner
void importPlanner(const QString &fileName="")
used to import tasks from imendio planner
Definition: taskview.cpp:602
TaskView::reSetTimes
void reSetTimes()
Task::startNewSession
void startNewSession()
sets session time to zero.
Definition: task.cpp:653
TimeKard::totalsAsText
QString totalsAsText(TaskView *taskview, ReportCriteria rc)
Generates ascii text of task totals, for current task on down.
Definition: timekard.cpp:47
TaskView::newFocusWindowDetected
void newFocusWindowDetected(const QString &)
React on the focus having changed to Window QString.
Definition: taskview.cpp:275
TaskView::itemAt
Task * itemAt(int i)
Return the i'th item (zero-based), cast to a Task pointer.
Definition: taskview.cpp:405
QWidget
TaskView::count
long count()
Return the total number of items in the view.
Definition: taskview.cpp:653
Task::setRunning
void setRunning(bool on, timetrackerstorage *storage, const QDateTime &when=QDateTime::currentDateTime())
starts or stops a task
Definition: task.cpp:159
KTimeTrackerSettings::displayPriority
static bool displayPriority()
Get displayPriority.
Definition: ktimetracker.h:278
TaskView::startTimerFor
void startTimerFor(Task *task, const QDateTime &startTime=QDateTime::currentDateTime())
starts timer for task.
Definition: taskview.cpp:721
TaskView::setClipBoardText
QString setClipBoardText(const QString &s)
Set the text of the application's clipboard.
Definition: taskview.cpp:1090
DesktopTracker::desktopCount
int desktopCount() const
Definition: desktoptracker.h:56
TaskView::reFreshTimes
QString reFreshTimes()
Refresh the times of the tasks, e.g.
Definition: taskview.cpp:548
EditTaskDialog::setDescription
void setDescription(const QString &description)
Definition: edittaskdialog.cpp:84
IdleTimeDetector
Keep track of how long the computer has been idle.
Definition: idletimedetector.h:47
EditTaskDialog::setTask
void setTask(const QString &name)
Definition: edittaskdialog.cpp:79
TaskView::updateButtons
void updateButtons()
TaskView::scheduleSave
void scheduleSave()
Schedule that we should save very soon.
Definition: taskview.cpp:693
TreeViewHeaderContextMenu
ContextMenu for QTreeView::header() to toggle the visible state of the columns.
Definition: treeviewheadercontextmenu.h:47
KTimeTrackerSettings::setEnabled
static void setEnabled(bool v)
Set enabled.
Definition: ktimetracker.h:59
TaskView::TaskView
TaskView(QWidget *parent=0)
Definition: taskview.cpp:163
TaskView::clipTotals
QString clipTotals(const ReportCriteria &rc)
Copy totals for current and all sub tasks to clipboard.
Definition: taskview.cpp:1079
QObject
TaskView::task
Task * task(const QString &uid)
return the task with the given UID
Definition: taskview.cpp:677
TaskView::stopCurrentTimer
void stopCurrentTimer()
Stop the timer for the current item in the view.
Definition: taskview.cpp:845
CSVExportDialog
Definition: csvexportdialog.h:46
TimeKard
Routines to output timecard data.
Definition: timekard.h:84
TaskView::subtractTime
void subtractTime(int minutes)
Subtracts time from all active tasks, and does not log event.
Definition: taskview.cpp:1058
TaskView::iCalFileModified
void iCalFileModified()
React on another process having modified the iCal file we rely on.
Definition: taskview.cpp:513
KTimeTrackerSettings::displaySessionTime
static bool displaySessionTime()
Get displaySessionTime.
Definition: ktimetracker.h:202
Task::remove
bool remove(timetrackerstorage *storage)
remove Task with all it's children
Definition: task.cpp:444
KTimeTrackerSettings::autoSave
static bool autoSave()
Get autoSave.
Definition: ktimetracker.h:126
secsPerMinute
const int secsPerMinute
Definition: ktimetrackerutility.h:53
EditTaskDialog::status
void status(DesktopList *desktopList) const
Definition: edittaskdialog.cpp:89
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
TaskView::timersActive
void timersActive()
KTimeTrackerSettings::enabled
static bool enabled()
Get enabled.
Definition: ktimetracker.h:69
TaskView::~TaskView
virtual ~TaskView()
Definition: taskview.cpp:392
TaskView::markTaskAsIncomplete
void markTaskAsIncomplete()
Definition: taskview.cpp:1074
TaskView::slotCustomContextMenuRequested
void slotCustomContextMenuRequested(const QPoint &)
Definition: taskview.cpp:1143
TaskView::markTaskAsComplete
void markTaskAsComplete()
Definition: taskview.cpp:1045
TaskView::activeTasks
QList< Task * > activeTasks() const
Returns a list of the current active tasks.
Definition: taskview.cpp:1186
EditTaskDialog::taskDescription
QString taskDescription()
Definition: edittaskdialog.cpp:69
Task::setName
void setName(const QString &name, timetrackerstorage *storage)
sets the name of the task
Definition: task.cpp:213
TaskView::clearActiveTasks
void clearActiveTasks()
clears all active tasks.
Definition: taskview.cpp:740
taskview.h
TaskView::slotColumnToggled
void slotColumnToggled(int)
Definition: taskview.cpp:1117
TaskView::tasksChanged
void tasksChanged(QList< Task * > activeTasks)
EditTaskDialog::timeChange
QString timeChange()
Definition: edittaskdialog.cpp:74
CSVExportDialog::reportCriteria
ReportCriteria reportCriteria()
Return an object that encapsulates the choices the user has made.
Definition: csvexportdialog.cpp:86
Task::resetTimes
void resetTimes()
Reset all times to 0 and adjust parent task's totalTiMes.
Definition: task.cpp:424
TaskView::newTask
void newTask()
Calls newTask dialog with caption "New Task".
Definition: taskview.cpp:865
KTimeTrackerSettings::setDisplayPercentComplete
static void setDisplayPercentComplete(bool v)
Set displayPercentComplete.
Definition: ktimetracker.h:287
TreeViewHeaderContextMenu::AlwaysCheckBox
Definition: treeviewheadercontextmenu.h:53
TaskView::startNewSession
void startNewSession()
Reset session time to zero for all tasks.
Definition: taskview.cpp:783
TaskView::slotItemDoubleClicked
void slotItemDoubleClicked(QTreeWidgetItem *item, int)
Definition: taskview.cpp:1097
KTimeTrackerSettings::autoSavePeriod
static uint autoSavePeriod()
Get autoSavePeriod.
Definition: ktimetracker.h:145
TaskView::refresh
void refresh()
Used to refresh (e.g.
Definition: taskview.cpp:526
IdleTimeDetector::setMaxIdle
void setMaxIdle(int maxIdle)
Sets the maximum allowed idle.
Definition: idletimedetector.cpp:80
TaskView::startCurrentTimer
void startCurrentTimer()
Start the timer on the current item (task) in view.
Definition: taskview.cpp:716
Task::delete_recursive
void delete_recursive()
Definition: task.cpp:149
TaskView::minuteUpdate
void minuteUpdate()
Definition: taskview.cpp:854
TaskView::allEventsHaveEndTiMe
bool allEventsHaveEndTiMe()
Deliver if all events from the storage have and end time.
Definition: taskview.cpp:508
Task::uid
QString uid() const
Return unique iCalendar Todo ID for this task.
Definition: task.cpp:660
TaskView::mousePressEvent
void mousePressEvent(QMouseEvent *)
Definition: taskview.cpp:351
TaskView::setPerCentComplete
void setPerCentComplete(int completion)
Sets % completed for the current task.
Definition: taskview.cpp:981
TaskView::exportcsvFile
void exportcsvFile()
Export comma separated values format for task time totals.
Definition: taskview.cpp:622
TaskView::closeStorage
void closeStorage()
Close the storage and release lock.
Definition: taskview.cpp:503
csvexportdialog.h
ReportCriteria
Stores entries from export dialog.
Definition: reportcriteria.h:41
EditTaskDialog
Class to show a dialog in ktimetracker to enter data about a task.
Definition: edittaskdialog.h:26
TaskView::timersInactive
void timersInactive()
IdleTimeDetector::toggleOverAllIdleDetection
void toggleOverAllIdleDetection(bool on)
Sets whether idle detection should be done at all.
Definition: idletimedetector.cpp:147
ktimetracker.h
TaskView::storage
timetrackerstorage * storage()
Returns a pointer to storage object.
Definition: taskview.cpp:387
ReportCriteria::CSVTotalsExport
Definition: reportcriteria.h:48
Task::isRunning
bool isRunning() const
return the state of a task - if it's running or not
Definition: task.cpp:208
timetrackerstorage::rawevents
KCalCore::Event::List rawevents()
list of all events
Definition: timetrackerstorage.cpp:320
TaskView::deleteTask
void deleteTask(Task *task=0)
Deletes the given or the current task (and children) from the view.
Definition: taskview.cpp:1018
TaskView::stopTimerFor
void stopTimerFor(Task *task)
Definition: taskview.cpp:828
TaskView::slotSetPercentage
void slotSetPercentage(QAction *)
Definition: taskview.cpp:1164
Preferences::deleteEntry
void deleteEntry(const QString &key)
Definition: preferences.cpp:55
TaskView::isFocusTrackingActive
bool isFocusTrackingActive() const
Returns whether the focus tracking is currently active.
Definition: taskview.cpp:1181
KTimeTrackerSettings::setDisplayTime
static void setDisplayTime(bool v)
Set displayTime.
Definition: ktimetracker.h:211
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
focusdetector.h
Task::addSessionTime
QString addSessionTime(long minutes)
Adds minutes to the task's session time and its supertasks' total session time.
Definition: task.cpp:331
KTimeTrackerSettings::promptDelete
static bool promptDelete()
Get promptDelete.
Definition: ktimetracker.h:164
QTreeWidgetItem
focusdetectornotifier.h
preferences.h
TaskView::tasks
QStringList tasks()
return all task names, e.g.
Definition: taskview.cpp:665
KTimeTrackerSettings::displayTotalTime
static bool displayTotalTime()
Get displayTotalTime.
Definition: ktimetracker.h:259
TaskView::deleteTaskBatch
void deleteTaskBatch(Task *task=0)
Deletes the given or the current task (and children) from the view.
Definition: taskview.cpp:1000
Preferences::writeEntry
void writeEntry(const QString &key, bool value)
Definition: preferences.cpp:48
Task::description
QString description() const
returns the description of this task.
Definition: task.cpp:685
TaskView::resetDisplayTimeForAllTasks
void resetDisplayTimeForAllTasks()
Reset session and total time for all tasks - do not touch the storage.
Definition: taskview.cpp:814
Task::setDesktopList
void setDesktopList(DesktopList dl)
Definition: task.cpp:306
Task::changeTime
void changeTime(long minutes, timetrackerstorage *storage)
Change task time.
Definition: task.cpp:407
ReportCriteria::CSVHistoryExport
Definition: reportcriteria.h:48
KTimeTrackerSettings::self
static KTimeTrackerSettings * self()
Definition: ktimetracker.cpp:17
DesktopList
QVector< int > DesktopList
Definition: desktoplist.h:28
task.h
KTimeTrackerSettings::setDisplayTotalTime
static void setDisplayTotalTime(bool v)
Set displayTotalTime.
Definition: ktimetracker.h:249
Task::setUid
void setUid(const QString &uid)
Set unique id for the task.
Definition: task.cpp:203
EditTaskDialog::taskName
QString taskName()
Definition: edittaskdialog.cpp:64
timekard.h
TaskView::totalTimesChanged
void totalTimesChanged(long session, long total)
DesktopTracker::startTracking
QString startTracking()
Start time tracking of tasks by virtual desktop.
Definition: desktoptracker.cpp:80
KTimeTrackerSettings::displayTime
static bool displayTime()
Get displayTime.
Definition: ktimetracker.h:221
DesktopTracker::registerForDesktops
void registerForDesktops(Task *task, DesktopList dl)
Definition: desktoptracker.cpp:98
PlannerParser
Definition: plannerparser.h:48
idletimedetector.h
TaskView::reconfigure
void reconfigure()
Reconfigures taskView depending on current configuration.
Definition: taskview.cpp:1191
TaskView::load
void load(const QString &filename)
Load the view from storage.
Definition: taskview.cpp:422
KTimeTracker::KTTCalendar::weakPointer
QWeakPointer< KTimeTracker::KTTCalendar > weakPointer() const
Definition: kttcalendar.cpp:75
KTimeTrackerSettings::setDisplaySessionTime
static void setDisplaySessionTime(bool v)
Set displaySessionTime.
Definition: ktimetracker.h:192
Task::desktops
DesktopList desktops() const
Definition: task.cpp:700
Task::recalculatetotalsessiontime
QString recalculatetotalsessiontime()
A recursive function to calculate the total session time of a task.
Definition: task.cpp:372
CSVExportDialog::enableTasksToExportQuestion
void enableTasksToExportQuestion()
Enable the "Tasks to export" question in the dialog.
Definition: csvexportdialog.cpp:68
TaskView::mouseMoveEvent
void mouseMoveEvent(QMouseEvent *)
Definition: taskview.cpp:316
KTimeTrackerSettings::uniTasking
static bool uniTasking()
Get uniTasking.
Definition: ktimetracker.h:183
TaskView::report
QString report(const ReportCriteria &rc)
call export function for csv totals or history
Definition: taskview.cpp:617
DesktopTracker
A utility to associate tasks with desktops As soon as a desktop is activated/left - an signal is emit...
Definition: desktoptracker.h:42
TaskView::save
void save()
Save to persistent storage.
Definition: taskview.cpp:698
KTimeTrackerSettings::setDisplayTotalSessionTime
static void setDisplayTotalSessionTime(bool v)
Set displayTotalSessionTime.
Definition: ktimetracker.h:230
TaskView::stopAllTimers
void stopAllTimers(const QDateTime &when=QDateTime::currentDateTime())
Stop all running timers.
Definition: taskview.cpp:745
KTimeTrackerSettings::displayTotalSessionTime
static bool displayTotalSessionTime()
Get displayTotalSessionTime.
Definition: ktimetracker.h:240
TaskView::newSubTask
void newSubTask()
Calls newTask dialog with caption "New Sub Task".
Definition: taskview.cpp:929
Task::setPriority
void setPriority(int priority)
Update priority for this task.
Definition: task.cpp:269
treeviewheadercontextmenu.h
TaskView::deletingTask
void deletingTask(Task *deletedTask)
receiving signal that a task is being deleted
Definition: taskview.cpp:1063
KTimeTrackerSettings::configPDA
static bool configPDA()
Get configPDA.
Definition: ktimetracker.h:335
TaskView::contextMenuRequested
void contextMenuRequested(const QPoint &)
TaskView::itemStateChanged
void itemStateChanged(QTreeWidgetItem *item)
item state stores if a task is expanded so you can see the subtasks
Definition: taskview.cpp:494
Task::setPixmapProgress
void setPixmapProgress()
Sets an appropriate icon for this task based on its level of completion.
Definition: task.cpp:284
KTimeTrackerSettings::setDisplayPriority
static void setDisplayPriority(bool v)
Set displayPriority.
Definition: ktimetracker.h:268
Task
A class representing a task.
Definition: task.h:54
FocusDetectorNotifier::attach
void attach(TaskView *view)
Definition: focusdetectornotifier.cpp:65
TaskView::exportcsvHistory
QString exportcsvHistory()
Export comma-separated values format for task history.
Definition: taskview.cpp:637
Task::recalculatetotaltime
QString recalculatetotaltime()
A recursive function to calculate the total time of a task.
Definition: task.cpp:361
plannerparser.h
TaskView::currentItem
Task * currentItem() const
Return the current item in the view, cast to a Task pointer.
Definition: taskview.cpp:399
timetrackerstorage
Class to store/retrieve KTimeTracker data to/from persistent storage.
Definition: timetrackerstorage.h:57
KTimeTrackerSettings::displayPercentComplete
static bool displayPercentComplete()
Get displayPercentComplete.
Definition: ktimetracker.h:297
TaskView::resetTimeForAllTasks
void resetTimeForAllTasks()
Reset session and total time to zero for all tasks.
Definition: taskview.cpp:799
TaskView::addTask
QString addTask(const QString &taskame, const QString &taskdescription=QString(), long total=0, long session=0, const DesktopList &desktops=QVector< int >(0, 0), Task *parent=0)
Add a task to view and storage.
Definition: taskview.cpp:902
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-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:10 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

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