taskview.h
00001 #ifndef KARM_TASK_VIEW_H 00002 #define KARM_TASK_VIEW_H 00003 00004 #include <qdict.h> 00005 #include <qptrlist.h> 00006 #include <qptrstack.h> 00007 00008 #include <klistview.h> 00009 00010 #include "desktoplist.h" 00011 #include "karmstorage.h" 00012 #include <qtimer.h> 00013 //#include "desktoptracker.h" 00014 00015 //#include "karmutility.h" 00016 00017 class QListBox; 00018 class QTextStream; 00019 class QTimer; 00020 00021 class KMenuBar; 00022 class KToolBar; 00023 00024 class DesktopTracker; 00025 class EditTaskDialog; 00026 class IdleTimeDetector; 00027 class Preferences; 00028 class Task; 00029 class KarmStorage; 00030 class HistoryEvent; 00031 00036 class TaskView : public KListView 00037 { 00038 Q_OBJECT 00039 00040 public: 00041 TaskView( QWidget *parent = 0, const char *name = 0 ); 00042 virtual ~TaskView(); 00043 00045 Task* first_child() const; 00046 00048 Task* current_item() const; 00049 00051 Task* item_at_index(int i); 00052 00054 void load(); 00055 00057 void closeStorage(); 00058 00060 void startNewSession(); 00061 00063 void resetTimeForAllTasks(); 00064 00066 long count(); 00067 00069 QValueList<HistoryEvent> getHistory(const QDate& from, const QDate& to) 00070 const; 00071 00073 void scheduleSave(); 00074 00076 Preferences *preferences(); 00077 00079 bool isReadOnly() const { return _storage->isReadOnly(); } 00080 00081 public slots: 00083 void save(); 00084 00086 void startCurrentTimer(); 00087 00089 void stopCurrentTimer(); 00090 00092 void stopAllTimers(); 00093 00095 void changeTimer( QListViewItem * = 0 ); 00096 00098 void newTask(); 00099 00101 void newTask( QString caption, Task* parent ); 00102 00104 void loadFromFlatFile(); 00105 00107 void exportcsvFile(); 00108 00110 void exportcsvHistory(); 00111 00113 void newSubTask(); 00114 00115 void editTask(); 00116 00125 void deleteTask(bool markingascomplete=false); 00126 // void addCommentToTask(); 00127 void markTaskAsComplete(); 00128 00130 void extractTime( int minutes ); 00131 void taskTotalTimesChanged( long session, long total) 00132 { emit totalTimesChanged( session, total); }; 00133 void adaptColumns(); 00135 void deletingTask(Task* deletedTask); 00136 void startTimerFor( Task* task ); 00137 void stopTimerFor( Task* task ); 00138 00140 void iCalFileChanged(QString file); 00141 00143 void clipTotals(); 00144 00146 void clipHistory(); 00147 00148 signals: 00149 void totalTimesChanged( long session, long total ); 00150 void updateButtons(); 00151 void timersActive(); 00152 void timersInactive(); 00153 void tasksChanged( QPtrList<Task> activeTasks ); 00154 00155 private: // member variables 00156 IdleTimeDetector *_idleTimeDetector; 00157 QTimer *_minuteTimer; 00158 QTimer *_autoSaveTimer; 00159 QTimer *_manualSaveTimer; 00160 Preferences *_preferences; 00161 QPtrList<Task> activeTasks; 00162 int previousColumnWidths[4]; 00163 DesktopTracker* _desktopTracker; 00164 bool _isloading; 00165 00166 //KCal::CalendarLocal _calendar; 00167 KarmStorage * _storage; 00168 00169 private: 00170 void updateParents( Task* task, long totalDiff, long sesssionDiff); 00171 void deleteChildTasks( Task *item ); 00172 void addTimeToActiveTasks( int minutes, bool save_data = true ); 00173 void restoreItemState( QListViewItem *item ); 00174 00175 protected slots: 00176 void autoSaveChanged( bool ); 00177 void autoSavePeriodChanged( int period ); 00178 void minuteUpdate(); 00179 void itemStateChanged( QListViewItem *item ); 00180 void deleteItemState( QListViewItem *item ); 00181 }; 00182 00183 #endif // KARM_TASK_VIEW