-rw-r--r-- | libopie/tododb.cpp | 25 | ||||
-rw-r--r-- | libopie/todoevent.cpp | 27 | ||||
-rw-r--r-- | libopie/todoevent.h | 15 | ||||
-rw-r--r-- | libopie/todovcalresource.cpp | 2 |
4 files changed, 46 insertions, 23 deletions
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp index 10ea2f0..7814c4f 100644 --- a/libopie/tododb.cpp +++ b/libopie/tododb.cpp | |||
@@ -16,22 +16,26 @@ public: | |||
16 | XMLElement *tasks = new XMLElement( ); | 16 | XMLElement *tasks = new XMLElement( ); |
17 | tasks->setTagName("Tasks" ); | 17 | tasks->setTagName("Tasks" ); |
18 | for( QValueList<ToDoEvent>::ConstIterator it = m_todos.begin(); it != m_todos.end(); ++it ){ | 18 | for( QValueList<ToDoEvent>::ConstIterator it = m_todos.begin(); it != m_todos.end(); ++it ){ |
19 | XMLElement::AttributeMap map; | 19 | XMLElement::AttributeMap map; |
20 | XMLElement *task = new XMLElement(); | 20 | XMLElement *task = new XMLElement(); |
21 | map.insert( "Completed", QString::number((int)(*it).isCompleted() ) ); | 21 | map.insert( "Completed", QString::number((int)(*it).isCompleted() ) ); |
22 | map.insert( "HasDate", QString::number((int)(*it).hasDate() ) ); | 22 | map.insert( "HasDate", QString::number((int)(*it).hasDate() ) ); |
23 | map.insert( "Priority", QString::number( (*it).priority() ) ); | 23 | map.insert( "Priority", QString::number( (*it).priority() ) ); |
24 | if(!(*it).category().isEmpty() ){ | 24 | QArray<int> arrat = (*it).categories(); |
25 | QArray<int> arrat(1); | 25 | QString attr; |
26 | arrat = Qtopia::Record::idsFromString( (*it).category() ); | 26 | for(uint i=0; i < arrat.count(); i++ ){ |
27 | map.insert( "Categories", QString::number( arrat[0] ) ); | 27 | attr.append(QString::number(arrat[i])+";" ); |
28 | }else | 28 | } |
29 | map.insert( "Categories", QString::null ); | 29 | if(!attr.isEmpty() ) // remove the last ; |
30 | attr.remove(attr.length()-1, 1 ); | ||
31 | map.insert( "Categories", attr ); | ||
32 | //else | ||
33 | //map.insert( "Categories", QString::null ); | ||
30 | map.insert( "Description", (*it).description() ); | 34 | map.insert( "Description", (*it).description() ); |
31 | if( (*it).hasDate() ){ | 35 | if( (*it).hasDate() ){ |
32 | map.insert("DateYear", QString::number( (*it).date().year() ) ); | 36 | map.insert("DateYear", QString::number( (*it).date().year() ) ); |
33 | map.insert("DateMonth", QString::number( (*it).date().month() ) ); | 37 | map.insert("DateMonth", QString::number( (*it).date().month() ) ); |
34 | map.insert("DateDay", QString::number( (*it).date().day() ) ); | 38 | map.insert("DateDay", QString::number( (*it).date().day() ) ); |
35 | } | 39 | } |
36 | map.insert("Uid", QString::number( (*it).uid() ) ); | 40 | map.insert("Uid", QString::number( (*it).uid() ) ); |
37 | task->setTagName("Task" ); | 41 | task->setTagName("Task" ); |
@@ -96,22 +100,19 @@ public: | |||
96 | dumInt = dummy.toInt(&ok ); | 100 | dumInt = dummy.toInt(&ok ); |
97 | if(!ok ) dumInt = ToDoEvent::NORMAL; | 101 | if(!ok ) dumInt = ToDoEvent::NORMAL; |
98 | event.setPriority( dumInt ); | 102 | event.setPriority( dumInt ); |
99 | //description | 103 | //description |
100 | dummy = element->attribute("Description" ); | 104 | dummy = element->attribute("Description" ); |
101 | event.setDescription( dummy ); | 105 | event.setDescription( dummy ); |
102 | // category | 106 | // category |
103 | dummy = element->attribute("Categories" ); | 107 | dummy = element->attribute("Categories" ); |
104 | dumInt = dummy.toInt(&ok ); | 108 | QStringList ids = QStringList::split(";", dummy ); |
105 | if(ok ) { | 109 | event.setCategories( ids ); |
106 | QArray<int> arrat(1); | 110 | |
107 | arrat[0] = dumInt; | ||
108 | event.setCategory( Qtopia::Record::idsToString( arrat ) ); | ||
109 | } | ||
110 | //uid | 111 | //uid |
111 | dummy = element->attribute("Uid" ); | 112 | dummy = element->attribute("Uid" ); |
112 | dumInt = dummy.toInt(&ok ); | 113 | dumInt = dummy.toInt(&ok ); |
113 | if(ok ) event.setUid( dumInt ); | 114 | if(ok ) event.setUid( dumInt ); |
114 | m_todos.append( event ); | 115 | m_todos.append( event ); |
115 | element = element->nextChild(); // next element | 116 | element = element->nextChild(); // next element |
116 | } | 117 | } |
117 | //} | 118 | //} |
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp index 7dbf907..28b2e98 100644 --- a/libopie/todoevent.cpp +++ b/libopie/todoevent.cpp | |||
@@ -4,17 +4,17 @@ | |||
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 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" ); | 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; |
@@ -23,18 +23,18 @@ ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category, | |||
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 | 29 | QArray<int> ToDoEvent::categories()const |
30 | { | 30 | { |
31 | QArray<int> array(1); // currently the datebook can be only in one category | 31 | QArray<int> array(m_category.count() ); // currently the datebook can be only in one category |
32 | array = Qtopia::Record::idsFromString( category() ); | 32 | array = Qtopia::Record::idsFromString( m_category.join(";") ); |
33 | return array; | 33 | return array; |
34 | } | 34 | } |
35 | bool ToDoEvent::match( const QRegExp ®Exp )const | 35 | bool ToDoEvent::match( const QRegExp ®Exp )const |
36 | { | 36 | { |
37 | if( QString::number( m_priority ).find( regExp ) != -1 ){ | 37 | if( QString::number( m_priority ).find( regExp ) != -1 ){ |
38 | return true; | 38 | return true; |
39 | }else if( m_hasDate && m_date.toString().find( regExp) != -1 ){ | 39 | }else if( m_hasDate && m_date.toString().find( regExp) != -1 ){ |
40 | return true; | 40 | return true; |
@@ -50,24 +50,38 @@ bool ToDoEvent::isCompleted() const | |||
50 | bool ToDoEvent::hasDate() const | 50 | bool ToDoEvent::hasDate() const |
51 | { | 51 | { |
52 | return m_hasDate; | 52 | return m_hasDate; |
53 | } | 53 | } |
54 | int ToDoEvent::priority()const | 54 | int ToDoEvent::priority()const |
55 | { | 55 | { |
56 | return m_priority; | 56 | return m_priority; |
57 | } | 57 | } |
58 | QString ToDoEvent::category()const | 58 | QStringList ToDoEvent::allCategories()const |
59 | { | 59 | { |
60 | return m_category; | 60 | return m_category; |
61 | } | 61 | } |
62 | void ToDoEvent::insertCategory(const QString &str ) | ||
63 | { | ||
64 | m_category.append( str ); | ||
65 | } | ||
66 | void ToDoEvent::clearCategories() | ||
67 | { | ||
68 | m_category.clear(); | ||
69 | } | ||
70 | void ToDoEvent::setCategories(const QStringList &list ) | ||
71 | { | ||
72 | m_category = list; | ||
73 | qWarning("todoevent: %s", list.join(";" ).latin1() ); | ||
74 | } | ||
62 | QDate ToDoEvent::date()const | 75 | QDate ToDoEvent::date()const |
63 | { | 76 | { |
64 | return m_date; | 77 | return m_date; |
65 | } | 78 | } |
79 | |||
66 | QString ToDoEvent::description()const | 80 | QString ToDoEvent::description()const |
67 | { | 81 | { |
68 | return m_desc; | 82 | return m_desc; |
69 | } | 83 | } |
70 | void ToDoEvent::setCompleted( bool completed ) | 84 | void ToDoEvent::setCompleted( bool completed ) |
71 | { | 85 | { |
72 | m_isCompleted = completed; | 86 | m_isCompleted = completed; |
73 | } | 87 | } |
@@ -77,17 +91,18 @@ void ToDoEvent::setHasDate( bool hasDate ) | |||
77 | } | 91 | } |
78 | void ToDoEvent::setDescription(const QString &desc ) | 92 | void ToDoEvent::setDescription(const QString &desc ) |
79 | { | 93 | { |
80 | m_desc = Qtopia::simplifyMultiLineSpace(desc ); | 94 | m_desc = Qtopia::simplifyMultiLineSpace(desc ); |
81 | } | 95 | } |
82 | void ToDoEvent::setCategory( const QString &cat ) | 96 | void ToDoEvent::setCategory( const QString &cat ) |
83 | { | 97 | { |
84 | qWarning("setCategory %s", cat.latin1() ); | 98 | qWarning("setCategory %s", cat.latin1() ); |
85 | m_category = cat; | 99 | m_category.clear(); |
100 | m_category << cat; | ||
86 | } | 101 | } |
87 | void ToDoEvent::setPriority(int prio ) | 102 | void ToDoEvent::setPriority(int prio ) |
88 | { | 103 | { |
89 | m_priority = prio; | 104 | m_priority = prio; |
90 | } | 105 | } |
91 | void ToDoEvent::setDate( QDate date ) | 106 | void ToDoEvent::setDate( QDate date ) |
92 | { | 107 | { |
93 | m_date = date; | 108 | m_date = date; |
@@ -146,17 +161,17 @@ bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const | |||
146 | }else{ | 161 | }else{ |
147 | return date() > toDoEvent.date(); | 162 | return date() > toDoEvent.date(); |
148 | } | 163 | } |
149 | } | 164 | } |
150 | return true; | 165 | return true; |
151 | } | 166 | } |
152 | bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const | 167 | bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const |
153 | { | 168 | { |
154 | 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 ) | 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 ) |
155 | return true; | 170 | return true; |
156 | return false; | 171 | return false; |
157 | } | 172 | } |
158 | ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) | 173 | ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) |
159 | { | 174 | { |
160 | m_date = item.m_date; | 175 | m_date = item.m_date; |
161 | m_isCompleted = item.m_isCompleted; | 176 | m_isCompleted = item.m_isCompleted; |
162 | m_hasDate = item.m_hasDate; | 177 | m_hasDate = item.m_hasDate; |
diff --git a/libopie/todoevent.h b/libopie/todoevent.h index ac996a1..0d477fd 100644 --- a/libopie/todoevent.h +++ b/libopie/todoevent.h | |||
@@ -1,36 +1,43 @@ | |||
1 | 1 | ||
2 | #ifndef todoevent_h | 2 | #ifndef todoevent_h |
3 | #define todoevent_h | 3 | #define todoevent_h |
4 | 4 | ||
5 | #include <qstringlist.h> | ||
5 | #include <qdatetime.h> | 6 | #include <qdatetime.h> |
6 | 7 | ||
7 | class ToDoEvent { | 8 | class ToDoEvent { |
8 | friend class ToDoDB; | 9 | friend class ToDoDB; |
9 | public: | 10 | public: |
10 | enum Priority { VERYHIGH=1, HIGH, NORMAL, LOW, VERYLOW }; | 11 | enum Priority { VERYHIGH=1, HIGH, NORMAL, LOW, VERYLOW }; |
11 | ToDoEvent( bool completed = false, int priority = NORMAL, | 12 | ToDoEvent( bool completed = false, int priority = NORMAL, |
12 | const QString &category = QString::null, | 13 | const QStringList &category = QStringList(), |
13 | const QString &description = QString::null , | 14 | const QString &description = QString::null , |
14 | bool hasDate = false, QDate date = QDate::currentDate(), int uid = -1 ); | 15 | bool hasDate = false, QDate date = QDate::currentDate(), int uid = -1 ); |
15 | ToDoEvent(const ToDoEvent & ); | 16 | ToDoEvent(const ToDoEvent & ); |
16 | bool isCompleted() const; | 17 | bool isCompleted() const; |
17 | bool hasDate() const; | 18 | bool hasDate() const; |
18 | int priority()const ; | 19 | int priority()const ; |
19 | QString category()const; | 20 | QStringList allCategories()const; |
20 | QArray<int> categories() const; | 21 | QArray<int> categories() const; |
21 | QDate date()const; | 22 | QDate date()const; |
22 | QString description()const; | 23 | QString description()const; |
23 | 24 | ||
24 | int uid()const { return m_uid;}; | 25 | int uid()const { return m_uid;}; |
25 | void setCompleted(bool completed ); | 26 | void setCompleted(bool completed ); |
26 | void setHasDate( bool hasDate ); | 27 | void setHasDate( bool hasDate ); |
27 | // if the category doesn't exist we will create it | 28 | // if the category doesn't exist we will create it |
29 | // this sets the the Category after this call category will be the only category | ||
28 | void setCategory( const QString &category ); | 30 | void setCategory( const QString &category ); |
31 | // adds a category to the Categories of this event | ||
32 | void insertCategory(const QString &category ); | ||
33 | void clearCategories(); | ||
34 | void setCategories(const QStringList& ); | ||
35 | |||
29 | void setPriority(int priority ); | 36 | void setPriority(int priority ); |
30 | void setDate( QDate date ); | 37 | void setDate( QDate date ); |
31 | void setDescription(const QString& ); | 38 | void setDescription(const QString& ); |
32 | bool isOverdue(); | 39 | bool isOverdue(); |
33 | 40 | ||
34 | bool match( const QRegExp &r )const; | 41 | bool match( const QRegExp &r )const; |
35 | 42 | ||
36 | void setUid(int id) {m_uid = id; }; | 43 | void setUid(int id) {m_uid = id; }; |
@@ -43,15 +50,15 @@ class ToDoEvent { | |||
43 | ToDoEvent &operator=(const ToDoEvent &toDoEvent ); | 50 | ToDoEvent &operator=(const ToDoEvent &toDoEvent ); |
44 | private: | 51 | private: |
45 | class ToDoEventPrivate; | 52 | class ToDoEventPrivate; |
46 | ToDoEventPrivate *d; | 53 | ToDoEventPrivate *d; |
47 | QDate m_date; | 54 | QDate m_date; |
48 | bool m_isCompleted:1; | 55 | bool m_isCompleted:1; |
49 | bool m_hasDate:1; | 56 | bool m_hasDate:1; |
50 | int m_priority; | 57 | int m_priority; |
51 | QString m_category; | 58 | QStringList m_category; |
52 | QString m_desc; | 59 | QString m_desc; |
53 | int m_uid; | 60 | int m_uid; |
54 | }; | 61 | }; |
55 | 62 | ||
56 | 63 | ||
57 | #endif | 64 | #endif |
diff --git a/libopie/todovcalresource.cpp b/libopie/todovcalresource.cpp index a6afe68..75f2197 100644 --- a/libopie/todovcalresource.cpp +++ b/libopie/todovcalresource.cpp | |||
@@ -43,17 +43,17 @@ static VObject *vobjByEvent( const ToDoEvent &event ) | |||
43 | if( event.hasDate() ) | 43 | if( event.hasDate() ) |
44 | addPropValue( task, VCDueProp, TimeConversion::toISO8601( event.date() ) ); | 44 | addPropValue( task, VCDueProp, TimeConversion::toISO8601( event.date() ) ); |
45 | 45 | ||
46 | if( event.isCompleted() ) | 46 | if( event.isCompleted() ) |
47 | addPropValue( task, VCStatusProp, "COMPLETED"); | 47 | addPropValue( task, VCStatusProp, "COMPLETED"); |
48 | 48 | ||
49 | QString string = QString::number(event.priority() ); | 49 | QString string = QString::number(event.priority() ); |
50 | addPropValue( task, VCPriorityProp, string.local8Bit() ); | 50 | addPropValue( task, VCPriorityProp, string.local8Bit() ); |
51 | addPropValue( task, VCCategoriesProp, event.category().local8Bit() ); | 51 | addPropValue( task, VCCategoriesProp, event.allCategories().join(";").local8Bit() ); |
52 | addPropValue( task, VCDescriptionProp, event.description().local8Bit() ); | 52 | addPropValue( task, VCDescriptionProp, event.description().local8Bit() ); |
53 | addPropValue( task, VCSummaryProp, event.description().left(15).local8Bit() ); | 53 | addPropValue( task, VCSummaryProp, event.description().left(15).local8Bit() ); |
54 | return task; | 54 | return task; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | static ToDoEvent eventByVObj( VObject *obj ){ | 57 | static ToDoEvent eventByVObj( VObject *obj ){ |
58 | ToDoEvent event; | 58 | ToDoEvent event; |
59 | VObject *ob; | 59 | VObject *ob; |