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>
30 class KActionCollection
;
36 class TimetrackerWidget
: public QWidget
41 explicit TimetrackerWidget( QWidget
*parent
= 0 );
43 virtual void saveProperties( KConfigGroup
& );
44 virtual void readProperties( const KConfigGroup
& );
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();
54 void addTaskView( const QString
&fileName
= "" );
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
);
67 Returns the TaskView widget of the current opened tabpage.
69 TaskView
* currentTaskView();
72 Returns the current task of the current opened TaskView widget.
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
83 void setupActions( KActionCollection
*actionCollection
);
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;
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.
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.
119 saves the current taskview. This is especially important on unsaved
120 files to give them a non-temporary filename.
125 call this method when the preferences changed to adjust all
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,
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() );
167 void markTaskAsComplete();
168 void markTaskAsIncomplete();
169 void exportcsvFile();
170 void exportcsvHistory();
171 void importPlanner( const QString
&fileName
= "" );
172 void startNewSession();
174 void resetAllTimes();
175 void focusTracking();
176 void slotSearchBar();
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
"e
);
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;
211 bool event ( QEvent
* event
); // inherited from QWidget
214 void slotCurrentChanged();
216 void slotAddTask( const QString
&taskName
);
217 void slotUpdateButtons();
218 void showSettingsDialog();
221 void setCaption( const QString
& qs
);
222 void currentTaskChanged();
223 void currentTaskViewChanged();
224 void updateButtons();
225 void totalTimesChanged( long session
, long total
);
227 void statusBarTextChangeRequested( const QString
&text
);
228 void contextMenuRequested( const QPoint
&pos
);
230 void timersInactive();
231 void tasksChanged( const QList
< Task
* >& );