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
);
47 Task
loadTaskFromFile(const QString
& filePath
);
50 void open(const QStringList
& filePaths
= QStringList());
55 void importFromGmail();
60 void addDefaultTask();
63 // commit changes on current tasks for temporary previews
64 void commitCurrentTask();
65 // permanentely save changes on tasks
66 void saveTaskChanges();
67 // permanentely save changes on hits
68 void saveHitChanges();
70 void doubleClickedTask(QTreeWidgetItem
* i
, int column
);
72 void grabKeyboard(); // delayed grab of keayboard
73 // popup task selection
75 // popup subtask selection
76 void popupSubtasks(const QString
& taskname
);
77 // save current selected hit (after popup)
78 void workingOnTask(const QString
& taskname
, const QString
& subtask
);
79 void focusedSubTask();
81 void trayIconActivated(QSystemTrayIcon::ActivationReason
);
82 // create a list of hits merging tasks
83 QList
<HitElement
> createHitsList(const QDateTime
& from
= QDateTime(), const QDateTime
& to
= QDateTime());
84 QMap
<double, QPair
<Task
*, QString
> > createSummaryList(const QList
<HitElement
>& hits
);
85 void selectedStartDate(const QDate
& date
);
86 void selectedEndDate(const QDate
& date
);
87 void hitsListItemChanged(QTreeWidgetItem
*, int column
);
88 void hitsSelectedInList(QTreeWidgetItem
*, QTreeWidgetItem
*);
89 void hitsSelectedInTimeline(HitItem
*);
90 void populateHitsList(const QList
<HitElement
>&, QTreeWidget
* t
= 0);
91 void populateHitsTimeline(const QList
<HitElement
>&, Timeline
* t
= 0);
93 void interactiveMergeHits();
95 int m_timerId
, m_timeoutPopup
, m_autoSaveTimer
, m_getFocusTimer
;
97 QDateTime m_nextTimerEvent
;
98 QMainWindow
* m_settings
;
99 QHash
<QString
, Task
> m_tasks
;
100 QHash
<QString
, Task
> m_editedTasks
;
101 QMultiMap
<int, SakWidget
*> m_widgets
;
102 QMultiMap
<int, SakSubWidget
*> m_subwidgets
;
103 class QGraphicsEllipseItem
* m_marker
;
104 QMap
<int, SakWidget
*>::iterator m_widgetsIterator
;
105 QMap
<int, SakSubWidget
*>::iterator m_subwidgetsIterator
;
107 QList
<QString
> m_taskSelectionHistory
;
108 QHash
< QString
, QList
< QString
> > m_subtaskSelectionHistory
;
109 QCompleter
* m_subtaskCompleter
;
110 int m_currentInterval
;
114 bool m_changedHit
, m_changedTask
;
116 static int taskCounter
;
118 QAction
* m_addTaskAction
;
119 QMenu
* m_addTaskMenu
;
122 QAction
* m_addHitAction
;
123 QAction
* m_exportDataAction
;
124 QString currentTask
, currentSubtask
;
126 class Backupper
* m_backupper
;
127 class Incremental
* m_incremental
;
128 class GmailPyInterface
* m_gmail
;
130 //BEGIN Settings data:
132 void setVisible(bool visible
);
134 QRect
Layouting( const QList
<SakWidget
*>& sortedWidgets
);
135 void layoutSubTasks( const QMap
<int, SakSubWidget
*> sortedWidgets
, int currentRank
);
137 QTreeWidget
* newHitsList();
138 QTreeWidget
* newTaskSummaryList();
139 void setupSettingsWidget();
140 void createActions();
142 void scrollTasks(int npos
);
143 void scrollSubTasks(int npos
);
150 QPushButton
* previewButton
;
151 QPushButton
* bgColorButton
;
152 QPushButton
* fgColorButton
;
154 QLabel
*durationLabel
, *durationLabel1
;
155 QLabel
*durationWarningLabel
;
157 QSpinBox
*durationSpinBox
;
159 PixmapViewer
* askingLady
;
160 PixmapViewer
* viewBackground
;
163 QTreeWidget
* tasksTree
;
164 QComboBox
* taskSelector
;
165 QTreeWidget
* hitsList
, *summaryList
;
166 Timeline
* hitsTimeline
;
167 QCalendarWidget
* cal1
, *cal2
, *cal3
, *cal4
;
168 PixmapViewer
* taskPixmapViewer
;
169 QTextEdit
* taskTextEditor
;
170 QLineEdit
* taskTitleEditor
;
171 QLineEdit
* taskTagsEditor
;
172 QSpinBox
* estimatedHoursEditor
;
173 QDateEdit
* dueEditor
;
174 QGraphicsView
* summaryView
;
175 class TaskSummaryPieChart
* summaryChart
;
177 QAction
*minimizeAction
;
178 QAction
*maximizeAction
;
179 QAction
*restoreAction
;
180 QAction
*startAction
;
182 QAction
*flushAction
;
184 QAction
*saveAsDbAction
;
186 QAction
*exportDbCsvAction
;
187 QAction
*gmailLoginAction
;
188 QAction
*saveToGmailAction
;
189 QAction
*sendByEmailAction
;
191 QSystemTrayIcon
*trayIcon
;
196 class MyDateItemDelegate
: public QItemDelegate
199 MyDateItemDelegate(QObject
*parent
= 0);
201 QWidget
*createEditor(QWidget
*parent
, const QStyleOptionViewItem
&option
,
202 const QModelIndex
&index
) const;
204 void setEditorData(QWidget
*editor
, const QModelIndex
&index
) const;
205 void setModelData(QWidget
*editor
, QAbstractItemModel
*model
,
206 const QModelIndex
&index
) const;
208 void updateEditorGeometry(QWidget
*editor
,
209 const QStyleOptionViewItem
&option
, const QModelIndex
&index
) const;
212 class TaskItemDelegate
: public QItemDelegate
215 TaskItemDelegate(Sak
* sak
, QObject
*parent
= 0);
217 QWidget
*createEditor(QWidget
*parent
, const QStyleOptionViewItem
&option
,
218 const QModelIndex
&index
) const;
220 void setEditorData(QWidget
*editor
, const QModelIndex
&index
) const;
221 void setModelData(QWidget
*editor
, QAbstractItemModel
*model
,
222 const QModelIndex
&index
) const;
224 void updateEditorGeometry(QWidget
*editor
,
225 const QStyleOptionViewItem
&option
, const QModelIndex
&index
) const;
231 class SubTaskItemDelegate
: public QItemDelegate
234 SubTaskItemDelegate(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;