00001 #ifndef KARM_TASK_VIEW_H
00002 #define KARM_TASK_VIEW_H
00003
00004 #include <tqdict.h>
00005 #include <tqptrlist.h>
00006 #include <tqptrstack.h>
00007
00008 #include <klistview.h>
00009
00010 #include "desktoplist.h"
00011 #include "resourcecalendar.h"
00012 #include "karmstorage.h"
00013 #include "mainwindow.h"
00014 #include "reportcriteria.h"
00015 #include <tqtimer.h>
00016
00017
00018
00019
00020 class TQListBox;
00021 class TQString;
00022 class TQTextStream;
00023 class TQTimer;
00024
00025 class KMenuBar;
00026 class KToolBar;
00027
00028 class DesktopTracker;
00029 class EditTaskDialog;
00030 class IdleTimeDetector;
00031 class Preferences;
00032 class Task;
00033 class KarmStorage;
00034 class HistoryEvent;
00035
00036 using namespace KCal;
00037
00042 class TaskView : public KListView
00043 {
00044 Q_OBJECT
00045 TQ_OBJECT
00046
00047 public:
00048 TaskView( TQWidget *parent = 0, const char *name = 0, const TQString &icsfile = "" );
00049 virtual ~TaskView();
00050
00052 Task* first_child() const;
00053
00055 Task* current_item() const;
00056
00058 Task* item_at_index(int i);
00059
00061 void load( TQString filename="" );
00062
00064 void closeStorage();
00065
00067 void startNewSession();
00068
00070 void resetTimeForAllTasks();
00071
00073 long count();
00074
00076 TQValueList<HistoryEvent> getHistory(const TQDate& from, const TQDate& to) const;
00077
00079 void scheduleSave();
00080
00082 Preferences *preferences();
00083
00085 TQString addTask( const TQString& taskame, long total, long session, const DesktopList& desktops,
00086 Task* parent = 0 );
00087
00088 public slots:
00090 TQString save();
00091
00093 void startCurrentTimer();
00094
00096 void stopCurrentTimer();
00097
00099 void stopAllTimers();
00100
00102 void stopAllTimersAt(TQDateTime qdt);
00103
00105 void newTask();
00106
00108 void newTask( TQString caption, Task* parent );
00109
00111 void refresh();
00112
00114 void loadFromFlatFile();
00115
00117 TQString importPlanner( TQString fileName="" );
00118
00120 TQString report( const ReportCriteria &rc );
00121
00123 void exportcsvFile();
00124
00126 TQString exportcsvHistory();
00127
00129 void newSubTask();
00130
00131 void editTask();
00132
00142 KarmStorage* storage();
00143
00152 void deleteTask(bool markingascomplete=false);
00153
00156 void reinstateTask(int completion);
00157
00158 void markTaskAsComplete();
00159 void markTaskAsIncomplete();
00160
00165 void extractTime( int minutes );
00166 void taskTotalTimesChanged( long session, long total)
00167 { emit totalTimesChanged( session, total); };
00168 void adaptColumns();
00170 void deletingTask(Task* deletedTask);
00171
00176 void startTimerFor( Task* task, TQDateTime startTime = TQDateTime::currentDateTime() );
00177 void stopTimerFor( Task* task );
00178
00182 void clearActiveTasks();
00183
00187 void iCalFileChanged(TQString file);
00188
00190 void clipTotals();
00191
00193 void clipSession();
00194
00196 void clipHistory();
00197
00198 signals:
00199 void totalTimesChanged( long session, long total );
00200 void updateButtons();
00201 void timersActive();
00202 void timersInactive();
00203 void tasksChanged( TQPtrList<Task> activeTasks );
00204 void setStatusBar( TQString );
00205
00206 private:
00207 IdleTimeDetector *_idleTimeDetector;
00208 TQTimer *_minuteTimer;
00209 TQTimer *_autoSaveTimer;
00210 TQTimer *_manualSaveTimer;
00211 Preferences *_preferences;
00212 TQPtrList<Task> activeTasks;
00213 int previousColumnWidths[4];
00214 DesktopTracker* _desktopTracker;
00215 bool _isloading;
00216
00217
00218 KarmStorage * _storage;
00219
00220 private:
00221 void contentsMousePressEvent ( TQMouseEvent * e );
00222 void contentsMouseDoubleClickEvent ( TQMouseEvent * e );
00223 void updateParents( Task* task, long totalDiff, long sesssionDiff);
00224 void deleteChildTasks( Task *item );
00225 void addTimeToActiveTasks( int minutes, bool save_data = true );
00227 void restoreItemState( TQListViewItem *item );
00228
00229 protected slots:
00230 void autoSaveChanged( bool );
00231 void autoSavePeriodChanged( int period );
00232 void minuteUpdate();
00234 void itemStateChanged( TQListViewItem *item );
00236 void iCalFileModified(ResourceCalendar *);
00237 };
00238
00239 #endif // KARM_TASK_VIEW