-rw-r--r-- | libopie/todoevent.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp index 5537b77..b820150 100644 --- a/libopie/todoevent.cpp +++ b/libopie/todoevent.cpp | |||
@@ -1,235 +1,235 @@ | |||
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 | ||
15 | ToDoEvent::ToDoEvent(const ToDoEvent &event ) | 15 | ToDoEvent::ToDoEvent(const ToDoEvent &event ) |
16 | { | 16 | { |
17 | *this = event; | 17 | *this = event; |
18 | } | 18 | } |
19 | 19 | ||
20 | ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category, | 20 | ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category, |
21 | const QString &description, bool hasDate, QDate date, int uid ) | 21 | const QString &description, bool hasDate, QDate date, int uid ) |
22 | { | 22 | { |
23 | m_date = date; | 23 | m_date = date; |
24 | m_isCompleted = completed; | 24 | m_isCompleted = completed; |
25 | m_hasDate = hasDate; | 25 | m_hasDate = hasDate; |
26 | m_priority = priority; | 26 | m_priority = priority; |
27 | m_category = category; | 27 | m_category = category; |
28 | m_desc = Qtopia::simplifyMultiLineSpace(description ); | 28 | m_desc = Qtopia::simplifyMultiLineSpace(description ); |
29 | if (uid == -1 ) { | 29 | if (uid == -1 ) { |
30 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); | 30 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); |
31 | uid = uidgen->generate(); | 31 | uid = uidgen->generate(); |
32 | delete uidgen; | 32 | delete uidgen; |
33 | }// generate the ids | 33 | }// generate the ids |
34 | m_uid = uid; | 34 | m_uid = uid; |
35 | } | 35 | } |
36 | QArray<int> ToDoEvent::categories()const | 36 | QArray<int> ToDoEvent::categories()const |
37 | { | 37 | { |
38 | QArray<int> array(m_category.count() ); // currently the datebook can be only in one category | 38 | QArray<int> array(m_category.count() ); // currently the datebook can be only in one category |
39 | array = Qtopia::Record::idsFromString( m_category.join(";") ); | 39 | array = Qtopia::Record::idsFromString( m_category.join(";") ); |
40 | return array; | 40 | return array; |
41 | } | 41 | } |
42 | bool ToDoEvent::match( const QRegExp ®Exp )const | 42 | bool ToDoEvent::match( const QRegExp ®Exp )const |
43 | { | 43 | { |
44 | if( QString::number( m_priority ).find( regExp ) != -1 ){ | 44 | if( QString::number( m_priority ).find( regExp ) != -1 ){ |
45 | return true; | 45 | return true; |
46 | }else if( m_hasDate && m_date.toString().find( regExp) != -1 ){ | 46 | }else if( m_hasDate && m_date.toString().find( regExp) != -1 ){ |
47 | return true; | 47 | return true; |
48 | }else if(m_desc.find( regExp ) != -1 ){ | 48 | }else if(m_desc.find( regExp ) != -1 ){ |
49 | return true; | 49 | return true; |
50 | } | 50 | } |
51 | return false; | 51 | return false; |
52 | } | 52 | } |
53 | bool ToDoEvent::isCompleted() const | 53 | bool ToDoEvent::isCompleted() const |
54 | { | 54 | { |
55 | return m_isCompleted; | 55 | return m_isCompleted; |
56 | } | 56 | } |
57 | bool ToDoEvent::hasDate() const | 57 | bool ToDoEvent::hasDate() const |
58 | { | 58 | { |
59 | return m_hasDate; | 59 | return m_hasDate; |
60 | } | 60 | } |
61 | int ToDoEvent::priority()const | 61 | int ToDoEvent::priority()const |
62 | { | 62 | { |
63 | return m_priority; | 63 | return m_priority; |
64 | } | 64 | } |
65 | QStringList ToDoEvent::allCategories()const | 65 | QStringList ToDoEvent::allCategories()const |
66 | { | 66 | { |
67 | return m_category; | 67 | return m_category; |
68 | } | 68 | } |
69 | void ToDoEvent::insertCategory(const QString &str ) | 69 | void ToDoEvent::insertCategory(const QString &str ) |
70 | { | 70 | { |
71 | m_category.append( str ); | 71 | m_category.append( str ); |
72 | } | 72 | } |
73 | void ToDoEvent::clearCategories() | 73 | void ToDoEvent::clearCategories() |
74 | { | 74 | { |
75 | m_category.clear(); | 75 | m_category.clear(); |
76 | } | 76 | } |
77 | void ToDoEvent::setCategories(const QStringList &list ) | 77 | void ToDoEvent::setCategories(const QStringList &list ) |
78 | { | 78 | { |
79 | m_category = list; | 79 | m_category = list; |
80 | } | 80 | } |
81 | QDate ToDoEvent::date()const | 81 | QDate ToDoEvent::date()const |
82 | { | 82 | { |
83 | return m_date; | 83 | return m_date; |
84 | } | 84 | } |
85 | 85 | ||
86 | QString ToDoEvent::description()const | 86 | QString ToDoEvent::description()const |
87 | { | 87 | { |
88 | return m_desc; | 88 | return m_desc; |
89 | } | 89 | } |
90 | void ToDoEvent::setCompleted( bool completed ) | 90 | void ToDoEvent::setCompleted( bool completed ) |
91 | { | 91 | { |
92 | m_isCompleted = completed; | 92 | m_isCompleted = completed; |
93 | } | 93 | } |
94 | void ToDoEvent::setHasDate( bool hasDate ) | 94 | void ToDoEvent::setHasDate( bool hasDate ) |
95 | { | 95 | { |
96 | m_hasDate = hasDate; | 96 | m_hasDate = hasDate; |
97 | } | 97 | } |
98 | void ToDoEvent::setDescription(const QString &desc ) | 98 | void ToDoEvent::setDescription(const QString &desc ) |
99 | { | 99 | { |
100 | m_desc = Qtopia::simplifyMultiLineSpace(desc ); | 100 | m_desc = Qtopia::simplifyMultiLineSpace(desc ); |
101 | } | 101 | } |
102 | void ToDoEvent::setCategory( const QString &cat ) | 102 | void ToDoEvent::setCategory( const QString &cat ) |
103 | { | 103 | { |
104 | qWarning("setCategory %s", cat.latin1() ); | 104 | qWarning("setCategory %s", cat.latin1() ); |
105 | m_category.clear(); | 105 | m_category.clear(); |
106 | m_category << cat; | 106 | m_category << cat; |
107 | } | 107 | } |
108 | void ToDoEvent::setPriority(int prio ) | 108 | void ToDoEvent::setPriority(int prio ) |
109 | { | 109 | { |
110 | m_priority = prio; | 110 | m_priority = prio; |
111 | } | 111 | } |
112 | void ToDoEvent::setDate( QDate date ) | 112 | void ToDoEvent::setDate( QDate date ) |
113 | { | 113 | { |
114 | m_date = date; | 114 | m_date = date; |
115 | } | 115 | } |
116 | bool ToDoEvent::isOverdue( ) | 116 | bool ToDoEvent::isOverdue( ) |
117 | { | 117 | { |
118 | if( m_hasDate ) | 118 | if( m_hasDate ) |
119 | return QDate::currentDate() > m_date; | 119 | return QDate::currentDate() > m_date; |
120 | return false; | 120 | return false; |
121 | } | 121 | } |
122 | 122 | ||
123 | /*! | 123 | /*! |
124 | Returns a richt text string | 124 | Returns a richt text string |
125 | */ | 125 | */ |
126 | QString ToDoEvent::richText() const | 126 | QString ToDoEvent::richText() const |
127 | { | 127 | { |
128 | QString text; | 128 | QString text; |
129 | QStringList catlist; | 129 | QStringList catlist; |
130 | 130 | ||
131 | // Description of the todo | 131 | // Description of the todo |
132 | if ( !description().isEmpty() ){ | 132 | if ( !description().isEmpty() ){ |
133 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 133 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
134 | text += Qtopia::escapeString(description() ) + "<br>"; | 134 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
135 | } | 135 | } |
136 | text += "<b>" + QObject::tr( "Priority:") +" </b>" | 136 | text += "<b>" + QObject::tr( "Priority:") +" </b>" |
137 | + QString::number( priority() ) + "<br>"; | 137 | + QString::number( priority() ) + "<br>"; |
138 | if (hasDate() ){ | 138 | if (hasDate() ){ |
139 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; | 139 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; |
140 | text += date().toString(); | 140 | text += date().toString(); |
141 | text += "<br>"; | 141 | text += "<br>"; |
142 | } | 142 | } |
143 | 143 | ||
144 | // Open database of all categories and get the list of | 144 | // Open database of all categories and get the list of |
145 | // the categories this todoevent belongs to. | 145 | // the categories this todoevent belongs to. |
146 | // Then print them... | 146 | // Then print them... |
147 | // I am not sure whether there is no better way doing this !? | 147 | // I am not sure whether there is no better way doing this !? |
148 | Categories catdb; | 148 | Categories catdb; |
149 | catdb.load( categoryFileName() ); | 149 | catdb.load( categoryFileName() ); |
150 | catlist = allCategories(); | 150 | catlist = allCategories(); |
151 | 151 | ||
152 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 152 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
153 | for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) { | 153 | for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) { |
154 | text += catdb.label ("todo", (*it).toInt()); | 154 | text += catdb.label ("todo", (*it).toInt()); |
155 | } | 155 | } |
156 | text += "<br>"; | 156 | text += "<br>"; |
157 | return text; | 157 | return text; |
158 | } | 158 | } |
159 | 159 | ||
160 | bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ | 160 | bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ |
161 | if( !hasDate() && !toDoEvent.hasDate() ) return true; | 161 | if( !hasDate() && !toDoEvent.hasDate() ) return true; |
162 | if( !hasDate() && toDoEvent.hasDate() ) return true; | 162 | if( !hasDate() && toDoEvent.hasDate() ) return true; |
163 | if( hasDate() && toDoEvent.hasDate() ){ | 163 | if( hasDate() && toDoEvent.hasDate() ){ |
164 | if( date() == toDoEvent.date() ){ // let's the priority decide | 164 | if( date() == toDoEvent.date() ){ // let's the priority decide |
165 | return priority() < toDoEvent.priority(); | 165 | return priority() < toDoEvent.priority(); |
166 | }else{ | 166 | }else{ |
167 | return date() < toDoEvent.date(); | 167 | return date() < toDoEvent.date(); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | return false; | 170 | return false; |
171 | } | 171 | } |
172 | bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const | 172 | bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const |
173 | { | 173 | { |
174 | if( !hasDate() && !toDoEvent.hasDate() ) return true; | 174 | if( !hasDate() && !toDoEvent.hasDate() ) return true; |
175 | if( !hasDate() && toDoEvent.hasDate() ) return true; | 175 | if( !hasDate() && toDoEvent.hasDate() ) return true; |
176 | if( hasDate() && toDoEvent.hasDate() ){ | 176 | if( hasDate() && toDoEvent.hasDate() ){ |
177 | if( date() == toDoEvent.date() ){ // let's the priority decide | 177 | if( date() == toDoEvent.date() ){ // let's the priority decide |
178 | return priority() <= toDoEvent.priority(); | 178 | return priority() <= toDoEvent.priority(); |
179 | }else{ | 179 | }else{ |
180 | return date() <= toDoEvent.date(); | 180 | return date() <= toDoEvent.date(); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | return true; | 183 | return true; |
184 | } | 184 | } |
185 | bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const | 185 | bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const |
186 | { | 186 | { |
187 | if( !hasDate() && !toDoEvent.hasDate() ) return false; | 187 | if( !hasDate() && !toDoEvent.hasDate() ) return false; |
188 | if( !hasDate() && toDoEvent.hasDate() ) return false; | 188 | if( !hasDate() && toDoEvent.hasDate() ) return false; |
189 | if( hasDate() && toDoEvent.hasDate() ){ | 189 | if( hasDate() && toDoEvent.hasDate() ){ |
190 | if( date() == toDoEvent.date() ){ // let's the priority decide | 190 | if( date() == toDoEvent.date() ){ // let's the priority decide |
191 | return priority() > toDoEvent.priority(); | 191 | return priority() > toDoEvent.priority(); |
192 | }else{ | 192 | }else{ |
193 | return date() > toDoEvent.date(); | 193 | return date() > toDoEvent.date(); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | return false; | 196 | return false; |
197 | } | 197 | } |
198 | bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const | 198 | bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const |
199 | { | 199 | { |
200 | if( !hasDate() && !toDoEvent.hasDate() ) return true; | 200 | if( !hasDate() && !toDoEvent.hasDate() ) return true; |
201 | if( !hasDate() && toDoEvent.hasDate() ) return false; | 201 | if( !hasDate() && toDoEvent.hasDate() ) return false; |
202 | if( hasDate() && toDoEvent.hasDate() ){ | 202 | if( hasDate() && toDoEvent.hasDate() ){ |
203 | if( date() == toDoEvent.date() ){ // let's the priority decide | 203 | if( date() == toDoEvent.date() ){ // let's the priority decide |
204 | return priority() > toDoEvent.priority(); | 204 | return priority() > toDoEvent.priority(); |
205 | }else{ | 205 | }else{ |
206 | return date() > toDoEvent.date(); | 206 | return date() > toDoEvent.date(); |
207 | } | 207 | } |
208 | } | 208 | } |
209 | return true; | 209 | return true; |
210 | } | 210 | } |
211 | bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const | 211 | bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const |
212 | { | 212 | { |
213 | 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 ) | 213 | 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 ) |
214 | return true; | 214 | return true; |
215 | return false; | 215 | return false; |
216 | } | 216 | } |
217 | ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) | 217 | ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) |
218 | { | 218 | { |
219 | m_date = item.m_date; | 219 | m_date = item.m_date; |
220 | m_isCompleted = item.m_isCompleted; | 220 | m_isCompleted = item.m_isCompleted; |
221 | m_hasDate = item.m_hasDate; | 221 | m_hasDate = item.m_hasDate; |
222 | m_priority = item.m_priority; | 222 | m_priority = item.m_priority; |
223 | m_category = item.m_category; | 223 | m_category = item.m_category; |
224 | m_desc = item.m_desc; | 224 | m_desc = item.m_desc; |
225 | m_uid = item.m_uid; | 225 | m_uid = item.m_uid; |
226 | return *this; | 226 | return *this; |
227 | } | 227 | } |
228 | 228 | ||
229 | 229 | ||
230 | 230 | ||
231 | 231 | ||
232 | 232 | ||
233 | 233 | ||
234 | 234 | ||
235 | 235 | ||