summaryrefslogtreecommitdiff
path: root/libopie
authorzecke <zecke>2002-06-16 16:34:10 (UTC)
committer zecke <zecke>2002-06-16 16:34:10 (UTC)
commit3b8192d0f5a41c40092af48df8abc39aa3d1c355 (patch) (unidiff)
treec1f5e0211a16bb4ceb2d78ec7a76e1bffdae088b /libopie
parent23c2d100ed9070d82f956cdcb7364f5627aa0600 (diff)
downloadopie-3b8192d0f5a41c40092af48df8abc39aa3d1c355.zip
opie-3b8192d0f5a41c40092af48df8abc39aa3d1c355.tar.gz
opie-3b8192d0f5a41c40092af48df8abc39aa3d1c355.tar.bz2
implement progress
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/oprocess.h2
-rw-r--r--libopie/tododb.cpp8
-rw-r--r--libopie/todoevent.cpp21
-rw-r--r--libopie/todoevent.h11
4 files changed, 37 insertions, 5 deletions
diff --git a/libopie/oprocess.h b/libopie/oprocess.h
index ce3c87d..fd726b4 100644
--- a/libopie/oprocess.h
+++ b/libopie/oprocess.h
@@ -1,539 +1,539 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at) 2 Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19// 19//
20// KPROCESS -- A class for handling child processes in KDE without 20// KPROCESS -- A class for handling child processes in KDE without
21// having to take care of Un*x specific implementation details 21// having to take care of Un*x specific implementation details
22// 22//
23// version 0.3.1, Jan 8th 1998 23// version 0.3.1, Jan 8th 1998
24// 24//
25// (C) Christian Czezatke 25// (C) Christian Czezatke
26// e9025461@student.tuwien.ac.at 26// e9025461@student.tuwien.ac.at
27// Ported by Holger Freyther 27// Ported by Holger Freyther to the Open Palmtop Integrated Environment
28// 28//
29 29
30#ifndef __kprocess_h__ 30#ifndef __kprocess_h__
31#define __kprocess_h__ 31#define __kprocess_h__
32 32
33#include <sys/types.h> // for pid_t 33#include <sys/types.h> // for pid_t
34#include <sys/wait.h> 34#include <sys/wait.h>
35#include <signal.h> 35#include <signal.h>
36#include <unistd.h> 36#include <unistd.h>
37#include <qvaluelist.h> 37#include <qvaluelist.h>
38#include <qcstring.h> 38#include <qcstring.h>
39#include <qobject.h> 39#include <qobject.h>
40 40
41class QSocketNotifier; 41class QSocketNotifier;
42class OProcessPrivate; 42class OProcessPrivate;
43 43
44/** 44/**
45 * Child process invocation, monitoring and control. 45 * Child process invocation, monitoring and control.
46 * 46 *
47 * @sect General usage and features 47 * @sect General usage and features
48 * 48 *
49 *This class allows a KDE application to start child processes without having 49 *This class allows a KDE application to start child processes without having
50 *to worry about UN*X signal handling issues and zombie process reaping. 50 *to worry about UN*X signal handling issues and zombie process reaping.
51 * 51 *
52 *@see KProcIO 52 *@see KProcIO
53 * 53 *
54 *Basically, this class distinguishes three different ways of running 54 *Basically, this class distinguishes three different ways of running
55 *child processes: 55 *child processes:
56 * 56 *
57 *@li OProcess::DontCare -- The child process is invoked and both the child 57 *@li OProcess::DontCare -- The child process is invoked and both the child
58 *process and the parent process continue concurrently. 58 *process and the parent process continue concurrently.
59 * 59 *
60 *Starting a DontCare child process means that the application is 60 *Starting a DontCare child process means that the application is
61 *not interested in any notification to determine whether the 61 *not interested in any notification to determine whether the
62 *child process has already exited or not. 62 *child process has already exited or not.
63 * 63 *
64 *@li OProcess::NotifyOnExit -- The child process is invoked and both the 64 *@li OProcess::NotifyOnExit -- The child process is invoked and both the
65 *child and the parent process run concurrently. 65 *child and the parent process run concurrently.
66 * 66 *
67 *When the child process exits, the OProcess instance 67 *When the child process exits, the OProcess instance
68 *corresponding to it emits the Qt signal @ref processExited(). 68 *corresponding to it emits the Qt signal @ref processExited().
69 * 69 *
70 *Since this signal is @em not emitted from within a UN*X 70 *Since this signal is @em not emitted from within a UN*X
71 *signal handler, arbitrary function calls can be made. 71 *signal handler, arbitrary function calls can be made.
72 * 72 *
73 *Be aware: When the OProcess objects gets destructed, the child 73 *Be aware: When the OProcess objects gets destructed, the child
74 *process will be killed if it is still running! 74 *process will be killed if it is still running!
75 *This means in particular, that you cannot use a OProcess on the stack 75 *This means in particular, that you cannot use a OProcess on the stack
76 *with OProcess::NotifyOnExit. 76 *with OProcess::NotifyOnExit.
77 * 77 *
78 *@li OProcess::Block -- The child process starts and the parent process 78 *@li OProcess::Block -- The child process starts and the parent process
79 *is suspended until the child process exits. (@em Really not recommended 79 *is suspended until the child process exits. (@em Really not recommended
80 *for programs with a GUI.) 80 *for programs with a GUI.)
81 * 81 *
82 *OProcess also provides several functions for determining the exit status 82 *OProcess also provides several functions for determining the exit status
83 *and the pid of the child process it represents. 83 *and the pid of the child process it represents.
84 * 84 *
85 *Furthermore it is possible to supply command-line arguments to the process 85 *Furthermore it is possible to supply command-line arguments to the process
86 *in a clean fashion (no null -- terminated stringlists and such...) 86 *in a clean fashion (no null -- terminated stringlists and such...)
87 * 87 *
88 *A small usage example: 88 *A small usage example:
89 *<pre> 89 *<pre>
90 *OProcess *proc = new OProcess; 90 *OProcess *proc = new OProcess;
91 * 91 *
92 **proc << "my_executable"; 92 **proc << "my_executable";
93 **proc << "These" << "are" << "the" << "command" << "line" << "args"; 93 **proc << "These" << "are" << "the" << "command" << "line" << "args";
94 *QApplication::connect(proc, SIGNAL(processExited(OProcess *)), 94 *QApplication::connect(proc, SIGNAL(processExited(OProcess *)),
95 * pointer_to_my_object, SLOT(my_objects_slot(OProcess *))); 95 * pointer_to_my_object, SLOT(my_objects_slot(OProcess *)));
96 *proc->start(); 96 *proc->start();
97 *</pre> 97 *</pre>
98 * 98 *
99 *This will start "my_executable" with the commandline arguments "These"... 99 *This will start "my_executable" with the commandline arguments "These"...
100 * 100 *
101 *When the child process exits, the respective Qt signal will be emitted. 101 *When the child process exits, the respective Qt signal will be emitted.
102 * 102 *
103 *@sect Communication with the child process 103 *@sect Communication with the child process
104 * 104 *
105 *OProcess supports communication with the child process through 105 *OProcess supports communication with the child process through
106 *stdin/stdout/stderr. 106 *stdin/stdout/stderr.
107 * 107 *
108 *The following functions are provided for getting data from the child 108 *The following functions are provided for getting data from the child
109 *process or sending data to the child's stdin (For more information, 109 *process or sending data to the child's stdin (For more information,
110 *have a look at the documentation of each function): 110 *have a look at the documentation of each function):
111 * 111 *
112 *@li bool @ref writeStdin(char *buffer, int buflen); 112 *@li bool @ref writeStdin(char *buffer, int buflen);
113 *@li -- Transmit data to the child process's stdin. 113 *@li -- Transmit data to the child process's stdin.
114 * 114 *
115 *@li bool @ref closeStdin(); 115 *@li bool @ref closeStdin();
116 *@li -- Closes the child process's stdin (which causes it to see an feof(stdin)). 116 *@li -- Closes the child process's stdin (which causes it to see an feof(stdin)).
117 *Returns false if you try to close stdin for a process that has been started 117 *Returns false if you try to close stdin for a process that has been started
118 *without a communication channel to stdin. 118 *without a communication channel to stdin.
119 * 119 *
120 *@li bool @ref closeStdout(); 120 *@li bool @ref closeStdout();
121 *@li -- Closes the child process's stdout. 121 *@li -- Closes the child process's stdout.
122 *Returns false if you try to close stdout for a process that has been started 122 *Returns false if you try to close stdout for a process that has been started
123 *without a communication channel to stdout. 123 *without a communication channel to stdout.
124 * 124 *
125 *@li bool @ref closeStderr(); 125 *@li bool @ref closeStderr();
126 *@li -- Closes the child process's stderr. 126 *@li -- Closes the child process's stderr.
127 *Returns false if you try to close stderr for a process that has been started 127 *Returns false if you try to close stderr for a process that has been started
128 *without a communication channel to stderr. 128 *without a communication channel to stderr.
129 * 129 *
130 * 130 *
131 *@sect QT signals: 131 *@sect QT signals:
132 * 132 *
133 *@li void @ref receivedStdout(OProcess *proc, char *buffer, int buflen); 133 *@li void @ref receivedStdout(OProcess *proc, char *buffer, int buflen);
134 *@li void @ref receivedStderr(OProcess *proc, char *buffer, int buflen); 134 *@li void @ref receivedStderr(OProcess *proc, char *buffer, int buflen);
135 *@li -- Indicates that new data has arrived from either the 135 *@li -- Indicates that new data has arrived from either the
136 *child process's stdout or stderr. 136 *child process's stdout or stderr.
137 * 137 *
138 *@li void @ref wroteStdin(OProcess *proc); 138 *@li void @ref wroteStdin(OProcess *proc);
139 *@li -- Indicates that all data that has been sent to the child process 139 *@li -- Indicates that all data that has been sent to the child process
140 *by a prior call to @ref writeStdin() has actually been transmitted to the 140 *by a prior call to @ref writeStdin() has actually been transmitted to the
141 *client . 141 *client .
142 * 142 *
143 *@author Christian Czezakte e9025461@student.tuwien.ac.at 143 *@author Christian Czezakte e9025461@student.tuwien.ac.at
144 * 144 *
145 * 145 *
146 **/ 146 **/
147class OProcess : public QObject 147class OProcess : public QObject
148{ 148{
149 Q_OBJECT 149 Q_OBJECT
150 150
151public: 151public:
152 152
153 /** 153 /**
154 * Modes in which the communication channel can be opened. 154 * Modes in which the communication channel can be opened.
155 * 155 *
156 * If communication for more than one channel is required, 156 * If communication for more than one channel is required,
157 * the values have to be or'ed together, for example to get 157 * the values have to be or'ed together, for example to get
158 * communication with stdout as well as with stdin, you would 158 * communication with stdout as well as with stdin, you would
159 * specify @p Stdin @p | @p Stdout 159 * specify @p Stdin @p | @p Stdout
160 * 160 *
161 * If @p NoRead is specified in conjunction with @p Stdout, 161 * If @p NoRead is specified in conjunction with @p Stdout,
162 * no data is actually read from @p Stdout but only 162 * no data is actually read from @p Stdout but only
163 * the signal @ref childOutput(int fd) is emitted. 163 * the signal @ref childOutput(int fd) is emitted.
164 */ 164 */
165 enum Communication { NoCommunication = 0, Stdin = 1, Stdout = 2, Stderr = 4, 165 enum Communication { NoCommunication = 0, Stdin = 1, Stdout = 2, Stderr = 4,
166 AllOutput = 6, All = 7, 166 AllOutput = 6, All = 7,
167 NoRead }; 167 NoRead };
168 168
169 /** 169 /**
170 * Run-modes for a child process. 170 * Run-modes for a child process.
171 */ 171 */
172 enum RunMode { 172 enum RunMode {
173 /** 173 /**
174 * The application does not receive notifications from the subprocess when 174 * The application does not receive notifications from the subprocess when
175 * it is finished or aborted. 175 * it is finished or aborted.
176 */ 176 */
177 DontCare, 177 DontCare,
178 /** 178 /**
179 * The application is notified when the subprocess dies. 179 * The application is notified when the subprocess dies.
180 */ 180 */
181 NotifyOnExit, 181 NotifyOnExit,
182 /** 182 /**
183 * The application is suspended until the started process is finished. 183 * The application is suspended until the started process is finished.
184 */ 184 */
185 Block }; 185 Block };
186 186
187 /** 187 /**
188 * Constructor 188 * Constructor
189 */ 189 */
190 OProcess(); 190 OProcess();
191 191
192 /** 192 /**
193 *Destructor: 193 *Destructor:
194 * 194 *
195 * If the process is running when the destructor for this class 195 * If the process is running when the destructor for this class
196 * is called, the child process is killed with a SIGKILL, but 196 * is called, the child process is killed with a SIGKILL, but
197 * only if the run mode is not of type @p DontCare. 197 * only if the run mode is not of type @p DontCare.
198 * Processes started as @p DontCare keep running anyway. 198 * Processes started as @p DontCare keep running anyway.
199 */ 199 */
200 virtual ~OProcess(); 200 virtual ~OProcess();
201 201
202 /** 202 /**
203 @deprecated 203 @deprecated
204 204
205 The use of this function is now deprecated. -- Please use the 205 The use of this function is now deprecated. -- Please use the
206 "operator<<" instead of "setExecutable". 206 "operator<<" instead of "setExecutable".
207 207
208 Sets the executable to be started with this OProcess object. 208 Sets the executable to be started with this OProcess object.
209 Returns false if the process is currently running (in that 209 Returns false if the process is currently running (in that
210 case the executable remains unchanged.) 210 case the executable remains unchanged.)
211 211
212 @see operator<< 212 @see operator<<
213 213
214 */ 214 */
215 bool setExecutable(const QString& proc); 215 bool setExecutable(const QString& proc);
216 216
217 217
218 /** 218 /**
219 * Sets the executable and the command line argument list for this process. 219 * Sets the executable and the command line argument list for this process.
220 * 220 *
221 * For example, doing an "ls -l /usr/local/bin" can be achieved by: 221 * For example, doing an "ls -l /usr/local/bin" can be achieved by:
222 * <pre> 222 * <pre>
223 * OProcess p; 223 * OProcess p;
224 * ... 224 * ...
225 * p << "ls" << "-l" << "/usr/local/bin" 225 * p << "ls" << "-l" << "/usr/local/bin"
226 * </pre> 226 * </pre>
227 * 227 *
228 **/ 228 **/
229 OProcess &operator<<(const QString& arg); 229 OProcess &operator<<(const QString& arg);
230 /** 230 /**
231 * Similar to previous method, takes a char *, supposed to be in locale 8 bit already. 231 * Similar to previous method, takes a char *, supposed to be in locale 8 bit already.
232 */ 232 */
233 OProcess &operator<<(const char * arg); 233 OProcess &operator<<(const char * arg);
234 /** 234 /**
235 * Similar to previous method, takes a QCString, supposed to be in locale 8 bit already. 235 * Similar to previous method, takes a QCString, supposed to be in locale 8 bit already.
236 */ 236 */
237 OProcess &operator<<(const QCString & arg); 237 OProcess &operator<<(const QCString & arg);
238 238
239 /** 239 /**
240 * Sets the executable and the command line argument list for this process, 240 * Sets the executable and the command line argument list for this process,
241 * in a single method call, or add a list of arguments. 241 * in a single method call, or add a list of arguments.
242 **/ 242 **/
243 OProcess &operator<<(const QStringList& args); 243 OProcess &operator<<(const QStringList& args);
244 244
245 /** 245 /**
246 * Clear a command line argument list that has been set by using 246 * Clear a command line argument list that has been set by using
247 * the "operator<<". 247 * the "operator<<".
248 */ 248 */
249 void clearArguments(); 249 void clearArguments();
250 250
251 /** 251 /**
252 * Starts the process. 252 * Starts the process.
253 * For a detailed description of the 253 * For a detailed description of the
254 * various run modes and communication semantics, have a look at the 254 * various run modes and communication semantics, have a look at the
255 * general description of the OProcess class. 255 * general description of the OProcess class.
256 * 256 *
257 * The following problems could cause this function to 257 * The following problems could cause this function to
258 * return false: 258 * return false:
259 * 259 *
260 * @li The process is already running. 260 * @li The process is already running.
261 * @li The command line argument list is empty. 261 * @li The command line argument list is empty.
262 * @li The starting of the process failed (could not fork). 262 * @li The starting of the process failed (could not fork).
263 * @li The executable was not found. 263 * @li The executable was not found.
264 * 264 *
265 * @param comm Specifies which communication links should be 265 * @param comm Specifies which communication links should be
266 * established to the child process (stdin/stdout/stderr). By default, 266 * established to the child process (stdin/stdout/stderr). By default,
267 * no communication takes place and the respective communication 267 * no communication takes place and the respective communication
268 * signals will never get emitted. 268 * signals will never get emitted.
269 * 269 *
270 * @return true on success, false on error 270 * @return true on success, false on error
271 * (see above for error conditions) 271 * (see above for error conditions)
272 **/ 272 **/
273 virtual bool start(RunMode runmode = NotifyOnExit, 273 virtual bool start(RunMode runmode = NotifyOnExit,
274 Communication comm = NoCommunication); 274 Communication comm = NoCommunication);
275 275
276 /** 276 /**
277 * Stop the process (by sending it a signal). 277 * Stop the process (by sending it a signal).
278 * 278 *
279 * @param signoThe signal to send. The default is SIGTERM. 279 * @param signoThe signal to send. The default is SIGTERM.
280 * @return @p true if the signal was delivered successfully. 280 * @return @p true if the signal was delivered successfully.
281 */ 281 */
282 virtual bool kill(int signo = SIGTERM); 282 virtual bool kill(int signo = SIGTERM);
283 283
284 /** 284 /**
285 @return @p true if the process is (still) considered to be running 285 @return @p true if the process is (still) considered to be running
286 */ 286 */
287 bool isRunning() const; 287 bool isRunning() const;
288 288
289 /** Returns the process id of the process. 289 /** Returns the process id of the process.
290 * 290 *
291 * If it is called after 291 * If it is called after
292 * the process has exited, it returns the process id of the last 292 * the process has exited, it returns the process id of the last
293 * child process that was created by this instance of OProcess. 293 * child process that was created by this instance of OProcess.
294 * 294 *
295 * Calling it before any child process has been started by this 295 * Calling it before any child process has been started by this
296 * OProcess instance causes pid() to return 0. 296 * OProcess instance causes pid() to return 0.
297 **/ 297 **/
298 pid_t pid() const; 298 pid_t pid() const;
299 299
300 /** 300 /**
301 * Use pid(). 301 * Use pid().
302 * @deprecated 302 * @deprecated
303 */ 303 */
304 pid_t getPid() const { return pid(); } 304 pid_t getPid() const { return pid(); }
305 305
306 /** 306 /**
307 * Suspend processing of data from stdout of the child process. 307 * Suspend processing of data from stdout of the child process.
308 */ 308 */
309 void suspend(); 309 void suspend();
310 310
311 /** 311 /**
312 * Resume processing of data from stdout of the child process. 312 * Resume processing of data from stdout of the child process.
313 */ 313 */
314 void resume(); 314 void resume();
315 315
316 /** 316 /**
317 * @return @p true if the process has already finished and has exited 317 * @return @p true if the process has already finished and has exited
318 * "voluntarily", ie: it has not been killed by a signal. 318 * "voluntarily", ie: it has not been killed by a signal.
319 * 319 *
320 * Note that you should check @ref OProcess::exitStatus() to determine 320 * Note that you should check @ref OProcess::exitStatus() to determine
321 * whether the process completed its task successful or not. 321 * whether the process completed its task successful or not.
322 */ 322 */
323 bool normalExit() const; 323 bool normalExit() const;
324 324
325 /** 325 /**
326 * Returns the exit status of the process. 326 * Returns the exit status of the process.
327 * 327 *
328 * Please use 328 * Please use
329 * @ref OProcess::normalExit() to check whether the process has exited 329 * @ref OProcess::normalExit() to check whether the process has exited
330 * cleanly (i.e., @ref OProcess::normalExit() returns @p true) before calling 330 * cleanly (i.e., @ref OProcess::normalExit() returns @p true) before calling
331 * this function because if the process did not exit normally, 331 * this function because if the process did not exit normally,
332 * it does not have a valid exit status. 332 * it does not have a valid exit status.
333 */ 333 */
334 int exitStatus() const; 334 int exitStatus() const;
335 335
336 336
337 /** 337 /**
338 * Transmit data to the child process's stdin. 338 * Transmit data to the child process's stdin.
339 * 339 *
340 * OProcess::writeStdin may return false in the following cases: 340 * OProcess::writeStdin may return false in the following cases:
341 * 341 *
342 * @li The process is not currently running. 342 * @li The process is not currently running.
343 * 343 *
344 * @li Communication to stdin has not been requested in the @ref start() call. 344 * @li Communication to stdin has not been requested in the @ref start() call.
345 * 345 *
346 * @li Transmission of data to the child process by a previous call to 346 * @li Transmission of data to the child process by a previous call to
347 * @ref writeStdin() is still in progress. 347 * @ref writeStdin() is still in progress.
348 * 348 *
349 * Please note that the data is sent to the client asynchronously, 349 * Please note that the data is sent to the client asynchronously,
350 * so when this function returns, the data might not have been 350 * so when this function returns, the data might not have been
351 * processed by the child process. 351 * processed by the child process.
352 * 352 *
353 * If all the data has been sent to the client, the signal 353 * If all the data has been sent to the client, the signal
354 * @ref wroteStdin() will be emitted. 354 * @ref wroteStdin() will be emitted.
355 * 355 *
356 * Please note that you must not free "buffer" or call @ref writeStdin() 356 * Please note that you must not free "buffer" or call @ref writeStdin()
357 * again until either a @ref wroteStdin() signal indicates that the 357 * again until either a @ref wroteStdin() signal indicates that the
358 * data has been sent or a @ref processHasExited() signal shows that 358 * data has been sent or a @ref processHasExited() signal shows that
359 * the child process is no longer alive... 359 * the child process is no longer alive...
360 **/ 360 **/
361 bool writeStdin(const char *buffer, int buflen); 361 bool writeStdin(const char *buffer, int buflen);
362 362
363 /** 363 /**
364 * This causes the stdin file descriptor of the child process to be 364 * This causes the stdin file descriptor of the child process to be
365 * closed indicating an "EOF" to the child. 365 * closed indicating an "EOF" to the child.
366 * 366 *
367 * @return @p false if no communication to the process's stdin 367 * @return @p false if no communication to the process's stdin
368 * had been specified in the call to @ref start(). 368 * had been specified in the call to @ref start().
369 */ 369 */
370 bool closeStdin(); 370 bool closeStdin();
371 371
372 /** 372 /**
373 * This causes the stdout file descriptor of the child process to be 373 * This causes the stdout file descriptor of the child process to be
374 * closed. 374 * closed.
375 * 375 *
376 * @return @p false if no communication to the process's stdout 376 * @return @p false if no communication to the process's stdout
377 * had been specified in the call to @ref start(). 377 * had been specified in the call to @ref start().
378 */ 378 */
379 bool closeStdout(); 379 bool closeStdout();
380 380
381 /** 381 /**
382 * This causes the stderr file descriptor of the child process to be 382 * This causes the stderr file descriptor of the child process to be
383 * closed. 383 * closed.
384 * 384 *
385 * @return @p false if no communication to the process's stderr 385 * @return @p false if no communication to the process's stderr
386 * had been specified in the call to @ref start(). 386 * had been specified in the call to @ref start().
387 */ 387 */
388 bool closeStderr(); 388 bool closeStderr();
389 389
390 /** 390 /**
391 * Lets you see what your arguments are for debugging. 391 * Lets you see what your arguments are for debugging.
392 */ 392 */
393 393
394 const QValueList<QCString> &args() { return arguments; } 394 const QValueList<QCString> &args() { return arguments; }
395 395
396 /** 396 /**
397 * Controls whether the started process should drop any 397 * Controls whether the started process should drop any
398 * setuid/segid privileges or whether it should keep them 398 * setuid/segid privileges or whether it should keep them
399 * 399 *
400 * The default is @p false : drop privileges 400 * The default is @p false : drop privileges
401 */ 401 */
402 void setRunPrivileged(bool keepPrivileges); 402 void setRunPrivileged(bool keepPrivileges);
403 403
404 /** 404 /**
405 * Returns whether the started process will drop any 405 * Returns whether the started process will drop any
406 * setuid/segid privileges or whether it will keep them 406 * setuid/segid privileges or whether it will keep them
407 */ 407 */
408 bool runPrivileged() const; 408 bool runPrivileged() const;
409 409
410 /** 410 /**
411 * Modifies the environment of the process to be started. 411 * Modifies the environment of the process to be started.
412 * This function must be called before starting the process. 412 * This function must be called before starting the process.
413 */ 413 */
414 void setEnvironment(const QString &name, const QString &value); 414 void setEnvironment(const QString &name, const QString &value);
415 415
416 /** 416 /**
417 * Changes the current working directory (CWD) of the process 417 * Changes the current working directory (CWD) of the process
418 * to be started. 418 * to be started.
419 * This function must be called before starting the process. 419 * This function must be called before starting the process.
420 */ 420 */
421 void setWorkingDirectory(const QString &dir); 421 void setWorkingDirectory(const QString &dir);
422 422
423 /** 423 /**
424 * Specify whether to start the command via a shell or directly. 424 * Specify whether to start the command via a shell or directly.
425 * The default is to start the command directly. 425 * The default is to start the command directly.
426 * If @p useShell is true @p shell will be used as shell, or 426 * If @p useShell is true @p shell will be used as shell, or
427 * if shell is empty, the standard shell is used. 427 * if shell is empty, the standard shell is used.
428 * @p quote A flag indicating whether to quote the arguments. 428 * @p quote A flag indicating whether to quote the arguments.
429 * 429 *
430 * When using a shell, the caller should make sure that all filenames etc. 430 * When using a shell, the caller should make sure that all filenames etc.
431 * are properly quoted when passed as argument. 431 * are properly quoted when passed as argument.
432 * @see quote() 432 * @see quote()
433 */ 433 */
434 void setUseShell(bool useShell, const char *shell = 0); 434 void setUseShell(bool useShell, const char *shell = 0);
435 435
436 /** 436 /**
437 * This function can be used to quote an argument string such that 437 * This function can be used to quote an argument string such that
438 * the shell processes it properly. This is e. g. necessary for 438 * the shell processes it properly. This is e. g. necessary for
439 * user-provided file names which may contain spaces or quotes. 439 * user-provided file names which may contain spaces or quotes.
440 * It also prevents expansion of wild cards and environment variables. 440 * It also prevents expansion of wild cards and environment variables.
441 */ 441 */
442 static QString quote(const QString &arg); 442 static QString quote(const QString &arg);
443 443
444 /** 444 /**
445 * Detaches OProcess from child process. All communication is closed. 445 * Detaches OProcess from child process. All communication is closed.
446 * No exit notification is emitted any more for the child process. 446 * No exit notification is emitted any more for the child process.
447 * Deleting the OProcess will no longer kill the child process. 447 * Deleting the OProcess will no longer kill the child process.
448 * Note that the current process remains the parent process of the 448 * Note that the current process remains the parent process of the
449 * child process. 449 * child process.
450 */ 450 */
451 void detach(); 451 void detach();
452 452
453 453
454 454
455signals: 455signals:
456 456
457 /** 457 /**
458 * Emitted after the process has terminated when 458 * Emitted after the process has terminated when
459 * the process was run in the @p NotifyOnExit (==default option to 459 * the process was run in the @p NotifyOnExit (==default option to
460 * @ref start()) or the @ref Block mode. 460 * @ref start()) or the @ref Block mode.
461 **/ 461 **/
462 void processExited(OProcess *proc); 462 void processExited(OProcess *proc);
463 463
464 464
465 /** 465 /**
466 * Emitted, when output from the child process has 466 * Emitted, when output from the child process has
467 * been received on stdout. 467 * been received on stdout.
468 * 468 *
469 * To actually get 469 * To actually get
470 * these signals, the respective communication link (stdout/stderr) 470 * these signals, the respective communication link (stdout/stderr)
471 * has to be turned on in @ref start(). 471 * has to be turned on in @ref start().
472 * 472 *
473 * @param buffer The data received. 473 * @param buffer The data received.
474 * @param buflen The number of bytes that are available. 474 * @param buflen The number of bytes that are available.
475 * 475 *
476 * You should copy the information contained in @p buffer to your private 476 * You should copy the information contained in @p buffer to your private
477 * data structures before returning from this slot. 477 * data structures before returning from this slot.
478 **/ 478 **/
479 void receivedStdout(OProcess *proc, char *buffer, int buflen); 479 void receivedStdout(OProcess *proc, char *buffer, int buflen);
480 480
481 /** 481 /**
482 * Emitted when output from the child process has 482 * Emitted when output from the child process has
483 * been received on stdout. 483 * been received on stdout.
484 * 484 *
485 * To actually get these signals, the respective communications link 485 * To actually get these signals, the respective communications link
486 * (stdout/stderr) has to be turned on in @ref start() and the 486 * (stdout/stderr) has to be turned on in @ref start() and the
487 * @p NoRead flag should have been passed. 487 * @p NoRead flag should have been passed.
488 * 488 *
489 * You will need to explicitly call resume() after your call to start() 489 * You will need to explicitly call resume() after your call to start()
490 * to begin processing data from the child process's stdout. This is 490 * to begin processing data from the child process's stdout. This is
491 * to ensure that this signal is not emitted when no one is connected 491 * to ensure that this signal is not emitted when no one is connected
492 * to it, otherwise this signal will not be emitted. 492 * to it, otherwise this signal will not be emitted.
493 * 493 *
494 * The data still has to be read from file descriptor @p fd. 494 * The data still has to be read from file descriptor @p fd.
495 **/ 495 **/
496 void receivedStdout(int fd, int &len); 496 void receivedStdout(int fd, int &len);
497 497
498 498
499 /** 499 /**
500 * Emitted, when output from the child process has 500 * Emitted, when output from the child process has
501 * been received on stderr. 501 * been received on stderr.
502 * To actually get 502 * To actually get
503 * these signals, the respective communication link (stdout/stderr) 503 * these signals, the respective communication link (stdout/stderr)
504 * has to be turned on in @ref start(). 504 * has to be turned on in @ref start().
505 * 505 *
506 * @param buffer The data received. 506 * @param buffer The data received.
507 * @param buflen The number of bytes that are available. 507 * @param buflen The number of bytes that are available.
508 * 508 *
509 * You should copy the information contained in @p buffer to your private 509 * You should copy the information contained in @p buffer to your private
510 * data structures before returning from this slot. 510 * data structures before returning from this slot.
511 */ 511 */
512 void receivedStderr(OProcess *proc, char *buffer, int buflen); 512 void receivedStderr(OProcess *proc, char *buffer, int buflen);
513 513
514 /** 514 /**
515 * Emitted after all the data that has been 515 * Emitted after all the data that has been
516 * specified by a prior call to @ref writeStdin() has actually been 516 * specified by a prior call to @ref writeStdin() has actually been
517 * written to the child process. 517 * written to the child process.
518 **/ 518 **/
519 void wroteStdin(OProcess *proc); 519 void wroteStdin(OProcess *proc);
520 520
521 521
522protected slots: 522protected slots:
523 523
524 /** 524 /**
525 * This slot gets activated when data from the child's stdout arrives. 525 * This slot gets activated when data from the child's stdout arrives.
526 * It usually calls "childOutput" 526 * It usually calls "childOutput"
527 */ 527 */
528 void slotChildOutput(int fdno); 528 void slotChildOutput(int fdno);
529 529
530 /** 530 /**
531 * This slot gets activated when data from the child's stderr arrives. 531 * This slot gets activated when data from the child's stderr arrives.
532 * It usually calls "childError" 532 * It usually calls "childError"
533 */ 533 */
534 void slotChildError(int fdno); 534 void slotChildError(int fdno);
535 /* 535 /*
536 Slot functions for capturing stdout and stderr of the child 536 Slot functions for capturing stdout and stderr of the child
537 */ 537 */
538 538
539 /** 539 /**
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp
index 6b10ec2..1e40c40 100644
--- a/libopie/tododb.cpp
+++ b/libopie/tododb.cpp
@@ -1,258 +1,266 @@
1 1
2#include <qdir.h> 2#include <qdir.h>
3#include <opie/tododb.h> 3#include <opie/tododb.h>
4#include <opie/xmltree.h> 4#include <opie/xmltree.h>
5#include <opie/todoresource.h> 5#include <opie/todoresource.h>
6#include <qpe/palmtoprecord.h> 6#include <qpe/palmtoprecord.h>
7#include <qpe/global.h> 7#include <qpe/global.h>
8 8
9using namespace Opie; 9using namespace Opie;
10 10
11namespace { 11namespace {
12 12
13class FileToDoResource : public ToDoResource { 13class FileToDoResource : public ToDoResource {
14public: 14public:
15 FileToDoResource() {}; 15 FileToDoResource() {};
16 // FIXME better parsing 16 // FIXME better parsing
17 bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){ 17 bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){
18 // prepare the XML 18 // prepare the XML
19 XMLElement *tasks = new XMLElement( ); 19 XMLElement *tasks = new XMLElement( );
20 tasks->setTagName("Tasks" ); 20 tasks->setTagName("Tasks" );
21 for( QValueList<ToDoEvent>::ConstIterator it = m_todos.begin(); it != m_todos.end(); ++it ){ 21 for( QValueList<ToDoEvent>::ConstIterator it = m_todos.begin(); it != m_todos.end(); ++it ){
22 XMLElement::AttributeMap map; 22 XMLElement::AttributeMap map;
23 XMLElement *task = new XMLElement(); 23 XMLElement *task = new XMLElement();
24 map.insert( "Completed", QString::number((int)(*it).isCompleted() ) ); 24 map.insert( "Completed", QString::number((int)(*it).isCompleted() ) );
25 map.insert( "HasDate", QString::number((int)(*it).hasDate() ) ); 25 map.insert( "HasDate", QString::number((int)(*it).hasDate() ) );
26 map.insert( "Priority", QString::number( (*it).priority() ) ); 26 map.insert( "Priority", QString::number( (*it).priority() ) );
27 map.insert( "Progress", QString::number( (*it).progress() ) );
27 map.insert( "Summary", (*it).summary() ); 28 map.insert( "Summary", (*it).summary() );
28 QArray<int> arrat = (*it).categories(); 29 QArray<int> arrat = (*it).categories();
29 QString attr; 30 QString attr;
30 for(uint i=0; i < arrat.count(); i++ ){ 31 for(uint i=0; i < arrat.count(); i++ ){
31 attr.append(QString::number(arrat[i])+";" ); 32 attr.append(QString::number(arrat[i])+";" );
32 } 33 }
33 if(!attr.isEmpty() ) // remove the last ; 34 if(!attr.isEmpty() ) // remove the last ;
34 attr.remove(attr.length()-1, 1 ); 35 attr.remove(attr.length()-1, 1 );
35 map.insert( "Categories", attr ); 36 map.insert( "Categories", attr );
36 //else 37 //else
37 //map.insert( "Categories", QString::null ); 38 //map.insert( "Categories", QString::null );
38 map.insert( "Description", (*it).description() ); 39 map.insert( "Description", (*it).description() );
39 if( (*it).hasDate() ){ 40 if( (*it).hasDate() ){
40 map.insert("DateYear", QString::number( (*it).date().year() ) ); 41 map.insert("DateYear", QString::number( (*it).date().year() ) );
41 map.insert("DateMonth", QString::number( (*it).date().month() ) ); 42 map.insert("DateMonth", QString::number( (*it).date().month() ) );
42 map.insert("DateDay", QString::number( (*it).date().day() ) ); 43 map.insert("DateDay", QString::number( (*it).date().day() ) );
43 } 44 }
44 map.insert("Uid", QString::number( (*it).uid() ) ); 45 map.insert("Uid", QString::number( (*it).uid() ) );
45 task->setTagName("Task" ); 46 task->setTagName("Task" );
46 task->setAttributes( map ); 47 task->setAttributes( map );
47 tasks->appendChild(task); 48 tasks->appendChild(task);
48 } 49 }
49 QFile file( name); 50 QFile file( name);
50 if( file.open(IO_WriteOnly ) ){ 51 if( file.open(IO_WriteOnly ) ){
51 QTextStream stream(&file ); 52 QTextStream stream(&file );
52 stream.setEncoding( QTextStream::UnicodeUTF8 ); 53 stream.setEncoding( QTextStream::UnicodeUTF8 );
53 stream << "<!DOCTYPE Tasks>" << endl; 54 stream << "<!DOCTYPE Tasks>" << endl;
54 tasks->save(stream ); 55 tasks->save(stream );
55 delete tasks; 56 delete tasks;
56 stream << "</Tasks>" << endl; 57 stream << "</Tasks>" << endl;
57 file.close(); 58 file.close();
58 return true; 59 return true;
59 } 60 }
60 return false; 61 return false;
61 } 62 }
62 QValueList<ToDoEvent> load( const QString &name ){ 63 QValueList<ToDoEvent> load( const QString &name ){
63 qWarning("loading tododb" ); 64 qWarning("loading tododb" );
64 QValueList<ToDoEvent> m_todos; 65 QValueList<ToDoEvent> m_todos;
65 XMLElement *root = XMLElement::load( name ); 66 XMLElement *root = XMLElement::load( name );
66 if(root != 0l ){ // start parsing 67 if(root != 0l ){ // start parsing
67 qWarning("ToDoDB::load tagName(): %s", root->tagName().latin1() ); 68 qWarning("ToDoDB::load tagName(): %s", root->tagName().latin1() );
68 //if( root->tagName() == QString::fromLatin1("Tasks" ) ){// Start 69 //if( root->tagName() == QString::fromLatin1("Tasks" ) ){// Start
69 XMLElement *element = root->firstChild(); 70 XMLElement *element = root->firstChild();
70 element = element->firstChild(); 71 element = element->firstChild();
71 while( element ){ 72 while( element ){
72 if( element->tagName() != QString::fromLatin1("Task") ){ 73 if( element->tagName() != QString::fromLatin1("Task") ){
73 element = element->nextChild(); 74 element = element->nextChild();
74 continue; 75 continue;
75 } 76 }
76 qWarning("ToDoDB::load element tagName() : %s", element->tagName().latin1() ); 77 qWarning("ToDoDB::load element tagName() : %s", element->tagName().latin1() );
77 QString dummy; 78 QString dummy;
78 ToDoEvent event; 79 ToDoEvent event;
79 bool ok; 80 bool ok;
80 int dumInt; 81 int dumInt;
81 // completed 82 // completed
82 dummy = element->attribute("Completed" ); 83 dummy = element->attribute("Completed" );
83 dumInt = dummy.toInt(&ok ); 84 dumInt = dummy.toInt(&ok );
84 if(ok ) event.setCompleted( dumInt == 0 ? false : true ); 85 if(ok ) event.setCompleted( dumInt == 0 ? false : true );
86 // progress
87 dummy = element->attribute("Progress" );
88 {
89 ushort dumShort = dummy.toUShort(&ok);
90 event.setProgress( dumShort );
91
92 }
85 // hasDate 93 // hasDate
86 dummy = element->attribute("HasDate" ); 94 dummy = element->attribute("HasDate" );
87 dumInt = dummy.toInt(&ok ); 95 dumInt = dummy.toInt(&ok );
88 if(ok ) event.setHasDate( dumInt == 0 ? false: true ); 96 if(ok ) event.setHasDate( dumInt == 0 ? false: true );
89 // set the date 97 // set the date
90 bool hasDa = dumInt; 98 bool hasDa = dumInt;
91 if ( hasDa ) { //parse the date 99 if ( hasDa ) { //parse the date
92 int year, day, month = 0; 100 int year, day, month = 0;
93 year = day = month; 101 year = day = month;
94 // year 102 // year
95 dummy = element->attribute("DateYear" ); 103 dummy = element->attribute("DateYear" );
96 dumInt = dummy.toInt(&ok ); 104 dumInt = dummy.toInt(&ok );
97 if( ok ) year = dumInt; 105 if( ok ) year = dumInt;
98 // month 106 // month
99 dummy = element->attribute("DateMonth" ); 107 dummy = element->attribute("DateMonth" );
100 dumInt = dummy.toInt(&ok ); 108 dumInt = dummy.toInt(&ok );
101 if(ok ) month = dumInt; 109 if(ok ) month = dumInt;
102 dummy = element->attribute("DateDay" ); 110 dummy = element->attribute("DateDay" );
103 dumInt = dummy.toInt(&ok ); 111 dumInt = dummy.toInt(&ok );
104 if(ok ) day = dumInt; 112 if(ok ) day = dumInt;
105 // set the date 113 // set the date
106 QDate date( year, month, day ); 114 QDate date( year, month, day );
107 event.setDate( date); 115 event.setDate( date);
108 } 116 }
109 dummy = element->attribute("Priority" ); 117 dummy = element->attribute("Priority" );
110 dumInt = dummy.toInt(&ok ); 118 dumInt = dummy.toInt(&ok );
111 if(!ok ) dumInt = ToDoEvent::NORMAL; 119 if(!ok ) dumInt = ToDoEvent::NORMAL;
112 event.setPriority( dumInt ); 120 event.setPriority( dumInt );
113 //description 121 //description
114 dummy = element->attribute("Description" ); 122 dummy = element->attribute("Description" );
115 event.setDescription( dummy ); 123 event.setDescription( dummy );
116 dummy = element->attribute("Summary" ); 124 dummy = element->attribute("Summary" );
117 event.setSummary( dummy ); 125 event.setSummary( dummy );
118 // category 126 // category
119 dummy = element->attribute("Categories" ); 127 dummy = element->attribute("Categories" );
120 QStringList ids = QStringList::split(";", dummy ); 128 QStringList ids = QStringList::split(";", dummy );
121 event.setCategories( ids ); 129 event.setCategories( ids );
122 130
123 //uid 131 //uid
124 dummy = element->attribute("Uid" ); 132 dummy = element->attribute("Uid" );
125 dumInt = dummy.toInt(&ok ); 133 dumInt = dummy.toInt(&ok );
126 if(ok ) event.setUid( dumInt ); 134 if(ok ) event.setUid( dumInt );
127 m_todos.append( event ); 135 m_todos.append( event );
128 element = element->nextChild(); // next element 136 element = element->nextChild(); // next element
129 } 137 }
130 //} 138 //}
131 }else { 139 }else {
132 qWarning("could not load" ); 140 qWarning("could not load" );
133 } 141 }
134 delete root; 142 delete root;
135 qWarning("returning" ); 143 qWarning("returning" );
136 return m_todos; 144 return m_todos;
137 } 145 }
138}; 146};
139 147
140} 148}
141 149
142ToDoDB::ToDoDB(const QString &fileName, ToDoResource *res ){ 150ToDoDB::ToDoDB(const QString &fileName, ToDoResource *res ){
143 m_fileName = fileName; 151 m_fileName = fileName;
144 if( fileName.isEmpty() && res == 0 ){ 152 if( fileName.isEmpty() && res == 0 ){
145 m_fileName = Global::applicationFileName("todolist","todolist.xml"); 153 m_fileName = Global::applicationFileName("todolist","todolist.xml");
146 res = new FileToDoResource(); 154 res = new FileToDoResource();
147 //qWarning("%s", m_fileName.latin1() ); 155 //qWarning("%s", m_fileName.latin1() );
148 }else if(res == 0 ){ // let's create a ToDoResource for xml 156 }else if(res == 0 ){ // let's create a ToDoResource for xml
149 res = new FileToDoResource(); 157 res = new FileToDoResource();
150 } 158 }
151 m_res = res; 159 m_res = res;
152 load(); 160 load();
153} 161}
154ToDoResource* ToDoDB::resource(){ 162ToDoResource* ToDoDB::resource(){
155 return m_res; 163 return m_res;
156}; 164};
157void ToDoDB::setResource( ToDoResource *res ) 165void ToDoDB::setResource( ToDoResource *res )
158{ 166{
159 delete m_res; 167 delete m_res;
160 m_res = res; 168 m_res = res;
161} 169}
162ToDoDB::~ToDoDB() 170ToDoDB::~ToDoDB()
163{ 171{
164 delete m_res; 172 delete m_res;
165} 173}
166QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, const QDate &to, 174QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, const QDate &to,
167 bool all ) 175 bool all )
168{ 176{
169 QValueList<ToDoEvent> events; 177 QValueList<ToDoEvent> events;
170 for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ 178 for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){
171 if( (*it).hasDate() ){ 179 if( (*it).hasDate() ){
172 if( (*it).date() >= from && (*it).date() <= to ) 180 if( (*it).date() >= from && (*it).date() <= to )
173 events.append( (*it) ); 181 events.append( (*it) );
174 }else if( all ){ 182 }else if( all ){
175 events.append( (*it) ); 183 events.append( (*it) );
176 } 184 }
177 } 185 }
178 return events; 186 return events;
179} 187}
180QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from, 188QValueList<ToDoEvent> ToDoDB::effectiveToDos(const QDate &from,
181 bool all) 189 bool all)
182{ 190{
183 return effectiveToDos( from, QDate::currentDate(), all ); 191 return effectiveToDos( from, QDate::currentDate(), all );
184} 192}
185QValueList<ToDoEvent> ToDoDB::overDue() 193QValueList<ToDoEvent> ToDoDB::overDue()
186{ 194{
187 QValueList<ToDoEvent> events; 195 QValueList<ToDoEvent> events;
188 for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){ 196 for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){
189 if( (*it).isOverdue() ) 197 if( (*it).isOverdue() )
190 events.append((*it) ); 198 events.append((*it) );
191 } 199 }
192 return events; 200 return events;
193} 201}
194QValueList<ToDoEvent> ToDoDB::rawToDos() 202QValueList<ToDoEvent> ToDoDB::rawToDos()
195{ 203{
196 return m_todos; 204 return m_todos;
197} 205}
198void ToDoDB::addEvent( const ToDoEvent &event ) 206void ToDoDB::addEvent( const ToDoEvent &event )
199{ 207{
200 m_todos.append( event ); 208 m_todos.append( event );
201} 209}
202void ToDoDB::editEvent( const ToDoEvent &event ) 210void ToDoDB::editEvent( const ToDoEvent &event )
203{ 211{
204 m_todos.remove( event ); 212 m_todos.remove( event );
205 m_todos.append( event ); 213 m_todos.append( event );
206} 214}
207void ToDoDB::removeEvent( const ToDoEvent &event ) 215void ToDoDB::removeEvent( const ToDoEvent &event )
208{ 216{
209 m_todos.remove( event ); 217 m_todos.remove( event );
210} 218}
211void ToDoDB::replaceEvent(const ToDoEvent &event ) 219void ToDoDB::replaceEvent(const ToDoEvent &event )
212{ 220{
213 QValueList<ToDoEvent>::Iterator it; 221 QValueList<ToDoEvent>::Iterator it;
214 int uid = event.uid(); 222 int uid = event.uid();
215 // == is not overloaded as we would like :( so let's search for the uid 223 // == is not overloaded as we would like :( so let's search for the uid
216 for(it = m_todos.begin(); it != m_todos.end(); ++it ){ 224 for(it = m_todos.begin(); it != m_todos.end(); ++it ){
217 if( (*it).uid() == uid ){ 225 if( (*it).uid() == uid ){
218 m_todos.remove( (*it) ); 226 m_todos.remove( (*it) );
219 break; // should save us the iterate is now borked 227 break; // should save us the iterate is now borked
220 } 228 }
221 } 229 }
222 m_todos.append(event); 230 m_todos.append(event);
223} 231}
224void ToDoDB::reload() 232void ToDoDB::reload()
225{ 233{
226 load(); 234 load();
227} 235}
228void ToDoDB::mergeWith(const QValueList<ToDoEvent>& events ) 236void ToDoDB::mergeWith(const QValueList<ToDoEvent>& events )
229{ 237{
230 QValueList<ToDoEvent>::ConstIterator it; 238 QValueList<ToDoEvent>::ConstIterator it;
231 for( it = events.begin(); it != events.end(); ++it ){ 239 for( it = events.begin(); it != events.end(); ++it ){
232 replaceEvent( (*it) ); 240 replaceEvent( (*it) );
233 } 241 }
234} 242}
235void ToDoDB::setFileName(const QString &file ) 243void ToDoDB::setFileName(const QString &file )
236{ 244{
237 m_fileName =file; 245 m_fileName =file;
238} 246}
239QString ToDoDB::fileName()const 247QString ToDoDB::fileName()const
240{ 248{
241 return m_fileName; 249 return m_fileName;
242} 250}
243void ToDoDB::load() 251void ToDoDB::load()
244{ 252{
245 m_todos = m_res->load( m_fileName ); 253 m_todos = m_res->load( m_fileName );
246} 254}
247bool ToDoDB::save() 255bool ToDoDB::save()
248{ 256{
249 return m_res->save( m_fileName, m_todos ); 257 return m_res->save( m_fileName, m_todos );
250} 258}
251 259
252 260
253 261
254 262
255 263
256 264
257 265
258 266
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp
index fb7073c..b35ac9d 100644
--- a/libopie/todoevent.cpp
+++ b/libopie/todoevent.cpp
@@ -1,269 +1,282 @@
1 1
2#include <opie/todoevent.h> 2#include <opie/todoevent.h>
3 3
4 4
5#include <qpe/palmtopuidgen.h> 5#include <qpe/palmtopuidgen.h>
6#include <qpe/stringutil.h> 6#include <qpe/stringutil.h>
7#include <qpe/palmtoprecord.h> 7#include <qpe/palmtoprecord.h>
8 8
9#include <qpe/stringutil.h> 9#include <qpe/stringutil.h>
10#include <qpe/categories.h> 10#include <qpe/categories.h>
11#include <qpe/categoryselect.h> 11#include <qpe/categoryselect.h>
12 12
13#include <qobject.h> 13#include <qobject.h>
14 14
15ToDoEvent::ToDoEvent(const ToDoEvent &event ) 15ToDoEvent::ToDoEvent(const ToDoEvent &event )
16{ 16{
17 *this = event; 17 *this = event;
18} 18}
19 19
20ToDoEvent::ToDoEvent(bool completed, int priority, 20ToDoEvent::ToDoEvent(bool completed, int priority,
21 const QStringList &category, 21 const QStringList &category,
22 const QString& summary, 22 const QString& summary,
23 const QString &description, 23 const QString &description,
24 ushort progress,
24 bool hasDate, QDate date, int uid ) 25 bool hasDate, QDate date, int uid )
25{ 26{
26 m_date = date; 27 m_date = date;
27 m_isCompleted = completed; 28 m_isCompleted = completed;
28 m_hasDate = hasDate; 29 m_hasDate = hasDate;
29 m_priority = priority; 30 m_priority = priority;
30 m_category = category; 31 m_category = category;
31 m_sum = summary; 32 m_sum = summary;
33 m_prog = progress;
32 m_desc = Qtopia::simplifyMultiLineSpace(description ); 34 m_desc = Qtopia::simplifyMultiLineSpace(description );
33 if (uid == -1 ) { 35 if (uid == -1 ) {
34 Qtopia::UidGen *uidgen = new Qtopia::UidGen(); 36 Qtopia::UidGen *uidgen = new Qtopia::UidGen();
35 uid = uidgen->generate(); 37 uid = uidgen->generate();
36 delete uidgen; 38 delete uidgen;
37 }// generate the ids 39 }// generate the ids
38 m_uid = uid; 40 m_uid = uid;
39} 41}
40QArray<int> ToDoEvent::categories()const 42QArray<int> ToDoEvent::categories()const
41{ 43{
42 QArray<int> array(m_category.count() ); // currently the datebook can be only in one category 44 QArray<int> array(m_category.count() ); // currently the datebook can be only in one category
43 array = Qtopia::Record::idsFromString( m_category.join(";") ); 45 array = Qtopia::Record::idsFromString( m_category.join(";") );
44 return array; 46 return array;
45} 47}
46bool ToDoEvent::match( const QRegExp &regExp )const 48bool ToDoEvent::match( const QRegExp &regExp )const
47{ 49{
48 if( QString::number( m_priority ).find( regExp ) != -1 ){ 50 if( QString::number( m_priority ).find( regExp ) != -1 ){
49 return true; 51 return true;
50 }else if( m_hasDate && m_date.toString().find( regExp) != -1 ){ 52 }else if( m_hasDate && m_date.toString().find( regExp) != -1 ){
51 return true; 53 return true;
52 }else if(m_desc.find( regExp ) != -1 ){ 54 }else if(m_desc.find( regExp ) != -1 ){
53 return true; 55 return true;
54 } 56 }
55 return false; 57 return false;
56} 58}
57bool ToDoEvent::isCompleted() const 59bool ToDoEvent::isCompleted() const
58{ 60{
59 return m_isCompleted; 61 return m_isCompleted;
60} 62}
61bool ToDoEvent::hasDate() const 63bool ToDoEvent::hasDate() const
62{ 64{
63 return m_hasDate; 65 return m_hasDate;
64} 66}
65int ToDoEvent::priority()const 67int ToDoEvent::priority()const
66{ 68{
67 return m_priority; 69 return m_priority;
68} 70}
69QStringList ToDoEvent::allCategories()const 71QStringList ToDoEvent::allCategories()const
70{ 72{
71 return m_category; 73 return m_category;
72} 74}
73QString ToDoEvent::extra(const QString& )const 75QString ToDoEvent::extra(const QString& )const
74{ 76{
75 return QString::null; 77 return QString::null;
76} 78}
77QString ToDoEvent::summary() const 79QString ToDoEvent::summary() const
78{ 80{
79 return m_sum; 81 return m_sum;
80} 82}
83ushort ToDoEvent::progress() const
84{
85 return m_prog;
86}
81void ToDoEvent::insertCategory(const QString &str ) 87void ToDoEvent::insertCategory(const QString &str )
82{ 88{
83 m_category.append( str ); 89 m_category.append( str );
84} 90}
85void ToDoEvent::clearCategories() 91void ToDoEvent::clearCategories()
86{ 92{
87 m_category.clear(); 93 m_category.clear();
88} 94}
89void ToDoEvent::setCategories(const QStringList &list ) 95void ToDoEvent::setCategories(const QStringList &list )
90{ 96{
91 m_category = list; 97 m_category = list;
92} 98}
93QDate ToDoEvent::date()const 99QDate ToDoEvent::date()const
94{ 100{
95 return m_date; 101 return m_date;
96} 102}
97 103
98QString ToDoEvent::description()const 104QString ToDoEvent::description()const
99{ 105{
100 return m_desc; 106 return m_desc;
101} 107}
102void ToDoEvent::setCompleted( bool completed ) 108void ToDoEvent::setCompleted( bool completed )
103{ 109{
104 m_isCompleted = completed; 110 m_isCompleted = completed;
105} 111}
106void ToDoEvent::setHasDate( bool hasDate ) 112void ToDoEvent::setHasDate( bool hasDate )
107{ 113{
108 m_hasDate = hasDate; 114 m_hasDate = hasDate;
109} 115}
110void ToDoEvent::setDescription(const QString &desc ) 116void ToDoEvent::setDescription(const QString &desc )
111{ 117{
112 m_desc = Qtopia::simplifyMultiLineSpace(desc ); 118 m_desc = Qtopia::simplifyMultiLineSpace(desc );
113} 119}
114void ToDoEvent::setExtra( const QString&, const QString& ) 120void ToDoEvent::setExtra( const QString&, const QString& )
115{ 121{
116 122
117} 123}
118void ToDoEvent::setSummary( const QString& sum ) 124void ToDoEvent::setSummary( const QString& sum )
119{ 125{
120 m_sum = sum; 126 m_sum = sum;
121} 127}
122void ToDoEvent::setCategory( const QString &cat ) 128void ToDoEvent::setCategory( const QString &cat )
123{ 129{
124 qWarning("setCategory %s", cat.latin1() ); 130 qWarning("setCategory %s", cat.latin1() );
125 m_category.clear(); 131 m_category.clear();
126 m_category << cat; 132 m_category << cat;
127} 133}
128void ToDoEvent::setPriority(int prio ) 134void ToDoEvent::setPriority(int prio )
129{ 135{
130 m_priority = prio; 136 m_priority = prio;
131} 137}
132void ToDoEvent::setDate( QDate date ) 138void ToDoEvent::setDate( QDate date )
133{ 139{
134 m_date = date; 140 m_date = date;
135} 141}
136bool ToDoEvent::isOverdue( ) 142bool ToDoEvent::isOverdue( )
137{ 143{
138 if( m_hasDate ) 144 if( m_hasDate )
139 return QDate::currentDate() > m_date; 145 return QDate::currentDate() > m_date;
140 return false; 146 return false;
141} 147}
142 148void ToDoEvent::setProgress(ushort progress )
149{
150 m_prog = progress;
151}
143/*! 152/*!
144 Returns a richt text string 153 Returns a richt text string
145*/ 154*/
146QString ToDoEvent::richText() const 155QString ToDoEvent::richText() const
147{ 156{
148 QString text; 157 QString text;
149 QStringList catlist; 158 QStringList catlist;
150 159
151 // Description of the todo 160 // Description of the todo
152 if ( !description().isEmpty() ){ 161 if ( !description().isEmpty() ){
153 text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; 162 text += "<b>" + QObject::tr( "Summary:") + "</b><br>";
154 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 163 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
155 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 164 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
156 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 165 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br><br><br>";
157 } 166 }
158 text += "<b>" + QObject::tr( "Priority:") +" </b>" 167 text += "<b>" + QObject::tr( "Priority:") +" </b>"
159 + QString::number( priority() ) + "<br>"; 168 + QString::number( priority() ) + " <br>";
169 text += "<b>" + QObject::tr( "Progress:") + " </b>"
170 + QString::number( progress() ) + " %<br>";
160 if (hasDate() ){ 171 if (hasDate() ){
161 text += "<b>" + QObject::tr( "Deadline:") + " </b>"; 172 text += "<b>" + QObject::tr( "Deadline:") + " </b>";
162 text += date().toString(); 173 text += date().toString();
163 text += "<br>"; 174 text += "<br>";
164 } 175 }
165 176
166 // Open database of all categories and get the list of 177 // Open database of all categories and get the list of
167 // the categories this todoevent belongs to. 178 // the categories this todoevent belongs to.
168 // Then print them... 179 // Then print them...
169 // I am not sure whether there is no better way doing this !? 180 // I am not sure whether there is no better way doing this !?
170 Categories catdb; 181 Categories catdb;
171 bool firstloop = true; 182 bool firstloop = true;
172 catdb.load( categoryFileName() ); 183 catdb.load( categoryFileName() );
173 catlist = allCategories(); 184 catlist = allCategories();
174 185
175 text += "<b>" + QObject::tr( "Category:") + "</b> "; 186 text += "<b>" + QObject::tr( "Category:") + "</b> ";
176 for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) { 187 for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) {
177 if (!firstloop){ 188 if (!firstloop){
178 text += ", "; 189 text += ", ";
179 } 190 }
180 firstloop = false; 191 firstloop = false;
181 text += catdb.label ("todo", (*it).toInt()); 192 text += catdb.label ("todo", (*it).toInt());
182 } 193 }
183 text += "<br>"; 194 text += "<br>";
184 return text; 195 return text;
185} 196}
186 197
187bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ 198bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{
188 if( !hasDate() && !toDoEvent.hasDate() ) return true; 199 if( !hasDate() && !toDoEvent.hasDate() ) return true;
189 if( !hasDate() && toDoEvent.hasDate() ) return true; 200 if( !hasDate() && toDoEvent.hasDate() ) return false;
190 if( hasDate() && toDoEvent.hasDate() ){ 201 if( hasDate() && toDoEvent.hasDate() ){
191 if( date() == toDoEvent.date() ){ // let's the priority decide 202 if( date() == toDoEvent.date() ){ // let's the priority decide
192 return priority() < toDoEvent.priority(); 203 return priority() < toDoEvent.priority();
193 }else{ 204 }else{
194 return date() < toDoEvent.date(); 205 return date() < toDoEvent.date();
195 } 206 }
196 } 207 }
197 return false; 208 return false;
198} 209}
199bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const 210bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const
200{ 211{
201 if( !hasDate() && !toDoEvent.hasDate() ) return true; 212 if( !hasDate() && !toDoEvent.hasDate() ) return true;
202 if( !hasDate() && toDoEvent.hasDate() ) return true; 213 if( !hasDate() && toDoEvent.hasDate() ) return true;
203 if( hasDate() && toDoEvent.hasDate() ){ 214 if( hasDate() && toDoEvent.hasDate() ){
204 if( date() == toDoEvent.date() ){ // let's the priority decide 215 if( date() == toDoEvent.date() ){ // let's the priority decide
205 return priority() <= toDoEvent.priority(); 216 return priority() <= toDoEvent.priority();
206 }else{ 217 }else{
207 return date() <= toDoEvent.date(); 218 return date() <= toDoEvent.date();
208 } 219 }
209 } 220 }
210 return true; 221 return true;
211} 222}
212bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const 223bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const
213{ 224{
214 if( !hasDate() && !toDoEvent.hasDate() ) return false; 225 if( !hasDate() && !toDoEvent.hasDate() ) return false;
215 if( !hasDate() && toDoEvent.hasDate() ) return false; 226 if( !hasDate() && toDoEvent.hasDate() ) return false;
216 if( hasDate() && toDoEvent.hasDate() ){ 227 if( hasDate() && toDoEvent.hasDate() ){
217 if( date() == toDoEvent.date() ){ // let's the priority decide 228 if( date() == toDoEvent.date() ){ // let's the priority decide
218 return priority() > toDoEvent.priority(); 229 return priority() > toDoEvent.priority();
219 }else{ 230 }else{
220 return date() > toDoEvent.date(); 231 return date() > toDoEvent.date();
221 } 232 }
222 } 233 }
223 return false; 234 return false;
224} 235}
225bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const 236bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const
226{ 237{
227 if( !hasDate() && !toDoEvent.hasDate() ) return true; 238 if( !hasDate() && !toDoEvent.hasDate() ) return true;
228 if( !hasDate() && toDoEvent.hasDate() ) return false; 239 if( !hasDate() && toDoEvent.hasDate() ) return false;
229 if( hasDate() && toDoEvent.hasDate() ){ 240 if( hasDate() && toDoEvent.hasDate() ){
230 if( date() == toDoEvent.date() ){ // let's the priority decide 241 if( date() == toDoEvent.date() ){ // let's the priority decide
231 return priority() > toDoEvent.priority(); 242 return priority() > toDoEvent.priority();
232 }else{ 243 }else{
233 return date() > toDoEvent.date(); 244 return date() > toDoEvent.date();
234 } 245 }
235 } 246 }
236 return true; 247 return true;
237} 248}
238bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const 249bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const
239{ 250{
240 if( m_priority == toDoEvent.m_priority && 251 if( m_priority == toDoEvent.m_priority &&
252 m_priority == toDoEvent.m_prog &&
241 m_isCompleted == toDoEvent.m_isCompleted && 253 m_isCompleted == toDoEvent.m_isCompleted &&
242 m_hasDate == toDoEvent.m_hasDate && 254 m_hasDate == toDoEvent.m_hasDate &&
243 m_date == toDoEvent.m_date && 255 m_date == toDoEvent.m_date &&
244 m_category == toDoEvent.m_category && 256 m_category == toDoEvent.m_category &&
245 m_sum == toDoEvent.m_sum && 257 m_sum == toDoEvent.m_sum &&
246 m_desc == toDoEvent.m_desc ) 258 m_desc == toDoEvent.m_desc )
247 return true; 259 return true;
248 return false; 260 return false;
249} 261}
250ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) 262ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item )
251{ 263{
252 m_date = item.m_date; 264 m_date = item.m_date;
253 m_isCompleted = item.m_isCompleted; 265 m_isCompleted = item.m_isCompleted;
254 m_hasDate = item.m_hasDate; 266 m_hasDate = item.m_hasDate;
255 m_priority = item.m_priority; 267 m_priority = item.m_priority;
256 m_category = item.m_category; 268 m_category = item.m_category;
257 m_desc = item.m_desc; 269 m_desc = item.m_desc;
258 m_uid = item.m_uid; 270 m_uid = item.m_uid;
259 m_sum = item.m_sum; 271 m_sum = item.m_sum;
272 m_prog = item.m_prog;
260 return *this; 273 return *this;
261} 274}
262 275
263 276
264 277
265 278
266 279
267 280
268 281
269 282
diff --git a/libopie/todoevent.h b/libopie/todoevent.h
index 7454241..de4623f 100644
--- a/libopie/todoevent.h
+++ b/libopie/todoevent.h
@@ -1,151 +1,162 @@
1 1
2#ifndef todoevent_h 2#ifndef todoevent_h
3#define todoevent_h 3#define todoevent_h
4 4
5#include <qmap.h> 5#include <qmap.h>
6#include <qregexp.h> 6#include <qregexp.h>
7#include <qstringlist.h> 7#include <qstringlist.h>
8#include <qdatetime.h> 8#include <qdatetime.h>
9 9
10class ToDoEvent { 10class ToDoEvent {
11 friend class ToDoDB; 11 friend class ToDoDB;
12 public: 12 public:
13 // priorities from Very low to very high 13 // priorities from Very low to very high
14 enum Priority { VERYHIGH=1, HIGH, NORMAL, LOW, VERYLOW }; 14 enum Priority { VERYHIGH=1, HIGH, NORMAL, LOW, VERYLOW };
15 /* Constructs a new ToDoEvent 15 /* Constructs a new ToDoEvent
16 @param completed Is the TodoEvent completed 16 @param completed Is the TodoEvent completed
17 @param priority What is the priority of this ToDoEvent 17 @param priority What is the priority of this ToDoEvent
18 @param category Which category does it belong( uid ) 18 @param category Which category does it belong( uid )
19 @param summary A small summary of the todo 19 @param summary A small summary of the todo
20 @param description What is this ToDoEvent about 20 @param description What is this ToDoEvent about
21 @param hasDate Does this Event got a deadline 21 @param hasDate Does this Event got a deadline
22 @param date what is the deadline? 22 @param date what is the deadline?
23 @param uid what is the UUID of this Event 23 @param uid what is the UUID of this Event
24 **/ 24 **/
25 ToDoEvent( bool completed = false, int priority = NORMAL, 25 ToDoEvent( bool completed = false, int priority = NORMAL,
26 const QStringList &category = QStringList(), 26 const QStringList &category = QStringList(),
27 const QString &summary = QString::null , 27 const QString &summary = QString::null ,
28 const QString &description = QString::null, 28 const QString &description = QString::null,
29 ushort progress = 0,
29 bool hasDate = false, QDate date = QDate::currentDate(), int uid = -1 ); 30 bool hasDate = false, QDate date = QDate::currentDate(), int uid = -1 );
30 /* Copy c'tor 31 /* Copy c'tor
31 32
32 **/ 33 **/
33 ToDoEvent(const ToDoEvent & ); 34 ToDoEvent(const ToDoEvent & );
34 35
35 /* 36 /*
36 Is this event completed? 37 Is this event completed?
37 **/ 38 **/
38 bool isCompleted() const; 39 bool isCompleted() const;
39 40
40 /* 41 /*
41 Does this Event have a deadline 42 Does this Event have a deadline
42 **/ 43 **/
43 bool hasDate() const; 44 bool hasDate() const;
44 45
45 /* 46 /*
46 What is the priority? 47 What is the priority?
47 **/ 48 **/
48 int priority()const ; 49 int priority()const ;
49 50
51 /**
52 * progress as ushort 0, 20, 40, 60, 80 or 100%
53 */
54 ushort progress() const;
50 /* 55 /*
51 All category numbers as QString in a List 56 All category numbers as QString in a List
52 **/ 57 **/
53 QStringList allCategories()const; 58 QStringList allCategories()const;
54 59
55 /* 60 /*
56 * Same as above but with QArray<int> 61 * Same as above but with QArray<int>
57 */ 62 */
58 QArray<int> categories() const; 63 QArray<int> categories() const;
59 64
60 /** 65 /**
61 * The end Date 66 * The end Date
62 */ 67 */
63 QDate date()const; 68 QDate date()const;
64 69
65 /** 70 /**
66 * The description of the todo 71 * The description of the todo
67 */ 72 */
68 QString description()const; 73 QString description()const;
69 74
70 /** 75 /**
71 * A small summary of the todo 76 * A small summary of the todo
72 */ 77 */
73 QString summary() const; 78 QString summary() const;
74 79
75 /** 80 /**
76 * Return this todoevent in a RichText formatted QString 81 * Return this todoevent in a RichText formatted QString
77 */ 82 */
78 QString richText() const; 83 QString richText() const;
79 84
80 /** 85 /**
81 * Returns the UID of the Todo 86 * Returns the UID of the Todo
82 */ 87 */
83 int uid()const { return m_uid;}; 88 int uid()const { return m_uid;};
84 89
85 90
86 QString extra(const QString& )const; 91 QString extra(const QString& )const;
87 /** 92 /**
88 * Set if this Todo is completed 93 * Set if this Todo is completed
89 */ 94 */
90 void setCompleted(bool completed ); 95 void setCompleted(bool completed );
91 96
92 /** 97 /**
93 * set if this todo got an end data 98 * set if this todo got an end data
94 */ 99 */
95 void setHasDate( bool hasDate ); 100 void setHasDate( bool hasDate );
96 // if the category doesn't exist we will create it 101 // if the category doesn't exist we will create it
97 // this sets the the Category after this call category will be the only category 102 // this sets the the Category after this call category will be the only category
98 void setCategory( const QString &category ); 103 void setCategory( const QString &category );
99 // adds a category to the Categories of this event 104 // adds a category to the Categories of this event
100 void insertCategory(const QString &category ); 105 void insertCategory(const QString &category );
101 106
102 /** 107 /**
103 * Removes this event from all categories 108 * Removes this event from all categories
104 */ 109 */
105 void clearCategories(); 110 void clearCategories();
106 111
107 /** 112 /**
108 * This todo belongs to xxx categories 113 * This todo belongs to xxx categories
109 */ 114 */
110 void setCategories(const QStringList& ); 115 void setCategories(const QStringList& );
111 116
112 /** 117 /**
113 * Set the priority of the Todo 118 * Set the priority of the Todo
114 */ 119 */
115 void setPriority(int priority ); 120 void setPriority(int priority );
116 121
117 /** 122 /**
123 * Set the progress.
124 */
125 void setProgress( ushort progress );
126
127 /**
118 * set the end date 128 * set the end date
119 */ 129 */
120 void setDate( QDate date ); 130 void setDate( QDate date );
121 void setDescription(const QString& ); 131 void setDescription(const QString& );
122 void setSummary(const QString& ); 132 void setSummary(const QString& );
123 void setExtra( const QString&, const QString& ); 133 void setExtra( const QString&, const QString& );
124 bool isOverdue(); 134 bool isOverdue();
125 135
126 bool match( const QRegExp &r )const; 136 bool match( const QRegExp &r )const;
127 137
128 void setUid(int id) {m_uid = id; }; 138 void setUid(int id) {m_uid = id; };
129 bool operator<(const ToDoEvent &toDoEvent )const; 139 bool operator<(const ToDoEvent &toDoEvent )const;
130 bool operator<=(const ToDoEvent &toDoEvent )const; 140 bool operator<=(const ToDoEvent &toDoEvent )const;
131 bool operator!=(const ToDoEvent &toDoEvent )const { return !(*this == toDoEvent); }; 141 bool operator!=(const ToDoEvent &toDoEvent )const { return !(*this == toDoEvent); };
132 bool operator>(const ToDoEvent &toDoEvent )const; 142 bool operator>(const ToDoEvent &toDoEvent )const;
133 bool operator>=(const ToDoEvent &toDoEvent)const; 143 bool operator>=(const ToDoEvent &toDoEvent)const;
134 bool operator==(const ToDoEvent &toDoEvent )const; 144 bool operator==(const ToDoEvent &toDoEvent )const;
135 ToDoEvent &operator=(const ToDoEvent &toDoEvent ); 145 ToDoEvent &operator=(const ToDoEvent &toDoEvent );
136 private: 146 private:
137 class ToDoEventPrivate; 147 class ToDoEventPrivate;
138 ToDoEventPrivate *d; 148 ToDoEventPrivate *d;
139 QDate m_date; 149 QDate m_date;
140 bool m_isCompleted:1; 150 bool m_isCompleted:1;
141 bool m_hasDate:1; 151 bool m_hasDate:1;
142 int m_priority; 152 int m_priority;
143 QStringList m_category; 153 QStringList m_category;
144 QString m_desc; 154 QString m_desc;
145 QString m_sum; 155 QString m_sum;
146 QMap<QString, QString> m_extra; 156 QMap<QString, QString> m_extra;
147 int m_uid; 157 int m_uid;
158 ushort m_prog;
148}; 159};
149 160
150 161
151#endif 162#endif