-rw-r--r-- | libopie/tododb.cpp | 25 | ||||
-rw-r--r-- | libopie/todoevent.cpp | 27 | ||||
-rw-r--r-- | libopie/todoevent.h | 13 | ||||
-rw-r--r-- | libopie/todovcalresource.cpp | 2 |
4 files changed, 45 insertions, 22 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: map.insert( "Completed", QString::number((int)(*it).isCompleted() ) ); map.insert( "HasDate", QString::number((int)(*it).hasDate() ) ); map.insert( "Priority", QString::number( (*it).priority() ) ); - if(!(*it).category().isEmpty() ){ - QArray<int> arrat(1); - arrat = Qtopia::Record::idsFromString( (*it).category() ); - map.insert( "Categories", QString::number( arrat[0] ) ); - }else - map.insert( "Categories", QString::null ); + QArray<int> arrat = (*it).categories(); + QString attr; + for(uint i=0; i < arrat.count(); i++ ){ + attr.append(QString::number(arrat[i])+";" ); + } + if(!attr.isEmpty() ) // remove the last ; + attr.remove(attr.length()-1, 1 ); + map.insert( "Categories", attr ); + //else + //map.insert( "Categories", QString::null ); map.insert( "Description", (*it).description() ); if( (*it).hasDate() ){ map.insert("DateYear", QString::number( (*it).date().year() ) ); @@ -101,12 +105,9 @@ public: event.setDescription( dummy ); // category dummy = element->attribute("Categories" ); - dumInt = dummy.toInt(&ok ); - if(ok ) { - QArray<int> arrat(1); - arrat[0] = dumInt; - event.setCategory( Qtopia::Record::idsToString( arrat ) ); - } + QStringList ids = QStringList::split(";", dummy ); + event.setCategories( ids ); + //uid dummy = element->attribute("Uid" ); 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 ) *this = event; } -ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category, +ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category, const QString &description, bool hasDate, QDate date, int uid ) { qWarning("todoEvent c'tor" ); @@ -28,8 +28,8 @@ ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category, } QArray<int> ToDoEvent::categories()const { - QArray<int> array(1); // currently the datebook can be only in one category - array = Qtopia::Record::idsFromString( category() ); + QArray<int> array(m_category.count() ); // currently the datebook can be only in one category + array = Qtopia::Record::idsFromString( m_category.join(";") ); return array; } bool ToDoEvent::match( const QRegExp ®Exp )const @@ -55,14 +55,28 @@ int ToDoEvent::priority()const { return m_priority; } -QString ToDoEvent::category()const +QStringList ToDoEvent::allCategories()const { return m_category; } +void ToDoEvent::insertCategory(const QString &str ) +{ + m_category.append( str ); +} +void ToDoEvent::clearCategories() +{ + m_category.clear(); +} +void ToDoEvent::setCategories(const QStringList &list ) +{ + m_category = list; + qWarning("todoevent: %s", list.join(";" ).latin1() ); +} QDate ToDoEvent::date()const { return m_date; } + QString ToDoEvent::description()const { return m_desc; @@ -82,7 +96,8 @@ void ToDoEvent::setDescription(const QString &desc ) void ToDoEvent::setCategory( const QString &cat ) { qWarning("setCategory %s", cat.latin1() ); - m_category = cat; + m_category.clear(); + m_category << cat; } void ToDoEvent::setPriority(int prio ) { @@ -151,7 +166,7 @@ bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const } bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const { - 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 ) + 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 ) return true; return false; } 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 @@ #ifndef todoevent_h #define todoevent_h +#include <qstringlist.h> #include <qdatetime.h> class ToDoEvent { @@ -9,14 +10,14 @@ class ToDoEvent { public: enum Priority { VERYHIGH=1, HIGH, NORMAL, LOW, VERYLOW }; ToDoEvent( bool completed = false, int priority = NORMAL, - const QString &category = QString::null, + const QStringList &category = QStringList(), const QString &description = QString::null , bool hasDate = false, QDate date = QDate::currentDate(), int uid = -1 ); ToDoEvent(const ToDoEvent & ); bool isCompleted() const; bool hasDate() const; int priority()const ; - QString category()const; + QStringList allCategories()const; QArray<int> categories() const; QDate date()const; QString description()const; @@ -25,7 +26,13 @@ class ToDoEvent { void setCompleted(bool completed ); void setHasDate( bool hasDate ); // if the category doesn't exist we will create it + // this sets the the Category after this call category will be the only category void setCategory( const QString &category ); + // adds a category to the Categories of this event + void insertCategory(const QString &category ); + void clearCategories(); + void setCategories(const QStringList& ); + void setPriority(int priority ); void setDate( QDate date ); void setDescription(const QString& ); @@ -48,7 +55,7 @@ class ToDoEvent { bool m_isCompleted:1; bool m_hasDate:1; int m_priority; - QString m_category; + QStringList m_category; QString m_desc; 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 @@ -48,7 +48,7 @@ static VObject *vobjByEvent( const ToDoEvent &event ) QString string = QString::number(event.priority() ); addPropValue( task, VCPriorityProp, string.local8Bit() ); - addPropValue( task, VCCategoriesProp, event.category().local8Bit() ); + addPropValue( task, VCCategoriesProp, event.allCategories().join(";").local8Bit() ); addPropValue( task, VCDescriptionProp, event.description().local8Bit() ); addPropValue( task, VCSummaryProp, event.description().left(15).local8Bit() ); return task; |