-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 | |||
@@ -22,10 +22,14 @@ public: | |||
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() ){ |
@@ -102,10 +106,7 @@ public: | |||
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" ); |
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp index 7dbf907..28b2e98 100644 --- a/libopie/todoevent.cpp +++ b/libopie/todoevent.cpp | |||
@@ -10,5 +10,5 @@ ToDoEvent::ToDoEvent(const ToDoEvent &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 | { |
@@ -29,6 +29,6 @@ ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category, | |||
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 | } |
@@ -56,12 +56,26 @@ int ToDoEvent::priority()const | |||
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 | { |
@@ -83,5 +97,6 @@ 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 ) |
@@ -152,5 +167,5 @@ bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const | |||
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; |
diff --git a/libopie/todoevent.h b/libopie/todoevent.h index ac996a1..0d477fd 100644 --- a/libopie/todoevent.h +++ b/libopie/todoevent.h | |||
@@ -3,4 +3,5 @@ | |||
3 | #define todoevent_h | 3 | #define todoevent_h |
4 | 4 | ||
5 | #include <qstringlist.h> | ||
5 | #include <qdatetime.h> | 6 | #include <qdatetime.h> |
6 | 7 | ||
@@ -10,5 +11,5 @@ class ToDoEvent { | |||
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 ); |
@@ -17,5 +18,5 @@ class ToDoEvent { | |||
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; |
@@ -25,6 +26,12 @@ class ToDoEvent { | |||
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 ); |
@@ -49,5 +56,5 @@ class ToDoEvent { | |||
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; |
diff --git a/libopie/todovcalresource.cpp b/libopie/todovcalresource.cpp index a6afe68..75f2197 100644 --- a/libopie/todovcalresource.cpp +++ b/libopie/todovcalresource.cpp | |||
@@ -49,5 +49,5 @@ static VObject *vobjByEvent( const ToDoEvent &event ) | |||
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() ); |