summaryrefslogtreecommitdiff
path: root/libopie
Side-by-side diff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/tododb.cpp12
-rw-r--r--libopie/todoevent.cpp43
-rw-r--r--libopie/todoevent.h67
-rw-r--r--libopie/todovcalresource.cpp23
4 files changed, 121 insertions, 24 deletions
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp
index fe8b8bf..6b10ec2 100644
--- a/libopie/tododb.cpp
+++ b/libopie/tododb.cpp
@@ -14,4 +14,5 @@ class FileToDoResource : public ToDoResource {
public:
FileToDoResource() {};
+ // FIXME better parsing
bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){
// prepare the XML
@@ -24,4 +25,5 @@ public:
map.insert( "HasDate", QString::number((int)(*it).hasDate() ) );
map.insert( "Priority", QString::number( (*it).priority() ) );
+ map.insert( "Summary", (*it).summary() );
QArray<int> arrat = (*it).categories();
QString attr;
@@ -112,9 +114,11 @@ public:
dummy = element->attribute("Description" );
event.setDescription( dummy );
+ dummy = element->attribute("Summary" );
+ event.setSummary( dummy );
// category
dummy = element->attribute("Categories" );
QStringList ids = QStringList::split(";", dummy );
- event.setCategories( ids );
-
+ event.setCategories( ids );
+
//uid
dummy = element->attribute("Uid" );
@@ -182,5 +186,5 @@ QValueList<ToDoEvent> ToDoDB::overDue()
{
QValueList<ToDoEvent> events;
- for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){
+ for( QValueList<ToDoEvent>::Iterator it = m_todos.begin(); it!= m_todos.end(); ++it ){
if( (*it).isOverdue() )
events.append((*it) );
@@ -239,5 +243,5 @@ QString ToDoDB::fileName()const
void ToDoDB::load()
{
- m_todos = m_res->load( m_fileName );
+ m_todos = m_res->load( m_fileName );
}
bool ToDoDB::save()
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp
index aa348a2..fb7073c 100644
--- a/libopie/todoevent.cpp
+++ b/libopie/todoevent.cpp
@@ -18,6 +18,9 @@ ToDoEvent::ToDoEvent(const ToDoEvent &event )
}
-ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category,
- const QString &description, bool hasDate, QDate date, int uid )
+ToDoEvent::ToDoEvent(bool completed, int priority,
+ const QStringList &category,
+ const QString& summary,
+ const QString &description,
+ bool hasDate, QDate date, int uid )
{
m_date = date;
@@ -26,4 +29,5 @@ ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category,
m_priority = priority;
m_category = category;
+ m_sum = summary;
m_desc = Qtopia::simplifyMultiLineSpace(description );
if (uid == -1 ) {
@@ -32,5 +36,5 @@ ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category,
delete uidgen;
}// generate the ids
- m_uid = uid;
+ m_uid = uid;
}
QArray<int> ToDoEvent::categories()const
@@ -67,4 +71,12 @@ QStringList ToDoEvent::allCategories()const
return m_category;
}
+QString ToDoEvent::extra(const QString& )const
+{
+ return QString::null;
+}
+QString ToDoEvent::summary() const
+{
+ return m_sum;
+}
void ToDoEvent::insertCategory(const QString &str )
{
@@ -100,4 +112,12 @@ void ToDoEvent::setDescription(const QString &desc )
m_desc = Qtopia::simplifyMultiLineSpace(desc );
}
+void ToDoEvent::setExtra( const QString&, const QString& )
+{
+
+}
+void ToDoEvent::setSummary( const QString& sum )
+{
+ m_sum = sum;
+}
void ToDoEvent::setCategory( const QString &cat )
{
@@ -128,7 +148,9 @@ QString ToDoEvent::richText() const
QString text;
QStringList catlist;
-
+
// Description of the todo
if ( !description().isEmpty() ){
+ text += "<b>" + QObject::tr( "Summary:") + "</b><br>";
+ text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
@@ -141,5 +163,5 @@ QString ToDoEvent::richText() const
text += "<br>";
}
-
+
// Open database of all categories and get the list of
// the categories this todoevent belongs to.
@@ -150,5 +172,5 @@ QString ToDoEvent::richText() const
catdb.load( categoryFileName() );
catlist = allCategories();
-
+
text += "<b>" + QObject::tr( "Category:") + "</b> ";
for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) {
@@ -216,5 +238,11 @@ 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_desc )
+ if( m_priority == toDoEvent.m_priority &&
+ m_isCompleted == toDoEvent.m_isCompleted &&
+ m_hasDate == toDoEvent.m_hasDate &&
+ m_date == toDoEvent.m_date &&
+ m_category == toDoEvent.m_category &&
+ m_sum == toDoEvent.m_sum &&
+ m_desc == toDoEvent.m_desc )
return true;
return false;
@@ -229,4 +257,5 @@ ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item )
m_desc = item.m_desc;
m_uid = item.m_uid;
+ m_sum = item.m_sum;
return *this;
}
diff --git a/libopie/todoevent.h b/libopie/todoevent.h
index 8a00f99..7454241 100644
--- a/libopie/todoevent.h
+++ b/libopie/todoevent.h
@@ -3,4 +3,5 @@
#define todoevent_h
+#include <qmap.h>
#include <qregexp.h>
#include <qstringlist.h>
@@ -16,4 +17,5 @@ class ToDoEvent {
@param priority What is the priority of this ToDoEvent
@param category Which category does it belong( uid )
+ @param summary A small summary of the todo
@param description What is this ToDoEvent about
@param hasDate Does this Event got a deadline
@@ -21,7 +23,8 @@ class ToDoEvent {
@param uid what is the UUID of this Event
**/
- ToDoEvent( bool completed = false, int priority = NORMAL,
- const QStringList &category = QStringList(),
- const QString &description = QString::null ,
+ ToDoEvent( bool completed = false, int priority = NORMAL,
+ const QStringList &category = QStringList(),
+ const QString &summary = QString::null ,
+ const QString &description = QString::null,
bool hasDate = false, QDate date = QDate::currentDate(), int uid = -1 );
/* Copy c'tor
@@ -44,25 +47,79 @@ class ToDoEvent {
**/
int priority()const ;
+
+ /*
+ All category numbers as QString in a List
+ **/
QStringList allCategories()const;
+
+ /*
+ * Same as above but with QArray<int>
+ */
QArray<int> categories() const;
+
+ /**
+ * The end Date
+ */
QDate date()const;
+
+ /**
+ * The description of the todo
+ */
QString description()const;
+ /**
+ * A small summary of the todo
+ */
+ QString summary() const;
+
+ /**
+ * Return this todoevent in a RichText formatted QString
+ */
QString richText() const;
+ /**
+ * Returns the UID of the Todo
+ */
int uid()const { return m_uid;};
+
+
+ QString extra(const QString& )const;
+ /**
+ * Set if this Todo is completed
+ */
void setCompleted(bool completed );
+
+ /**
+ * set if this todo got an end data
+ */
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
+ // 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 );
+
+ /**
+ * Removes this event from all categories
+ */
void clearCategories();
+
+ /**
+ * This todo belongs to xxx categories
+ */
void setCategories(const QStringList& );
+ /**
+ * Set the priority of the Todo
+ */
void setPriority(int priority );
+
+ /**
+ * set the end date
+ */
void setDate( QDate date );
void setDescription(const QString& );
+ void setSummary(const QString& );
+ void setExtra( const QString&, const QString& );
bool isOverdue();
@@ -86,4 +143,6 @@ class ToDoEvent {
QStringList m_category;
QString m_desc;
+ QString m_sum;
+ QMap<QString, QString> m_extra;
int m_uid;
};
diff --git a/libopie/todovcalresource.cpp b/libopie/todovcalresource.cpp
index 75f2197..80f8c60 100644
--- a/libopie/todovcalresource.cpp
+++ b/libopie/todovcalresource.cpp
@@ -3,5 +3,5 @@
             .=l. Copyright (c) 2002 Holger Freyther <freyther@kde.org>
           .>+-= the use of vobject was inspired by libkcal
- _;:,     .>    :=|. This library is free software; you can
+ _;:,     .>    :=|. 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
@@ -9,6 +9,6 @@
 - .   .-<_>     .<> 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
+    .%`+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
@@ -17,8 +17,8 @@
..}^=.=       =       ; 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.
+    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
@@ -51,5 +51,5 @@ static VObject *vobjByEvent( const ToDoEvent &event )
addPropValue( task, VCCategoriesProp, event.allCategories().join(";").local8Bit() );
addPropValue( task, VCDescriptionProp, event.description().local8Bit() );
- addPropValue( task, VCSummaryProp, event.description().left(15).local8Bit() );
+ addPropValue( task, VCSummaryProp, event.summary().left(15).local8Bit() );
return task;
};
@@ -64,5 +64,10 @@ static ToDoEvent eventByVObj( VObject *obj ){
name = vObjectStringZValue( ob );
event.setDescription( name );
- }
+ }
+ // summary
+ if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) {
+ name = vObjectStringZValue( ob );
+ event.setSummary( name );
+ }
// completed
if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){
@@ -86,5 +91,5 @@ static ToDoEvent eventByVObj( VObject *obj ){
name = vObjectStringZValue( ob );
event.setDate( TimeConversion::fromISO8601( name).date() );
- }
+ }
// categories
if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){
@@ -97,5 +102,5 @@ static ToDoEvent eventByVObj( VObject *obj ){
-QValueList<ToDoEvent> ToDoVCalResource::load(const QString &file)
+QValueList<ToDoEvent> ToDoVCalResource::load(const QString &file)
{
QValueList<ToDoEvent> events;