summaryrefslogtreecommitdiff
path: root/libopie/todoevent.cpp
Unidiff
Diffstat (limited to 'libopie/todoevent.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/todoevent.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp
index a5dba4f..5537b77 100644
--- a/libopie/todoevent.cpp
+++ b/libopie/todoevent.cpp
@@ -1,18 +1,26 @@
1 1
2#include <opie/todoevent.h> 2#include <opie/todoevent.h>
3
4
3#include <qpe/palmtopuidgen.h> 5#include <qpe/palmtopuidgen.h>
4#include <qpe/stringutil.h> 6#include <qpe/stringutil.h>
5#include <qpe/palmtoprecord.h> 7#include <qpe/palmtoprecord.h>
6 8
9#include <qpe/stringutil.h>
10#include <qpe/categories.h>
11#include <qpe/categoryselect.h>
12
13#include <qobject.h>
14
7ToDoEvent::ToDoEvent(const ToDoEvent &event ) 15ToDoEvent::ToDoEvent(const ToDoEvent &event )
8{ 16{
9 *this = event; 17 *this = event;
10} 18}
11 19
12ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category, 20ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category,
13 const QString &description, bool hasDate, QDate date, int uid ) 21 const QString &description, bool hasDate, QDate date, int uid )
14{ 22{
15 m_date = date; 23 m_date = date;
16 m_isCompleted = completed; 24 m_isCompleted = completed;
17 m_hasDate = hasDate; 25 m_hasDate = hasDate;
18 m_priority = priority; 26 m_priority = priority;
@@ -102,24 +110,62 @@ void ToDoEvent::setPriority(int prio )
102 m_priority = prio; 110 m_priority = prio;
103} 111}
104void ToDoEvent::setDate( QDate date ) 112void ToDoEvent::setDate( QDate date )
105{ 113{
106 m_date = date; 114 m_date = date;
107} 115}
108bool ToDoEvent::isOverdue( ) 116bool ToDoEvent::isOverdue( )
109{ 117{
110 if( m_hasDate ) 118 if( m_hasDate )
111 return QDate::currentDate() > m_date; 119 return QDate::currentDate() > m_date;
112 return false; 120 return false;
113} 121}
122
123/*!
124 Returns a richt text string
125*/
126QString ToDoEvent::richText() const
127{
128 QString text;
129 QStringList catlist;
130
131 // Description of the todo
132 if ( !description().isEmpty() ){
133 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
134 text += Qtopia::escapeString(description() ) + "<br>";
135 }
136 text += "<b>" + QObject::tr( "Priority:") +" </b>"
137 + QString::number( priority() ) + "<br>";
138 if (hasDate() ){
139 text += "<b>" + QObject::tr( "Deadline:") + " </b>";
140 text += date().toString();
141 text += "<br>";
142 }
143
144 // Open database of all categories and get the list of
145 // the categories this todoevent belongs to.
146 // Then print them...
147 // I am not sure whether there is no better way doing this !?
148 Categories catdb;
149 catdb.load( categoryFileName() );
150 catlist = allCategories();
151
152 text += "<b>" + QObject::tr( "Category:") + "</b> ";
153 for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) {
154 text += catdb.label ("todo", (*it).toInt());
155 }
156 text += "<br>";
157 return text;
158}
159
114bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ 160bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{
115 if( !hasDate() && !toDoEvent.hasDate() ) return true; 161 if( !hasDate() && !toDoEvent.hasDate() ) return true;
116 if( !hasDate() && toDoEvent.hasDate() ) return true; 162 if( !hasDate() && toDoEvent.hasDate() ) return true;
117 if( hasDate() && toDoEvent.hasDate() ){ 163 if( hasDate() && toDoEvent.hasDate() ){
118 if( date() == toDoEvent.date() ){ // let's the priority decide 164 if( date() == toDoEvent.date() ){ // let's the priority decide
119 return priority() < toDoEvent.priority(); 165 return priority() < toDoEvent.priority();
120 }else{ 166 }else{
121 return date() < toDoEvent.date(); 167 return date() < toDoEvent.date();
122 } 168 }
123 } 169 }
124 return false; 170 return false;
125} 171}