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