1 /***************************************************************************
2 * Copyright (C) 2007 by Arrigo Zanette *
4 ***************************************************************************/
31 class Sak
: public QObject
35 Sak(QObject
* parent
= 0);
37 QHash
<QString
, Task
>* tasks() { return &m_tasks
; }
39 void timerEvent(QTimerEvent
* e
);
40 bool eventFilter(QObject
* obj
, QEvent
* e
);
41 bool taskTreeEventFilter(QEvent
* e
);
42 bool hitsListEventFilter(QEvent
* e
);
48 Task
loadTaskFromFile(const QString
& filePath
, bool tryRecover
=true);
49 // recover from error using backup file for given file taskXmlFile
50 Task
recoverTaskFromBackup(QFile
& taskXmlFile
, const QString
& error
);
53 void open(const QStringList
& filePaths
= QStringList());
58 void importFromGmail();
59 void selectTodayDate();
60 void selectThisWeeDate();
61 void selectThisMonthDate();
62 void selectLastWeekDate();
63 void selectLastMonthDate();
68 void addDefaultTask();
71 // commit changes on current tasks for temporary previews
72 void commitCurrentTask();
73 // permanentely save changes on tasks
74 void saveTaskChanges();
75 // permanentely save changes on hits
76 void saveHitChanges();
78 void doubleClickedTask(QTreeWidgetItem
* i
, int column
);
80 void grabKeyboard(); // delayed grab of keayboard
81 // popup task selection
83 // popup subtask selection
84 void popupSubtasks(const QString
& taskname
);
85 // save current selected hit (after popup)
86 void workingOnTask(const QString
& taskname
, const QString
& subtask
);
87 void focusedSubTask();
89 void trayIconActivated(QSystemTrayIcon::ActivationReason
);
90 // create a list of hits merging tasks
91 QList
<HitElement
> createHitsList(const QDateTime
& from
= QDateTime(), const QDateTime
& to
= QDateTime());
92 QMap
<double, QPair
<Task
*, QString
> > createSummaryList(const QList
<HitElement
>& hits
);
93 void selectedStartDate(const QDate
& date
);
94 void selectedEndDate(const QDate
& date
);
95 void hitsListItemChanged(QTreeWidgetItem
*, int column
);
96 void hitsSelectedInList(QTreeWidgetItem
*, QTreeWidgetItem
*);
97 void hitsSelectedInTimeline(HitItem
*);
98 void populateHitsList(const QList
<HitElement
>&, QTreeWidget
* t
= 0);
99 void populateHitsTimeline(const QList
<HitElement
>&, Timeline
* t
= 0);
100 void addDefaultHit();
101 void interactiveMergeHits();
103 int m_timerId
, m_timeoutPopup
, m_autoSaveTimer
, m_getFocusTimer
;
105 QDateTime m_nextTimerEvent
;
106 QMainWindow
* m_settings
;
107 QHash
<QString
, Task
> m_tasks
;
108 QHash
<QString
, Task
> m_editedTasks
;
109 QMultiMap
<int, SakWidget
*> m_widgets
;
110 QMultiMap
<int, SakSubWidget
*> m_subwidgets
;
111 class QGraphicsEllipseItem
* m_marker
;
112 QMap
<int, SakWidget
*>::iterator m_widgetsIterator
;
113 QMap
<int, SakSubWidget
*>::iterator m_subwidgetsIterator
;
115 QList
<QString
> m_taskSelectionHistory
;
116 QHash
< QString
, QList
< QString
> > m_subtaskSelectionHistory
;
117 QCompleter
* m_subtaskCompleter
;
118 int m_currentInterval
;
121 double workingOnDeclared
;
123 bool m_changedHit
, m_changedTask
;
125 static int taskCounter
;
129 QAction
* m_addTaskAction
;
130 QMenu
* m_addTaskMenu
;
133 QAction
* m_addHitAction
;
134 QAction
* m_exportDataAction
;
135 QString currentTask
, currentSubtask
;
137 class Backupper
* m_backupper
;
138 class Incremental
* m_incremental
;
139 class GmailPyInterface
* m_gmail
;
141 //BEGIN Settings data:
143 void setVisible(bool visible
);
145 QRect
Layouting( const QList
<SakWidget
*>& sortedWidgets
);
146 void layoutSubTasks( const QMap
<int, SakSubWidget
*> sortedWidgets
, int currentRank
);
148 QTreeWidget
* newHitsList();
149 QTreeWidget
* newTaskSummaryList();
150 void setupSettingsWidget();
151 void createActions();
153 void scrollTasks(int npos
);
154 void scrollSubTasks(int npos
);
161 QPushButton
* previewButton
;
162 QPushButton
* bgColorButton
;
163 QPushButton
* fgColorButton
;
165 QLabel
*durationLabel
, *durationLabel1
;
166 QLabel
*durationWarningLabel
;
168 QSpinBox
*durationSpinBox
;
170 PixmapViewer
* askingLady
;
171 PixmapViewer
* viewBackground
;
174 QTreeWidget
* tasksTree
;
175 QComboBox
* taskSelector
;
176 QTreeWidget
* hitsList
, *summaryList
;
177 Timeline
* hitsTimeline
;
178 QCalendarWidget
* cal1
, *cal2
, *cal3
, *cal4
;
179 QPushButton
* today1
, *thisWeek1
, *thisMonth1
, *lastWeek1
, *lastMonth1
;
180 QPushButton
* today2
, *thisWeek2
, *thisMonth2
, *lastWeek2
, *lastMonth2
;
181 PixmapViewer
* taskPixmapViewer
;
182 QTextEdit
* taskTextEditor
;
183 QLineEdit
* taskTitleEditor
;
184 QLineEdit
* taskTagsEditor
;
185 QLineEdit
* taskUrlEditor
;
186 QSpinBox
* estimatedHoursEditor
;
187 QDateEdit
* dueEditor
;
188 QGraphicsView
* summaryView
;
189 class TaskSummaryPieChart
* summaryChart
;
191 QAction
*minimizeAction
;
192 QAction
*maximizeAction
;
193 QAction
*restoreAction
;
194 QAction
*startAction
;
196 QAction
*workingOnAction
;
197 QAction
*flushAction
;
199 QAction
*saveAsDbAction
;
201 QAction
*exportDbCsvAction
;
202 QAction
*gmailLoginAction
;
203 QAction
*saveToGmailAction
;
204 QAction
*sendByEmailAction
;
206 QSystemTrayIcon
*trayIcon
;
209 QTimer
*workingOnTimer
;
211 /*! Avoids recursion and crash when updating hitList as a result of updating timeline */
212 bool m_updatingFromTimeline
;
215 class MyDateItemDelegate
: public QItemDelegate
218 MyDateItemDelegate(QObject
*parent
= 0);
220 QWidget
*createEditor(QWidget
*parent
, const QStyleOptionViewItem
&option
,
221 const QModelIndex
&index
) const;
223 void setEditorData(QWidget
*editor
, const QModelIndex
&index
) const;
224 void setModelData(QWidget
*editor
, QAbstractItemModel
*model
,
225 const QModelIndex
&index
) const;
227 void updateEditorGeometry(QWidget
*editor
,
228 const QStyleOptionViewItem
&option
, const QModelIndex
&index
) const;
231 class TaskItemDelegate
: public QItemDelegate
234 TaskItemDelegate(Sak
* sak
, QObject
*parent
= 0);
236 QWidget
*createEditor(QWidget
*parent
, const QStyleOptionViewItem
&option
,
237 const QModelIndex
&index
) const;
239 void setEditorData(QWidget
*editor
, const QModelIndex
&index
) const;
240 void setModelData(QWidget
*editor
, QAbstractItemModel
*model
,
241 const QModelIndex
&index
) const;
243 void updateEditorGeometry(QWidget
*editor
,
244 const QStyleOptionViewItem
&option
, const QModelIndex
&index
) const;
250 class SubTaskItemDelegate
: public QItemDelegate
253 SubTaskItemDelegate(Sak
* sak
, QObject
*parent
= 0);
255 QWidget
*createEditor(QWidget
*parent
, const QStyleOptionViewItem
&option
,
256 const QModelIndex
&index
) const;
258 void setEditorData(QWidget
*editor
, const QModelIndex
&index
) const;
259 void setModelData(QWidget
*editor
, QAbstractItemModel
*model
,
260 const QModelIndex
&index
) const;
262 void updateEditorGeometry(QWidget
*editor
,
263 const QStyleOptionViewItem
&option
, const QModelIndex
&index
) const;