summaryrefslogtreecommitdiff
path: root/libopie
Unidiff
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
@@ -15,25 +15,25 @@
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>
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp
index 6b10ec2..1e40c40 100644
--- a/libopie/tododb.cpp
+++ b/libopie/tododb.cpp
@@ -15,24 +15,25 @@ public:
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() );
@@ -73,24 +74,31 @@ public:
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 );
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp
index fb7073c..b35ac9d 100644
--- a/libopie/todoevent.cpp
+++ b/libopie/todoevent.cpp
@@ -12,32 +12,34 @@
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(";") );
@@ -69,24 +71,28 @@ int ToDoEvent::priority()const
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}
@@ -130,42 +136,47 @@ void ToDoEvent::setPriority(int prio )
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;
@@ -177,25 +188,25 @@ QString ToDoEvent::richText() const
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;
@@ -229,41 +240,43 @@ bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const
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
@@ -17,45 +17,50 @@ class ToDoEvent {
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
@@ -106,24 +111,29 @@ class ToDoEvent {
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;
@@ -136,16 +146,17 @@ class 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