no unsigned
[Sak.git] / sak.h
blob0a4202c40d27645a3f69d0e1e652e63a98ae313c
1 /***************************************************************************
2 * Copyright (C) 2007 by Arrigo Zanette *
3 * zanettea@gmail.com *
4 ***************************************************************************/
7 #ifndef __SAK_H__
8 #define __SAK_H__
10 #include <QtGui>
11 #include <QFont>
12 #include <QList>
13 #include <QHash>
14 #include <QPair>
15 #include <QObject>
16 #include <QDateTime>
17 #include <QPixmap>
18 #include <QRectF>
19 #include <QDebug>
21 #include "task.h"
24 class SakWidget;
25 class SakSubWidget;
26 class SakMessageItem;
27 class PixmapViewer;
28 class Timeline;
29 class HitItem;
31 class Sak : public QObject
33 Q_OBJECT;
34 public:
35 Sak(QObject* parent = 0);
36 virtual ~Sak();
37 QHash<QString, Task>* tasks() { return &m_tasks; }
38 protected:
39 void timerEvent(QTimerEvent* e);
40 bool eventFilter(QObject* obj, QEvent* e);
41 bool taskTreeEventFilter(QEvent* e);
42 bool hitsListEventFilter(QEvent* e);
43 public slots:
44 void start();
45 void stop();
46 Task loadTaskFromFile(const QString& filePath);
47 void flush();
48 void open(const QStringList& filePaths = QStringList());
49 // void saveAsDb();
50 void exportDbCsv();
51 void logInGmail();
52 void saveToGmail();
53 void importFromGmail();
54 protected slots:
55 void init();
56 void destroy();
57 // tasks
58 void addDefaultTask();
59 void exportHits();
60 void populateTasks();
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();
67 void selectedTask();
68 void doubleClickedTask(QTreeWidgetItem* i, int column);
69 void selectColor();
70 void grabKeyboard(); // delayed grab of keayboard
71 // popup task selection
72 void popup();
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();
78 void clearView();
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);
90 void addDefaultHit();
91 void interactiveMergeHits();
92 private:
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;
103 int m_subWidgetRank;
104 QList<QString> m_taskSelectionHistory;
105 QHash< QString, QList< QString > > m_subtaskSelectionHistory;
106 QCompleter* m_subtaskCompleter;
107 int m_currentInterval;
109 bool m_previewing;
110 bool m_changedHit, m_changedTask;
111 bool m_subtaskView;
112 static int taskCounter;
114 QAction* m_addTaskAction;
115 QMenu* m_addTaskMenu;
117 QMenu* m_addHitMenu;
118 QAction* m_addHitAction;
119 QAction* m_exportDataAction;
120 QString currentTask, currentSubtask;
121 class GView* m_view;
122 class Backupper* m_backupper;
123 class Incremental* m_incremental;
124 class GmailPyInterface* m_gmail;
126 //BEGIN Settings data:
127 public:
128 void setVisible(bool visible);
129 private:
130 QTreeWidget* newHitsList();
131 QTreeWidget* newTaskSummaryList();
132 void setupSettingsWidget();
133 void createActions();
135 void scrollTasks(int npos);
136 void scrollSubTasks(int npos);
138 QTabWidget* tabs;
139 QWidget* tab1;
140 QWidget* tab2;
141 QWidget* tab3;
142 QWidget* tab4;
143 QPushButton* previewButton;
144 QPushButton* bgColorButton;
145 QPushButton* fgColorButton;
147 QLabel *durationLabel, *durationLabel1;
148 QLabel *durationWarningLabel;
149 QLabel *bodyLabel;
150 QSpinBox *durationSpinBox;
151 QTextEdit *bodyEdit;
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;
168 QAction *stopAction;
169 QAction *flushAction;
170 QAction *quitAction;
171 QAction *saveAsDbAction;
172 QAction *openAction;
173 QAction *exportDbCsvAction;
174 QAction *gmailLoginAction;
175 QAction *saveToGmailAction;
176 QAction *sendByEmailAction;
178 QSystemTrayIcon *trayIcon;
179 QMenu *trayIconMenu;
183 class MyDateItemDelegate : public QItemDelegate
185 public:
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
201 public:
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;
213 private:
214 Sak* m_sak;
218 class SubTaskItemDelegate : public QItemDelegate
220 public:
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;
232 private:
233 Sak* m_sak;
238 #endif