krop's commit fixes my problem in a better way, reverting
[kdepim.git] / ktimetracker / timetrackerwidget.h
blob6b60441e31236781cbc2580ccde3367ce847cec9
1 /*
2 * Copyright (C) 2007 by Mathias Soeken <msoeken@tzi.de>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the
16 * Free Software Foundation, Inc.
17 * 51 Franklin Street, Fifth Floor
18 * Boston, MA 02110-1301 USA.
22 #ifndef TIMETRACKER_WIDGET_H
23 #define TIMETRACKER_WIDGET_H
25 #include <kconfiggroup.h>
26 #include <QWidget>
27 #include <QDateTime>
29 class KAction;
30 class KActionCollection;
31 class KUrl;
33 class Task;
34 class TaskView;
36 class TimetrackerWidget : public QWidget
38 Q_OBJECT
40 public:
41 explicit TimetrackerWidget( QWidget *parent = 0 );
42 ~TimetrackerWidget();
43 virtual void saveProperties( KConfigGroup& );
44 virtual void readProperties( const KConfigGroup& );
46 /**
47 Delivers if all task have an end time.
48 This is useful e.g. at the start of the program to see if a timer needs to be resumed.
49 This function checks all (TaskView) mTabWidget->widget() to see if any task is open.
51 bool allEventsHaveEndTiMe();
53 private:
54 void addTaskView( const QString &fileName = "" );
56 /**
57 Opens a file dialog to save the current taskView.
59 @returns true if save was successfully, false otherwise.
61 bool saveCurrentTaskView();
63 bool eventFilter( QObject *obj, QEvent *event );
65 public:
66 /**
67 Returns the TaskView widget of the current opened tabpage.
69 TaskView* currentTaskView();
71 /**
72 Returns the current task of the current opened TaskView widget.
74 Task* currentTask();
76 /**
77 initializes the KActionCollection object of a main window for example.
78 The actions are connected to the TreeWidget itself to ensure reusability.
80 @param actionCollection The KActionCollection instance of the host
81 object.
83 void setupActions( KActionCollection *actionCollection );
85 /**
86 returns a generated action by name. You have to call setupActions before.
88 @param name The name of the action
89 @returns A pointer to a KAction instance
91 KAction *action( const QString &name ) const;
93 public Q_SLOTS:
94 /**
95 opens a new untitled file which is stored firstly as temporary file
96 but with a flag, that it has to be saved in a proper place.
98 void newFile();
101 opens an existing ics file.
103 void openFile( const QString &fileName = QString() );
106 opens an existing ics file (wrapper for KUrl).
108 void openFile( const KUrl &fileName );
111 closes the current opened tab widget and saves the data
112 of the corresponding taskview.
114 @returns whether the file has been closed.
116 bool closeFile();
119 saves the current taskview. This is especially important on unsaved
120 files to give them a non-temporary filename.
122 void saveFile();
125 call this method when the preferences changed to adjust all
126 taskviews.
128 void reconfigureFiles();
131 this method puts the input focus onto the search bar
133 int focusSearchBar();
136 shows/hides the search bar.
138 void showSearchBar( bool visible );
141 shows/hides the tabbar.
143 void showTabBar( bool visible );
146 tries to close all files. This slot has to be called before quitting
147 the application to ensure that no data is lost.
149 @returns true if the user has saved or consciously not saved all files,
150 otherwise false.
152 bool closeAllFiles();
155 //BEGIN wrapper slots
157 * The following slots are wrapper slots which fires the corresponding
158 * slot of the current taskview.
160 void startCurrentTimer();
161 void stopCurrentTimer();
162 void stopAllTimers( const QDateTime &when = QDateTime::currentDateTime() );
163 void newTask();
164 void newSubTask();
165 void editTask();
166 void deleteTask();
167 void markTaskAsComplete();
168 void markTaskAsIncomplete();
169 void exportcsvFile();
170 void exportcsvHistory();
171 void importPlanner( const QString &fileName = "" );
172 void startNewSession();
173 void editHistory();
174 void resetAllTimes();
175 void focusTracking();
176 void slotSearchBar();
177 //END
179 //BEGIN dbus slots
180 QString version() const;
181 QStringList taskIdsFromName( const QString &taskName ) const;
182 void addTask( const QString &taskName );
183 void addSubTask( const QString& taskName, const QString &taskId );
184 void deleteTask( const QString &taskId );
185 void setPercentComplete( const QString &taskId, int percent );
186 int bookTime( const QString &taskId, const QString &dateTime, int minutes );
187 QString error( int errorCode ) const;
188 int totalMinutesForTaskId( const QString &taskId ) const;
189 void startTimerFor( const QString &taskId );
190 void stopTimerFor( const QString &taskId );
192 bool startTimerForTaskName( const QString &taskName );
193 bool stopTimerForTaskName( const QString &taskName );
195 // FIXME rename, when the wrapper slot is removed
196 void stopAllTimersDBUS();
197 QString exportCSVFile( const QString &filename, const QString &from,
198 const QString &to, int type, bool decimalMinutes,
199 bool allTasks, const QString &delimiter,
200 const QString &quote );
201 void importPlannerFile( const QString &filename );
202 QStringList tasks() const;
203 QStringList activeTasks() const;
204 bool isActive( const QString &taskId ) const;
205 bool isTaskNameActive( const QString &taskId ) const;
206 void saveAll();
207 void quit();
208 //END
210 protected:
211 bool event ( QEvent * event ); // inherited from QWidget
213 private Q_SLOTS:
214 void slotCurrentChanged();
215 void updateTabs();
216 void slotAddTask( const QString &taskName );
217 void slotUpdateButtons();
218 void showSettingsDialog();
220 Q_SIGNALS:
221 void setCaption( const QString& qs );
222 void currentTaskChanged();
223 void currentTaskViewChanged();
224 void updateButtons();
225 void totalTimesChanged( long session, long total );
226 void reSetTimes();
227 void statusBarTextChangeRequested( const QString &text );
228 void contextMenuRequested( const QPoint &pos );
229 void timersActive();
230 void timersInactive();
231 void tasksChanged( const QList< Task* >& );
233 private:
234 //@cond PRIVATE
235 class Private;
236 Private *const d;
237 //@endcond
240 #endif