summaryrefslogtreecommitdiff
path: root/libopie/todoevent.cpp
authorzecke <zecke>2002-04-13 16:27:19 (UTC)
committer zecke <zecke>2002-04-13 16:27:19 (UTC)
commitdef870c6fcccf2b20d7ce3821055391b18243a24 (patch) (unidiff)
tree006357788654cf0e18c76640bd821cf87731d952 /libopie/todoevent.cpp
parente42465b45553f51cf7c7d24130aa3a90a6be3ddd (diff)
downloadopie-def870c6fcccf2b20d7ce3821055391b18243a24.zip
opie-def870c6fcccf2b20d7ce3821055391b18243a24.tar.gz
opie-def870c6fcccf2b20d7ce3821055391b18243a24.tar.bz2
multiple categories
Diffstat (limited to 'libopie/todoevent.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/todoevent.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp
index 7dbf907..28b2e98 100644
--- a/libopie/todoevent.cpp
+++ b/libopie/todoevent.cpp
@@ -1,117 +1,132 @@
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 QStringList &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 29QArray<int> ToDoEvent::categories()const
30{ 30{
31 QArray<int> array(1); // currently the datebook can be only in one category 31 QArray<int> array(m_category.count() ); // currently the datebook can be only in one category
32 array = Qtopia::Record::idsFromString( category() ); 32 array = Qtopia::Record::idsFromString( m_category.join(";") );
33 return array; 33 return array;
34} 34}
35bool ToDoEvent::match( const QRegExp &regExp )const 35bool ToDoEvent::match( const QRegExp &regExp )const
36{ 36{
37 if( QString::number( m_priority ).find( regExp ) != -1 ){ 37 if( QString::number( m_priority ).find( regExp ) != -1 ){
38 return true; 38 return true;
39 }else if( m_hasDate && m_date.toString().find( regExp) != -1 ){ 39 }else if( m_hasDate && m_date.toString().find( regExp) != -1 ){
40 return true; 40 return true;
41 }else if(m_desc.find( regExp ) != -1 ){ 41 }else if(m_desc.find( regExp ) != -1 ){
42 return true; 42 return true;
43 } 43 }
44 return false; 44 return false;
45} 45}
46bool ToDoEvent::isCompleted() const 46bool ToDoEvent::isCompleted() const
47{ 47{
48 return m_isCompleted; 48 return m_isCompleted;
49} 49}
50bool ToDoEvent::hasDate() const 50bool ToDoEvent::hasDate() const
51{ 51{
52 return m_hasDate; 52 return m_hasDate;
53} 53}
54int ToDoEvent::priority()const 54int ToDoEvent::priority()const
55{ 55{
56 return m_priority; 56 return m_priority;
57} 57}
58QString ToDoEvent::category()const 58QStringList ToDoEvent::allCategories()const
59{ 59{
60 return m_category; 60 return m_category;
61} 61}
62void ToDoEvent::insertCategory(const QString &str )
63{
64 m_category.append( str );
65}
66void ToDoEvent::clearCategories()
67{
68 m_category.clear();
69}
70void ToDoEvent::setCategories(const QStringList &list )
71{
72 m_category = list;
73 qWarning("todoevent: %s", list.join(";" ).latin1() );
74}
62QDate ToDoEvent::date()const 75QDate ToDoEvent::date()const
63{ 76{
64 return m_date; 77 return m_date;
65} 78}
79
66QString ToDoEvent::description()const 80QString ToDoEvent::description()const
67{ 81{
68 return m_desc; 82 return m_desc;
69} 83}
70void ToDoEvent::setCompleted( bool completed ) 84void ToDoEvent::setCompleted( bool completed )
71{ 85{
72 m_isCompleted = completed; 86 m_isCompleted = completed;
73} 87}
74void ToDoEvent::setHasDate( bool hasDate ) 88void ToDoEvent::setHasDate( bool hasDate )
75{ 89{
76 m_hasDate = hasDate; 90 m_hasDate = hasDate;
77} 91}
78void ToDoEvent::setDescription(const QString &desc ) 92void ToDoEvent::setDescription(const QString &desc )
79{ 93{
80 m_desc = Qtopia::simplifyMultiLineSpace(desc ); 94 m_desc = Qtopia::simplifyMultiLineSpace(desc );
81} 95}
82void ToDoEvent::setCategory( const QString &cat ) 96void ToDoEvent::setCategory( const QString &cat )
83{ 97{
84 qWarning("setCategory %s", cat.latin1() ); 98 qWarning("setCategory %s", cat.latin1() );
85 m_category = cat; 99 m_category.clear();
100 m_category << cat;
86} 101}
87void ToDoEvent::setPriority(int prio ) 102void ToDoEvent::setPriority(int prio )
88{ 103{
89 m_priority = prio; 104 m_priority = prio;
90} 105}
91void ToDoEvent::setDate( QDate date ) 106void ToDoEvent::setDate( QDate date )
92{ 107{
93 m_date = date; 108 m_date = date;
94} 109}
95bool ToDoEvent::isOverdue( ) 110bool ToDoEvent::isOverdue( )
96{ 111{
97 if( m_hasDate ) 112 if( m_hasDate )
98 return QDate::currentDate() > m_date; 113 return QDate::currentDate() > m_date;
99 return false; 114 return false;
100} 115}
101bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ 116bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{
102 if( !hasDate() && !toDoEvent.hasDate() ) return true; 117 if( !hasDate() && !toDoEvent.hasDate() ) return true;
103 if( !hasDate() && toDoEvent.hasDate() ) return true; 118 if( !hasDate() && toDoEvent.hasDate() ) return true;
104 if( hasDate() && toDoEvent.hasDate() ){ 119 if( hasDate() && toDoEvent.hasDate() ){
105 if( date() == toDoEvent.date() ){ // let's the priority decide 120 if( date() == toDoEvent.date() ){ // let's the priority decide
106 return priority() < toDoEvent.priority(); 121 return priority() < toDoEvent.priority();
107 }else{ 122 }else{
108 return date() < toDoEvent.date(); 123 return date() < toDoEvent.date();
109 } 124 }
110 } 125 }
111 return false; 126 return false;
112} 127}
113bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const 128bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const
114{ 129{
115 if( !hasDate() && !toDoEvent.hasDate() ) return true; 130 if( !hasDate() && !toDoEvent.hasDate() ) return true;
116 if( !hasDate() && toDoEvent.hasDate() ) return true; 131 if( !hasDate() && toDoEvent.hasDate() ) return true;
117 if( hasDate() && toDoEvent.hasDate() ){ 132 if( hasDate() && toDoEvent.hasDate() ){
@@ -122,55 +137,55 @@ bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const
122 } 137 }
123 } 138 }
124 return true; 139 return true;
125} 140}
126bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const 141bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const
127{ 142{
128 if( !hasDate() && !toDoEvent.hasDate() ) return false; 143 if( !hasDate() && !toDoEvent.hasDate() ) return false;
129 if( !hasDate() && toDoEvent.hasDate() ) return false; 144 if( !hasDate() && toDoEvent.hasDate() ) return false;
130 if( hasDate() && toDoEvent.hasDate() ){ 145 if( hasDate() && toDoEvent.hasDate() ){
131 if( date() == toDoEvent.date() ){ // let's the priority decide 146 if( date() == toDoEvent.date() ){ // let's the priority decide
132 return priority() > toDoEvent.priority(); 147 return priority() > toDoEvent.priority();
133 }else{ 148 }else{
134 return date() > toDoEvent.date(); 149 return date() > toDoEvent.date();
135 } 150 }
136 } 151 }
137 return false; 152 return false;
138} 153}
139bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const 154bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const
140{ 155{
141 if( !hasDate() && !toDoEvent.hasDate() ) return true; 156 if( !hasDate() && !toDoEvent.hasDate() ) return true;
142 if( !hasDate() && toDoEvent.hasDate() ) return false; 157 if( !hasDate() && toDoEvent.hasDate() ) return false;
143 if( hasDate() && toDoEvent.hasDate() ){ 158 if( hasDate() && toDoEvent.hasDate() ){
144 if( date() == toDoEvent.date() ){ // let's the priority decide 159 if( date() == toDoEvent.date() ){ // let's the priority decide
145 return priority() > toDoEvent.priority(); 160 return priority() > toDoEvent.priority();
146 }else{ 161 }else{
147 return date() > toDoEvent.date(); 162 return date() > toDoEvent.date();
148 } 163 }
149 } 164 }
150 return true; 165 return true;
151} 166}
152bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const 167bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const
153{ 168{
154 if( m_date == toDoEvent.m_date && m_isCompleted == toDoEvent.m_isCompleted && m_hasDate == toDoEvent.m_hasDate && m_priority == toDoEvent.m_priority && m_category == toDoEvent.m_category && m_desc == toDoEvent.m_category ) 169 if( m_date == toDoEvent.m_date && m_isCompleted == toDoEvent.m_isCompleted && m_hasDate == toDoEvent.m_hasDate && m_priority == toDoEvent.m_priority && m_category == toDoEvent.m_category && m_desc == toDoEvent.m_desc )
155 return true; 170 return true;
156 return false; 171 return false;
157} 172}
158ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) 173ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item )
159{ 174{
160 m_date = item.m_date; 175 m_date = item.m_date;
161 m_isCompleted = item.m_isCompleted; 176 m_isCompleted = item.m_isCompleted;
162 m_hasDate = item.m_hasDate; 177 m_hasDate = item.m_hasDate;
163 m_priority = item.m_priority; 178 m_priority = item.m_priority;
164 m_category = item.m_category; 179 m_category = item.m_category;
165 m_desc = item.m_desc; 180 m_desc = item.m_desc;
166 m_uid = item.m_uid; 181 m_uid = item.m_uid;
167 return *this; 182 return *this;
168} 183}
169 184
170 185
171 186
172 187
173 188
174 189
175 190
176 191