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,155 +1,155 @@
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 *
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp
index 6b10ec2..1e40c40 100644
--- a/libopie/tododb.cpp
+++ b/libopie/tododb.cpp
@@ -1,212 +1,220 @@
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{
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