-rw-r--r-- | libopie/todoevent.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp index 4cfe1c0..5fa4472 100644 --- a/libopie/todoevent.cpp +++ b/libopie/todoevent.cpp | |||
@@ -1,150 +1,152 @@ | |||
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> | ||
5 | //#include <qpe/palmtoprecord.h> | ||
4 | 6 | ||
5 | ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category, | 7 | ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category, |
6 | const QString &description, bool hasDate, QDate date, int uid ) | 8 | const QString &description, bool hasDate, QDate date, int uid ) |
7 | { | 9 | { |
8 | qWarning("todoEvent c'tor" ); | 10 | qWarning("todoEvent c'tor" ); |
9 | m_date = date; | 11 | m_date = date; |
10 | m_isCompleted = completed; | 12 | m_isCompleted = completed; |
11 | m_hasDate = hasDate; | 13 | m_hasDate = hasDate; |
12 | m_priority = priority; | 14 | m_priority = priority; |
13 | m_category = category; | 15 | m_category = category; |
14 | m_desc = description; | 16 | m_desc = Qtopia::simplifyMultiLineSpace(description ); |
15 | if (uid == -1 ) { | 17 | if (uid == -1 ) { |
16 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); | 18 | Qtopia::UidGen *uidgen = new Qtopia::UidGen(); |
17 | uid = uidgen->generate(); | 19 | uid = uidgen->generate(); |
18 | delete uidgen; | 20 | delete uidgen; |
19 | }// generate the ids | 21 | }// generate the ids |
20 | m_uid = uid; | 22 | m_uid = uid; |
21 | } | 23 | } |
22 | bool ToDoEvent::isCompleted() const | 24 | bool ToDoEvent::isCompleted() const |
23 | { | 25 | { |
24 | return m_isCompleted; | 26 | return m_isCompleted; |
25 | } | 27 | } |
26 | bool ToDoEvent::hasDate() const | 28 | bool ToDoEvent::hasDate() const |
27 | { | 29 | { |
28 | return m_hasDate; | 30 | return m_hasDate; |
29 | } | 31 | } |
30 | int ToDoEvent::priority()const | 32 | int ToDoEvent::priority()const |
31 | { | 33 | { |
32 | return m_priority; | 34 | return m_priority; |
33 | } | 35 | } |
34 | QString ToDoEvent::category()const | 36 | QString ToDoEvent::category()const |
35 | { | 37 | { |
36 | return m_category; | 38 | return m_category; |
37 | } | 39 | } |
38 | QDate ToDoEvent::date()const | 40 | QDate ToDoEvent::date()const |
39 | { | 41 | { |
40 | return m_date; | 42 | return m_date; |
41 | } | 43 | } |
42 | QString ToDoEvent::description()const | 44 | QString ToDoEvent::description()const |
43 | { | 45 | { |
44 | return m_desc; | 46 | return m_desc; |
45 | } | 47 | } |
46 | void ToDoEvent::setCompleted( bool completed ) | 48 | void ToDoEvent::setCompleted( bool completed ) |
47 | { | 49 | { |
48 | m_isCompleted = completed; | 50 | m_isCompleted = completed; |
49 | } | 51 | } |
50 | void ToDoEvent::setHasDate( bool hasDate ) | 52 | void ToDoEvent::setHasDate( bool hasDate ) |
51 | { | 53 | { |
52 | m_hasDate = hasDate; | 54 | m_hasDate = hasDate; |
53 | } | 55 | } |
54 | void ToDoEvent::setDescription(const QString &desc ) | 56 | void ToDoEvent::setDescription(const QString &desc ) |
55 | { | 57 | { |
56 | m_desc = desc; | 58 | m_desc = Qtopia::simplifyMultiLineSpace(desc ); |
57 | } | 59 | } |
58 | void ToDoEvent::setCategory( const QString &cat ) | 60 | void ToDoEvent::setCategory( const QString &cat ) |
59 | { | 61 | { |
60 | m_category = cat; | 62 | m_category = cat; |
61 | } | 63 | } |
62 | void ToDoEvent::setPriority(int prio ) | 64 | void ToDoEvent::setPriority(int prio ) |
63 | { | 65 | { |
64 | m_priority = prio; | 66 | m_priority = prio; |
65 | } | 67 | } |
66 | void ToDoEvent::setDate( QDate date ) | 68 | void ToDoEvent::setDate( QDate date ) |
67 | { | 69 | { |
68 | m_date = date; | 70 | m_date = date; |
69 | } | 71 | } |
70 | bool ToDoEvent::isOverdue( ) | 72 | bool ToDoEvent::isOverdue( ) |
71 | { | 73 | { |
72 | if( m_hasDate ) | 74 | if( m_hasDate ) |
73 | return QDate::currentDate() > m_date; | 75 | return QDate::currentDate() > m_date; |
74 | return false; | 76 | return false; |
75 | } | 77 | } |
76 | bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ | 78 | bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ |
77 | if( !hasDate() && !toDoEvent.hasDate() ) return true; | 79 | if( !hasDate() && !toDoEvent.hasDate() ) return true; |
78 | if( !hasDate() && toDoEvent.hasDate() ) return true; | 80 | if( !hasDate() && toDoEvent.hasDate() ) return true; |
79 | if( hasDate() && toDoEvent.hasDate() ){ | 81 | if( hasDate() && toDoEvent.hasDate() ){ |
80 | if( date() == toDoEvent.date() ){ // let's the priority decide | 82 | if( date() == toDoEvent.date() ){ // let's the priority decide |
81 | return priority() < toDoEvent.priority(); | 83 | return priority() < toDoEvent.priority(); |
82 | }else{ | 84 | }else{ |
83 | return date() < toDoEvent.date(); | 85 | return date() < toDoEvent.date(); |
84 | } | 86 | } |
85 | } | 87 | } |
86 | return false; | 88 | return false; |
87 | } | 89 | } |
88 | bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const | 90 | bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const |
89 | { | 91 | { |
90 | if( !hasDate() && !toDoEvent.hasDate() ) return true; | 92 | if( !hasDate() && !toDoEvent.hasDate() ) return true; |
91 | if( !hasDate() && toDoEvent.hasDate() ) return true; | 93 | if( !hasDate() && toDoEvent.hasDate() ) return true; |
92 | if( hasDate() && toDoEvent.hasDate() ){ | 94 | if( hasDate() && toDoEvent.hasDate() ){ |
93 | if( date() == toDoEvent.date() ){ // let's the priority decide | 95 | if( date() == toDoEvent.date() ){ // let's the priority decide |
94 | return priority() <= toDoEvent.priority(); | 96 | return priority() <= toDoEvent.priority(); |
95 | }else{ | 97 | }else{ |
96 | return date() <= toDoEvent.date(); | 98 | return date() <= toDoEvent.date(); |
97 | } | 99 | } |
98 | } | 100 | } |
99 | return true; | 101 | return true; |
100 | } | 102 | } |
101 | bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const | 103 | bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const |
102 | { | 104 | { |
103 | if( !hasDate() && !toDoEvent.hasDate() ) return false; | 105 | if( !hasDate() && !toDoEvent.hasDate() ) return false; |
104 | if( !hasDate() && toDoEvent.hasDate() ) return false; | 106 | if( !hasDate() && toDoEvent.hasDate() ) return false; |
105 | if( hasDate() && toDoEvent.hasDate() ){ | 107 | if( hasDate() && toDoEvent.hasDate() ){ |
106 | if( date() == toDoEvent.date() ){ // let's the priority decide | 108 | if( date() == toDoEvent.date() ){ // let's the priority decide |
107 | return priority() > toDoEvent.priority(); | 109 | return priority() > toDoEvent.priority(); |
108 | }else{ | 110 | }else{ |
109 | return date() > toDoEvent.date(); | 111 | return date() > toDoEvent.date(); |
110 | } | 112 | } |
111 | } | 113 | } |
112 | return false; | 114 | return false; |
113 | } | 115 | } |
114 | bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const | 116 | bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const |
115 | { | 117 | { |
116 | if( !hasDate() && !toDoEvent.hasDate() ) return true; | 118 | if( !hasDate() && !toDoEvent.hasDate() ) return true; |
117 | if( !hasDate() && toDoEvent.hasDate() ) return false; | 119 | if( !hasDate() && toDoEvent.hasDate() ) return false; |
118 | if( hasDate() && toDoEvent.hasDate() ){ | 120 | if( hasDate() && toDoEvent.hasDate() ){ |
119 | if( date() == toDoEvent.date() ){ // let's the priority decide | 121 | if( date() == toDoEvent.date() ){ // let's the priority decide |
120 | return priority() > toDoEvent.priority(); | 122 | return priority() > toDoEvent.priority(); |
121 | }else{ | 123 | }else{ |
122 | return date() > toDoEvent.date(); | 124 | return date() > toDoEvent.date(); |
123 | } | 125 | } |
124 | } | 126 | } |
125 | return true; | 127 | return true; |
126 | } | 128 | } |
127 | bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const | 129 | bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const |
128 | { | 130 | { |
129 | 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_category ) | 131 | 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_category ) |
130 | return true; | 132 | return true; |
131 | return false; | 133 | return false; |
132 | } | 134 | } |
133 | ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) | 135 | ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) |
134 | { | 136 | { |
135 | m_date = item.m_date; | 137 | m_date = item.m_date; |
136 | m_isCompleted = item.m_isCompleted; | 138 | m_isCompleted = item.m_isCompleted; |
137 | m_hasDate = item.m_hasDate; | 139 | m_hasDate = item.m_hasDate; |
138 | m_priority = item.m_priority; | 140 | m_priority = item.m_priority; |
139 | m_category = item.m_category; | 141 | m_category = item.m_category; |
140 | m_desc = item.m_desc; | 142 | m_desc = item.m_desc; |
141 | return *this; | 143 | return *this; |
142 | } | 144 | } |
143 | 145 | ||
144 | 146 | ||
145 | 147 | ||
146 | 148 | ||
147 | 149 | ||
148 | 150 | ||
149 | 151 | ||
150 | 152 | ||