author | zecke <zecke> | 2002-04-13 16:27:19 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-13 16:27:19 (UTC) |
commit | def870c6fcccf2b20d7ce3821055391b18243a24 (patch) (unidiff) | |
tree | 006357788654cf0e18c76640bd821cf87731d952 | |
parent | e42465b45553f51cf7c7d24130aa3a90a6be3ddd (diff) | |
download | opie-def870c6fcccf2b20d7ce3821055391b18243a24.zip opie-def870c6fcccf2b20d7ce3821055391b18243a24.tar.gz opie-def870c6fcccf2b20d7ce3821055391b18243a24.tar.bz2 |
multiple categories
-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 | |||
@@ -23,8 +23,12 @@ public: | |||
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() ); |
@@ -103,8 +107,5 @@ public: | |||
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 |
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp index 7dbf907..28b2e98 100644 --- a/libopie/todoevent.cpp +++ b/libopie/todoevent.cpp | |||
@@ -11,3 +11,3 @@ ToDoEvent::ToDoEvent(const ToDoEvent &event ) | |||
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 ) |
@@ -30,4 +30,4 @@ 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; |
@@ -57,3 +57,3 @@ int ToDoEvent::priority()const | |||
57 | } | 57 | } |
58 | QString ToDoEvent::category()const | 58 | QStringList ToDoEvent::allCategories()const |
59 | { | 59 | { |
@@ -61,2 +61,15 @@ QString ToDoEvent::category()const | |||
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 |
@@ -65,2 +78,3 @@ QDate ToDoEvent::date()const | |||
65 | } | 78 | } |
79 | |||
66 | QString ToDoEvent::description()const | 80 | QString ToDoEvent::description()const |
@@ -84,3 +98,4 @@ void ToDoEvent::setCategory( const QString &cat ) | |||
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 | } |
@@ -153,3 +168,3 @@ 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; |
diff --git a/libopie/todoevent.h b/libopie/todoevent.h index ac996a1..0d477fd 100644 --- a/libopie/todoevent.h +++ b/libopie/todoevent.h | |||
@@ -4,2 +4,3 @@ | |||
4 | 4 | ||
5 | #include <qstringlist.h> | ||
5 | #include <qdatetime.h> | 6 | #include <qdatetime.h> |
@@ -11,3 +12,3 @@ class ToDoEvent { | |||
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 , |
@@ -18,3 +19,3 @@ class ToDoEvent { | |||
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; |
@@ -26,4 +27,10 @@ class ToDoEvent { | |||
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 ); |
@@ -50,3 +57,3 @@ class ToDoEvent { | |||
50 | int m_priority; | 57 | int m_priority; |
51 | QString m_category; | 58 | QStringList m_category; |
52 | QString m_desc; | 59 | QString m_desc; |
diff --git a/libopie/todovcalresource.cpp b/libopie/todovcalresource.cpp index a6afe68..75f2197 100644 --- a/libopie/todovcalresource.cpp +++ b/libopie/todovcalresource.cpp | |||
@@ -50,3 +50,3 @@ static VObject *vobjByEvent( const ToDoEvent &event ) | |||
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() ); |