summaryrefslogtreecommitdiff
authorzecke <zecke>2002-04-13 16:27:19 (UTC)
committer zecke <zecke>2002-04-13 16:27:19 (UTC)
commitdef870c6fcccf2b20d7ce3821055391b18243a24 (patch) (unidiff)
tree006357788654cf0e18c76640bd821cf87731d952
parente42465b45553f51cf7c7d24130aa3a90a6be3ddd (diff)
downloadopie-def870c6fcccf2b20d7ce3821055391b18243a24.zip
opie-def870c6fcccf2b20d7ce3821055391b18243a24.tar.gz
opie-def870c6fcccf2b20d7ce3821055391b18243a24.tar.bz2
multiple categories
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/tododb.cpp25
-rw-r--r--libopie/todoevent.cpp27
-rw-r--r--libopie/todoevent.h15
-rw-r--r--libopie/todovcalresource.cpp2
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
@@ -21,12 +21,16 @@ public:
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() ) );
@@ -101,12 +105,9 @@ public:
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 );
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp
index 7dbf907..28b2e98 100644
--- a/libopie/todoevent.cpp
+++ b/libopie/todoevent.cpp
@@ -9,7 +9,7 @@ ToDoEvent::ToDoEvent(const ToDoEvent &event )
9 *this = event; 9 *this = event;
10} 10}
11 11
12ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category, 12ToDoEvent::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" );
@@ -28,8 +28,8 @@ ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category,
28} 28}
29QArray<int> ToDoEvent::categories()const 29QArray<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}
35bool ToDoEvent::match( const QRegExp &regExp )const 35bool ToDoEvent::match( const QRegExp &regExp )const
@@ -55,14 +55,28 @@ int ToDoEvent::priority()const
55{ 55{
56 return m_priority; 56 return m_priority;
57} 57}
58QString ToDoEvent::category()const 58QStringList ToDoEvent::allCategories()const
59{ 59{
60 return m_category; 60 return m_category;
61} 61}
62void ToDoEvent::insertCategory(const QString &str )
63{
64 m_category.append( str );
65}
66void ToDoEvent::clearCategories()
67{
68 m_category.clear();
69}
70void ToDoEvent::setCategories(const QStringList &list )
71{
72 m_category = list;
73 qWarning("todoevent: %s", list.join(";" ).latin1() );
74}
62QDate ToDoEvent::date()const 75QDate ToDoEvent::date()const
63{ 76{
64 return m_date; 77 return m_date;
65} 78}
79
66QString ToDoEvent::description()const 80QString ToDoEvent::description()const
67{ 81{
68 return m_desc; 82 return m_desc;
@@ -82,7 +96,8 @@ void ToDoEvent::setDescription(const QString &desc )
82void ToDoEvent::setCategory( const QString &cat ) 96void 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}
87void ToDoEvent::setPriority(int prio ) 102void ToDoEvent::setPriority(int prio )
88{ 103{
@@ -151,7 +166,7 @@ bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const
151} 166}
152bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const 167bool 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}
diff --git a/libopie/todoevent.h b/libopie/todoevent.h
index ac996a1..0d477fd 100644
--- a/libopie/todoevent.h
+++ b/libopie/todoevent.h
@@ -2,6 +2,7 @@
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
7class ToDoEvent { 8class ToDoEvent {
@@ -9,14 +10,14 @@ class ToDoEvent {
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;
@@ -24,8 +25,14 @@ class ToDoEvent {
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& );
@@ -48,7 +55,7 @@ class ToDoEvent {
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};
diff --git a/libopie/todovcalresource.cpp b/libopie/todovcalresource.cpp
index a6afe68..75f2197 100644
--- a/libopie/todovcalresource.cpp
+++ b/libopie/todovcalresource.cpp
@@ -48,7 +48,7 @@ static VObject *vobjByEvent( const ToDoEvent &event )
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;