summaryrefslogtreecommitdiff
path: root/libopie
authorzecke <zecke>2002-03-21 00:26:39 (UTC)
committer zecke <zecke>2002-03-21 00:26:39 (UTC)
commit8bfe366ce8667addc539f11fc560250c306340ae (patch) (unidiff)
tree4b890a47d86621d3e1f0aacde2485457862f02c8 /libopie
parente8f15a98c611b0c6030e8210672b249b42107526 (diff)
downloadopie-8bfe366ce8667addc539f11fc560250c306340ae.zip
opie-8bfe366ce8667addc539f11fc560250c306340ae.tar.gz
opie-8bfe366ce8667addc539f11fc560250c306340ae.tar.bz2
Move todolist to tododb
Please test todolist
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/todoevent.cpp22
-rw-r--r--libopie/todoevent.h3
2 files changed, 23 insertions, 2 deletions
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp
index daa25f4..7dbf907 100644
--- a/libopie/todoevent.cpp
+++ b/libopie/todoevent.cpp
@@ -1,131 +1,149 @@
1 1
2#include <opie/todoevent.h> 2#include <opie/todoevent.h>
3#include <qpe/palmtopuidgen.h> 3#include <qpe/palmtopuidgen.h>
4#include <qpe/stringutil.h> 4#include <qpe/stringutil.h>
5//#include <qpe/palmtoprecord.h> 5#include <qpe/palmtoprecord.h>
6 6
7ToDoEvent::ToDoEvent(const ToDoEvent &event ) 7ToDoEvent::ToDoEvent(const ToDoEvent &event )
8{ 8{
9 *this = event; 9 *this = event;
10} 10}
11 11
12ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category, 12ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category,
13 const QString &description, bool hasDate, QDate date, int uid ) 13 const QString &description, bool hasDate, QDate date, int uid )
14{ 14{
15 qWarning("todoEvent c'tor" ); 15 qWarning("todoEvent c'tor" );
16 m_date = date; 16 m_date = date;
17 m_isCompleted = completed; 17 m_isCompleted = completed;
18 m_hasDate = hasDate; 18 m_hasDate = hasDate;
19 m_priority = priority; 19 m_priority = priority;
20 m_category = category; 20 m_category = category;
21 m_desc = Qtopia::simplifyMultiLineSpace(description ); 21 m_desc = Qtopia::simplifyMultiLineSpace(description );
22 if (uid == -1 ) { 22 if (uid == -1 ) {
23 Qtopia::UidGen *uidgen = new Qtopia::UidGen(); 23 Qtopia::UidGen *uidgen = new Qtopia::UidGen();
24 uid = uidgen->generate(); 24 uid = uidgen->generate();
25 delete uidgen; 25 delete uidgen;
26 }// generate the ids 26 }// generate the ids
27 m_uid = uid; 27 m_uid = uid;
28} 28}
29QArray<int> ToDoEvent::categories()const
30{
31 QArray<int> array(1); // currently the datebook can be only in one category
32 array = Qtopia::Record::idsFromString( category() );
33 return array;
34}
35bool ToDoEvent::match( const QRegExp &regExp )const
36{
37 if( QString::number( m_priority ).find( regExp ) != -1 ){
38 return true;
39 }else if( m_hasDate && m_date.toString().find( regExp) != -1 ){
40 return true;
41 }else if(m_desc.find( regExp ) != -1 ){
42 return true;
43 }
44 return false;
45}
29bool ToDoEvent::isCompleted() const 46bool ToDoEvent::isCompleted() const
30{ 47{
31 return m_isCompleted; 48 return m_isCompleted;
32} 49}
33bool ToDoEvent::hasDate() const 50bool ToDoEvent::hasDate() const
34{ 51{
35 return m_hasDate; 52 return m_hasDate;
36} 53}
37int ToDoEvent::priority()const 54int ToDoEvent::priority()const
38{ 55{
39 return m_priority; 56 return m_priority;
40} 57}
41QString ToDoEvent::category()const 58QString ToDoEvent::category()const
42{ 59{
43 return m_category; 60 return m_category;
44} 61}
45QDate ToDoEvent::date()const 62QDate ToDoEvent::date()const
46{ 63{
47 return m_date; 64 return m_date;
48} 65}
49QString ToDoEvent::description()const 66QString ToDoEvent::description()const
50{ 67{
51 return m_desc; 68 return m_desc;
52} 69}
53void ToDoEvent::setCompleted( bool completed ) 70void ToDoEvent::setCompleted( bool completed )
54{ 71{
55 m_isCompleted = completed; 72 m_isCompleted = completed;
56} 73}
57void ToDoEvent::setHasDate( bool hasDate ) 74void ToDoEvent::setHasDate( bool hasDate )
58{ 75{
59 m_hasDate = hasDate; 76 m_hasDate = hasDate;
60} 77}
61void ToDoEvent::setDescription(const QString &desc ) 78void ToDoEvent::setDescription(const QString &desc )
62{ 79{
63 m_desc = Qtopia::simplifyMultiLineSpace(desc ); 80 m_desc = Qtopia::simplifyMultiLineSpace(desc );
64} 81}
65void ToDoEvent::setCategory( const QString &cat ) 82void ToDoEvent::setCategory( const QString &cat )
66{ 83{
67 m_category = cat; 84 qWarning("setCategory %s", cat.latin1() );
85 m_category = cat;
68} 86}
69void ToDoEvent::setPriority(int prio ) 87void ToDoEvent::setPriority(int prio )
70{ 88{
71 m_priority = prio; 89 m_priority = prio;
72} 90}
73void ToDoEvent::setDate( QDate date ) 91void ToDoEvent::setDate( QDate date )
74{ 92{
75 m_date = date; 93 m_date = date;
76} 94}
77bool ToDoEvent::isOverdue( ) 95bool ToDoEvent::isOverdue( )
78{ 96{
79 if( m_hasDate ) 97 if( m_hasDate )
80 return QDate::currentDate() > m_date; 98 return QDate::currentDate() > m_date;
81 return false; 99 return false;
82} 100}
83bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ 101bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{
84 if( !hasDate() && !toDoEvent.hasDate() ) return true; 102 if( !hasDate() && !toDoEvent.hasDate() ) return true;
85 if( !hasDate() && toDoEvent.hasDate() ) return true; 103 if( !hasDate() && toDoEvent.hasDate() ) return true;
86 if( hasDate() && toDoEvent.hasDate() ){ 104 if( hasDate() && toDoEvent.hasDate() ){
87 if( date() == toDoEvent.date() ){ // let's the priority decide 105 if( date() == toDoEvent.date() ){ // let's the priority decide
88 return priority() < toDoEvent.priority(); 106 return priority() < toDoEvent.priority();
89 }else{ 107 }else{
90 return date() < toDoEvent.date(); 108 return date() < toDoEvent.date();
91 } 109 }
92 } 110 }
93 return false; 111 return false;
94} 112}
95bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const 113bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const
96{ 114{
97 if( !hasDate() && !toDoEvent.hasDate() ) return true; 115 if( !hasDate() && !toDoEvent.hasDate() ) return true;
98 if( !hasDate() && toDoEvent.hasDate() ) return true; 116 if( !hasDate() && toDoEvent.hasDate() ) return true;
99 if( hasDate() && toDoEvent.hasDate() ){ 117 if( hasDate() && toDoEvent.hasDate() ){
100 if( date() == toDoEvent.date() ){ // let's the priority decide 118 if( date() == toDoEvent.date() ){ // let's the priority decide
101 return priority() <= toDoEvent.priority(); 119 return priority() <= toDoEvent.priority();
102 }else{ 120 }else{
103 return date() <= toDoEvent.date(); 121 return date() <= toDoEvent.date();
104 } 122 }
105 } 123 }
106 return true; 124 return true;
107} 125}
108bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const 126bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const
109{ 127{
110 if( !hasDate() && !toDoEvent.hasDate() ) return false; 128 if( !hasDate() && !toDoEvent.hasDate() ) return false;
111 if( !hasDate() && toDoEvent.hasDate() ) return false; 129 if( !hasDate() && toDoEvent.hasDate() ) return false;
112 if( hasDate() && toDoEvent.hasDate() ){ 130 if( hasDate() && toDoEvent.hasDate() ){
113 if( date() == toDoEvent.date() ){ // let's the priority decide 131 if( date() == toDoEvent.date() ){ // let's the priority decide
114 return priority() > toDoEvent.priority(); 132 return priority() > toDoEvent.priority();
115 }else{ 133 }else{
116 return date() > toDoEvent.date(); 134 return date() > toDoEvent.date();
117 } 135 }
118 } 136 }
119 return false; 137 return false;
120} 138}
121bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const 139bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const
122{ 140{
123 if( !hasDate() && !toDoEvent.hasDate() ) return true; 141 if( !hasDate() && !toDoEvent.hasDate() ) return true;
124 if( !hasDate() && toDoEvent.hasDate() ) return false; 142 if( !hasDate() && toDoEvent.hasDate() ) return false;
125 if( hasDate() && toDoEvent.hasDate() ){ 143 if( hasDate() && toDoEvent.hasDate() ){
126 if( date() == toDoEvent.date() ){ // let's the priority decide 144 if( date() == toDoEvent.date() ){ // let's the priority decide
127 return priority() > toDoEvent.priority(); 145 return priority() > toDoEvent.priority();
128 }else{ 146 }else{
129 return date() > toDoEvent.date(); 147 return date() > toDoEvent.date();
130 } 148 }
131 } 149 }
diff --git a/libopie/todoevent.h b/libopie/todoevent.h
index bca7f6e..ac996a1 100644
--- a/libopie/todoevent.h
+++ b/libopie/todoevent.h
@@ -1,54 +1,57 @@
1 1
2#ifndef todoevent_h 2#ifndef todoevent_h
3#define todoevent_h 3#define todoevent_h
4 4
5#include <qdatetime.h> 5#include <qdatetime.h>
6 6
7class ToDoEvent { 7class ToDoEvent {
8 friend class ToDoDB; 8 friend class ToDoDB;
9 public: 9 public:
10 enum Priority { VERYHIGH=1, HIGH, NORMAL, LOW, VERYLOW }; 10 enum Priority { VERYHIGH=1, HIGH, NORMAL, LOW, VERYLOW };
11 ToDoEvent( bool completed = false, int priority = NORMAL, 11 ToDoEvent( bool completed = false, int priority = NORMAL,
12 const QString &category = QString::null, 12 const QString &category = QString::null,
13 const QString &description = QString::null , 13 const QString &description = QString::null ,
14 bool hasDate = false, QDate date = QDate::currentDate(), int uid = -1 ); 14 bool hasDate = false, QDate date = QDate::currentDate(), int uid = -1 );
15 ToDoEvent(const ToDoEvent & ); 15 ToDoEvent(const ToDoEvent & );
16 bool isCompleted() const; 16 bool isCompleted() const;
17 bool hasDate() const; 17 bool hasDate() const;
18 int priority()const ; 18 int priority()const ;
19 QString category()const; 19 QString category()const;
20 QArray<int> categories() const;
20 QDate date()const; 21 QDate date()const;
21 QString description()const; 22 QString description()const;
22 23
23 int uid()const { return m_uid;}; 24 int uid()const { return m_uid;};
24 void setCompleted(bool completed ); 25 void setCompleted(bool completed );
25 void setHasDate( bool hasDate ); 26 void setHasDate( bool hasDate );
26 // if the category doesn't exist we will create it 27 // if the category doesn't exist we will create it
27 void setCategory( const QString &category ); 28 void setCategory( const QString &category );
28 void setPriority(int priority ); 29 void setPriority(int priority );
29 void setDate( QDate date ); 30 void setDate( QDate date );
30 void setDescription(const QString& ); 31 void setDescription(const QString& );
31 bool isOverdue(); 32 bool isOverdue();
32 33
34 bool match( const QRegExp &r )const;
35
33 void setUid(int id) {m_uid = id; }; 36 void setUid(int id) {m_uid = id; };
34 bool operator<(const ToDoEvent &toDoEvent )const; 37 bool operator<(const ToDoEvent &toDoEvent )const;
35 bool operator<=(const ToDoEvent &toDoEvent )const; 38 bool operator<=(const ToDoEvent &toDoEvent )const;
36 bool operator!=(const ToDoEvent &toDoEvent )const { return !(*this == toDoEvent); }; 39 bool operator!=(const ToDoEvent &toDoEvent )const { return !(*this == toDoEvent); };
37 bool operator>(const ToDoEvent &toDoEvent )const; 40 bool operator>(const ToDoEvent &toDoEvent )const;
38 bool operator>=(const ToDoEvent &toDoEvent)const; 41 bool operator>=(const ToDoEvent &toDoEvent)const;
39 bool operator==(const ToDoEvent &toDoEvent )const; 42 bool operator==(const ToDoEvent &toDoEvent )const;
40 ToDoEvent &operator=(const ToDoEvent &toDoEvent ); 43 ToDoEvent &operator=(const ToDoEvent &toDoEvent );
41 private: 44 private:
42 class ToDoEventPrivate; 45 class ToDoEventPrivate;
43 ToDoEventPrivate *d; 46 ToDoEventPrivate *d;
44 QDate m_date; 47 QDate m_date;
45 bool m_isCompleted:1; 48 bool m_isCompleted:1;
46 bool m_hasDate:1; 49 bool m_hasDate:1;
47 int m_priority; 50 int m_priority;
48 QString m_category; 51 QString m_category;
49 QString m_desc; 52 QString m_desc;
50 int m_uid; 53 int m_uid;
51}; 54};
52 55
53 56
54#endif 57#endif