-rw-r--r-- | libopie2/opiepim/core/opimrecord.cpp | 26 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.h | 4 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.cpp | 265 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.h | 26 |
4 files changed, 95 insertions, 226 deletions
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp index 95de1df..d8f73c7 100644 --- a/libopie2/opiepim/core/opimrecord.cpp +++ b/libopie2/opiepim/core/opimrecord.cpp | |||
@@ -1,90 +1,106 @@ | |||
1 | #include "opimrecord.h" | 1 | #include "opimrecord.h" |
2 | 2 | ||
3 | OPimRecord::OPimRecord( int uid ) | 3 | OPimRecord::OPimRecord( int uid ) |
4 | : Qtopia::Record() { | 4 | : Qtopia::Record() { |
5 | |||
5 | setUid( uid ); | 6 | setUid( uid ); |
7 | /* assign a new UID */ | ||
6 | if ( uid == 1 ) | 8 | if ( uid == 1 ) |
7 | assignUid(); | 9 | assignUid(); |
8 | } | 10 | } |
9 | OPimRecord::~OPimRecord() { | 11 | OPimRecord::~OPimRecord() { |
10 | } | 12 | } |
11 | OPimRecord::OPimRecord( OPimRecord& rec ) | 13 | OPimRecord::OPimRecord( const OPimRecord& rec ) |
12 | : Qtopia::Record( rec ) | 14 | : Qtopia::Record( rec ) |
13 | { | 15 | { |
14 | (*this) = rec; | 16 | (*this) = rec; |
15 | } | 17 | } |
16 | 18 | ||
17 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { | 19 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { |
18 | /* how do I call the parent copy operator ? */ | 20 | Qtopia::Record::operator=( rec ); |
19 | setUid( rec.uid() ); | 21 | m_relations = rec.m_relations; |
20 | setCategories( rec.categories() ); | 22 | |
21 | return *this; | 23 | return *this; |
22 | } | 24 | } |
23 | QStringList OPimRecord::categoryNames()const { | 25 | QStringList OPimRecord::categoryNames()const { |
24 | QStringList list; | 26 | QStringList list; |
25 | 27 | ||
26 | return list; | 28 | return list; |
27 | } | 29 | } |
28 | void OPimRecord::setCategoryName( const QStringList& ) { | 30 | void OPimRecord::setCategoryNames( const QStringList& ) { |
29 | 31 | ||
30 | } | 32 | } |
31 | void OPimRecord::addCategoryName( const QString& ) { | 33 | void OPimRecord::addCategoryName( const QString& ) { |
32 | 34 | ||
33 | } | 35 | } |
34 | bool OPimRecord::isEmpty()const { | 36 | bool OPimRecord::isEmpty()const { |
35 | return ( uid() == 0 ); | 37 | return ( uid() == 0 ); |
36 | } | 38 | } |
37 | QStringList OPimRecord::relatedApps()const{ | 39 | QStringList OPimRecord::relatedApps()const{ |
38 | QStringList list; | 40 | QStringList list; |
39 | QMap<QString, QArray<int> >::ConstIterator it; | 41 | QMap<QString, QArray<int> >::ConstIterator it; |
40 | for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { | 42 | for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { |
41 | list << it.key(); | 43 | list << it.key(); |
42 | } | 44 | } |
43 | return list; | 45 | return list; |
44 | } | 46 | } |
45 | QArray<int> OPimRecord::relations(const QString& app )const { | 47 | QArray<int> OPimRecord::relations(const QString& app )const { |
46 | QArray<int> tmp; | 48 | QArray<int> tmp; |
47 | QMap<QString, QArray<int> >::ConstIterator it; | 49 | QMap<QString, QArray<int> >::ConstIterator it; |
48 | it = m_relations.find( app); | 50 | it = m_relations.find( app); |
49 | if ( it != m_relations.end() ) | 51 | if ( it != m_relations.end() ) |
50 | tmp = it.data(); | 52 | tmp = it.data(); |
51 | return tmp; | 53 | return tmp; |
52 | } | 54 | } |
53 | void OPimRecord::clearRelation( const QString& app ) { | 55 | void OPimRecord::clearRelation( const QString& app ) { |
54 | m_relations.remove( app ); | 56 | m_relations.remove( app ); |
55 | } | 57 | } |
56 | void OPimRecord::addRelation( const QString& app, int id ) { | 58 | void OPimRecord::addRelation( const QString& app, int id ) { |
57 | 59 | ||
58 | QMap<QString, QArray<int> >::Iterator it; | 60 | QMap<QString, QArray<int> >::Iterator it; |
59 | QArray<int> tmp; | 61 | QArray<int> tmp; |
60 | 62 | ||
61 | it = m_relations.find( app ); | 63 | it = m_relations.find( app ); |
62 | if ( it == m_relations.end() ) { | 64 | if ( it == m_relations.end() ) { |
63 | tmp.resize(1 ); | 65 | tmp.resize(1 ); |
64 | tmp[0] = id; | 66 | tmp[0] = id; |
65 | }else{ | 67 | }else{ |
66 | tmp = it.data(); | 68 | tmp = it.data(); |
67 | tmp.resize( tmp.size() + 1 ); | 69 | tmp.resize( tmp.size() + 1 ); |
68 | tmp[tmp.size() - 1] = id; | 70 | tmp[tmp.size() - 1] = id; |
69 | } | 71 | } |
70 | m_relations.replace( app, tmp ); | 72 | m_relations.replace( app, tmp ); |
71 | } | 73 | } |
72 | void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { | 74 | void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { |
73 | 75 | ||
74 | QMap<QString, QArray<int> >::Iterator it; | 76 | QMap<QString, QArray<int> >::Iterator it; |
75 | QArray<int> tmp; | 77 | QArray<int> tmp; |
76 | 78 | ||
77 | it = m_relations.find( app); | 79 | it = m_relations.find( app); |
78 | if ( it == m_relations.end() ) { | 80 | if ( it == m_relations.end() ) { |
79 | tmp = ids; | 81 | tmp = ids; |
80 | }else{ | 82 | }else{ |
81 | tmp = it.data(); | 83 | tmp = it.data(); |
82 | int offset = tmp.size()-1; | 84 | int offset = tmp.size()-1; |
83 | tmp.resize( tmp.size() + ids.size() ); | 85 | tmp.resize( tmp.size() + ids.size() ); |
84 | for (uint i = 0; i < ids.size(); i++ ) { | 86 | for (uint i = 0; i < ids.size(); i++ ) { |
85 | tmp[offset+i] = ids[i]; | 87 | tmp[offset+i] = ids[i]; |
86 | } | 88 | } |
87 | 89 | ||
88 | } | 90 | } |
89 | m_relations.replace( app, tmp ); | 91 | m_relations.replace( app, tmp ); |
90 | } | 92 | } |
93 | QString OPimRecord::crossToString()const { | ||
94 | QString str; | ||
95 | QMap<QString, QArray<int> >::ConstIterator it; | ||
96 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { | ||
97 | QArray<int> id = it.data(); | ||
98 | for ( uint i = 0; i < id.size(); ++i ) { | ||
99 | str += it.key() + "," + QString::number( i ) + ";"; | ||
100 | } | ||
101 | } | ||
102 | str = str.remove( str.length()-1, 1); // strip the ; | ||
103 | //qWarning("IDS " + str ); | ||
104 | |||
105 | return str; | ||
106 | } | ||
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h index a0e0413..18112d4 100644 --- a/libopie2/opiepim/core/opimrecord.h +++ b/libopie2/opiepim/core/opimrecord.h | |||
@@ -1,69 +1,69 @@ | |||
1 | #ifndef OPIE_PIM_RECORD_H | 1 | #ifndef OPIE_PIM_RECORD_H |
2 | #define OPIE_PIM_RECORD_H | 2 | #define OPIE_PIM_RECORD_H |
3 | 3 | ||
4 | #include <qmap.h> | 4 | #include <qmap.h> |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | #include <qstringlist.h> | 6 | #include <qstringlist.h> |
7 | 7 | ||
8 | #include <qpe/palmtoprecord.h> | 8 | #include <qpe/palmtoprecord.h> |
9 | 9 | ||
10 | class OPimRecord : public Qtopia::Record { | 10 | class OPimRecord : public Qtopia::Record { |
11 | public: | 11 | public: |
12 | /** | 12 | /** |
13 | * uid of 0 isEmpty | 13 | * uid of 0 isEmpty |
14 | * uid of 1 will be assigned a new one | 14 | * uid of 1 will be assigned a new one |
15 | */ | 15 | */ |
16 | OPimRecord(int uid = 0); | 16 | OPimRecord(int uid = 0); |
17 | ~OPimRecord(); | 17 | ~OPimRecord(); |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * copy c'tor | 20 | * copy c'tor |
21 | */ | 21 | */ |
22 | OPimRecord( OPimRecord& rec ); | 22 | OPimRecord( const OPimRecord& rec ); |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * copy operator | 25 | * copy operator |
26 | */ | 26 | */ |
27 | OPimRecord &operator=( const OPimRecord& ); | 27 | OPimRecord &operator=( const OPimRecord& ); |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * category names resolved | 30 | * category names resolved |
31 | */ | 31 | */ |
32 | QStringList categoryNames()const; | 32 | QStringList categoryNames()const; |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * set category names they will be resolved | 35 | * set category names they will be resolved |
36 | */ | 36 | */ |
37 | void setCategoryName( const QStringList& ); | 37 | void setCategoryNames( const QStringList& ); |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * addCategoryName adds a name | 40 | * addCategoryName adds a name |
41 | * to the internal category list | 41 | * to the internal category list |
42 | */ | 42 | */ |
43 | void addCategoryName( const QString& ); | 43 | void addCategoryName( const QString& ); |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * if a Record isEmpty | 46 | * if a Record isEmpty |
47 | */ | 47 | */ |
48 | virtual bool isEmpty()const; | 48 | virtual bool isEmpty()const; |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * toRichText summary | 51 | * toRichText summary |
52 | */ | 52 | */ |
53 | virtual QString toRichText()const = 0; | 53 | virtual QString toRichText()const = 0; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * a small one line summary | 56 | * a small one line summary |
57 | */ | 57 | */ |
58 | virtual QString toShortText()const = 0; | 58 | virtual QString toShortText()const = 0; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * the name of the Record | 61 | * the name of the Record |
62 | */ | 62 | */ |
63 | virtual QString type()const = 0; | 63 | virtual QString type()const = 0; |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * converts the internal structure to a map | 66 | * converts the internal structure to a map |
67 | */ | 67 | */ |
68 | virtual QMap<int, QString> toMap()const = 0; | 68 | virtual QMap<int, QString> toMap()const = 0; |
69 | 69 | ||
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp index d8e0447..3c93838 100644 --- a/libopie2/opiepim/otodo.cpp +++ b/libopie2/opiepim/otodo.cpp | |||
@@ -1,507 +1,354 @@ | |||
1 | 1 | ||
2 | #include <qobject.h> | 2 | #include <qobject.h> |
3 | #include <qshared.h> | 3 | #include <qshared.h> |
4 | 4 | ||
5 | 5 | ||
6 | 6 | ||
7 | #include <qpe/palmtopuidgen.h> | 7 | #include <qpe/palmtopuidgen.h> |
8 | #include <qpe/stringutil.h> | 8 | #include <qpe/stringutil.h> |
9 | #include <qpe/palmtoprecord.h> | 9 | #include <qpe/palmtoprecord.h> |
10 | #include <qpe/stringutil.h> | 10 | #include <qpe/stringutil.h> |
11 | #include <qpe/categories.h> | 11 | #include <qpe/categories.h> |
12 | #include <qpe/categoryselect.h> | 12 | #include <qpe/categoryselect.h> |
13 | 13 | ||
14 | #include "todoevent.h" | ||
15 | 14 | ||
16 | using namespace Opie; | ||
17 | 15 | ||
18 | Qtopia::UidGen ToDoEvent::m_gen; | 16 | #include "otodo.h" |
19 | 17 | ||
20 | struct ToDoEvent::ToDoEventData : public QShared { | 18 | |
21 | ToDoEventData() : QShared() { | 19 | struct OTodo::OTodoData : public QShared { |
20 | OTodoData() : QShared() { | ||
22 | }; | 21 | }; |
23 | 22 | ||
24 | QDate date; | 23 | QDate date; |
25 | bool isCompleted:1; | 24 | bool isCompleted:1; |
26 | bool hasDate:1; | 25 | bool hasDate:1; |
27 | int priority; | 26 | int priority; |
28 | QStringList category; | 27 | QStringList category; |
29 | QString desc; | 28 | QString desc; |
30 | QString sum; | 29 | QString sum; |
31 | QMap<QString, QString> extra; | 30 | QMap<QString, QString> extra; |
32 | QMap<QString, QArray<int> > relations; | ||
33 | int uid; | ||
34 | ushort prog; | 31 | ushort prog; |
35 | bool hasAlarmDateTime :1; | 32 | bool hasAlarmDateTime :1; |
36 | QDateTime alarmDateTime; | 33 | QDateTime alarmDateTime; |
37 | }; | 34 | }; |
38 | 35 | ||
39 | ToDoEvent::ToDoEvent(const ToDoEvent &event ) | 36 | OTodo::OTodo(const OTodo &event ) |
40 | : data( event.data ) | 37 | : OPimRecord( event ), data( event.data ) |
41 | { | 38 | { |
42 | data->ref(); | 39 | data->ref(); |
43 | //qWarning("ref up"); | 40 | //qWarning("ref up"); |
44 | } | 41 | } |
45 | ToDoEvent::~ToDoEvent() { | 42 | OTodo::~OTodo() { |
46 | if ( data->deref() ) { | 43 | if ( data->deref() ) { |
47 | //qWarning("ToDoEvent::dereffing"); | 44 | //qWarning("OTodo::dereffing"); |
48 | delete data; | 45 | delete data; |
49 | data = 0l; | 46 | data = 0l; |
50 | } | 47 | } |
51 | } | 48 | } |
52 | 49 | ||
53 | ToDoEvent::ToDoEvent(bool completed, int priority, | 50 | OTodo::OTodo(bool completed, int priority, |
54 | const QStringList &category, | 51 | const QStringList &category, |
55 | const QString& summary, | 52 | const QString& summary, |
56 | const QString &description, | 53 | const QString &description, |
57 | ushort progress, | 54 | ushort progress, |
58 | bool hasDate, QDate date, int uid ) | 55 | bool hasDate, QDate date, int uid ) |
56 | : OPimRecord( uid ) | ||
59 | { | 57 | { |
60 | //qWarning("ToDoEventData"); | 58 | //qWarning("OTodoData"); |
61 | data = new ToDoEventData; | 59 | setCategories( idsFromString( category.join(";") ) ); |
60 | data = new OTodoData; | ||
62 | data->date = date; | 61 | data->date = date; |
63 | data->isCompleted = completed; | 62 | data->isCompleted = completed; |
64 | data->hasDate = hasDate; | 63 | data->hasDate = hasDate; |
65 | data->priority = priority; | 64 | data->priority = priority; |
66 | data->category = category; | ||
67 | data->sum = summary; | 65 | data->sum = summary; |
68 | data->prog = progress; | 66 | data->prog = progress; |
69 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 67 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
70 | if (uid == -1 ) { | ||
71 | uid = m_gen.generate(); | ||
72 | |||
73 | }// generated the ids | ||
74 | m_gen.store( uid ); | ||
75 | |||
76 | data->uid = uid; | ||
77 | data->hasAlarmDateTime = false; | 68 | data->hasAlarmDateTime = false; |
78 | 69 | ||
79 | } | 70 | } |
80 | QArray<int> ToDoEvent::categories()const | 71 | bool OTodo::match( const QRegExp ®Exp )const |
81 | { | ||
82 | qWarning( "ToDoEvent:cats" + data->category.join(";") ); | ||
83 | QArray<int> array(data->category.count() ); // currently the datebook can be only in one category | ||
84 | array = Qtopia::Record::idsFromString( data->category.join(";") ); | ||
85 | return array; | ||
86 | } | ||
87 | bool ToDoEvent::match( const QRegExp ®Exp )const | ||
88 | { | 72 | { |
89 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 73 | if( QString::number( data->priority ).find( regExp ) != -1 ){ |
90 | return true; | 74 | return true; |
91 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ | 75 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ |
92 | return true; | 76 | return true; |
93 | }else if(data->desc.find( regExp ) != -1 ){ | 77 | }else if(data->desc.find( regExp ) != -1 ){ |
94 | return true; | 78 | return true; |
79 | }else if(data->sum.find( regExp ) != -1 ) { | ||
80 | return true; | ||
95 | } | 81 | } |
96 | return false; | 82 | return false; |
97 | } | 83 | } |
98 | bool ToDoEvent::isCompleted() const | 84 | bool OTodo::isCompleted() const |
99 | { | 85 | { |
100 | return data->isCompleted; | 86 | return data->isCompleted; |
101 | } | 87 | } |
102 | bool ToDoEvent::hasDueDate() const | 88 | bool OTodo::hasDueDate() const |
103 | { | 89 | { |
104 | return data->hasDate; | 90 | return data->hasDate; |
105 | } | 91 | } |
106 | bool ToDoEvent::hasAlarmDateTime() const | 92 | bool OTodo::hasAlarmDateTime() const |
107 | { | 93 | { |
108 | return data->hasAlarmDateTime; | 94 | return data->hasAlarmDateTime; |
109 | } | 95 | } |
110 | int ToDoEvent::priority()const | 96 | int OTodo::priority()const |
111 | { | 97 | { |
112 | return data->priority; | 98 | return data->priority; |
113 | } | 99 | } |
114 | QStringList ToDoEvent::allCategories()const | 100 | QString OTodo::summary() const |
115 | { | ||
116 | return data->category; | ||
117 | } | ||
118 | QString ToDoEvent::extra(const QString& )const | ||
119 | { | ||
120 | return QString::null; | ||
121 | } | ||
122 | QString ToDoEvent::summary() const | ||
123 | { | 101 | { |
124 | return data->sum; | 102 | return data->sum; |
125 | } | 103 | } |
126 | ushort ToDoEvent::progress() const | 104 | ushort OTodo::progress() const |
127 | { | 105 | { |
128 | return data->prog; | 106 | return data->prog; |
129 | } | 107 | } |
130 | QStringList ToDoEvent::relatedApps() const | 108 | QDate OTodo::dueDate()const |
131 | { | ||
132 | QStringList list; | ||
133 | QMap<QString, QArray<int> >::ConstIterator it; | ||
134 | for ( it = data->relations.begin(); it != data->relations.end(); ++it ) { | ||
135 | list << it.key(); | ||
136 | } | ||
137 | return list; | ||
138 | } | ||
139 | QArray<int> ToDoEvent::relations( const QString& app)const | ||
140 | { | ||
141 | QArray<int> tmp; | ||
142 | QMap<QString, QArray<int> >::ConstIterator it; | ||
143 | it = data->relations.find( app); | ||
144 | if ( it != data->relations.end() ) | ||
145 | tmp = it.data(); | ||
146 | return tmp; | ||
147 | } | ||
148 | void ToDoEvent::insertCategory(const QString &str ) | ||
149 | { | ||
150 | changeOrModify(); | ||
151 | qWarning("insert category;" + str ); | ||
152 | data->category.append( str ); | ||
153 | } | ||
154 | void ToDoEvent::clearCategories() | ||
155 | { | ||
156 | changeOrModify(); | ||
157 | data->category.clear(); | ||
158 | } | ||
159 | void ToDoEvent::setCategories(const QStringList &list ) | ||
160 | { | ||
161 | changeOrModify(); | ||
162 | qWarning("set categories" + list.join(";") ); | ||
163 | data->category = list; | ||
164 | } | ||
165 | QDate ToDoEvent::dueDate()const | ||
166 | { | 109 | { |
167 | return data->date; | 110 | return data->date; |
168 | } | 111 | } |
169 | 112 | ||
170 | QDateTime ToDoEvent::alarmDateTime() const | 113 | QDateTime OTodo::alarmDateTime() const |
171 | { | 114 | { |
172 | return data->alarmDateTime; | 115 | return data->alarmDateTime; |
173 | } | 116 | } |
174 | 117 | ||
175 | QString ToDoEvent::description()const | 118 | QString OTodo::description()const |
176 | { | 119 | { |
177 | return data->desc; | 120 | return data->desc; |
178 | } | 121 | } |
179 | void ToDoEvent::setCompleted( bool completed ) | 122 | void OTodo::setCompleted( bool completed ) |
180 | { | 123 | { |
181 | changeOrModify(); | 124 | changeOrModify(); |
182 | data->isCompleted = completed; | 125 | data->isCompleted = completed; |
183 | } | 126 | } |
184 | void ToDoEvent::setHasDueDate( bool hasDate ) | 127 | void OTodo::setHasDueDate( bool hasDate ) |
185 | { | 128 | { |
186 | changeOrModify(); | 129 | changeOrModify(); |
187 | data->hasDate = hasDate; | 130 | data->hasDate = hasDate; |
188 | } | 131 | } |
189 | void ToDoEvent::setHasAlarmDateTime( bool hasAlarmDateTime ) | 132 | void OTodo::setHasAlarmDateTime( bool hasAlarmDateTime ) |
190 | { | 133 | { |
191 | changeOrModify(); | 134 | changeOrModify(); |
192 | data->hasAlarmDateTime = hasAlarmDateTime; | 135 | data->hasAlarmDateTime = hasAlarmDateTime; |
193 | } | 136 | } |
194 | void ToDoEvent::setDescription(const QString &desc ) | 137 | void OTodo::setDescription(const QString &desc ) |
195 | { | 138 | { |
196 | changeOrModify(); | 139 | changeOrModify(); |
197 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); | 140 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); |
198 | } | 141 | } |
199 | void ToDoEvent::setExtra( const QString&, const QString& ) | 142 | void OTodo::setSummary( const QString& sum ) |
200 | { | ||
201 | |||
202 | } | ||
203 | void ToDoEvent::setSummary( const QString& sum ) | ||
204 | { | 143 | { |
205 | changeOrModify(); | 144 | changeOrModify(); |
206 | data->sum = sum; | 145 | data->sum = sum; |
207 | } | 146 | } |
208 | void ToDoEvent::setCategory( const QString &cat ) | 147 | void OTodo::setPriority(int prio ) |
209 | { | ||
210 | changeOrModify(); | ||
211 | //qWarning("setCategory %s", cat.latin1() ); | ||
212 | data->category.clear(); | ||
213 | data->category << cat; | ||
214 | } | ||
215 | void ToDoEvent::setPriority(int prio ) | ||
216 | { | 148 | { |
217 | changeOrModify(); | 149 | changeOrModify(); |
218 | data->priority = prio; | 150 | data->priority = prio; |
219 | } | 151 | } |
220 | void ToDoEvent::setDueDate( QDate date ) | 152 | void OTodo::setDueDate( QDate date ) |
221 | { | 153 | { |
222 | changeOrModify(); | 154 | changeOrModify(); |
223 | data->date = date; | 155 | data->date = date; |
224 | } | 156 | } |
225 | void ToDoEvent::setAlarmDateTime( const QDateTime& alarm ) | 157 | void OTodo::setAlarmDateTime( const QDateTime& alarm ) |
226 | { | 158 | { |
227 | changeOrModify(); | 159 | changeOrModify(); |
228 | data->alarmDateTime = alarm; | 160 | data->alarmDateTime = alarm; |
229 | } | 161 | } |
230 | void ToDoEvent::addRelated( const QString &app, int id ) | 162 | bool OTodo::isOverdue( ) |
231 | { | ||
232 | changeOrModify(); | ||
233 | |||
234 | QMap<QString, QArray<int> >::Iterator it; | ||
235 | QArray<int> tmp; | ||
236 | it = data->relations.find( app ); | ||
237 | if ( it == data->relations.end() ) { | ||
238 | tmp.resize(1 ); | ||
239 | tmp[0] = id; | ||
240 | }else{ | ||
241 | tmp = it.data(); | ||
242 | tmp.resize( tmp.size() + 1 ); | ||
243 | tmp[tmp.size() - 1] = id; | ||
244 | } | ||
245 | data->relations.replace( app, tmp ); | ||
246 | } | ||
247 | void ToDoEvent::addRelated(const QString& app, QArray<int> ids ) | ||
248 | { | ||
249 | changeOrModify(); | ||
250 | |||
251 | QMap<QString, QArray<int> >::Iterator it; | ||
252 | QArray<int> tmp; | ||
253 | it = data->relations.find( app); | ||
254 | if ( it == data->relations.end() ) { // not there | ||
255 | /** tmp.resize( ids.size() ); stupid?? | ||
256 | */ | ||
257 | tmp = ids; | ||
258 | }else{ | ||
259 | tmp = it.data(); | ||
260 | int offset = tmp.size()-1; | ||
261 | tmp.resize( tmp.size() + ids.size() ); | ||
262 | for (uint i = 0; i < ids.size(); i++ ) { | ||
263 | tmp[offset+i] = ids[i]; | ||
264 | } | ||
265 | |||
266 | } | ||
267 | data->relations.replace( app, tmp ); | ||
268 | } | ||
269 | void ToDoEvent::clearRelated( const QString& app ) | ||
270 | { | ||
271 | changeOrModify(); | ||
272 | data->relations.remove( app ); | ||
273 | } | ||
274 | bool ToDoEvent::isOverdue( ) | ||
275 | { | 163 | { |
276 | if( data->hasDate ) | 164 | if( data->hasDate ) |
277 | return QDate::currentDate() > data->date; | 165 | return QDate::currentDate() > data->date; |
278 | return false; | 166 | return false; |
279 | } | 167 | } |
280 | void ToDoEvent::setProgress(ushort progress ) | 168 | void OTodo::setProgress(ushort progress ) |
281 | { | 169 | { |
282 | changeOrModify(); | 170 | changeOrModify(); |
283 | data->prog = progress; | 171 | data->prog = progress; |
284 | } | 172 | } |
173 | QString OTodo::toShortText() const { | ||
174 | return summary(); | ||
175 | } | ||
285 | /*! | 176 | /*! |
286 | Returns a richt text string | 177 | Returns a richt text string |
287 | */ | 178 | */ |
288 | QString ToDoEvent::richText() const | 179 | QString OTodo::toRichText() const |
289 | { | 180 | { |
290 | QString text; | 181 | QString text; |
291 | QStringList catlist; | 182 | QStringList catlist; |
292 | 183 | ||
293 | // Description of the todo | 184 | // Description of the todo |
294 | if ( !summary().isEmpty() ) { | 185 | if ( !summary().isEmpty() ) { |
295 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; | 186 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; |
296 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 187 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
297 | } | 188 | } |
298 | if( !description().isEmpty() ){ | 189 | if( !description().isEmpty() ){ |
299 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 190 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
300 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; | 191 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; |
301 | } | 192 | } |
302 | text += "<br><br><br>"; | 193 | text += "<br><br><br>"; |
303 | 194 | ||
304 | text += "<b>" + QObject::tr( "Priority:") +" </b>" | 195 | text += "<b>" + QObject::tr( "Priority:") +" </b>" |
305 | + QString::number( priority() ) + " <br>"; | 196 | + QString::number( priority() ) + " <br>"; |
306 | text += "<b>" + QObject::tr( "Progress:") + " </b>" | 197 | text += "<b>" + QObject::tr( "Progress:") + " </b>" |
307 | + QString::number( progress() ) + " %<br>"; | 198 | + QString::number( progress() ) + " %<br>"; |
308 | if (hasDueDate() ){ | 199 | if (hasDueDate() ){ |
309 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; | 200 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; |
310 | text += dueDate().toString(); | 201 | text += dueDate().toString(); |
311 | text += "<br>"; | 202 | text += "<br>"; |
312 | } | 203 | } |
313 | if (hasAlarmDateTime() ){ | 204 | if (hasAlarmDateTime() ){ |
314 | text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>"; | 205 | text += "<b>" + QObject::tr( "Alarmed Notification:") + " </b>"; |
315 | text += alarmDateTime().toString(); | 206 | text += alarmDateTime().toString(); |
316 | text += "<br>"; | 207 | text += "<br>"; |
317 | } | 208 | } |
318 | 209 | ||
319 | // Open database of all categories and get the list of | ||
320 | // the categories this todoevent belongs to. | ||
321 | // Then print them... | ||
322 | // I am not sure whether there is no better way doing this !? | ||
323 | Categories catdb; | ||
324 | bool firstloop = true; | ||
325 | catdb.load( categoryFileName() ); | ||
326 | catlist = allCategories(); | ||
327 | |||
328 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 210 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
329 | for ( QStringList::Iterator it = catlist.begin(); it != catlist.end(); ++it ) { | 211 | text += categoryNames().join(", "); |
330 | if (!firstloop){ | ||
331 | text += ", "; | ||
332 | } | ||
333 | firstloop = false; | ||
334 | text += catdb.label ("todo", (*it).toInt()); | ||
335 | } | ||
336 | text += "<br>"; | 212 | text += "<br>"; |
213 | |||
337 | return text; | 214 | return text; |
338 | } | 215 | } |
339 | 216 | ||
340 | bool ToDoEvent::operator<( const ToDoEvent &toDoEvent )const{ | 217 | bool OTodo::operator<( const OTodo &toDoEvent )const{ |
341 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 218 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
342 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 219 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
343 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 220 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
344 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 221 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
345 | return priority() < toDoEvent.priority(); | 222 | return priority() < toDoEvent.priority(); |
346 | }else{ | 223 | }else{ |
347 | return dueDate() < toDoEvent.dueDate(); | 224 | return dueDate() < toDoEvent.dueDate(); |
348 | } | 225 | } |
349 | } | 226 | } |
350 | return false; | 227 | return false; |
351 | } | 228 | } |
352 | bool ToDoEvent::operator<=(const ToDoEvent &toDoEvent )const | 229 | bool OTodo::operator<=(const OTodo &toDoEvent )const |
353 | { | 230 | { |
354 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 231 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
355 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; | 232 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; |
356 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 233 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
357 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 234 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
358 | return priority() <= toDoEvent.priority(); | 235 | return priority() <= toDoEvent.priority(); |
359 | }else{ | 236 | }else{ |
360 | return dueDate() <= toDoEvent.dueDate(); | 237 | return dueDate() <= toDoEvent.dueDate(); |
361 | } | 238 | } |
362 | } | 239 | } |
363 | return true; | 240 | return true; |
364 | } | 241 | } |
365 | bool ToDoEvent::operator>(const ToDoEvent &toDoEvent )const | 242 | bool OTodo::operator>(const OTodo &toDoEvent )const |
366 | { | 243 | { |
367 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; | 244 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; |
368 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 245 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
369 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 246 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
370 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 247 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
371 | return priority() > toDoEvent.priority(); | 248 | return priority() > toDoEvent.priority(); |
372 | }else{ | 249 | }else{ |
373 | return dueDate() > toDoEvent.dueDate(); | 250 | return dueDate() > toDoEvent.dueDate(); |
374 | } | 251 | } |
375 | } | 252 | } |
376 | return false; | 253 | return false; |
377 | } | 254 | } |
378 | bool ToDoEvent::operator>=(const ToDoEvent &toDoEvent )const | 255 | bool OTodo::operator>=(const OTodo &toDoEvent )const |
379 | { | 256 | { |
380 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 257 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
381 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 258 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
382 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 259 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
383 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 260 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
384 | return priority() > toDoEvent.priority(); | 261 | return priority() > toDoEvent.priority(); |
385 | }else{ | 262 | }else{ |
386 | return dueDate() > toDoEvent.dueDate(); | 263 | return dueDate() > toDoEvent.dueDate(); |
387 | } | 264 | } |
388 | } | 265 | } |
389 | return true; | 266 | return true; |
390 | } | 267 | } |
391 | bool ToDoEvent::operator==(const ToDoEvent &toDoEvent )const | 268 | bool OTodo::operator==(const OTodo &toDoEvent )const |
392 | { | 269 | { |
393 | if( data->priority == toDoEvent.data->priority && | 270 | if( data->priority == toDoEvent.data->priority && |
394 | data->priority == toDoEvent.data->prog && | 271 | data->priority == toDoEvent.data->prog && |
395 | data->isCompleted == toDoEvent.data->isCompleted && | 272 | data->isCompleted == toDoEvent.data->isCompleted && |
396 | data->hasDate == toDoEvent.data->hasDate && | 273 | data->hasDate == toDoEvent.data->hasDate && |
397 | data->date == toDoEvent.data->date && | 274 | data->date == toDoEvent.data->date && |
398 | data->category == toDoEvent.data->category && | 275 | data->category == toDoEvent.data->category && |
399 | data->sum == toDoEvent.data->sum && | 276 | data->sum == toDoEvent.data->sum && |
400 | data->desc == toDoEvent.data->desc && | 277 | data->desc == toDoEvent.data->desc && |
401 | data->hasAlarmDateTime == toDoEvent.data->hasAlarmDateTime && | 278 | data->hasAlarmDateTime == toDoEvent.data->hasAlarmDateTime && |
402 | data->alarmDateTime == toDoEvent.data->alarmDateTime ) | 279 | data->alarmDateTime == toDoEvent.data->alarmDateTime ) |
403 | return true; | 280 | return true; |
404 | 281 | ||
405 | return false; | 282 | return false; |
406 | } | 283 | } |
407 | void ToDoEvent::deref() { | 284 | void OTodo::deref() { |
408 | 285 | ||
409 | //qWarning("deref in ToDoEvent"); | 286 | //qWarning("deref in ToDoEvent"); |
410 | if ( data->deref() ) { | 287 | if ( data->deref() ) { |
411 | //qWarning("deleting"); | 288 | //qWarning("deleting"); |
412 | delete data; | 289 | delete data; |
413 | d= 0; | 290 | d= 0; |
414 | } | 291 | } |
415 | } | 292 | } |
416 | ToDoEvent &ToDoEvent::operator=(const ToDoEvent &item ) | 293 | OTodo &OTodo::operator=(const OTodo &item ) |
417 | { | 294 | { |
295 | OPimRecord::operator=( item ); | ||
418 | //qWarning("operator= ref "); | 296 | //qWarning("operator= ref "); |
419 | item.data->ref(); | 297 | item.data->ref(); |
420 | deref(); | 298 | deref(); |
421 | 299 | ||
422 | data = item.data; | ||
423 | |||
424 | |||
425 | return *this; | 300 | return *this; |
426 | } | 301 | } |
427 | 302 | ||
428 | QMap<int, QString> ToDoEvent::toMap() const { | 303 | QMap<int, QString> OTodo::toMap() const { |
429 | QMap<int, QString> map; | 304 | QMap<int, QString> map; |
430 | 305 | ||
431 | map.insert( Uid, QString::number( data->uid ) ); | 306 | map.insert( Uid, QString::number( uid() ) ); |
432 | map.insert( Category, data->category.join(";") ); | 307 | map.insert( Category, idsToString( categories() ) ); |
433 | map.insert( HasDate, QString::number( data->hasDate ) ); | 308 | map.insert( HasDate, QString::number( data->hasDate ) ); |
434 | map.insert( Completed, QString::number( data->isCompleted ) ); | 309 | map.insert( Completed, QString::number( data->isCompleted ) ); |
435 | map.insert( Description, data->desc ); | 310 | map.insert( Description, data->desc ); |
436 | map.insert( Summary, data->sum ); | 311 | map.insert( Summary, data->sum ); |
437 | map.insert( Priority, QString::number( data->priority ) ); | 312 | map.insert( Priority, QString::number( data->priority ) ); |
438 | map.insert( DateDay, QString::number( data->date.day() ) ); | 313 | map.insert( DateDay, QString::number( data->date.day() ) ); |
439 | map.insert( DateMonth, QString::number( data->date.month() ) ); | 314 | map.insert( DateMonth, QString::number( data->date.month() ) ); |
440 | map.insert( DateYear, QString::number( data->date.year() ) ); | 315 | map.insert( DateYear, QString::number( data->date.year() ) ); |
441 | map.insert( Progress, QString::number( data->prog ) ); | 316 | map.insert( Progress, QString::number( data->prog ) ); |
442 | map.insert( CrossReference, crossToString() ); | 317 | map.insert( CrossReference, crossToString() ); |
443 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); | 318 | map.insert( HasAlarmDateTime, QString::number( data->hasAlarmDateTime ) ); |
444 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); | 319 | map.insert( AlarmDateTime, data->alarmDateTime.toString() ); |
445 | 320 | ||
446 | return map; | 321 | return map; |
447 | } | 322 | } |
448 | 323 | ||
449 | 324 | QMap<QString, QString> OTodo::toExtraMap()const { | |
450 | QString ToDoEvent::crossToString()const { | ||
451 | QString str; | ||
452 | QMap<QString, QArray<int> >::ConstIterator it; | ||
453 | for (it = data->relations.begin(); it != data->relations.end(); ++it ) { | ||
454 | QArray<int> id = it.data(); | ||
455 | for ( uint i = 0; i < id.size(); ++i ) { | ||
456 | str += it.key() + "," + QString::number( i ) + ";"; | ||
457 | } | ||
458 | } | ||
459 | str = str.remove( str.length()-1, 1); // strip the ; | ||
460 | //qWarning("IDS " + str ); | ||
461 | |||
462 | return str; | ||
463 | } | ||
464 | int ToDoEvent::uid()const { | ||
465 | return data->uid; | ||
466 | } | ||
467 | void ToDoEvent::setUid( int id ) { | ||
468 | if ( id == -1 ) | ||
469 | id = m_gen.generate(); | ||
470 | m_gen.store(id ); | ||
471 | changeOrModify(); | ||
472 | data->uid = id; | ||
473 | } | ||
474 | QMap<QString, QString> ToDoEvent::extras()const { | ||
475 | return data->extra; | 325 | return data->extra; |
476 | } | 326 | } |
477 | /** | 327 | /** |
478 | * change or modify looks at the ref count and either | 328 | * change or modify looks at the ref count and either |
479 | * creates a new QShared Object or it can modify it | 329 | * creates a new QShared Object or it can modify it |
480 | * right in place | 330 | * right in place |
481 | */ | 331 | */ |
482 | void ToDoEvent::changeOrModify() { | 332 | void OTodo::changeOrModify() { |
483 | if ( data->count != 1 ) { | 333 | if ( data->count != 1 ) { |
484 | //qWarning("changeOrModify"); | 334 | //qWarning("changeOrModify"); |
485 | data->deref(); | 335 | data->deref(); |
486 | ToDoEventData* d2 = new ToDoEventData(); | 336 | OTodoData* d2 = new OTodoData(); |
487 | copy(data, d2 ); | 337 | copy(data, d2 ); |
488 | data = d2; | 338 | data = d2; |
489 | } | 339 | } |
490 | } | 340 | } |
491 | void ToDoEvent::copy( ToDoEventData* src, ToDoEventData* dest ) { | 341 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { |
492 | dest->date = src->date; | 342 | dest->date = src->date; |
493 | dest->isCompleted = src->isCompleted; | 343 | dest->isCompleted = src->isCompleted; |
494 | dest->hasDate = src->hasDate; | 344 | dest->hasDate = src->hasDate; |
495 | dest->priority = src->priority; | 345 | dest->priority = src->priority; |
496 | dest->category = src->category; | ||
497 | dest->desc = src->desc; | 346 | dest->desc = src->desc; |
498 | dest->sum = src->sum; | 347 | dest->sum = src->sum; |
499 | dest->extra = src->extra; | 348 | dest->extra = src->extra; |
500 | dest->relations = src->relations; | ||
501 | dest->uid = src->uid; | ||
502 | dest->prog = src->prog; | 349 | dest->prog = src->prog; |
503 | dest->hasAlarmDateTime = src->hasAlarmDateTime; | 350 | dest->hasAlarmDateTime = src->hasAlarmDateTime; |
504 | dest->alarmDateTime = src->alarmDateTime; | 351 | dest->alarmDateTime = src->alarmDateTime; |
505 | } | 352 | } |
506 | 353 | ||
507 | 354 | ||
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h index 429108a..e1729db 100644 --- a/libopie2/opiepim/otodo.h +++ b/libopie2/opiepim/otodo.h | |||
@@ -1,53 +1,53 @@ | |||
1 | 1 | ||
2 | #ifndef OPIE_TODO_EVENT_H | 2 | #ifndef OPIE_TODO_EVENT_H |
3 | #define OPIE_TODO_EVENT_H | 3 | #define OPIE_TODO_EVENT_H |
4 | 4 | ||
5 | 5 | ||
6 | #include <qarray.h> | 6 | #include <qarray.h> |
7 | #include <qmap.h> | 7 | #include <qmap.h> |
8 | #include <qregexp.h> | 8 | #include <qregexp.h> |
9 | #include <qstringlist.h> | 9 | #include <qstringlist.h> |
10 | #include <qdatetime.h> | 10 | #include <qdatetime.h> |
11 | #include <qvaluelist.h> | 11 | #include <qvaluelist.h> |
12 | 12 | ||
13 | #include <qpe/recordfields.h> | 13 | #include <qpe/recordfields.h> |
14 | #include <qpe/palmtopuidgen.h> | 14 | #include <qpe/palmtopuidgen.h> |
15 | 15 | ||
16 | #include <opie/opimrecord.h> | 16 | #include <opie/opimrecord.h> |
17 | 17 | ||
18 | 18 | ||
19 | class OTodo : public OPimRecord { | 19 | class OTodo : public OPimRecord { |
20 | public: | 20 | public: |
21 | typedef QValueList<ToDoEvent> ValueList; | 21 | typedef QValueList<OTodo> ValueList; |
22 | enum RecordFields { | 22 | enum RecordFields { |
23 | Uid = Qtopia::UID_ID, | 23 | Uid = Qtopia::UID_ID, |
24 | Category = Qtopia::CATEGORY_ID, | 24 | Category = Qtopia::CATEGORY_ID, |
25 | HasDate, | 25 | HasDate, |
26 | Completed, | 26 | Completed, |
27 | Description, | 27 | Description, |
28 | Summary, | 28 | Summary, |
29 | Priority, | 29 | Priority, |
30 | DateDay, | 30 | DateDay, |
31 | DateMonth, | 31 | DateMonth, |
32 | DateYear, | 32 | DateYear, |
33 | Progress, | 33 | Progress, |
34 | CrossReference, | 34 | CrossReference, |
35 | HasAlarmDateTime, | 35 | HasAlarmDateTime, |
36 | AlarmDateTime | 36 | AlarmDateTime |
37 | }; | 37 | }; |
38 | public: | 38 | public: |
39 | // priorities from Very low to very high | 39 | // priorities from Very low to very high |
40 | enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; | 40 | enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; |
41 | 41 | ||
42 | /* Constructs a new ToDoEvent | 42 | /* Constructs a new ToDoEvent |
43 | @param completed Is the TodoEvent completed | 43 | @param completed Is the TodoEvent completed |
44 | @param priority What is the priority of this ToDoEvent | 44 | @param priority What is the priority of this ToDoEvent |
45 | @param category Which category does it belong( uid ) | 45 | @param category Which category does it belong( uid ) |
46 | @param summary A small summary of the todo | 46 | @param summary A small summary of the todo |
47 | @param description What is this ToDoEvent about | 47 | @param description What is this ToDoEvent about |
48 | @param hasDate Does this Event got a deadline | 48 | @param hasDate Does this Event got a deadline |
49 | @param date what is the deadline? | 49 | @param date what is the deadline? |
50 | @param uid what is the UUID of this Event | 50 | @param uid what is the UUID of this Event |
51 | **/ | 51 | **/ |
52 | OTodo( bool completed = false, int priority = Normal, | 52 | OTodo( bool completed = false, int priority = Normal, |
53 | const QStringList &category = QStringList(), | 53 | const QStringList &category = QStringList(), |
@@ -89,64 +89,71 @@ public: | |||
89 | 89 | ||
90 | /** | 90 | /** |
91 | * progress as ushort 0, 20, 40, 60, 80 or 100% | 91 | * progress as ushort 0, 20, 40, 60, 80 or 100% |
92 | */ | 92 | */ |
93 | ushort progress() const; | 93 | ushort progress() const; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * The due Date | 96 | * The due Date |
97 | */ | 97 | */ |
98 | QDate dueDate()const; | 98 | QDate dueDate()const; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Alarm Date and Time | 101 | * Alarm Date and Time |
102 | */ | 102 | */ |
103 | QDateTime alarmDateTime()const; | 103 | QDateTime alarmDateTime()const; |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * The description of the todo | 106 | * The description of the todo |
107 | */ | 107 | */ |
108 | QString description()const; | 108 | QString description()const; |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * A small summary of the todo | 111 | * A small summary of the todo |
112 | */ | 112 | */ |
113 | QString summary() const; | 113 | QString summary() const; |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * @reimplemented | 116 | * @reimplemented |
117 | * Return this todoevent in a RichText formatted QString | 117 | * Return this todoevent in a RichText formatted QString |
118 | */ | 118 | */ |
119 | QString toRichText() const; | 119 | QString toRichText() const; |
120 | 120 | ||
121 | /** | ||
122 | * reimplementation | ||
123 | */ | ||
124 | QString type()const; | ||
125 | QString toShortText()const; | ||
126 | QMap<QString, QString> toExtraMap()const; | ||
127 | QString recordField(int id )const; | ||
121 | 128 | ||
122 | /** | 129 | /** |
123 | * returns a list of apps which have related items | 130 | * returns a list of apps which have related items |
124 | */ | 131 | */ |
125 | QStringList relatedApps()const; | 132 | QStringList relatedApps()const; |
126 | 133 | ||
127 | /** | 134 | /** |
128 | * returns all relations for one app | 135 | * returns all relations for one app |
129 | */ | 136 | */ |
130 | QArray<int> relations( const QString& app )const; | 137 | QArray<int> relations( const QString& app )const; |
131 | 138 | ||
132 | /** | 139 | /** |
133 | * toMap puts all data into the map. int relates | 140 | * toMap puts all data into the map. int relates |
134 | * to ToDoEvent RecordFields enum | 141 | * to ToDoEvent RecordFields enum |
135 | */ | 142 | */ |
136 | QMap<int, QString> toMap()const; | 143 | QMap<int, QString> toMap()const; |
137 | 144 | ||
138 | /** | 145 | /** |
139 | * Set if this Todo is completed | 146 | * Set if this Todo is completed |
140 | */ | 147 | */ |
141 | void setCompleted(bool completed ); | 148 | void setCompleted(bool completed ); |
142 | 149 | ||
143 | /** | 150 | /** |
144 | * set if this todo got an end data | 151 | * set if this todo got an end data |
145 | */ | 152 | */ |
146 | void setHasDueDate( bool hasDate ); | 153 | void setHasDueDate( bool hasDate ); |
147 | 154 | ||
148 | /** | 155 | /** |
149 | * set if this todo has an alarm time and date | 156 | * set if this todo has an alarm time and date |
150 | */ | 157 | */ |
151 | void setHasAlarmDateTime ( bool hasAlarm ); | 158 | void setHasAlarmDateTime ( bool hasAlarm ); |
152 | 159 | ||
@@ -154,52 +161,51 @@ public: | |||
154 | * Set the priority of the Todo | 161 | * Set the priority of the Todo |
155 | */ | 162 | */ |
156 | void setPriority(int priority ); | 163 | void setPriority(int priority ); |
157 | 164 | ||
158 | /** | 165 | /** |
159 | * Set the progress. | 166 | * Set the progress. |
160 | */ | 167 | */ |
161 | void setProgress( ushort progress ); | 168 | void setProgress( ushort progress ); |
162 | 169 | ||
163 | /** | 170 | /** |
164 | * set the end date | 171 | * set the end date |
165 | */ | 172 | */ |
166 | void setDueDate( QDate date ); | 173 | void setDueDate( QDate date ); |
167 | 174 | ||
168 | /** | 175 | /** |
169 | * set the alarm time | 176 | * set the alarm time |
170 | */ | 177 | */ |
171 | void setAlarmDateTime ( const QDateTime& alarm ); | 178 | void setAlarmDateTime ( const QDateTime& alarm ); |
172 | 179 | ||
173 | void setDescription(const QString& ); | 180 | void setDescription(const QString& ); |
174 | void setSummary(const QString& ); | 181 | void setSummary(const QString& ); |
175 | bool isOverdue(); | 182 | bool isOverdue(); |
176 | 183 | ||
177 | 184 | ||
178 | bool match( const QRegExp &r )const; | 185 | bool match( const QRegExp &r )const; |
179 | 186 | ||
180 | bool operator<(const OTodo &toDoEvent )const; | 187 | bool operator<(const OTodo &toDoEvent )const; |
181 | bool operator<=(const OTodo &toDoEvent )const; | 188 | bool operator<=(const OTodo &toDoEvent )const; |
182 | bool operator!=(const OTodo &toDoEvent )const; | 189 | bool operator!=(const OTodo &toDoEvent )const; |
183 | bool operator>(const OTodo &toDoEvent )const; | 190 | bool operator>(const OTodo &toDoEvent )const; |
184 | bool operator>=(const OTodo &toDoEvent)const; | 191 | bool operator>=(const OTodo &toDoEvent)const; |
185 | bool operator==(const OTodo &toDoEvent )const; | 192 | bool operator==(const OTodo &toDoEvent )const; |
186 | ToDoEvent &operator=(const OTodo &toDoEvent ); | 193 | OTodo &operator=(const OTodo &toDoEvent ); |
187 | 194 | ||
188 | private: | 195 | private: |
189 | class OTodoPrivate; | 196 | class OTodoPrivate; |
190 | struct OTodoEventData; | 197 | struct OTodoData; |
191 | 198 | ||
192 | void deref(); | 199 | void deref(); |
193 | void changeOrModify(); | 200 | void changeOrModify(); |
194 | void copy( OTodoData* src, OTodoData* dest ); | 201 | void copy( OTodoData* src, OTodoData* dest ); |
195 | ToDoEventPrivate *d; | 202 | OTodoPrivate *d; |
196 | ToDoEventData *data; | 203 | OTodoData *data; |
197 | 204 | ||
198 | static Qtopia::UidGen m_gen; | ||
199 | }; | ||
200 | inline bool ToDoEvent::operator!=(const ToDoEvent &toDoEvent )const { | ||
201 | return !(*this == toDoEvent); | ||
202 | } | ||
203 | }; | 205 | }; |
206 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { | ||
207 | return !(*this == toDoEvent); | ||
208 | } | ||
209 | |||
204 | 210 | ||
205 | #endif | 211 | #endif |