-rw-r--r-- | libopie/todoevent.cpp | 22 |
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,44 +1,61 @@ | |||
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 | ||
7 | ToDoEvent::ToDoEvent(const ToDoEvent &event ) | 7 | ToDoEvent::ToDoEvent(const ToDoEvent &event ) |
8 | { | 8 | { |
9 | *this = event; | 9 | *this = event; |
10 | } | 10 | } |
11 | 11 | ||
12 | ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category, | 12 | ToDoEvent::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 | } |
29 | QArray<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 | } | ||
35 | bool ToDoEvent::match( const QRegExp ®Exp )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 | } | ||
29 | bool ToDoEvent::isCompleted() const | 46 | bool ToDoEvent::isCompleted() const |
30 | { | 47 | { |
31 | return m_isCompleted; | 48 | return m_isCompleted; |
32 | } | 49 | } |
33 | bool ToDoEvent::hasDate() const | 50 | bool ToDoEvent::hasDate() const |
34 | { | 51 | { |
35 | return m_hasDate; | 52 | return m_hasDate; |
36 | } | 53 | } |
37 | int ToDoEvent::priority()const | 54 | int ToDoEvent::priority()const |
38 | { | 55 | { |
39 | return m_priority; | 56 | return m_priority; |
40 | } | 57 | } |
41 | QString ToDoEvent::category()const | 58 | QString ToDoEvent::category()const |
42 | { | 59 | { |
43 | return m_category; | 60 | return m_category; |
44 | } | 61 | } |
@@ -51,33 +68,34 @@ QString ToDoEvent::description()const | |||
51 | return m_desc; | 68 | return m_desc; |
52 | } | 69 | } |
53 | void ToDoEvent::setCompleted( bool completed ) | 70 | void ToDoEvent::setCompleted( bool completed ) |
54 | { | 71 | { |
55 | m_isCompleted = completed; | 72 | m_isCompleted = completed; |
56 | } | 73 | } |
57 | void ToDoEvent::setHasDate( bool hasDate ) | 74 | void ToDoEvent::setHasDate( bool hasDate ) |
58 | { | 75 | { |
59 | m_hasDate = hasDate; | 76 | m_hasDate = hasDate; |
60 | } | 77 | } |
61 | void ToDoEvent::setDescription(const QString &desc ) | 78 | void ToDoEvent::setDescription(const QString &desc ) |
62 | { | 79 | { |
63 | m_desc = Qtopia::simplifyMultiLineSpace(desc ); | 80 | m_desc = Qtopia::simplifyMultiLineSpace(desc ); |
64 | } | 81 | } |
65 | void ToDoEvent::setCategory( const QString &cat ) | 82 | void ToDoEvent::setCategory( const QString &cat ) |
66 | { | 83 | { |
67 | m_category = cat; | 84 | qWarning("setCategory %s", cat.latin1() ); |
85 | m_category = cat; | ||
68 | } | 86 | } |
69 | void ToDoEvent::setPriority(int prio ) | 87 | void ToDoEvent::setPriority(int prio ) |
70 | { | 88 | { |
71 | m_priority = prio; | 89 | m_priority = prio; |
72 | } | 90 | } |
73 | void ToDoEvent::setDate( QDate date ) | 91 | void ToDoEvent::setDate( QDate date ) |
74 | { | 92 | { |
75 | m_date = date; | 93 | m_date = date; |
76 | } | 94 | } |
77 | bool ToDoEvent::isOverdue( ) | 95 | bool 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 | } |
83 | bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ | 101 | bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ |