summaryrefslogtreecommitdiff
path: root/libopie/todoevent.cpp
Unidiff
Diffstat (limited to 'libopie/todoevent.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/todoevent.cpp22
1 files changed, 20 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,115 +1,133 @@
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{