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
;
95 QDateTime m_nextTimerEvent
;
96 QMainWindow
* m_settings
;
97 QHash
<QString
, Task
> m_tasks
;
98 QHash
<QString
, Task
> m_editedTasks
;
99 QMultiMap
<int, SakWidget
*> m_widgets
;
100 QMultiMap
<int, SakSubWidget
*> m_subwidgets
;
101 class QGraphicsEllipseItem
* m_marker
;
102 QMap
<int, SakWidget
*>::iterator m_widgetsIterator
;
103 QMap
<int, SakSubWidget
*>::iterator m_subwidgetsIterator
;
105 QList
<QString
> m_taskSelectionHistory
;
106 QHash
< QString
, QList
< QString
> > m_subtaskSelectionHistory
;
107 QCompleter
* m_subtaskCompleter
;
108 int m_currentInterval
;
112 bool m_changedHit
, m_changedTask
;
114 static int taskCounter
;
116 QAction
* m_addTaskAction
;
117 QMenu
* m_addTaskMenu
;
120 QAction
* m_addHitAction
;
121 QAction
* m_exportDataAction
;
122 QString currentTask
, currentSubtask
;
124 class Backupper
* m_backupper
;
125 class Incremental
* m_incremental
;
126 class GmailPyInterface
* m_gmail
;
128 //BEGIN Settings data:
130 void setVisible(bool visible
);
132 QRect
Layouting( const QList
<SakWidget
*>& sortedWidgets
);
133 void layoutSubTasks( const QMap
<int, SakSubWidget
*> sortedWidgets
, int currentRank
);
135 QTreeWidget
* newHitsList();
136 QTreeWidget
* newTaskSummaryList();
137 void setupSettingsWidget();
138 void createActions();
140 void scrollTasks(int npos
);
141 void scrollSubTasks(int npos
);
148 QPushButton
* previewButton
;
149 QPushButton
* bgColorButton
;
150 QPushButton
* fgColorButton
;
152 QLabel
*durationLabel
, *durationLabel1
;
153 QLabel
*durationWarningLabel
;
155 QSpinBox
*durationSpinBox
;
158 QTreeWidget
* tasksTree
;
159 QComboBox
* taskSelector
;
160 QTreeWidget
* hitsList
, *summaryList
;
161 Timeline
* hitsTimeline
;
162 QCalendarWidget
* cal1
, *cal2
, *cal3
, *cal4
;
163 PixmapViewer
* taskPixmapViewer
;
164 QTextEdit
* taskTextEditor
;
165 QLineEdit
* taskTitleEditor
;
166 QSpinBox
* estimatedHoursEditor
;
167 QDateEdit
* dueEditor
;
169 QAction
*minimizeAction
;
170 QAction
*maximizeAction
;
171 QAction
*restoreAction
;
172 QAction
*startAction
;
174 QAction
*flushAction
;
176 QAction
*saveAsDbAction
;
178 QAction
*exportDbCsvAction
;
179 QAction
*gmailLoginAction
;
180 QAction
*saveToGmailAction
;
181 QAction
*sendByEmailAction
;
183 QSystemTrayIcon
*trayIcon
;
188 class MyDateItemDelegate
: public QItemDelegate
191 MyDateItemDelegate(QObject
*parent
= 0);
193 QWidget
*createEditor(QWidget
*parent
, const QStyleOptionViewItem
&option
,
194 const QModelIndex
&index
) const;
196 void setEditorData(QWidget
*editor
, const QModelIndex
&index
) const;
197 void setModelData(QWidget
*editor
, QAbstractItemModel
*model
,
198 const QModelIndex
&index
) const;
200 void updateEditorGeometry(QWidget
*editor
,
201 const QStyleOptionViewItem
&option
, const QModelIndex
&index
) const;
204 class TaskItemDelegate
: public QItemDelegate
207 TaskItemDelegate(Sak
* sak
, QObject
*parent
= 0);
209 QWidget
*createEditor(QWidget
*parent
, const QStyleOptionViewItem
&option
,
210 const QModelIndex
&index
) const;
212 void setEditorData(QWidget
*editor
, const QModelIndex
&index
) const;
213 void setModelData(QWidget
*editor
, QAbstractItemModel
*model
,
214 const QModelIndex
&index
) const;
216 void updateEditorGeometry(QWidget
*editor
,
217 const QStyleOptionViewItem
&option
, const QModelIndex
&index
) const;
223 class SubTaskItemDelegate
: public QItemDelegate
226 SubTaskItemDelegate(Sak
* sak
, QObject
*parent
= 0);
228 QWidget
*createEditor(QWidget
*parent
, const QStyleOptionViewItem
&option
,
229 const QModelIndex
&index
) const;
231 void setEditorData(QWidget
*editor
, const QModelIndex
&index
) const;
232 void setModelData(QWidget
*editor
, QAbstractItemModel
*model
,
233 const QModelIndex
&index
) const;
235 void updateEditorGeometry(QWidget
*editor
,
236 const QStyleOptionViewItem
&option
, const QModelIndex
&index
) const;