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