summaryrefslogtreecommitdiff
authorzecke <zecke>2002-05-09 15:39:38 (UTC)
committer zecke <zecke>2002-05-09 15:39:38 (UTC)
commit7999411de407eaaf57cae9e2d0cb3767c714d161 (patch) (unidiff)
treea29d0744a5aa698c8eb329721d1df651096eeb10
parent543122f38cc6e2b711d4afa321f7fed469b76621 (diff)
downloadopie-7999411de407eaaf57cae9e2d0cb3767c714d161.zip
opie-7999411de407eaaf57cae9e2d0cb3767c714d161.tar.gz
opie-7999411de407eaaf57cae9e2d0cb3767c714d161.tar.bz2
Patch from Stefan Eilers to separate multiple categories by a ,
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/todoevent.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp
index b820150..aa348a2 100644
--- a/libopie/todoevent.cpp
+++ b/libopie/todoevent.cpp
@@ -53,183 +53,188 @@ bool ToDoEvent::match( const QRegExp &regExp )const
53bool ToDoEvent::isCompleted() const 53bool ToDoEvent::isCompleted() const
54{ 54{
55 return m_isCompleted; 55 return m_isCompleted;
56} 56}
57bool ToDoEvent::hasDate() const 57bool ToDoEvent::hasDate() const
58{ 58{
59 return m_hasDate; 59 return m_hasDate;
60} 60}
61int ToDoEvent::priority()const 61int ToDoEvent::priority()const
62{ 62{
63 return m_priority; 63 return m_priority;
64} 64}
65QStringList ToDoEvent::allCategories()const 65QStringList ToDoEvent::allCategories()const
66{ 66{
67 return m_category; 67 return m_category;
68} 68}
69void ToDoEvent::insertCategory(const QString &str ) 69void ToDoEvent::insertCategory(const QString &str )
70{ 70{
71 m_category.append( str ); 71 m_category.append( str );
72} 72}
73void ToDoEvent::clearCategories() 73void ToDoEvent::clearCategories()
74{ 74{
75 m_category.clear(); 75 m_category.clear();
76} 76}
77void ToDoEvent::setCategories(const QStringList &list ) 77void ToDoEvent::setCategories(const QStringList &list )
78{ 78{
79 m_category = list; 79 m_category = list;
80} 80}
81QDate ToDoEvent::date()const 81QDate ToDoEvent::date()const
82{ 82{
83 return m_date; 83 return m_date;
84} 84}
85 85
86QString ToDoEvent::description()const 86QString ToDoEvent::description()const
87{ 87{
88 return m_desc; 88 return m_desc;
89} 89}
90void ToDoEvent::setCompleted( bool completed ) 90void ToDoEvent::setCompleted( bool completed )
91{ 91{
92 m_isCompleted = completed; 92 m_isCompleted = completed;
93} 93}
94void ToDoEvent::setHasDate( bool hasDate ) 94void ToDoEvent::setHasDate( bool hasDate )
95{ 95{
96 m_hasDate = hasDate; 96 m_hasDate = hasDate;
97} 97}
98void ToDoEvent::setDescription(const QString &desc ) 98void ToDoEvent::setDescription(const QString &desc )
99{ 99{
100 m_desc = Qtopia::simplifyMultiLineSpace(desc ); 100 m_desc = Qtopia::simplifyMultiLineSpace(desc );
101} 101}
102void ToDoEvent::setCategory( const QString &cat ) 102void 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}
108void ToDoEvent::setPriority(int prio ) 108void ToDoEvent::setPriority(int prio )
109{ 109{
110 m_priority = prio; 110 m_priority = prio;
111} 111}
112void ToDoEvent::setDate( QDate date ) 112void ToDoEvent::setDate( QDate date )
113{ 113{
114 m_date = date; 114 m_date = date;
115} 115}
116bool ToDoEvent::isOverdue( ) 116bool 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*/
126QString ToDoEvent::richText() const 126QString 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() ).replace(QRegExp( "[\n]"), "<br>" ) + "<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 bool firstloop = true;
149 catdb.load( categoryFileName() ); 150 catdb.load( categoryFileName() );
150 catlist = allCategories(); 151 catlist = allCategories();
151 152
152 text += "<b>" + QObject::tr( "Category:") + "</b> "; 153 text += "<b>" + QObject::tr( "Category:") + "</b> ";
153 for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) { 154 for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) {
155 if (!firstloop){
156 text += ", ";
157 }
158 firstloop = false;
154 text += catdb.label ("todo", (*it).toInt()); 159 text += catdb.label ("todo", (*it).toInt());
155 } 160 }
156 text += "<br>"; 161 text += "<br>";
157 return text; 162 return text;
158} 163}
159 164
160bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ 165bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{
161 if( !hasDate() && !toDoEvent.hasDate() ) return true; 166 if( !hasDate() && !toDoEvent.hasDate() ) return true;
162 if( !hasDate() && toDoEvent.hasDate() ) return true; 167 if( !hasDate() && toDoEvent.hasDate() ) return true;
163 if( hasDate() && toDoEvent.hasDate() ){ 168 if( hasDate() && toDoEvent.hasDate() ){
164 if( date() == toDoEvent.date() ){ // let's the priority decide 169 if( date() == toDoEvent.date() ){ // let's the priority decide
165 return priority() < toDoEvent.priority(); 170 return priority() < toDoEvent.priority();
166 }else{ 171 }else{
167 return date() < toDoEvent.date(); 172 return date() < toDoEvent.date();
168 } 173 }
169 } 174 }
170 return false; 175 return false;
171} 176}
172bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const 177bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const
173{ 178{
174 if( !hasDate() && !toDoEvent.hasDate() ) return true; 179 if( !hasDate() && !toDoEvent.hasDate() ) return true;
175 if( !hasDate() && toDoEvent.hasDate() ) return true; 180 if( !hasDate() && toDoEvent.hasDate() ) return true;
176 if( hasDate() && toDoEvent.hasDate() ){ 181 if( hasDate() && toDoEvent.hasDate() ){
177 if( date() == toDoEvent.date() ){ // let's the priority decide 182 if( date() == toDoEvent.date() ){ // let's the priority decide
178 return priority() <= toDoEvent.priority(); 183 return priority() <= toDoEvent.priority();
179 }else{ 184 }else{
180 return date() <= toDoEvent.date(); 185 return date() <= toDoEvent.date();
181 } 186 }
182 } 187 }
183 return true; 188 return true;
184} 189}
185bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const 190bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const
186{ 191{
187 if( !hasDate() && !toDoEvent.hasDate() ) return false; 192 if( !hasDate() && !toDoEvent.hasDate() ) return false;
188 if( !hasDate() && toDoEvent.hasDate() ) return false; 193 if( !hasDate() && toDoEvent.hasDate() ) return false;
189 if( hasDate() && toDoEvent.hasDate() ){ 194 if( hasDate() && toDoEvent.hasDate() ){
190 if( date() == toDoEvent.date() ){ // let's the priority decide 195 if( date() == toDoEvent.date() ){ // let's the priority decide
191 return priority() > toDoEvent.priority(); 196 return priority() > toDoEvent.priority();
192 }else{ 197 }else{
193 return date() > toDoEvent.date(); 198 return date() > toDoEvent.date();
194 } 199 }
195 } 200 }
196 return false; 201 return false;
197} 202}
198bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const 203bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const
199{ 204{
200 if( !hasDate() && !toDoEvent.hasDate() ) return true; 205 if( !hasDate() && !toDoEvent.hasDate() ) return true;
201 if( !hasDate() && toDoEvent.hasDate() ) return false; 206 if( !hasDate() && toDoEvent.hasDate() ) return false;
202 if( hasDate() && toDoEvent.hasDate() ){ 207 if( hasDate() && toDoEvent.hasDate() ){
203 if( date() == toDoEvent.date() ){ // let's the priority decide 208 if( date() == toDoEvent.date() ){ // let's the priority decide
204 return priority() > toDoEvent.priority(); 209 return priority() > toDoEvent.priority();
205 }else{ 210 }else{
206 return date() > toDoEvent.date(); 211 return date() > toDoEvent.date();
207 } 212 }
208 } 213 }
209 return true; 214 return true;
210} 215}
211bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const 216bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const
212{ 217{
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 ) 218 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; 219 return true;
215 return false; 220 return false;
216} 221}
217ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) 222ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item )
218{ 223{
219 m_date = item.m_date; 224 m_date = item.m_date;
220 m_isCompleted = item.m_isCompleted; 225 m_isCompleted = item.m_isCompleted;
221 m_hasDate = item.m_hasDate; 226 m_hasDate = item.m_hasDate;
222 m_priority = item.m_priority; 227 m_priority = item.m_priority;
223 m_category = item.m_category; 228 m_category = item.m_category;
224 m_desc = item.m_desc; 229 m_desc = item.m_desc;
225 m_uid = item.m_uid; 230 m_uid = item.m_uid;
226 return *this; 231 return *this;
227} 232}
228 233
229 234
230 235
231 236
232 237
233 238
234 239
235 240