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
);
46 Task
loadTaskFromFile(const QString
& filePath
);
48 void open(const QStringList
& filePaths
= QStringList());
53 void importFromGmail();
58 void addDefaultTask();
61 // commit changes on current tasks for temporary previews
62 void commitCurrentTask();
63 // permanentely save changes on tasks
64 void saveTaskChanges();
65 // permanentely save changes on hits
66 void saveHitChanges();
68 void doubleClickedTask(QTreeWidgetItem
* i
, int column
);
70 void grabKeyboard(); // delayed grab of keayboard
71 // popup task selection
73 // popup subtask selection
74 void popupSubtasks(const QString
& taskname
);
75 // save current selected hit (after popup)
76 void workingOnTask(const QString
& taskname
, const QString
& subtask
);
77 void focusedSubTask();
79 void trayIconActivated(QSystemTrayIcon::ActivationReason
);
80 // create a list of hits merging tasks
81 QList
<HitElement
> createHitsList(const QDateTime
& from
= QDateTime(), const QDateTime
& to
= QDateTime());
82 QMap
<double, QPair
<Task
*, QString
> > createSummaryList(const QList
<HitElement
>& hits
);
83 void selectedStartDate(const QDate
& date
);
84 void selectedEndDate(const QDate
& date
);
85 void hitsListItemChanged(QTreeWidgetItem
*, int column
);
86 void hitsSelectedInList(QTreeWidgetItem
*, QTreeWidgetItem
*);
87 void hitsSelectedInTimeline(HitItem
*);
88 void populateHitsList(const QList
<HitElement
>&, QTreeWidget
* t
= 0);
89 void populateHitsTimeline(const QList
<HitElement
>&, Timeline
* t
= 0);
91 void interactiveMergeHits();
93 int m_timerId
, m_timeoutPopup
, m_autoSaveTimer
;
94 QDateTime m_nextTimerEvent
;
95 QMainWindow
* m_settings
;
96 QHash
<QString
, Task
> m_tasks
;
97 QHash
<QString
, Task
> m_editedTasks
;
98 QMultiMap
<int, SakWidget
*> m_widgets
;
99 QMultiMap
<int, SakSubWidget
*> m_subwidgets
;
100 class QGraphicsEllipseItem
* m_marker
;
101 QMap
<int, SakWidget
*>::iterator m_widgetsIterator
;
102 QMap
<int, SakSubWidget
*>::iterator m_subwidgetsIterator
;
104 QList
<QString
> m_taskSelectionHistory
;
105 QHash
< QString
, QList
< QString
> > m_subtaskSelectionHistory
;
106 QCompleter
* m_subtaskCompleter
;
107 int m_currentInterval
;
110 bool m_changedHit
, m_changedTask
;
112 static int taskCounter
;
114 QAction
* m_addTaskAction
;
115 QMenu
* m_addTaskMenu
;
118 QAction
* m_addHitAction
;
119 QAction
* m_exportDataAction
;
120 QString currentTask
, currentSubtask
;
122 class Backupper
* m_backupper
;
123 class Incremental
* m_incremental
;
124 class GmailPyInterface
* m_gmail
;
126 //BEGIN Settings data:
128 void setVisible(bool visible
);
130 QTreeWidget
* newHitsList();
131 QTreeWidget
* newTaskSummaryList();
132 void setupSettingsWidget();
133 void createActions();
135 void scrollTasks(int npos
);
136 void scrollSubTasks(int npos
);
143 QPushButton
* previewButton
;
144 QPushButton
* bgColorButton
;
145 QPushButton
* fgColorButton
;
147 QLabel
*durationLabel
, *durationLabel1
;
148 QLabel
*durationWarningLabel
;
150 QSpinBox
*durationSpinBox
;
153 QTreeWidget
* tasksTree
;
154 QComboBox
* taskSelector
;
155 QTreeWidget
* hitsList
, *summaryList
;
156 Timeline
* hitsTimeline
;
157 QCalendarWidget
* cal1
, *cal2
, *cal3
, *cal4
;
158 PixmapViewer
* taskPixmapViewer
;
159 QTextEdit
* taskTextEditor
;
160 QLineEdit
* taskTitleEditor
;
161 QSpinBox
* estimatedHoursEditor
;
162 QDateEdit
* dueEditor
;
164 QAction
*minimizeAction
;
165 QAction
*maximizeAction
;
166 QAction
*restoreAction
;
167 QAction
*startAction
;
169 QAction
*flushAction
;
171 QAction
*saveAsDbAction
;
173 QAction
*exportDbCsvAction
;
174 QAction
*gmailLoginAction
;
175 QAction
*saveToGmailAction
;
176 QAction
*sendByEmailAction
;
178 QSystemTrayIcon
*trayIcon
;
183 class MyDateItemDelegate
: public QItemDelegate
186 MyDateItemDelegate(QObject
*parent
= 0);
188 QWidget
*createEditor(QWidget
*parent
, const QStyleOptionViewItem
&option
,
189 const QModelIndex
&index
) const;
191 void setEditorData(QWidget
*editor
, const QModelIndex
&index
) const;
192 void setModelData(QWidget
*editor
, QAbstractItemModel
*model
,
193 const QModelIndex
&index
) const;
195 void updateEditorGeometry(QWidget
*editor
,
196 const QStyleOptionViewItem
&option
, const QModelIndex
&index
) const;
199 class TaskItemDelegate
: public QItemDelegate
202 TaskItemDelegate(Sak
* sak
, QObject
*parent
= 0);
204 QWidget
*createEditor(QWidget
*parent
, const QStyleOptionViewItem
&option
,
205 const QModelIndex
&index
) const;
207 void setEditorData(QWidget
*editor
, const QModelIndex
&index
) const;
208 void setModelData(QWidget
*editor
, QAbstractItemModel
*model
,
209 const QModelIndex
&index
) const;
211 void updateEditorGeometry(QWidget
*editor
,
212 const QStyleOptionViewItem
&option
, const QModelIndex
&index
) const;
218 class SubTaskItemDelegate
: public QItemDelegate
221 SubTaskItemDelegate(Sak
* sak
, QObject
*parent
= 0);
223 QWidget
*createEditor(QWidget
*parent
, const QStyleOptionViewItem
&option
,
224 const QModelIndex
&index
) const;
226 void setEditorData(QWidget
*editor
, const QModelIndex
&index
) const;
227 void setModelData(QWidget
*editor
, QAbstractItemModel
*model
,
228 const QModelIndex
&index
) const;
230 void updateEditorGeometry(QWidget
*editor
,
231 const QStyleOptionViewItem
&option
, const QModelIndex
&index
) const;