karm

karm_part.cpp
1 
2 #include "tdeaccelmenuwatch.h"
3 #include "karm_part.h"
4 #include "karmerrors.h"
5 #include "task.h"
6 #include "preferences.h"
7 #include "tray.h"
8 #include "version.h"
9 #include <tdeaccel.h>
10 
11 #include <kinstance.h>
12 #include <tdeaction.h>
13 #include <kstdaction.h>
14 #include <tdefiledialog.h>
15 #include <tdeglobal.h>
16 #include <tdelocale.h>
17 
18 #include <tqfile.h>
19 #include <tqtextstream.h>
20 #include <tqmultilineedit.h>
21 #include <tqpopupmenu.h>
22 #include "mainwindow.h"
23 
24 karmPart::karmPart( TQWidget *parentWidget, const char *widgetName,
25  TQObject *parent, const char *name )
26  : DCOPObject ( "KarmDCOPIface" ), KParts::ReadWritePart(parent, name),
27  _accel ( new TDEAccel( parentWidget ) ),
28  _watcher ( new TDEAccelMenuWatch( _accel, parentWidget ) )
29 {
30  // we need an instance
31  setInstance( karmPartFactory::instance() );
32 
33  // this should be your custom internal widget
34  _taskView = new TaskView( parentWidget, widgetName );
35 
36  // setup PreferenceDialog.
37  _preferences = Preferences::instance();
38 
39  // notify the part that this is our internal widget
40  setWidget(_taskView);
41 
42  // create our actions
43  KStdAction::open(this, TQ_SLOT(fileOpen()), actionCollection());
44  KStdAction::saveAs(this, TQ_SLOT(fileSaveAs()), actionCollection());
45  KStdAction::save(this, TQ_SLOT(save()), actionCollection());
46 
47  makeMenus();
48 
49  _watcher->updateMenus();
50 
51  // connections
52 
53  connect( _taskView, TQ_SIGNAL( totalTimesChanged( long, long ) ),
54  this, TQ_SLOT( updateTime( long, long ) ) );
55  connect( _taskView, TQ_SIGNAL( selectionChanged ( TQListViewItem * )),
56  this, TQ_SLOT(slotSelectionChanged()));
57  connect( _taskView, TQ_SIGNAL( updateButtons() ),
58  this, TQ_SLOT(slotSelectionChanged()));
59 
60  // Setup context menu request handling
61  connect( _taskView,
62  TQ_SIGNAL( contextMenuRequested( TQListViewItem*, const TQPoint&, int )),
63  this,
64  TQ_SLOT( contextMenuRequest( TQListViewItem*, const TQPoint&, int )));
65 
66  _tray = new KarmTray( this );
67 
68  connect( _tray, TQ_SIGNAL( quitSelected() ), TQ_SLOT( quit() ) );
69 
70  connect( _taskView, TQ_SIGNAL( timersActive() ), _tray, TQ_SLOT( startClock() ) );
71  connect( _taskView, TQ_SIGNAL( timersActive() ), this, TQ_SLOT( enableStopAll() ));
72  connect( _taskView, TQ_SIGNAL( timersInactive() ), _tray, TQ_SLOT( stopClock() ) );
73  connect( _taskView, TQ_SIGNAL( timersInactive() ), this, TQ_SLOT( disableStopAll()));
74  connect( _taskView, TQ_SIGNAL( tasksChanged( TQPtrList<Task> ) ),
75  _tray, TQ_SLOT( updateToolTip( TQPtrList<Task> ) ));
76 
77  _taskView->load();
78 
79  // Everything that uses Preferences has been created now, we can let it
80  // emit its signals
81  _preferences->emitSignals();
82  slotSelectionChanged();
83 
84  // set our XML-UI resource file
85  setXMLFile("karmui.rc");
86 
87  // we are read-write by default
88  setReadWrite(true);
89 
90  // we are not modified since we haven't done anything yet
91  setModified(false);
92 }
93 
94 karmPart::~karmPart()
95 {
96 }
97 
98 void karmPart::slotSelectionChanged()
99 {
100  Task* item= _taskView->current_item();
101  actionDelete->setEnabled(item);
102  actionEdit->setEnabled(item);
103  actionStart->setEnabled(item && !item->isRunning() && !item->isComplete());
104  actionStop->setEnabled(item && item->isRunning());
105  actionMarkAsComplete->setEnabled(item && !item->isComplete());
106  actionMarkAsIncomplete->setEnabled(item && item->isComplete());
107 }
108 
109 void karmPart::makeMenus()
110 {
111  TDEAction
112  *actionKeyBindings,
113  *actionNew,
114  *actionNewSub;
115 
116  (void) KStdAction::quit( this, TQ_SLOT( quit() ), actionCollection());
117  (void) KStdAction::print( this, TQ_SLOT( print() ), actionCollection());
118  actionKeyBindings = KStdAction::keyBindings( this, TQ_SLOT( keyBindings() ),
119  actionCollection() );
120  actionPreferences = KStdAction::preferences(_preferences,
121  TQ_SLOT(showDialog()),
122  actionCollection() );
123  (void) KStdAction::save( this, TQ_SLOT( save() ), actionCollection() );
124  TDEAction* actionStartNewSession = new TDEAction( i18n("Start &New Session"),
125  0,
126  this,
127  TQ_SLOT( startNewSession() ),
128  actionCollection(),
129  "start_new_session");
130  TDEAction* actionResetAll = new TDEAction( i18n("&Reset All Times"),
131  0,
132  this,
133  TQ_SLOT( resetAllTimes() ),
134  actionCollection(),
135  "reset_all_times");
136  actionStart = new TDEAction( i18n("&Start"),
137  TQString::fromLatin1("1rightarrow"), Key_S,
138  _taskView,
139  TQ_SLOT( startCurrentTimer() ), actionCollection(),
140  "start");
141  actionStop = new TDEAction( i18n("S&top"),
142  TQString::fromLatin1("process-stop"), 0,
143  _taskView,
144  TQ_SLOT( stopCurrentTimer() ), actionCollection(),
145  "stop");
146  actionStopAll = new TDEAction( i18n("Stop &All Timers"),
147  Key_Escape,
148  _taskView,
149  TQ_SLOT( stopAllTimers() ), actionCollection(),
150  "stopAll");
151  actionStopAll->setEnabled(false);
152 
153  actionNew = new TDEAction( i18n("&New..."),
154  TQString::fromLatin1("document-new"), CTRL+Key_N,
155  _taskView,
156  TQ_SLOT( newTask() ), actionCollection(),
157  "new_task");
158  actionNewSub = new TDEAction( i18n("New &Subtask..."),
159  TQString::fromLatin1("application-vnd.tde.tdemultiple"), CTRL+ALT+Key_N,
160  _taskView,
161  TQ_SLOT( newSubTask() ), actionCollection(),
162  "new_sub_task");
163  actionDelete = new TDEAction( i18n("&Delete"),
164  TQString::fromLatin1("edit-delete"), Key_Delete,
165  _taskView,
166  TQ_SLOT( deleteTask() ), actionCollection(),
167  "delete_task");
168  actionEdit = new TDEAction( i18n("&Edit..."),
169  TQString::fromLatin1("edit"), CTRL + Key_E,
170  _taskView,
171  TQ_SLOT( editTask() ), actionCollection(),
172  "edit_task");
173 // actionAddComment = new TDEAction( i18n("&Add Comment..."),
174 // TQString::fromLatin1("text-x-generic"),
175 // CTRL+ALT+Key_E,
176 // _taskView,
177 // TQ_SLOT( addCommentToTask() ),
178 // actionCollection(),
179 // "add_comment_to_task");
180  actionMarkAsComplete = new TDEAction( i18n("&Mark as Complete"),
181  TQString::fromLatin1("text-x-generic"),
182  CTRL+Key_M,
183  _taskView,
184  TQ_SLOT( markTaskAsComplete() ),
185  actionCollection(),
186  "mark_as_complete");
187  actionMarkAsIncomplete = new TDEAction( i18n("&Mark as Incomplete"),
188  TQString::fromLatin1("text-x-generic"),
189  CTRL+Key_M,
190  _taskView,
191  TQ_SLOT( markTaskAsIncomplete() ),
192  actionCollection(),
193  "mark_as_incomplete");
194  actionClipTotals = new TDEAction( i18n("&Copy Totals to Clipboard"),
195  TQString::fromLatin1("klipper"),
196  CTRL+Key_C,
197  _taskView,
198  TQ_SLOT( clipTotals() ),
199  actionCollection(),
200  "clip_totals");
201  actionClipHistory = new TDEAction( i18n("Copy &History to Clipboard"),
202  TQString::fromLatin1("klipper"),
203  CTRL+ALT+Key_C,
204  _taskView,
205  TQ_SLOT( clipHistory() ),
206  actionCollection(),
207  "clip_history");
208 
209  new TDEAction( i18n("Import &Legacy Flat File..."), 0,
210  _taskView, TQ_SLOT(loadFromFlatFile()), actionCollection(),
211  "import_flatfile");
212  new TDEAction( i18n("&Export to CSV File..."), 0,
213  _taskView, TQ_SLOT(exportcsvFile()), actionCollection(),
214  "export_csvfile");
215  new TDEAction( i18n("Export &History to CSV File..."), 0,
216  this, TQ_SLOT(exportcsvHistory()), actionCollection(),
217  "export_csvhistory");
218  new TDEAction( i18n("Import Tasks From &Planner..."), 0,
219  _taskView, TQ_SLOT(importPlanner()), actionCollection(),
220  "import_planner");
221  new TDEAction( i18n("Configure KArm..."), 0,
222  _preferences, TQ_SLOT(showDialog()), actionCollection(),
223  "configure_karm");
224 
225 /*
226  new TDEAction( i18n("Import E&vents"), 0,
227  _taskView,
228  TQ_SLOT( loadFromKOrgEvents() ), actionCollection(),
229  "import_korg_events");
230  */
231 
232  // Tool tops must be set after the createGUI.
233  actionKeyBindings->setToolTip( i18n("Configure key bindings") );
234  actionKeyBindings->setWhatsThis( i18n("This will let you configure key"
235  "bindings which is specific to karm") );
236 
237  actionStartNewSession->setToolTip( i18n("Start a new session") );
238  actionStartNewSession->setWhatsThis( i18n("This will reset the session time "
239  "to 0 for all tasks, to start a "
240  "new session, without affecting "
241  "the totals.") );
242  actionResetAll->setToolTip( i18n("Reset all times") );
243  actionResetAll->setWhatsThis( i18n("This will reset the session and total "
244  "time to 0 for all tasks, to restart from "
245  "scratch.") );
246 
247  actionStart->setToolTip( i18n("Start timing for selected task") );
248  actionStart->setWhatsThis( i18n("This will start timing for the selected "
249  "task.\n"
250  "It is even possible to time several tasks "
251  "simultaneously.\n\n"
252  "You may also start timing of a tasks by "
253  "double clicking the left mouse "
254  "button on a given task. This will, however, "
255  "stop timing of other tasks."));
256 
257  actionStop->setToolTip( i18n("Stop timing of the selected task") );
258  actionStop->setWhatsThis( i18n("Stop timing of the selected task") );
259 
260  actionStopAll->setToolTip( i18n("Stop all of the active timers") );
261  actionStopAll->setWhatsThis( i18n("Stop all of the active timers") );
262 
263  actionNew->setToolTip( i18n("Create new top level task") );
264  actionNew->setWhatsThis( i18n("This will create a new top level task.") );
265 
266  actionDelete->setToolTip( i18n("Delete selected task") );
267  actionDelete->setWhatsThis( i18n("This will delete the selected task and "
268  "all its subtasks.") );
269 
270  actionEdit->setToolTip( i18n("Edit name or times for selected task") );
271  actionEdit->setWhatsThis( i18n("This will bring up a dialog box where you "
272  "may edit the parameters for the selected "
273  "task."));
274  //actionAddComment->setToolTip( i18n("Add a comment to a task") );
275  //actionAddComment->setWhatsThis( i18n("This will bring up a dialog box where "
276  // "you can add a comment to a task. The "
277  // "comment can for instance add information on what you "
278  // "are currently doing. The comment will "
279  // "be logged in the log file."));
280  actionClipTotals->setToolTip(i18n("Copy task totals to clipboard"));
281  actionClipHistory->setToolTip(i18n("Copy time card history to clipboard."));
282 
283  slotSelectionChanged();
284 }
285 
287 {
288  // notify your internal widget of the read-write state
289  if (rw)
290  connect(_taskView, TQ_SIGNAL(textChanged()),
291  this, TQ_SLOT(setModified()));
292  else
293  {
294  disconnect(_taskView, TQ_SIGNAL(textChanged()),
295  this, TQ_SLOT(setModified()));
296  }
297 
298  ReadWritePart::setReadWrite(rw);
299 }
300 
301 void karmPart::setModified(bool modified)
302 {
303  // get a handle on our Save action and make sure it is valid
304  TDEAction *save = actionCollection()->action(KStdAction::stdName(KStdAction::Save));
305  if (!save)
306  return;
307 
308  // if so, we either enable or disable it based on the current
309  // state
310  if (modified)
311  save->setEnabled(true);
312  else
313  save->setEnabled(false);
314 
315  // in any event, we want our parent to do it's thing
316  ReadWritePart::setModified(modified);
317 }
318 
320 {
321  // m_file is always local so we can use TQFile on it
322  _taskView->load(m_file);
323 
324  // just for fun, set the status bar
325  emit setStatusBarText( m_url.prettyURL() );
326 
327  return true;
328 }
329 
331 {
332  // if we aren't read-write, return immediately
333  if (isReadWrite() == false)
334  return false;
335 
336  // m_file is always local, so we use TQFile
337  TQFile file(m_file);
338  if (file.open(IO_WriteOnly) == false)
339  return false;
340 
341  // use TQTextStream to dump the text to the file
342  TQTextStream stream(&file);
343 
344  file.close();
345 
346  return true;
347 }
348 
349 void karmPart::fileOpen()
350 {
351  // this slot is called whenever the File->Open menu is selected,
352  // the Open shortcut is pressed (usually CTRL+O) or the Open toolbar
353  // button is clicked
354  TQString file_name = KFileDialog::getOpenFileName();
355 
356  if (file_name.isEmpty() == false)
357  openURL(file_name);
358 }
359 
360 void karmPart::fileSaveAs()
361 {
362  // this slot is called whenever the File->Save As menu is selected,
363  TQString file_name = KFileDialog::getSaveFileName();
364  if (file_name.isEmpty() == false)
365  saveAs(file_name);
366 }
367 
368 
369 // It's usually safe to leave the factory code alone.. with the
370 // notable exception of the TDEAboutData data
371 #include <tdeaboutdata.h>
372 #include <tdelocale.h>
373 
374 TDEInstance* karmPartFactory::s_instance = 0L;
375 TDEAboutData* karmPartFactory::s_about = 0L;
376 
377 karmPartFactory::karmPartFactory()
378  : KParts::Factory()
379 {
380 }
381 
382 karmPartFactory::~karmPartFactory()
383 {
384  delete s_instance;
385  delete s_about;
386 
387  s_instance = 0L;
388 }
389 
390 KParts::Part* karmPartFactory::createPartObject( TQWidget *parentWidget, const char *widgetName,
391  TQObject *parent, const char *name,
392  const char *classname, const TQStringList &args )
393 {
394  // Create an instance of our Part
395  karmPart* obj = new karmPart( parentWidget, widgetName, parent, name );
396 
397  // See if we are to be read-write or not
398  if (TQCString(classname) == "KParts::ReadOnlyPart")
399  obj->setReadWrite(false);
400 
401  return obj;
402 }
403 
404 TDEInstance* karmPartFactory::instance()
405 {
406  if( !s_instance )
407  {
408  s_about = new TDEAboutData("karmpart", I18N_NOOP("karmPart"), "0.1");
409  s_about->addAuthor("Thorsten Staerk", 0, "thorsten@staerk.de");
410  s_instance = new TDEInstance(s_about);
411  }
412  return s_instance;
413 }
414 
415 extern "C"
416 {
417  TDE_EXPORT void* init_libkarmpart()
418  {
419  TDEGlobal::locale()->insertCatalogue("karm");
420  return new karmPartFactory;
421  }
422 }
423 
424 void karmPart::contextMenuRequest( TQListViewItem*, const TQPoint& point, int )
425 {
426  TQPopupMenu* pop = dynamic_cast<TQPopupMenu*>(
427  factory()->container( i18n( "task_popup" ), this ) );
428  if ( pop )
429  pop->popup( point );
430 }
431 
432 //----------------------------------------------------------------------------
433 //
434 // D C O P I N T E R F A C E
435 //
436 //----------------------------------------------------------------------------
437 
438 TQString karmPart::version() const
439 {
440  return KARM_VERSION;
441 }
442 
444 {
445  _taskView->deleteTask();
446  return "";
447 }
448 
450 {
451  return _preferences->promptDelete();
452 }
453 
454 TQString karmPart::setpromptdelete( bool prompt )
455 {
456  _preferences->setPromptDelete( prompt );
457  return "";
458 }
459 
460 TQString karmPart::taskIdFromName( const TQString &taskname ) const
461 {
462  TQString rval = "";
463 
464  Task* task = _taskView->first_child();
465  while ( rval.isEmpty() && task )
466  {
467  rval = _hasTask( task, taskname );
468  task = task->nextSibling();
469  }
470 
471  return rval;
472 }
473 
475 {
476  // TODO: write something for kapp->quit();
477 }
478 
480 {
481  kdDebug(5970) << "Saving time data to disk." << endl;
482  TQString err=_taskView->save(); // untranslated error msg.
483  // TODO:
484  /* if (err.isEmpty()) statusBar()->message(i18n("Successfully saved tasks and history"),1807);
485  else statusBar()->message(i18n(err.ascii()),7707); // no msgbox since save is called when exiting */
486  return true;
487 }
488 
489 int karmPart::addTask( const TQString& taskname )
490 {
491  DesktopList desktopList;
492  TQString uid = _taskView->addTask( taskname, 0, 0, desktopList );
493  kdDebug(5970) << "MainWindow::addTask( " << taskname << " ) returns " << uid << endl;
494  if ( uid.length() > 0 ) return 0;
495  else
496  {
497  // We can't really tell what happened, b/c the resource framework only
498  // returns a boolean.
499  return KARM_ERR_GENERIC_SAVE_FAILED;
500  }
501 }
502 
503 TQString karmPart::setPerCentComplete( const TQString& taskName, int perCent )
504 {
505  int index = 0;
506  TQString err="no such task";
507  for (int i=0; i<_taskView->count(); i++)
508  {
509  if ((_taskView->item_at_index(i)->name()==taskName))
510  {
511  index=i;
512  if (err==TQString()) err="task name is abigious";
513  if (err=="no such task") err=TQString();
514  }
515  }
516  if (err==TQString())
517  {
518  _taskView->item_at_index(index)->setPercentComplete( perCent, _taskView->storage() );
519  }
520  return err;
521 }
522 
524 ( const TQString& taskId, const TQString& datetime, long minutes )
525 {
526  int rval = 0;
527  TQDate startDate;
528  TQTime startTime;
529  TQDateTime startDateTime;
530  Task *task, *t;
531 
532  if ( minutes <= 0 ) rval = KARM_ERR_INVALID_DURATION;
533 
534  // Find task
535  task = _taskView->first_child();
536  t = NULL;
537  while ( !t && task )
538  {
539  t = _hasUid( task, taskId );
540  task = task->nextSibling();
541  }
542  if ( t == NULL ) rval = KARM_ERR_UID_NOT_FOUND;
543 
544  // Parse datetime
545  if ( !rval )
546  {
547  startDate = TQDate::fromString( datetime, TQt::ISODate );
548  if ( datetime.length() > 10 ) // "YYYY-MM-DD".length() = 10
549  {
550  startTime = TQTime::fromString( datetime, TQt::ISODate );
551  }
552  else startTime = TQTime( 12, 0 );
553  if ( startDate.isValid() && startTime.isValid() )
554  {
555  startDateTime = TQDateTime( startDate, startTime );
556  }
557  else rval = KARM_ERR_INVALID_DATE;
558 
559  }
560 
561  // Update task totals (session and total) and save to disk
562  if ( !rval )
563  {
564  t->changeTotalTimes( t->sessionTime() + minutes, t->totalTime() + minutes );
565  if ( ! _taskView->storage()->bookTime( t, startDateTime, minutes * 60 ) )
566  {
567  rval = KARM_ERR_GENERIC_SAVE_FAILED;
568  }
569  }
570 
571  return rval;
572 }
573 
574 // There was something really bad going on with DCOP when I used a particular
575 // argument name; if I recall correctly, the argument name was errno.
576 TQString karmPart::getError( int mkb ) const
577 {
578  if ( mkb <= KARM_MAX_ERROR_NO ) return m_error[ mkb ];
579  else return i18n( "Invalid error number: %1" ).arg( mkb );
580 }
581 
582 int karmPart::totalMinutesForTaskId( const TQString& taskId )
583 {
584  int rval = 0;
585  Task *task, *t;
586 
587  kdDebug(5970) << "MainWindow::totalTimeForTask( " << taskId << " )" << endl;
588 
589  // Find task
590  task = _taskView->first_child();
591  t = NULL;
592  while ( !t && task )
593  {
594  t = _hasUid( task, taskId );
595  task = task->nextSibling();
596  }
597  if ( t != NULL )
598  {
599  rval = t->totalTime();
600  kdDebug(5970) << "MainWindow::totalTimeForTask - task found: rval = " << rval << endl;
601  }
602  else
603  {
604  kdDebug(5970) << "MainWindow::totalTimeForTask - task not found" << endl;
605  rval = KARM_ERR_UID_NOT_FOUND;
606  }
607 
608  return rval;
609 }
610 
611 TQString karmPart::_hasTask( Task* task, const TQString &taskname ) const
612 {
613  TQString rval = "";
614  if ( task->name() == taskname )
615  {
616  rval = task->uid();
617  }
618  else
619  {
620  Task* nexttask = task->firstChild();
621  while ( rval.isEmpty() && nexttask )
622  {
623  rval = _hasTask( nexttask, taskname );
624  nexttask = nexttask->nextSibling();
625  }
626  }
627  return rval;
628 }
629 
630 Task* karmPart::_hasUid( Task* task, const TQString &uid ) const
631 {
632  Task *rval = NULL;
633 
634  //kdDebug(5970) << "MainWindow::_hasUid( " << task << ", " << uid << " )" << endl;
635 
636  if ( task->uid() == uid ) rval = task;
637  else
638  {
639  Task* nexttask = task->firstChild();
640  while ( !rval && nexttask )
641  {
642  rval = _hasUid( nexttask, uid );
643  nexttask = nexttask->nextSibling();
644  }
645  }
646  return rval;
647 }
648 
649 TQString karmPart::starttimerfor( const TQString& taskname )
650 {
651  TQString err="no such task";
652  for (int i=0; i<_taskView->count(); i++)
653  {
654  if ((_taskView->item_at_index(i)->name()==taskname))
655  {
656  _taskView->startTimerFor( _taskView->item_at_index(i) );
657  err="";
658  }
659  }
660  return err;
661 }
662 
663 TQString karmPart::stoptimerfor( const TQString& taskname )
664 {
665  TQString err="no such task";
666  for (int i=0; i<_taskView->count(); i++)
667  {
668  if ((_taskView->item_at_index(i)->name()==taskname))
669  {
670  _taskView->stopTimerFor( _taskView->item_at_index(i) );
671  err="";
672  }
673  }
674  return err;
675 }
676 
677 TQString karmPart::exportcsvfile( TQString filename, TQString from, TQString to, int type, bool decimalMinutes, bool allTasks, TQString delimiter, TQString quote )
678 {
679  ReportCriteria rc;
680  rc.allTasks=allTasks;
681  rc.decimalMinutes=decimalMinutes;
682  rc.delimiter=delimiter;
683  rc.from=TQDate::fromString( from );
684  rc.quote=quote;
686  rc.to=TQDate::fromString( to );
687  rc.url=filename;
688  return _taskView->report( rc );
689 }
690 
691 TQString karmPart::importplannerfile( TQString fileName )
692 {
693  return _taskView->importPlanner(fileName);
694 }
695 
696 void karmPart::startNewSession()
697 {
698  _taskView->startNewSession();
699  _taskView->save();
700 }
701 
702 #include <tqpopupmenu.h>
703 #include "karm_part.moc"
Stores entries from export dialog.
virtual void setModified(bool modified)
Reimplemented to disable and enable Save action.
Definition: karm_part.cpp:301
long count()
Return the total number if items in the view.
Definition: taskview.cpp:379
void changeTotalTimes(long minutesSession, long minutes)
adds minutes to total and session time
Definition: task.cpp:224
void setPercentComplete(const int percent, KarmStorage *storage)
Update percent complete for this task.
Definition: task.cpp:149
TQDate from
For history reports, the lower bound of the date range to report on.
TQString taskIdFromName(const TQString &taskName) const
Return id of task found, empty string if no match.
Definition: karm_part.cpp:460
bool decimalMinutes
True if the durations should be output in decimal hours.
bool isComplete()
Return true if task is complete (percent complete equals 100).
Definition: task.cpp:194
TQString setpromptdelete(bool prompt)
set if prompted on deleting a task
Definition: karm_part.cpp:454
void load(TQString filename="")
Load the view from storage.
Definition: taskview.cpp:187
bool isRunning() const
return the state of a task - if it's running or not
Definition: task.cpp:132
void quit()
Graceful shutdown.
Definition: karm_part.cpp:474
void startNewSession()
Reset session time to zero for all tasks.
Definition: taskview.cpp:444
Task * current_item() const
Return the current item in the view, cast to a Task pointer.
Definition: taskview.cpp:177
bool allTasks
True if the report should contain all tasks in Karm.
Easy updating of menu accels when changing a TDEAccel object.
void startTimerFor(Task *task, TQDateTime startTime=TQDateTime::currentDateTime())
starts timer for task.
Definition: taskview.cpp:386
TQString deletetodo()
delete the current item
Definition: karm_part.cpp:443
REPORTTYPE reportType
The type of report we are running.
virtual bool openFile()
This must be implemented by each part.
Definition: karm_part.cpp:319
int bookTime(const TQString &taskId, const TQString &iso8601StartDateTime, long durationInMinutes)
Definition: karm_part.cpp:524
TQString name() const
returns the name of this task.
Definition: task.h:162
void deleteTask(bool markingascomplete=false)
Delete task (and children) from view.
Definition: taskview.cpp:640
bool getpromptdelete()
get if prompted on deleting a task
Definition: karm_part.cpp:449
Container and interface for the tasks.
Definition: taskview.h:42
virtual bool save()
save your tasks
Definition: karm_part.cpp:479
TQString stoptimerfor(const TQString &taskname)
Stop timer for all tasks with the summary taskname.
Definition: karm_part.cpp:663
A class representing a task.
Definition: task.h:41
Task * firstChild() const
return parent Task or null in case of TaskView.
Definition: task.h:60
TQString save()
Save to persistent storage.
Definition: taskview.cpp:365
Task * item_at_index(int i)
Return the i'th item (zero-based), cast to a Task pointer.
Definition: taskview.cpp:182
TQString delimiter
The delimiter to use when outputting comma-seperated value reports.
TQString setPerCentComplete(const TQString &taskName, int PerCent)
Definition: karm_part.cpp:503
TQString importplannerfile(TQString filename)
import planner project file
Definition: karm_part.cpp:691
This is a "Part".
Definition: karm_part.h:30
int addTask(const TQString &taskName)
Definition: karm_part.cpp:489
int totalMinutesForTaskId(const TQString &taskId)
Total time currently associated with a task.
Definition: karm_part.cpp:582
TQString getError(int karmErrorNumber) const
Definition: karm_part.cpp:576
TQString starttimerfor(const TQString &taskname)
Start timer for all tasks with the summary taskname.
Definition: karm_part.cpp:649
TQString uid() const
Return unique iCalendar Todo ID for this task.
Definition: task.h:70
TQString quote
The quote to use for text fields when outputting comma-seperated reports.
TQString exportcsvfile(TQString filename, TQString from, TQString to, int type=0, bool decimalMinutes=true, bool allTasks=true, TQString delimiter="r", TQString quote="q")
export csv history or totals file
Definition: karm_part.cpp:677
virtual bool saveFile()
This must be implemented by each read-write part.
Definition: karm_part.cpp:330
TQString version() const
Return karm version.
Definition: karm_part.cpp:438
TQDate to
For history reports, the upper bound of the date range to report on.
KarmStorage * storage()
Returns a pointer to storage object.
Definition: taskview.cpp:114
TQString report(const ReportCriteria &rc)
call export function for csv totals or history
Definition: taskview.cpp:322
TQString importPlanner(TQString fileName="")
used to import tasks from imendio planner
Definition: taskview.cpp:308
Task * first_child() const
Return the first item in the view, cast to a Task pointer.
Definition: taskview.cpp:172
TQString addTask(const TQString &taskame, long total, long session, const DesktopList &desktops, Task *parent=0)
Add a task to view and storage.
Definition: taskview.cpp:529
KURL url
For reports that write to a file, the filename to write to.
virtual void setReadWrite(bool rw)
This is a virtual function inherited from KParts::ReadWritePart.
Definition: karm_part.cpp:286
REPORTTYPE
The different report types.