summaryrefslogtreecommitdiff
path: root/libopie
Unidiff
Diffstat (limited to 'libopie') (more/less context) (show whitespace changes)
-rw-r--r--libopie/tododb.cpp4
-rw-r--r--libopie/todoevent.cpp35
-rw-r--r--libopie/todoevent.h59
-rw-r--r--libopie/todovcalresource.cpp7
4 files changed, 101 insertions, 4 deletions
diff --git a/libopie/tododb.cpp b/libopie/tododb.cpp
index fe8b8bf..6b10ec2 100644
--- a/libopie/tododb.cpp
+++ b/libopie/tododb.cpp
@@ -13,6 +13,7 @@ namespace {
13class FileToDoResource : public ToDoResource { 13class FileToDoResource : public ToDoResource {
14public: 14public:
15 FileToDoResource() {}; 15 FileToDoResource() {};
16 // FIXME better parsing
16 bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){ 17 bool save(const QString &name, const QValueList<ToDoEvent> &m_todos ){
17 // prepare the XML 18 // prepare the XML
18 XMLElement *tasks = new XMLElement( ); 19 XMLElement *tasks = new XMLElement( );
@@ -23,6 +24,7 @@ public:
23 map.insert( "Completed", QString::number((int)(*it).isCompleted() ) ); 24 map.insert( "Completed", QString::number((int)(*it).isCompleted() ) );
24 map.insert( "HasDate", QString::number((int)(*it).hasDate() ) ); 25 map.insert( "HasDate", QString::number((int)(*it).hasDate() ) );
25 map.insert( "Priority", QString::number( (*it).priority() ) ); 26 map.insert( "Priority", QString::number( (*it).priority() ) );
27 map.insert( "Summary", (*it).summary() );
26 QArray<int> arrat = (*it).categories(); 28 QArray<int> arrat = (*it).categories();
27 QString attr; 29 QString attr;
28 for(uint i=0; i < arrat.count(); i++ ){ 30 for(uint i=0; i < arrat.count(); i++ ){
@@ -111,6 +113,8 @@ public:
111 //description 113 //description
112 dummy = element->attribute("Description" ); 114 dummy = element->attribute("Description" );
113 event.setDescription( dummy ); 115 event.setDescription( dummy );
116 dummy = element->attribute("Summary" );
117 event.setSummary( dummy );
114 // category 118 // category
115 dummy = element->attribute("Categories" ); 119 dummy = element->attribute("Categories" );
116 QStringList ids = QStringList::split(";", dummy ); 120 QStringList ids = QStringList::split(";", dummy );
diff --git a/libopie/todoevent.cpp b/libopie/todoevent.cpp
index aa348a2..fb7073c 100644
--- a/libopie/todoevent.cpp
+++ b/libopie/todoevent.cpp
@@ -17,14 +17,18 @@ ToDoEvent::ToDoEvent(const ToDoEvent &event )
17 *this = event; 17 *this = event;
18} 18}
19 19
20ToDoEvent::ToDoEvent(bool completed, int priority, const QStringList &category, 20ToDoEvent::ToDoEvent(bool completed, int priority,
21 const QString &description, bool hasDate, QDate date, int uid ) 21 const QStringList &category,
22 const QString& summary,
23 const QString &description,
24 bool hasDate, QDate date, int uid )
22{ 25{
23 m_date = date; 26 m_date = date;
24 m_isCompleted = completed; 27 m_isCompleted = completed;
25 m_hasDate = hasDate; 28 m_hasDate = hasDate;
26 m_priority = priority; 29 m_priority = priority;
27 m_category = category; 30 m_category = category;
31 m_sum = summary;
28 m_desc = Qtopia::simplifyMultiLineSpace(description ); 32 m_desc = Qtopia::simplifyMultiLineSpace(description );
29 if (uid == -1 ) { 33 if (uid == -1 ) {
30 Qtopia::UidGen *uidgen = new Qtopia::UidGen(); 34 Qtopia::UidGen *uidgen = new Qtopia::UidGen();
@@ -66,6 +70,14 @@ QStringList ToDoEvent::allCategories()const
66{ 70{
67 return m_category; 71 return m_category;
68} 72}
73QString ToDoEvent::extra(const QString& )const
74{
75 return QString::null;
76}
77QString ToDoEvent::summary() const
78{
79 return m_sum;
80}
69void ToDoEvent::insertCategory(const QString &str ) 81void ToDoEvent::insertCategory(const QString &str )
70{ 82{
71 m_category.append( str ); 83 m_category.append( str );
@@ -99,6 +111,14 @@ void ToDoEvent::setDescription(const QString &desc )
99{ 111{
100 m_desc = Qtopia::simplifyMultiLineSpace(desc ); 112 m_desc = Qtopia::simplifyMultiLineSpace(desc );
101} 113}
114void ToDoEvent::setExtra( const QString&, const QString& )
115{
116
117}
118void ToDoEvent::setSummary( const QString& sum )
119{
120 m_sum = sum;
121}
102void ToDoEvent::setCategory( const QString &cat ) 122void ToDoEvent::setCategory( const QString &cat )
103{ 123{
104 qWarning("setCategory %s", cat.latin1() ); 124 qWarning("setCategory %s", cat.latin1() );
@@ -130,6 +150,8 @@ QString ToDoEvent::richText() const
130 150
131 // Description of the todo 151 // Description of the todo
132 if ( !description().isEmpty() ){ 152 if ( !description().isEmpty() ){
153 text += "<b>" + QObject::tr( "Summary:") + "</b><br>";
154 text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
133 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 155 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
134 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 156 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
135 } 157 }
@@ -215,7 +237,13 @@ bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const
215} 237}
216bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const 238bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const
217{ 239{
218 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 ) 240 if( m_priority == toDoEvent.m_priority &&
241 m_isCompleted == toDoEvent.m_isCompleted &&
242 m_hasDate == toDoEvent.m_hasDate &&
243 m_date == toDoEvent.m_date &&
244 m_category == toDoEvent.m_category &&
245 m_sum == toDoEvent.m_sum &&
246 m_desc == toDoEvent.m_desc )
219 return true; 247 return true;
220 return false; 248 return false;
221} 249}
@@ -228,6 +256,7 @@ ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item )
228 m_category = item.m_category; 256 m_category = item.m_category;
229 m_desc = item.m_desc; 257 m_desc = item.m_desc;
230 m_uid = item.m_uid; 258 m_uid = item.m_uid;
259 m_sum = item.m_sum;
231 return *this; 260 return *this;
232} 261}
233 262
diff --git a/libopie/todoevent.h b/libopie/todoevent.h
index 8a00f99..7454241 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 <qmap.h>
5#include <qregexp.h> 6#include <qregexp.h>
6#include <qstringlist.h> 7#include <qstringlist.h>
7#include <qdatetime.h> 8#include <qdatetime.h>
@@ -15,6 +16,7 @@ class ToDoEvent {
15 @param completed Is the TodoEvent completed 16 @param completed Is the TodoEvent completed
16 @param priority What is the priority of this ToDoEvent 17 @param priority What is the priority of this ToDoEvent
17 @param category Which category does it belong( uid ) 18 @param category Which category does it belong( uid )
19 @param summary A small summary of the todo
18 @param description What is this ToDoEvent about 20 @param description What is this ToDoEvent about
19 @param hasDate Does this Event got a deadline 21 @param hasDate Does this Event got a deadline
20 @param date what is the deadline? 22 @param date what is the deadline?
@@ -22,6 +24,7 @@ class ToDoEvent {
22 **/ 24 **/
23 ToDoEvent( bool completed = false, int priority = NORMAL, 25 ToDoEvent( bool completed = false, int priority = NORMAL,
24 const QStringList &category = QStringList(), 26 const QStringList &category = QStringList(),
27 const QString &summary = QString::null ,
25 const QString &description = QString::null , 28 const QString &description = QString::null ,
26 bool hasDate = false, QDate date = QDate::currentDate(), int uid = -1 ); 29 bool hasDate = false, QDate date = QDate::currentDate(), int uid = -1 );
27 /* Copy c'tor 30 /* Copy c'tor
@@ -43,27 +46,81 @@ class ToDoEvent {
43 What is the priority? 46 What is the priority?
44 **/ 47 **/
45 int priority()const ; 48 int priority()const ;
49
50 /*
51 All category numbers as QString in a List
52 **/
46 QStringList allCategories()const; 53 QStringList allCategories()const;
54
55 /*
56 * Same as above but with QArray<int>
57 */
47 QArray<int> categories() const; 58 QArray<int> categories() const;
59
60 /**
61 * The end Date
62 */
48 QDate date()const; 63 QDate date()const;
64
65 /**
66 * The description of the todo
67 */
49 QString description()const; 68 QString description()const;
50 69
70 /**
71 * A small summary of the todo
72 */
73 QString summary() const;
74
75 /**
76 * Return this todoevent in a RichText formatted QString
77 */
51 QString richText() const; 78 QString richText() const;
52 79
80 /**
81 * Returns the UID of the Todo
82 */
53 int uid()const { return m_uid;}; 83 int uid()const { return m_uid;};
84
85
86 QString extra(const QString& )const;
87 /**
88 * Set if this Todo is completed
89 */
54 void setCompleted(bool completed ); 90 void setCompleted(bool completed );
91
92 /**
93 * set if this todo got an end data
94 */
55 void setHasDate( bool hasDate ); 95 void setHasDate( bool hasDate );
56 // if the category doesn't exist we will create it 96 // if the category doesn't exist we will create it
57 // this sets the the Category after this call category will be the only category 97 // this sets the the Category after this call category will be the only category
58 void setCategory( const QString &category ); 98 void setCategory( const QString &category );
59 // adds a category to the Categories of this event 99 // adds a category to the Categories of this event
60 void insertCategory(const QString &category ); 100 void insertCategory(const QString &category );
101
102 /**
103 * Removes this event from all categories
104 */
61 void clearCategories(); 105 void clearCategories();
106
107 /**
108 * This todo belongs to xxx categories
109 */
62 void setCategories(const QStringList& ); 110 void setCategories(const QStringList& );
63 111
112 /**
113 * Set the priority of the Todo
114 */
64 void setPriority(int priority ); 115 void setPriority(int priority );
116
117 /**
118 * set the end date
119 */
65 void setDate( QDate date ); 120 void setDate( QDate date );
66 void setDescription(const QString& ); 121 void setDescription(const QString& );
122 void setSummary(const QString& );
123 void setExtra( const QString&, const QString& );
67 bool isOverdue(); 124 bool isOverdue();
68 125
69 bool match( const QRegExp &r )const; 126 bool match( const QRegExp &r )const;
@@ -85,6 +142,8 @@ class ToDoEvent {
85 int m_priority; 142 int m_priority;
86 QStringList m_category; 143 QStringList m_category;
87 QString m_desc; 144 QString m_desc;
145 QString m_sum;
146 QMap<QString, QString> m_extra;
88 int m_uid; 147 int m_uid;
89}; 148};
90 149
diff --git a/libopie/todovcalresource.cpp b/libopie/todovcalresource.cpp
index 75f2197..80f8c60 100644
--- a/libopie/todovcalresource.cpp
+++ b/libopie/todovcalresource.cpp
@@ -50,7 +50,7 @@ static VObject *vobjByEvent( const ToDoEvent &event )
50 addPropValue( task, VCPriorityProp, string.local8Bit() ); 50 addPropValue( task, VCPriorityProp, string.local8Bit() );
51 addPropValue( task, VCCategoriesProp, event.allCategories().join(";").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.summary().left(15).local8Bit() );
54 return task; 54 return task;
55}; 55};
56 56
@@ -64,6 +64,11 @@ static ToDoEvent eventByVObj( VObject *obj ){
64 name = vObjectStringZValue( ob ); 64 name = vObjectStringZValue( ob );
65 event.setDescription( name ); 65 event.setDescription( name );
66 } 66 }
67 // summary
68 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) {
69 name = vObjectStringZValue( ob );
70 event.setSummary( name );
71 }
67 // completed 72 // completed
68 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ 73 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){
69 name = vObjectStringZValue( ob ); 74 name = vObjectStringZValue( ob );