author | zecke <zecke> | 2002-03-20 21:55:54 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-03-20 21:55:54 (UTC) |
commit | c6e7f6e2ab8556064ec79fc9bbaa9e0398a7b344 (patch) (side-by-side diff) | |
tree | f68d6a7c899e1ffe297af30002a3dc8b4f3762c6 | |
parent | 0d759d6e9c84a8597b6594bb7c5ad5d17621b966 (diff) | |
download | opie-c6e7f6e2ab8556064ec79fc9bbaa9e0398a7b344.zip opie-c6e7f6e2ab8556064ec79fc9bbaa9e0398a7b344.tar.gz opie-c6e7f6e2ab8556064ec79fc9bbaa9e0398a7b344.tar.bz2 |
tododb vCal support
-rw-r--r-- | libopie/tododb.h | 4 | ||||
-rw-r--r-- | libopie/todoevent.cpp | 6 | ||||
-rw-r--r-- | libopie/todoevent.h | 1 | ||||
-rw-r--r-- | libopie/todovcalresource.h | 42 |
4 files changed, 51 insertions, 2 deletions
diff --git a/libopie/tododb.h b/libopie/tododb.h index 945f343..e77a0f4 100644 --- a/libopie/tododb.h +++ b/libopie/tododb.h @@ -1,44 +1,44 @@ #ifndef tododb_h #define tododb_h #include <qvaluelist.h> #include <opie/todoevent.h> class ToDoResource; class ToDoDB { public: // if no argument is supplied pick the default book ToDoDB(const QString &fileName = QString::null, ToDoResource* resource= 0 ); ~ToDoDB(); QValueList<ToDoEvent> effectiveToDos(const QDate &from, const QDate &to, bool includeNoDates = true); QValueList<ToDoEvent> effectiveToDos(const QDate &start, bool includeNoDates = true ); QValueList<ToDoEvent> rawToDos(); // all events QValueList<ToDoEvent> overDue(); void addEvent(const ToDoEvent &event ); void editEvent(const ToDoEvent &editEvent ); void removeEvent(const ToDoEvent &event); void reload(); void setFileName(const QString & ); QString fileName()const; bool save(); - ToDoResource *resource(); - void setResource(ToDoResource* res); + ToDoResource *resource(); + void setResource(ToDoResource* res); private: class ToDoDBPrivate; ToDoDBPrivate *d; QString m_fileName; ToDoResource *m_res; QValueList<ToDoEvent> m_todos; void load(); }; #endif diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp index 5fa4472..daa25f4 100644 --- a/libopie/todoevent.cpp +++ b/libopie/todoevent.cpp @@ -1,70 +1,75 @@ #include <opie/todoevent.h> #include <qpe/palmtopuidgen.h> #include <qpe/stringutil.h> //#include <qpe/palmtoprecord.h> +ToDoEvent::ToDoEvent(const ToDoEvent &event ) +{ + *this = event; +} + ToDoEvent::ToDoEvent(bool completed, int priority, const QString &category, const QString &description, bool hasDate, QDate date, int uid ) { qWarning("todoEvent c'tor" ); m_date = date; m_isCompleted = completed; m_hasDate = hasDate; m_priority = priority; m_category = category; m_desc = Qtopia::simplifyMultiLineSpace(description ); if (uid == -1 ) { Qtopia::UidGen *uidgen = new Qtopia::UidGen(); uid = uidgen->generate(); delete uidgen; }// generate the ids m_uid = uid; } bool ToDoEvent::isCompleted() const { return m_isCompleted; } bool ToDoEvent::hasDate() const { return m_hasDate; } int ToDoEvent::priority()const { return m_priority; } QString ToDoEvent::category()const { return m_category; } QDate ToDoEvent::date()const { return m_date; } QString ToDoEvent::description()const { return m_desc; } void ToDoEvent::setCompleted( bool completed ) { m_isCompleted = completed; } void ToDoEvent::setHasDate( bool hasDate ) { m_hasDate = hasDate; } void ToDoEvent::setDescription(const QString &desc ) { m_desc = Qtopia::simplifyMultiLineSpace(desc ); } void ToDoEvent::setCategory( const QString &cat ) { m_category = cat; } void ToDoEvent::setPriority(int prio ) { m_priority = prio; } void ToDoEvent::setDate( QDate date ) { m_date = date; @@ -79,74 +84,75 @@ bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ if( !hasDate() && !toDoEvent.hasDate() ) return true; if( !hasDate() && toDoEvent.hasDate() ) return true; if( hasDate() && toDoEvent.hasDate() ){ if( date() == toDoEvent.date() ){ // let's the priority decide return priority() < toDoEvent.priority(); }else{ return date() < toDoEvent.date(); } } return false; } bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const { if( !hasDate() && !toDoEvent.hasDate() ) return true; if( !hasDate() && toDoEvent.hasDate() ) return true; if( hasDate() && toDoEvent.hasDate() ){ if( date() == toDoEvent.date() ){ // let's the priority decide return priority() <= toDoEvent.priority(); }else{ return date() <= toDoEvent.date(); } } return true; } bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const { if( !hasDate() && !toDoEvent.hasDate() ) return false; if( !hasDate() && toDoEvent.hasDate() ) return false; if( hasDate() && toDoEvent.hasDate() ){ if( date() == toDoEvent.date() ){ // let's the priority decide return priority() > toDoEvent.priority(); }else{ return date() > toDoEvent.date(); } } return false; } bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const { if( !hasDate() && !toDoEvent.hasDate() ) return true; if( !hasDate() && toDoEvent.hasDate() ) return false; if( hasDate() && toDoEvent.hasDate() ){ if( date() == toDoEvent.date() ){ // let's the priority decide return priority() > toDoEvent.priority(); }else{ return date() > toDoEvent.date(); } } return true; } 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 ) return true; return false; } ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) { m_date = item.m_date; m_isCompleted = item.m_isCompleted; m_hasDate = item.m_hasDate; m_priority = item.m_priority; m_category = item.m_category; m_desc = item.m_desc; + m_uid = item.m_uid; return *this; } diff --git a/libopie/todoevent.h b/libopie/todoevent.h index 79522b2..bca7f6e 100644 --- a/libopie/todoevent.h +++ b/libopie/todoevent.h @@ -1,53 +1,54 @@ #ifndef todoevent_h #define todoevent_h #include <qdatetime.h> class ToDoEvent { friend class ToDoDB; public: enum Priority { VERYHIGH=1, HIGH, NORMAL, LOW, VERYLOW }; ToDoEvent( bool completed = false, int priority = NORMAL, const QString &category = QString::null, 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; QDate date()const; QString description()const; int uid()const { return m_uid;}; void setCompleted(bool completed ); void setHasDate( bool hasDate ); // if the category doesn't exist we will create it void setCategory( const QString &category ); void setPriority(int priority ); void setDate( QDate date ); void setDescription(const QString& ); bool isOverdue(); void setUid(int id) {m_uid = id; }; bool operator<(const ToDoEvent &toDoEvent )const; bool operator<=(const ToDoEvent &toDoEvent )const; bool operator!=(const ToDoEvent &toDoEvent )const { return !(*this == toDoEvent); }; bool operator>(const ToDoEvent &toDoEvent )const; bool operator>=(const ToDoEvent &toDoEvent)const; bool operator==(const ToDoEvent &toDoEvent )const; ToDoEvent &operator=(const ToDoEvent &toDoEvent ); private: class ToDoEventPrivate; ToDoEventPrivate *d; QDate m_date; bool m_isCompleted:1; bool m_hasDate:1; int m_priority; QString m_category; QString m_desc; int m_uid; }; #endif diff --git a/libopie/todovcalresource.h b/libopie/todovcalresource.h new file mode 100644 index 0000000..0663bc2 --- a/dev/null +++ b/libopie/todovcalresource.h @@ -0,0 +1,42 @@ +/* + =. This file is part of the OPIE Project + .=l. Copyright (c) 2002 Holger Freyther <freyther@kde.org> + .>+-= + _;:, .> :=|. This library is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This library is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#ifndef opievcaltodoresource_h +#define opievcaltodoresource_h + +#include <opie/todoresource.h> + +class ToDoVCalResource : public ToDoResource { + public: + ToDoVCalResource() { }; + QValueList<ToDoEvent> load(const QString &file ); + bool save( const QString &filename, const QValueList<ToDoEvent> & ); + +}; + +#endif |