author | zecke <zecke> | 2004-11-18 21:45:49 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-11-18 21:45:49 (UTC) |
commit | 7484344ff5be1f7c54e51715776d0e3cadeb1ed0 (patch) (unidiff) | |
tree | 96f427f7a1fb1c8ca0a6efbd72b51e916cb1651d | |
parent | 3302eb30390e6053637929316670da3e8fbe279e (diff) | |
download | opie-7484344ff5be1f7c54e51715776d0e3cadeb1ed0.zip opie-7484344ff5be1f7c54e51715776d0e3cadeb1ed0.tar.gz opie-7484344ff5be1f7c54e51715776d0e3cadeb1ed0.tar.bz2 |
Big PIM API Update Core Part (1/2 of what should be implemented):
OPimRecords:
-Add a so called safeCast using the rtti value
OPimTodo:
-Fix memleak with OPimState
OPimOccurrence:
-New class. Every 'Access' can give occurrences
for a period of time
Move Documentation
26 files changed, 1244 insertions, 328 deletions
diff --git a/libopie2/opiepim/core/core.pro b/libopie2/opiepim/core/core.pro index b1b5655..f943318 100644 --- a/libopie2/opiepim/core/core.pro +++ b/libopie2/opiepim/core/core.pro | |||
@@ -14,2 +14,3 @@ HEADERS += \ | |||
14 | core/opimnotifymanager.h \ | 14 | core/opimnotifymanager.h \ |
15 | core/opimoccurrence.h \ | ||
15 | core/opimrecord.h \ | 16 | core/opimrecord.h \ |
@@ -37,2 +38,3 @@ SOURCES += \ | |||
37 | core/opimnotifymanager.cpp \ | 38 | core/opimnotifymanager.cpp \ |
39 | core/opimoccurrence.cpp \ | ||
38 | core/opimrecord.cpp \ | 40 | core/opimrecord.cpp \ |
@@ -41,2 +43,3 @@ SOURCES += \ | |||
41 | core/opimstate.cpp \ | 43 | core/opimstate.cpp \ |
44 | core/opimtemplatebase.cpp \ | ||
42 | core/opimtimezone.cpp \ | 45 | core/opimtimezone.cpp \ |
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp index 771d855..9bbc820 100644 --- a/libopie2/opiepim/core/ocontactaccess.cpp +++ b/libopie2/opiepim/core/ocontactaccess.cpp | |||
@@ -72,3 +72,2 @@ OPimContactAccess::OPimContactAccess ( const QString appname, const QString , | |||
72 | if( end == 0 ) { | 72 | if( end == 0 ) { |
73 | owarn << "Using BackendFactory !" << oendl; | ||
74 | end = OBackendFactory<OPimContactAccessBackend>::defaultBackend( OPimGlobal::CONTACTLIST, appname ); | 73 | end = OBackendFactory<OPimContactAccessBackend>::defaultBackend( OPimGlobal::CONTACTLIST, appname ); |
@@ -130,2 +129,4 @@ bool OPimContactAccess::hasQuerySettings ( int querySettings ) const | |||
130 | } | 129 | } |
130 | |||
131 | #if 0 | ||
131 | OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const | 132 | OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const |
@@ -135,2 +136,3 @@ OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortO | |||
135 | } | 136 | } |
137 | #endif | ||
136 | 138 | ||
@@ -146,9 +148,6 @@ void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & ) | |||
146 | if ( msg == "addressbookUpdated()" ){ | 148 | if ( msg == "addressbookUpdated()" ){ |
147 | owarn << "OPimContactAccess: Received addressbokUpdated()" << oendl; | ||
148 | emit signalChanged ( this ); | 149 | emit signalChanged ( this ); |
149 | } else if ( msg == "flush()" ) { | 150 | } else if ( msg == "flush()" ) { |
150 | owarn << "OPimContactAccess: Received flush()" << oendl; | ||
151 | save (); | 151 | save (); |
152 | } else if ( msg == "reload()" ) { | 152 | } else if ( msg == "reload()" ) { |
153 | owarn << "OPimContactAccess: Received reload()" << oendl; | ||
154 | reload (); | 153 | reload (); |
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h index 4429b6f..691ece2 100644 --- a/libopie2/opiepim/core/ocontactaccess.h +++ b/libopie2/opiepim/core/ocontactaccess.h | |||
@@ -62,2 +62,22 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact> | |||
62 | public: | 62 | public: |
63 | enum SortFilter { | ||
64 | DoNotShowNoneChildren = FilterCustom<<1, | ||
65 | DoNotShowNoneAnniversary = FilterCustom<<2, | ||
66 | DoNotShowNoneBirthday = FilterCustom<<3, | ||
67 | DoNotShowNoHomeAddress = FilterCustom<<4, | ||
68 | DoNotShowNoBusinessAddress = FilterCustom<<5 | ||
69 | }; | ||
70 | |||
71 | enum SortOrder { | ||
72 | SortTitle = SortCustom, | ||
73 | SortFirstName, | ||
74 | SortMiddleName, | ||
75 | SortSuffix, | ||
76 | SortEmail, | ||
77 | SortNickname, | ||
78 | SortAnniversary, | ||
79 | SortBirthday, | ||
80 | SortGender | ||
81 | }; | ||
82 | |||
63 | /** | 83 | /** |
@@ -77,30 +97,5 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact> | |||
77 | OPimContactAccess (const QString appname, const QString filename = 0l, | 97 | OPimContactAccess (const QString appname, const QString filename = 0l, |
78 | OPimContactAccessBackend* backend = 0l, bool handlesync = true); | 98 | OPimContactAccessBackend* backend = 0l, bool handlesync = true); |
79 | ~OPimContactAccess (); | 99 | ~OPimContactAccess (); |
80 | 100 | ||
81 | /** Constants for query. | ||
82 | * Use this constants to set the query parameters. | ||
83 | * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! | ||
84 | * @see queryByExample() | ||
85 | */ | ||
86 | enum QuerySettings { | ||
87 | WildCards = 0x0001, | ||
88 | IgnoreCase = 0x0002, | ||
89 | RegExp = 0x0004, | ||
90 | ExactMatch = 0x0008, | ||
91 | MatchOne = 0x0010, // Only one Entry must match | ||
92 | DateDiff = 0x0020, // Find all entries from today until given date | ||
93 | DateYear = 0x0040, // The year matches | ||
94 | DateMonth = 0x0080, // The month matches | ||
95 | DateDay = 0x0100, // The day matches | ||
96 | }; | ||
97 | |||
98 | |||
99 | /** Return all Contacts in a sorted manner. | ||
100 | * @param ascending true: Sorted in acending order. | ||
101 | * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess | ||
102 | * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess | ||
103 | * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess | ||
104 | */ | ||
105 | List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; | ||
106 | 101 | ||
@@ -128,5 +123,5 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact> | |||
128 | */ | 123 | */ |
129 | bool save(); | 124 | bool save(); |
130 | 125 | ||
131 | /** | 126 | /** |
132 | * Return identification of used records | 127 | * Return identification of used records |
@@ -146,4 +141,2 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact> | |||
146 | private: | 141 | private: |
147 | // class OPimContactAccessPrivate; | ||
148 | // OPimContactAccessPrivate* d; | ||
149 | OPimContactAccessBackend *m_backEnd; | 142 | OPimContactAccessBackend *m_backEnd; |
diff --git a/libopie2/opiepim/core/odatebookaccess.cpp b/libopie2/opiepim/core/odatebookaccess.cpp index 440ee0a..32fbb7d 100644 --- a/libopie2/opiepim/core/odatebookaccess.cpp +++ b/libopie2/opiepim/core/odatebookaccess.cpp | |||
@@ -41,3 +41,3 @@ namespace Opie { | |||
41 | */ | 41 | */ |
42 | ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac ) | 42 | ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ) |
43 | : OPimAccessTemplate<OPimEvent>( back ) | 43 | : OPimAccessTemplate<OPimEvent>( back ) |
@@ -53,11 +53,2 @@ ODateBookAccess::~ODateBookAccess() { | |||
53 | 53 | ||
54 | /** | ||
55 | * @return all events available | ||
56 | */ | ||
57 | ODateBookAccess::List ODateBookAccess::rawEvents()const { | ||
58 | QArray<int> ints = m_backEnd->rawEvents(); | ||
59 | |||
60 | List lis( ints, this ); | ||
61 | return lis; | ||
62 | } | ||
63 | 54 | ||
@@ -84,17 +75,2 @@ ODateBookAccess::List ODateBookAccess::nonRepeats()const { | |||
84 | /** | 75 | /** |
85 | * @return dates in the time span between from and to | ||
86 | * @param from Include all events from... | ||
87 | * @param to Include all events to... | ||
88 | */ | ||
89 | OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) const { | ||
90 | return m_backEnd->effectiveEvents( from, to ); | ||
91 | } | ||
92 | /** | ||
93 | * @return all events at a given datetime | ||
94 | */ | ||
95 | OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) const { | ||
96 | return m_backEnd->effectiveEvents( start ); | ||
97 | } | ||
98 | |||
99 | /** | ||
100 | * @return non repeating dates in the time span between from and to | 76 | * @return non repeating dates in the time span between from and to |
@@ -103,4 +79,4 @@ OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& st | |||
103 | */ | 79 | */ |
104 | OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const { | 80 | OPimOccurrence::List ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const { |
105 | return m_backEnd->effectiveNonRepeatingEvents( from, to ); | 81 | return OPimBase::convertOccurrenceFromBackend( m_backEnd->effectiveNonRepeatingEvents( from, to ) ); |
106 | } | 82 | } |
@@ -109,5 +85,6 @@ OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const Q | |||
109 | */ | 85 | */ |
110 | OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const { | 86 | OPimOccurrence::List ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const { |
111 | return m_backEnd->effectiveNonRepeatingEvents( start ); | 87 | return OPimBase::convertOccurrenceFromBackend( m_backEnd->effectiveNonRepeatingEvents( start ) ); |
112 | } | 88 | } |
89 | |||
113 | int ODateBookAccess::rtti() const | 90 | int ODateBookAccess::rtti() const |
diff --git a/libopie2/opiepim/core/odatebookaccess.h b/libopie2/opiepim/core/odatebookaccess.h index c6c3598..0be8606 100644 --- a/libopie2/opiepim/core/odatebookaccess.h +++ b/libopie2/opiepim/core/odatebookaccess.h | |||
@@ -51,5 +51,2 @@ public: | |||
51 | 51 | ||
52 | /* return all events */ | ||
53 | List rawEvents()const; | ||
54 | |||
55 | /* return repeating events */ | 52 | /* return repeating events */ |
@@ -61,8 +58,6 @@ public: | |||
61 | /* return non repeating events (from,to) */ | 58 | /* return non repeating events (from,to) */ |
62 | OEffectiveEvent::ValueList effectiveEvents( const QDate& from, const QDate& to ) const; | 59 | OPimOccurrence::List effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const; |
63 | OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start ) const; | 60 | OPimOccurrence::List effectiveNonRepeatingEvents( const QDateTime& start ) const; |
64 | OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const; | ||
65 | OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start ) const; | ||
66 | 61 | ||
67 | /** | 62 | /** |
68 | * Return identification of used records | 63 | * Return identification of used records |
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index f936d4e..2deb92a 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h | |||
@@ -3,3 +3,3 @@ | |||
3 | Copyright (C) Holger Freyther <zecke@handhelds.org> | 3 | Copyright (C) Holger Freyther <zecke@handhelds.org> |
4 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> | 4 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
5 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 5 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
@@ -42,2 +42,3 @@ | |||
42 | #include <qarray.h> | 42 | #include <qarray.h> |
43 | #include <qdatetime.h> | ||
43 | 44 | ||
@@ -58,2 +59,5 @@ class OPimAccessTemplate : public OTemplateBase<T> { | |||
58 | public: | 59 | public: |
60 | /** | ||
61 | * | ||
62 | */ | ||
59 | enum Access { | 63 | enum Access { |
@@ -66,116 +70,64 @@ public: | |||
66 | 70 | ||
67 | /** | 71 | //@{ |
68 | * c'tor BackEnd | ||
69 | * enum Access a small hint on how to handle the backend | ||
70 | */ | ||
71 | OPimAccessTemplate( BackEnd* end); | 72 | OPimAccessTemplate( BackEnd* end); |
72 | |||
73 | virtual ~OPimAccessTemplate(); | 73 | virtual ~OPimAccessTemplate(); |
74 | //@} | ||
74 | 75 | ||
75 | /** | 76 | //@{ |
76 | * load from the backend | ||
77 | */ | ||
78 | bool load(); | 77 | bool load(); |
79 | |||
80 | /** Reload database. | ||
81 | * You should execute this function if the external database | ||
82 | * was changed. | ||
83 | * This function will load the external database and afterwards | ||
84 | * rejoin the local changes. Therefore the local database will be set consistent. | ||
85 | */ | ||
86 | virtual bool reload(); | 78 | virtual bool reload(); |
87 | |||
88 | /** Save contacts database. | ||
89 | * Save is more a "commit". After calling this function, all changes are public available. | ||
90 | * @return true if successful | ||
91 | */ | ||
92 | bool save(); | 79 | bool save(); |
80 | void clear() ; | ||
81 | //@} | ||
82 | |||
93 | 83 | ||
94 | /** | ||
95 | * if the resource was changed externally | ||
96 | * You should use the signal handling instead of polling possible changes ! | ||
97 | * zecke: Do you implement a signal for otodoaccess ? | ||
98 | */ | ||
99 | bool wasChangedExternally()const; | 84 | bool wasChangedExternally()const; |
100 | 85 | ||
101 | /** | 86 | //@{ |
102 | * return a List of records | ||
103 | * you can iterate over them | ||
104 | */ | ||
105 | virtual List allRecords()const; | 87 | virtual List allRecords()const; |
106 | |||
107 | /** | ||
108 | * return a List of records | ||
109 | * that match the regex | ||
110 | */ | ||
111 | virtual List matchRegexp( const QRegExp &r ) const; | 88 | virtual List matchRegexp( const QRegExp &r ) const; |
112 | |||
113 | /** | ||
114 | * queryByExample. | ||
115 | * @see otodoaccess, ocontactaccess | ||
116 | */ | ||
117 | virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); | 89 | virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); |
90 | virtual T find( UID uid )const; | ||
91 | virtual T find( UID uid, const QArray<int>&, | ||
92 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; | ||
93 | virtual List sorted( const List&, bool ascending, int sortOrder, | ||
94 | int sortFilter, int cat )const; | ||
95 | virtual List sorted( const List&, bool ascending, int sortOrder, | ||
96 | int sortFilter, const QArray<UID>& cats )const; | ||
97 | virtual List sorted( bool ascending, int sortOrder, int sortFilter, int cat )const; | ||
98 | virtual List sorted( bool ascending, int sortOrder, int sortOrder, | ||
99 | const QArray<UID>& cats )const; | ||
100 | //@} | ||
118 | 101 | ||
119 | /** | 102 | /** |
120 | * find the OPimRecord uid | 103 | * (Re)Implementation |
121 | */ | ||
122 | T find( int uid )const; | ||
123 | |||
124 | /** | ||
125 | * read ahead cache find method ;) | ||
126 | */ | ||
127 | T find( int uid, const QArray<int>&, | ||
128 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; | ||
129 | |||
130 | |||
131 | /* invalidate cache here */ | ||
132 | /** | ||
133 | * clears the backend and invalidates the backend | ||
134 | */ | 104 | */ |
135 | void clear() ; | 105 | //@{ |
136 | 106 | UIDArray matchRegexpSimple( const QRegExp& r )const; | |
137 | /** | 107 | UIDArray queryByExampleSimple( const OPimRecord*, int, const QDateTime& )const; |
138 | * add T to the backend | 108 | UIDArray sortedSimple( const UIDArray&, bool asc, int sortOrder, |
139 | * @param t The item to add. | 109 | int sortFilter, int cat )const; |
140 | * @return <i>true</i> if added successfully. | 110 | UIDArray sortedSimple( const UIDArray&, bool asc, int sortOrder, |
141 | */ | 111 | int sortFilter, const QArray<int>& )const; |
142 | virtual bool add( const T& t ) ; | 112 | UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, |
143 | 113 | int cat )const; | |
114 | UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, | ||
115 | const QArray<int>& )const; | ||
116 | OPimOccurrence::List occurrences( const QDate& start, const QDate& end )const; | ||
117 | OPimOccurrence::List occurrences( const QDateTime& dt )const; | ||
118 | //@} | ||
119 | |||
120 | //@{ | ||
121 | virtual bool add( const T& t ) ; | ||
144 | bool add( const OPimRecord& ); | 122 | bool add( const OPimRecord& ); |
145 | /** | ||
146 | * Add an Opie PimRecord. | ||
147 | * Info: Take this if you are working with OPimRecords and you need to add it into any database. | ||
148 | * But take care that the accessing database is compatible to the real type of OPimRecord !! | ||
149 | * Otherwise this access will be rejected ! | ||
150 | */ | ||
151 | bool add( const OPimRecord* ); | 123 | bool add( const OPimRecord* ); |
152 | |||
153 | |||
154 | /* only the uid matters */ | ||
155 | /** | ||
156 | * remove T from the backend | ||
157 | * @param t The item to remove | ||
158 | * @return <i>true</i> if successful. | ||
159 | */ | ||
160 | virtual bool remove( const T& t ); | 124 | virtual bool remove( const T& t ); |
161 | 125 | bool remove( UID uid ); | |
162 | /** | ||
163 | * remove the OPimRecord with uid | ||
164 | * @param uid The ID of the item to remove | ||
165 | * @return <i>true</i> if successful. | ||
166 | */ | ||
167 | bool remove( int uid ); | ||
168 | bool remove( const OPimRecord& ); | 126 | bool remove( const OPimRecord& ); |
169 | |||
170 | /** | ||
171 | * replace T from backend | ||
172 | * @param t The item to replace | ||
173 | * @return <i>true</i> if successful. | ||
174 | */ | ||
175 | virtual bool replace( const T& t) ; | 127 | virtual bool replace( const T& t) ; |
176 | 128 | ||
129 | //@} | ||
130 | |||
177 | void setReadAhead( uint count ); | 131 | void setReadAhead( uint count ); |
178 | /** | 132 | virtual T cacheFind( int uid )const; |
179 | * @internal | ||
180 | */ | ||
181 | void cache( const T& )const; | 133 | void cache( const T& )const; |
@@ -183,3 +135,3 @@ public: | |||
183 | 135 | ||
184 | QArray<int> records()const; | 136 | QArray<UID> records()const; |
185 | protected: | 137 | protected: |
@@ -204,2 +156,6 @@ private: | |||
204 | 156 | ||
157 | /** | ||
158 | * c'tor BackEnd | ||
159 | * enum Access a small hint on how to handle the backend | ||
160 | */ | ||
205 | template <class T> | 161 | template <class T> |
@@ -213,5 +169,8 @@ template <class T> | |||
213 | OPimAccessTemplate<T>::~OPimAccessTemplate() { | 169 | OPimAccessTemplate<T>::~OPimAccessTemplate() { |
214 | owarn << "~OPimAccessTemplate<T>" << oendl; | ||
215 | delete m_backEnd; | 170 | delete m_backEnd; |
216 | } | 171 | } |
172 | |||
173 | /** | ||
174 | * load from the backend | ||
175 | */ | ||
217 | template <class T> | 176 | template <class T> |
@@ -221,2 +180,9 @@ bool OPimAccessTemplate<T>::load() { | |||
221 | } | 180 | } |
181 | |||
182 | /** Reload database. | ||
183 | * You should execute this function if the external database | ||
184 | * was changed. | ||
185 | * This function will load the external database and afterwards | ||
186 | * rejoin the local changes. Therefore the local database will be set consistent. | ||
187 | */ | ||
222 | template <class T> | 188 | template <class T> |
@@ -226,2 +192,8 @@ bool OPimAccessTemplate<T>::reload() { | |||
226 | } | 192 | } |
193 | |||
194 | /** | ||
195 | * Save contacts database. | ||
196 | * Save is more a "commit". After calling this function, all changes are public available. | ||
197 | * @return true if successful | ||
198 | */ | ||
227 | template <class T> | 199 | template <class T> |
@@ -230,2 +202,8 @@ bool OPimAccessTemplate<T>::save() { | |||
230 | } | 202 | } |
203 | |||
204 | |||
205 | /** | ||
206 | * return a List of records | ||
207 | * you can iterate over them | ||
208 | */ | ||
231 | template <class T> | 209 | template <class T> |
@@ -236,2 +214,7 @@ typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { | |||
236 | } | 214 | } |
215 | |||
216 | /** | ||
217 | * return a List of records | ||
218 | * that match the regex | ||
219 | */ | ||
237 | template <class T> | 220 | template <class T> |
@@ -242,2 +225,6 @@ typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const Q | |||
242 | } | 225 | } |
226 | |||
227 | /** | ||
228 | * find the OPimRecord uid | ||
229 | */ | ||
243 | template <class T> | 230 | template <class T> |
@@ -246,2 +233,8 @@ QArray<int> OPimAccessTemplate<T>::records()const { | |||
246 | } | 233 | } |
234 | |||
235 | |||
236 | /** | ||
237 | * queryByExample. | ||
238 | * @see otodoaccess, ocontactaccess | ||
239 | */ | ||
247 | template <class T> | 240 | template <class T> |
@@ -254,4 +247,5 @@ OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime | |||
254 | } | 247 | } |
248 | |||
255 | template <class T> | 249 | template <class T> |
256 | T OPimAccessTemplate<T>::find( int uid ) const{ | 250 | T OPimAccessTemplate<T>::find( UID uid ) const{ |
257 | // First search in cache.. | 251 | // First search in cache.. |
@@ -267,3 +261,12 @@ T OPimAccessTemplate<T>::find( int uid ) const{ | |||
267 | template <class T> | 261 | template <class T> |
268 | T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, | 262 | T OPimAccessTemplate<T>::cacheFind( int uid ) const |
263 | { | ||
264 | return m_cache.find( uid ); | ||
265 | } | ||
266 | |||
267 | /** | ||
268 | * read ahead cache find method ;) | ||
269 | */ | ||
270 | template <class T> | ||
271 | T OPimAccessTemplate<T>::find( UID uid, const QArray<int>& ar, | ||
269 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { | 272 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { |
@@ -274,6 +277,5 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, | |||
274 | */ | 277 | */ |
275 | // owarn << "find it now " << uid << oendl; | 278 | if (m_cache.contains( uid ) ) |
276 | if ( m_cache.contains( uid ) ) { | ||
277 | return m_cache.find( uid ); | 279 | return m_cache.find( uid ); |
278 | } | 280 | |
279 | 281 | ||
@@ -283,2 +285,6 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, | |||
283 | } | 285 | } |
286 | |||
287 | /** | ||
288 | * clears the backend and invalidates the backend | ||
289 | */ | ||
284 | template <class T> | 290 | template <class T> |
@@ -288,2 +294,9 @@ void OPimAccessTemplate<T>::clear() { | |||
288 | } | 294 | } |
295 | |||
296 | |||
297 | /** | ||
298 | * add T to the backend | ||
299 | * @param t The item to add. | ||
300 | * @return <i>true</i> if added successfully. | ||
301 | */ | ||
289 | template <class T> | 302 | template <class T> |
@@ -307,2 +320,8 @@ bool OPimAccessTemplate<T>::add( const OPimRecord& rec ) { | |||
307 | 320 | ||
321 | /** | ||
322 | * Add an Opie PimRecord. | ||
323 | * Info: Take this if you are working with OPimRecords and you need to add it into any database. | ||
324 | * But take care that the accessing database is compatible to the real type of OPimRecord !! | ||
325 | * Otherwise this access will be rejected ! | ||
326 | */ | ||
308 | template <class T> | 327 | template <class T> |
@@ -320,2 +339,7 @@ bool OPimAccessTemplate<T>::add( const OPimRecord* rec) { | |||
320 | 339 | ||
340 | /** | ||
341 | * remove T from the backend | ||
342 | * @param t The item to remove | ||
343 | * @return <i>true</i> if successful. | ||
344 | */ | ||
321 | template <class T> | 345 | template <class T> |
@@ -324,4 +348,10 @@ bool OPimAccessTemplate<T>::remove( const T& t ) { | |||
324 | } | 348 | } |
349 | |||
350 | /** | ||
351 | * remove the OPimRecord with uid | ||
352 | * @param uid The ID of the item to remove | ||
353 | * @return <i>true</i> if successful. | ||
354 | */ | ||
325 | template <class T> | 355 | template <class T> |
326 | bool OPimAccessTemplate<T>::remove( int uid ) { | 356 | bool OPimAccessTemplate<T>::remove( UID uid ) { |
327 | m_cache.remove( uid ); | 357 | m_cache.remove( uid ); |
@@ -333,2 +363,8 @@ bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { | |||
333 | } | 363 | } |
364 | |||
365 | /** | ||
366 | * replace T from backend | ||
367 | * @param t The item to replace | ||
368 | * @return <i>true</i> if successful. | ||
369 | */ | ||
334 | template <class T> | 370 | template <class T> |
@@ -338,2 +374,6 @@ bool OPimAccessTemplate<T>::replace( const T& t ) { | |||
338 | } | 374 | } |
375 | |||
376 | /** | ||
377 | * @internal | ||
378 | */ | ||
339 | template <class T> | 379 | template <class T> |
@@ -346,2 +386,8 @@ typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { | |||
346 | } | 386 | } |
387 | |||
388 | /** | ||
389 | * if the resource was changed externally | ||
390 | * You should use the signal handling instead of polling possible changes ! | ||
391 | * zecke: Do you implement a signal for otodoaccess ? | ||
392 | */ | ||
347 | template <class T> | 393 | template <class T> |
@@ -370,2 +416,105 @@ void OPimAccessTemplate<T>::setReadAhead( uint count ) { | |||
370 | 416 | ||
417 | |||
418 | template <class T> | ||
419 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::sorted( const OPimAccessTemplate::List& lst, | ||
420 | bool ascending, int sortOrder, | ||
421 | int sortFilter, int cat )const { | ||
422 | QArray<int> cats( 1 ); | ||
423 | cats[0] = cat; | ||
424 | UIDArray ints = m_backEnd->sorted( lst.uids(), ascending, sortOrder, | ||
425 | sortFilter, cats ); | ||
426 | return List(ints, this); | ||
427 | } | ||
428 | |||
429 | template<class T> | ||
430 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::sorted( const OPimAccessTemplate::List& lst, | ||
431 | bool ascending, int sortOrder, | ||
432 | int sortFilter, const QArray<UID>& cats )const { | ||
433 | UIDArray ints = m_backEnd->sorted( lst.uids(), ascending, sortOrder, | ||
434 | sortFilter, cats ); | ||
435 | return List(ints, this); | ||
436 | } | ||
437 | |||
438 | template<class T> | ||
439 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::sorted( bool ascending, int sortOrder, | ||
440 | int sortFilter, int cat )const { | ||
441 | QArray<int> cats( 1 ); | ||
442 | cats[0] = cat; | ||
443 | UIDArray ints = m_backEnd->sorted( ascending, sortOrder, | ||
444 | sortFilter, cats ); | ||
445 | return List(ints, this); | ||
446 | } | ||
447 | |||
448 | template<class T> | ||
449 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::sorted( bool ascending, int sortOrder, | ||
450 | int sortFilter, const QArray<UID>& cats )const { | ||
451 | UIDArray ints = m_backEnd->sorted( ascending, sortOrder, | ||
452 | sortFilter, cats ); | ||
453 | return List(ints, this); | ||
454 | } | ||
455 | |||
456 | template <class T> | ||
457 | OPimOccurrence::List OPimAccessTemplate<T>::occurrences( const QDate& start, | ||
458 | const QDate& end ) const { | ||
459 | /* | ||
460 | * Some magic involved to go from single OPimBackendOccurrence | ||
461 | * to multiple OPimOccurrence's | ||
462 | */ | ||
463 | return OPimBase::convertOccurrenceFromBackend( m_backEnd->occurrences( start, end ) ); | ||
464 | } | ||
465 | |||
466 | template<class T> | ||
467 | OPimOccurrence::List OPimAccessTemplate<T>::occurrences( const QDateTime& dt )const { | ||
468 | return OPimBase::convertOccurrenceFromBackend( m_backEnd->occurrences( dt ) ); | ||
469 | } | ||
470 | |||
471 | /* | ||
472 | *Implementations!! | ||
473 | */ | ||
474 | template <class T> | ||
475 | UIDArray OPimAccessTemplate<T>::matchRegexpSimple( const QRegExp &r )const { | ||
476 | return m_backEnd->matchRegexp( r ); | ||
477 | } | ||
478 | |||
479 | template <class T> | ||
480 | UIDArray OPimAccessTemplate<T>::queryByExampleSimple( const OPimRecord* rec, | ||
481 | int settings, | ||
482 | const QDateTime& d )const { | ||
483 | return m_backEnd->queryByExample( rec, settings, d ); | ||
484 | } | ||
485 | |||
486 | template <class T> | ||
487 | UIDArray OPimAccessTemplate<T>::sortedSimple( const UIDArray& lst, | ||
488 | bool ascending, | ||
489 | int sortOrder, int sortFilter, | ||
490 | int cat ) const{ | ||
491 | QArray<int> cats( 1 ); | ||
492 | cats[0] = cat; | ||
493 | return m_backEnd->sorted( lst, ascending, sortOrder, sortFilter, cats ); | ||
494 | } | ||
495 | |||
496 | template <class T> | ||
497 | UIDArray OPimAccessTemplate<T>::sortedSimple( const UIDArray& lst, | ||
498 | bool ascending, | ||
499 | int sortOrder, int sortFilter, | ||
500 | const QArray<int>& cats ) const{ | ||
501 | return m_backEnd->sorted( lst, ascending, sortOrder, sortFilter, cats ); | ||
502 | } | ||
503 | |||
504 | template <class T> | ||
505 | UIDArray OPimAccessTemplate<T>::sortedSimple( bool ascending, | ||
506 | int sortOrder, int sortFilter, | ||
507 | int cat ) const{ | ||
508 | QArray<int> cats( 1 ); | ||
509 | cats[0] = cat; | ||
510 | |||
511 | return m_backEnd->sorted( ascending, sortOrder, sortFilter, cats ); | ||
512 | } | ||
513 | |||
514 | template <class T> | ||
515 | UIDArray OPimAccessTemplate<T>::sortedSimple( bool ascending, | ||
516 | int sortOrder, int sortFilter, | ||
517 | const QArray<int>& cats ) const{ | ||
518 | return m_backEnd->sorted( ascending, sortOrder, sortFilter, cats ); | ||
519 | } | ||
371 | } | 520 | } |
diff --git a/libopie2/opiepim/core/opimcontact.cpp b/libopie2/opiepim/core/opimcontact.cpp index 36e9a93..64f195b 100644 --- a/libopie2/opiepim/core/opimcontact.cpp +++ b/libopie2/opiepim/core/opimcontact.cpp | |||
@@ -83,3 +83,2 @@ OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap | |||
83 | { | 83 | { |
84 | owarn << "Invalid UID found. Generate new one.." << oendl; | ||
85 | setUid( uidGen().generate() ); | 84 | setUid( uidGen().generate() ); |
@@ -1140,3 +1139,2 @@ void OPimContact::setBirthday( const QDate &v ) | |||
1140 | { | 1139 | { |
1141 | owarn << "Remove Birthday" << oendl; | ||
1142 | replace( Qtopia::Birthday, QString::null ); | 1140 | replace( Qtopia::Birthday, QString::null ); |
@@ -1159,3 +1157,2 @@ void OPimContact::setAnniversary( const QDate &v ) | |||
1159 | { | 1157 | { |
1160 | owarn << "Remove Anniversary" << oendl; | ||
1161 | replace( Qtopia::Anniversary, QString::null ); | 1158 | replace( Qtopia::Anniversary, QString::null ); |
@@ -1175,3 +1172,2 @@ QDate OPimContact::birthday() const | |||
1175 | QString str = find( Qtopia::Birthday ); | 1172 | QString str = find( Qtopia::Birthday ); |
1176 | // owarn << "Birthday " << str << oendl; | ||
1177 | if ( !str.isEmpty() ) | 1173 | if ( !str.isEmpty() ) |
@@ -1190,3 +1186,2 @@ QDate OPimContact::anniversary() const | |||
1190 | QString str = find( Qtopia::Anniversary ); | 1186 | QString str = find( Qtopia::Anniversary ); |
1191 | // owarn << "Anniversary " << str << oendl; | ||
1192 | if ( !str.isEmpty() ) | 1187 | if ( !str.isEmpty() ) |
@@ -1284,2 +1279,21 @@ int OPimContact::rtti() const | |||
1284 | 1279 | ||
1280 | /** | ||
1281 | * \brief Cast to OPimContact or on failure return 0l | ||
1282 | * | ||
1283 | * This method tries to cast from a OPimRecord to a | ||
1284 | * OPimContact it uses. If the OPimRecord is from type | ||
1285 | * OPimContact the case will suceed and a pointer to | ||
1286 | * OPimContact is returned otherwise a Null Pointer is returned. | ||
1287 | * | ||
1288 | * | ||
1289 | * @see OPimTodo::safeCast() | ||
1290 | * @see OPimEvent::safeCast() | ||
1291 | * @return Return a OPimContact or a Null Pointer | ||
1292 | */ | ||
1293 | OPimContact* OPimContact::safeCast( const OPimRecord* rec ) { | ||
1294 | return( rec && rec->rtti() == OPimResolver::AddressBook ) ? | ||
1295 | static_cast<OPimContact*>( const_cast<OPimRecord*>(rec) ) : | ||
1296 | 0l; | ||
1297 | } | ||
1298 | |||
1285 | 1299 | ||
diff --git a/libopie2/opiepim/core/opimcontact.h b/libopie2/opiepim/core/opimcontact.h index 6891dd6..6fa2c4b 100644 --- a/libopie2/opiepim/core/opimcontact.h +++ b/libopie2/opiepim/core/opimcontact.h | |||
@@ -230,3 +230,7 @@ class QPC_EXPORT OPimContact : public OPimRecord | |||
230 | QString emails() const { return find( Qtopia::Emails ); } | 230 | QString emails() const { return find( Qtopia::Emails ); } |
231 | |||
232 | //@{ | ||
231 | int rtti() const; | 233 | int rtti() const; |
234 | static OPimContact* safeCast( const OPimRecord* ); | ||
235 | //@} | ||
232 | 236 | ||
diff --git a/libopie2/opiepim/core/opimevent.cpp b/libopie2/opiepim/core/opimevent.cpp index 7bc6c32..1b553d8 100644 --- a/libopie2/opiepim/core/opimevent.cpp +++ b/libopie2/opiepim/core/opimevent.cpp | |||
@@ -491,2 +491,21 @@ int OPimEvent::rtti() const | |||
491 | 491 | ||
492 | /** | ||
493 | * \brief Cast safely to OPimEvent from OPimRecord | ||
494 | * | ||
495 | * Safely cast from OPimRecord to OPimEvent. If the | ||
496 | * OPimRecord is not of type OPimEvent Null will be | ||
497 | * returned. | ||
498 | * | ||
499 | * @param rec The OPimRecord to be casted to OPimEvent | ||
500 | * | ||
501 | * @see OPimTodo::safeCast | ||
502 | * @return OPimEvent or Null Pointer | ||
503 | */ | ||
504 | OPimEvent* OPimEvent::safeCast( const OPimRecord* rec) { | ||
505 | return ( rec && rec->rtti() == OPimResolver::DateBook ) ? | ||
506 | static_cast<OPimEvent*>( const_cast<OPimRecord*>(rec) ) : | ||
507 | 0l; | ||
508 | } | ||
509 | |||
510 | |||
492 | 511 | ||
diff --git a/libopie2/opiepim/core/opimevent.h b/libopie2/opiepim/core/opimevent.h index 5553cac..32f648f 100644 --- a/libopie2/opiepim/core/opimevent.h +++ b/libopie2/opiepim/core/opimevent.h | |||
@@ -120,2 +120,3 @@ class OPimEvent : public OPimRecord | |||
120 | 120 | ||
121 | //@{ | ||
121 | QString description() const; | 122 | QString description() const; |
@@ -125,6 +126,10 @@ class OPimEvent : public OPimRecord | |||
125 | void setLocation( const QString& loc ); | 126 | void setLocation( const QString& loc ); |
127 | //@} | ||
126 | 128 | ||
129 | //@{ | ||
127 | bool hasNotifiers() const; | 130 | bool hasNotifiers() const; |
128 | OPimNotifyManager ¬ifiers() const; | 131 | OPimNotifyManager ¬ifiers() const; |
132 | //@} | ||
129 | 133 | ||
134 | //@{ | ||
130 | OPimRecurrence recurrence() const; | 135 | OPimRecurrence recurrence() const; |
@@ -132,5 +137,8 @@ class OPimEvent : public OPimRecord | |||
132 | bool hasRecurrence() const; | 137 | bool hasRecurrence() const; |
138 | //@} | ||
133 | 139 | ||
140 | //@{ | ||
134 | QString note() const; | 141 | QString note() const; |
135 | void setNote( const QString& note ); | 142 | void setNote( const QString& note ); |
143 | //@} | ||
136 | 144 | ||
@@ -163,4 +171,3 @@ class OPimEvent : public OPimRecord | |||
163 | 171 | ||
164 | virtual bool match( const QRegExp& ) const; | 172 | //@{ |
165 | |||
166 | /** For exception to recurrence here is a list of children... */ | 173 | /** For exception to recurrence here is a list of children... */ |
@@ -170,2 +177,3 @@ class OPimEvent : public OPimRecord | |||
170 | void removeChild( int uid ); | 177 | void removeChild( int uid ); |
178 | //@} | ||
171 | 179 | ||
@@ -177,2 +185,4 @@ class OPimEvent : public OPimRecord | |||
177 | /* needed reimp */ | 185 | /* needed reimp */ |
186 | //@{ Reimplementations | ||
187 | virtual bool match( const QRegExp& ) const; | ||
178 | QString toRichText() const; | 188 | QString toRichText() const; |
@@ -185,8 +195,12 @@ class OPimEvent : public OPimRecord | |||
185 | 195 | ||
186 | int rtti() const; | ||
187 | |||
188 | bool loadFromStream( QDataStream& ); | 196 | bool loadFromStream( QDataStream& ); |
189 | bool saveToStream( QDataStream& ) const; | 197 | bool saveToStream( QDataStream& ) const; |
198 | //@} | ||
199 | |||
200 | //@{ | ||
201 | int rtti() const; | ||
202 | static OPimEvent* safeCast( const OPimRecord* ); | ||
203 | //@} | ||
190 | 204 | ||
191 | /* bool operator==( const OPimEvent& ); | 205 | /* bool operator==( const OPimEvent& ); |
192 | bool operator!=( const OPimEvent& ); | 206 | bool operator!=( const OPimEvent& ); |
diff --git a/libopie2/opiepim/core/opimglobal.h b/libopie2/opiepim/core/opimglobal.h index 3925c89..9d319a1 100644 --- a/libopie2/opiepim/core/opimglobal.h +++ b/libopie2/opiepim/core/opimglobal.h | |||
@@ -31,3 +31,15 @@ | |||
31 | 31 | ||
32 | #include <qarray.h> | ||
33 | |||
32 | namespace Opie{ | 34 | namespace Opie{ |
35 | |||
36 | /** | ||
37 | * The unique identifier for every | ||
38 | * PIM record. For now it is a negative | ||
39 | * int but we could change it to long or QUuid | ||
40 | * in the future | ||
41 | */ | ||
42 | typedef int UID; | ||
43 | typedef QArray<UID> UIDArray; | ||
44 | |||
33 | namespace Pim{ | 45 | namespace Pim{ |
@@ -35,4 +47,4 @@ namespace Pim{ | |||
35 | 47 | ||
36 | /** | 48 | /** |
37 | * Contains global types and enums for the PIM-API | 49 | * Contains global types and enums for the PIM-API |
38 | */ | 50 | */ |
@@ -46,3 +58,3 @@ class OPimGlobal{ | |||
46 | }; | 58 | }; |
47 | 59 | ||
48 | enum DatabaseStyle { | 60 | enum DatabaseStyle { |
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp index 516dc79..77cd922 100644 --- a/libopie2/opiepim/core/opimnotifymanager.cpp +++ b/libopie2/opiepim/core/opimnotifymanager.cpp | |||
@@ -166,3 +166,2 @@ bool OPimNotifyManager::isEmpty() const | |||
166 | { | 166 | { |
167 | owarn << "is Empty called on OPimNotifyManager " << m_rem.count() << " " << m_al.count() << "" << oendl; | ||
168 | if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; | 167 | if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; |
@@ -194,3 +193,2 @@ QString OPimNotifyManager::alarmsToString() const | |||
194 | // now write the list | 193 | // now write the list |
195 | owarn << "als: " << als.join( "____________" ) << "" << oendl; | ||
196 | str = als.join( ";" ); | 194 | str = als.join( ";" ); |
@@ -228,5 +226,2 @@ void OPimNotifyManager::alarmsFromString( const QString& str ) | |||
228 | QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty | 226 | QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty |
229 | owarn << "alarm: " << alarm.join( "___" ) << "" << oendl; | ||
230 | owarn << "alarm[0]: " << alarm[ 0 ] << " " | ||
231 | << OPimDateConversion::dateTimeFromString( alarm[ 0 ] ).toString() << oendl; | ||
232 | OPimAlarm al( alarm[ 2 ].toInt(), OPimDateConversion::dateTimeFromString( alarm[ 0 ] ), | 227 | OPimAlarm al( alarm[ 2 ].toInt(), OPimDateConversion::dateTimeFromString( alarm[ 0 ] ), |
diff --git a/libopie2/opiepim/core/opimoccurrence.cpp b/libopie2/opiepim/core/opimoccurrence.cpp new file mode 100644 index 0000000..14ab5cf --- a/dev/null +++ b/libopie2/opiepim/core/opimoccurrence.cpp | |||
@@ -0,0 +1,319 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) 2003, 2004 Holger Freyther <zecke@handhelds.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | |||
30 | #include "opimoccurrence.h" | ||
31 | #include <opie2/opimtemplatebase.h> | ||
32 | #include <opie2/private/opimoccurrence_p.h> | ||
33 | |||
34 | |||
35 | /* QT */ | ||
36 | #include <qshared.h> | ||
37 | |||
38 | |||
39 | namespace Opie { | ||
40 | |||
41 | OPimOccurrence::OPimOccurrence( OPimOccurrence::Data* _data, | ||
42 | enum OPimOccurrence::Position pos ) | ||
43 | : m_pos( pos ), data( _data ) | ||
44 | {} | ||
45 | |||
46 | /** | ||
47 | * \brief Copy constructor | ||
48 | */ | ||
49 | OPimOccurrence::OPimOccurrence( const OPimOccurrence& oc ) | ||
50 | : data( oc.data ) | ||
51 | { | ||
52 | /* | ||
53 | * Increment the reference count | ||
54 | */ | ||
55 | data->ref(); | ||
56 | |||
57 | /* | ||
58 | * copy the other information | ||
59 | */ | ||
60 | m_start = oc.m_start; | ||
61 | m_end = oc.m_end; | ||
62 | m_occurrence = oc.m_occurrence; | ||
63 | m_isAllDay = oc.m_isAllDay; | ||
64 | m_pos = oc.m_pos; | ||
65 | } | ||
66 | |||
67 | OPimOccurrence::OPimOccurrence() | ||
68 | : m_isAllDay( false ), m_pos( StartEnd ) | ||
69 | { | ||
70 | /* simple convient c'tor */ | ||
71 | data = new OPimOccurrence::Data(); | ||
72 | } | ||
73 | |||
74 | OPimOccurrence::~OPimOccurrence() { | ||
75 | deref(); | ||
76 | } | ||
77 | |||
78 | /** | ||
79 | * \brief Copy Operator | ||
80 | */ | ||
81 | OPimOccurrence& OPimOccurrence::operator=( const OPimOccurrence& oc ) { | ||
82 | /* guard against self assignment */ | ||
83 | if ( this == &oc ) return *this; | ||
84 | |||
85 | oc.data->ref(); | ||
86 | deref(); | ||
87 | data = oc.data; | ||
88 | |||
89 | |||
90 | /* | ||
91 | * copy the other information | ||
92 | */ | ||
93 | m_start = oc.m_start; | ||
94 | m_end = oc.m_end; | ||
95 | m_occurrence = oc.m_occurrence; | ||
96 | m_isAllDay = oc.m_isAllDay; | ||
97 | m_pos = oc.m_pos; | ||
98 | |||
99 | return *this; | ||
100 | } | ||
101 | |||
102 | |||
103 | /** | ||
104 | * @internal | ||
105 | */ | ||
106 | void OPimOccurrence::deref() { | ||
107 | if ( data->deref() ) { | ||
108 | delete data; | ||
109 | data = 0; | ||
110 | } | ||
111 | } | ||
112 | |||
113 | /** | ||
114 | * \brief Set the Occurrence to be All Day on a specified QDate | ||
115 | * | ||
116 | * If no QTime is associated to a OPimOccurrence use this Method | ||
117 | * to set the Period of this Occurrence. When using this Method | ||
118 | * later calls to \sa isAllDay() will return true. | ||
119 | * The Occurrence will be set to occurr on \par from. | ||
120 | * | ||
121 | * @param from The Day this OPimOccurrence occurs | ||
122 | * | ||
123 | */ | ||
124 | void OPimOccurrence::setPeriod( const QDate& from ) { | ||
125 | m_occurrence = from; | ||
126 | m_start = m_end = QTime(); // assign invalid value just in case | ||
127 | m_isAllDay = true; | ||
128 | } | ||
129 | |||
130 | /** | ||
131 | * \brief Set the period of this Occurrence with a QTime associated (overloaded) | ||
132 | * | ||
133 | * Set the period of time for this Occurrence. Each Ocurrence is limited | ||
134 | * to one day. Using this Method will make \sa isAllDay() return false. | ||
135 | * If \par from and \par to are on two different days the QDate of the | ||
136 | * \par from QDateTime will be used. | ||
137 | * | ||
138 | * @param from The Start Date Time of the Occurrence | ||
139 | * @param to The End Date Time of the Occurrence | ||
140 | */ | ||
141 | void OPimOccurrence::setPeriod( const QDateTime& from, const QDateTime& to ) { | ||
142 | m_occurrence = from.date(); | ||
143 | m_start = from.time(); | ||
144 | m_end = to.time(); | ||
145 | m_isAllDay = false; | ||
146 | } | ||
147 | |||
148 | /** | ||
149 | * \brief Set the period of this Occurrence with a QTime associated | ||
150 | * | ||
151 | * @param from The QDate of the Occurrence | ||
152 | * @param start The Start QTime of the Occurrence | ||
153 | * @param end The End QTime of the Occurrence | ||
154 | */ | ||
155 | void OPimOccurrence::setPeriod( const QDate& from, const QTime& start, | ||
156 | const QTime& end ) { | ||
157 | m_occurrence = from; | ||
158 | m_start = start; | ||
159 | m_end = end; | ||
160 | m_isAllDay = false; | ||
161 | } | ||
162 | |||
163 | |||
164 | /** | ||
165 | * \brief Is a QTime associated to the OPimOccurrence | ||
166 | * | ||
167 | * @return Return true if no QTime is associated | ||
168 | */ | ||
169 | bool OPimOccurrence::isAllDay()const { | ||
170 | return m_isAllDay; | ||
171 | } | ||
172 | |||
173 | |||
174 | /** | ||
175 | * \brief Return the QDate where this OPimOccurrence takes place | ||
176 | * @return the QDate where this OPimOccurrence occurrs. | ||
177 | */ | ||
178 | QDate OPimOccurrence::date()const { | ||
179 | return m_occurrence; | ||
180 | } | ||
181 | |||
182 | |||
183 | /** | ||
184 | * \brief Return the start time of the OPimOccurrence | ||
185 | * | ||
186 | * @return Return the Start Time of the OPimOccurrence. It is | ||
187 | * invalid if \sa isAllDay() returns true. | ||
188 | */ | ||
189 | QTime OPimOccurrence::startTime()const { | ||
190 | return m_start; | ||
191 | } | ||
192 | |||
193 | QTime OPimOccurrence::endTime()const { | ||
194 | return m_end; | ||
195 | } | ||
196 | |||
197 | QDateTime OPimOccurrence::startDateTime()const { | ||
198 | return QDateTime( m_occurrence, m_start ); | ||
199 | } | ||
200 | |||
201 | QDateTime OPimOccurrence::endDateTime()const { | ||
202 | return QDateTime( m_occurrence, m_end ); | ||
203 | } | ||
204 | |||
205 | |||
206 | QString OPimOccurrence::summary()const { | ||
207 | return data->summary; | ||
208 | } | ||
209 | |||
210 | QString OPimOccurrence::location()const { | ||
211 | return data->location; | ||
212 | } | ||
213 | |||
214 | QString OPimOccurrence::note()const { | ||
215 | return data->note; | ||
216 | } | ||
217 | |||
218 | |||
219 | /** | ||
220 | * -1 if no time is associated | ||
221 | * otherwise the length of the occurrence in hours | ||
222 | */ | ||
223 | int OPimOccurrence::length()const { | ||
224 | if ( m_isAllDay ) | ||
225 | return -1; | ||
226 | else | ||
227 | return ( m_end.hour() * 60 - m_start.hour() * 60 ) | ||
228 | + QABS( m_start.minute() - m_end.minute() ); | ||
229 | } | ||
230 | |||
231 | enum OPimOccurrence::Position OPimOccurrence::position()const { | ||
232 | return m_pos; | ||
233 | } | ||
234 | |||
235 | void OPimOccurrence::setPosition( enum OPimOccurrence::Position& pos ) { | ||
236 | m_pos = pos; | ||
237 | } | ||
238 | |||
239 | |||
240 | Opie::Core::OSharedPointer<OPimRecord> OPimOccurrence::record()const { | ||
241 | if ( !data->record && data->backend ) | ||
242 | data->record = data->backend->record( data->uid ); | ||
243 | return data->record; | ||
244 | } | ||
245 | |||
246 | template<class Record> Record OPimOccurrence::internalToRecord()const { | ||
247 | Record target; | ||
248 | |||
249 | /* If it is not loaded, try to load it using OPimBase */ | ||
250 | if ( !data->record && data->backend ) | ||
251 | data->record = data->backend->record( data->uid ); | ||
252 | |||
253 | Record *ta = Record::safeCast( data->record ); | ||
254 | if ( ta ) | ||
255 | target = *ta; | ||
256 | |||
257 | |||
258 | return target; | ||
259 | } | ||
260 | |||
261 | OPimEvent OPimOccurrence::toEvent()const { | ||
262 | return internalToRecord<OPimEvent>(); | ||
263 | } | ||
264 | |||
265 | OPimTodo OPimOccurrence::toTodo()const { | ||
266 | return internalToRecord<OPimTodo>(); | ||
267 | } | ||
268 | |||
269 | OPimContact OPimOccurrence::toContact()const { | ||
270 | return internalToRecord<OPimContact>(); | ||
271 | } | ||
272 | |||
273 | bool OPimOccurrence::operator<( const OPimOccurrence& oc )const { | ||
274 | if ( m_occurrence < oc.m_occurrence ) | ||
275 | return true; | ||
276 | if ( m_occurrence == oc.m_occurrence ) | ||
277 | return m_start < oc.m_start; | ||
278 | else | ||
279 | return false; | ||
280 | } | ||
281 | |||
282 | bool OPimOccurrence::operator<=( const OPimOccurrence& oc )const { | ||
283 | return ( m_occurrence <= oc.m_occurrence ); | ||
284 | } | ||
285 | |||
286 | bool OPimOccurrence::operator==( const OPimOccurrence& oc )const { | ||
287 | if ( data->uid != oc.data->uid ) | ||
288 | return false; | ||
289 | if ( m_occurrence != oc.m_occurrence ) | ||
290 | return false; | ||
291 | if ( m_isAllDay != oc.m_isAllDay ) | ||
292 | return false; | ||
293 | if ( m_isAllDay && oc.m_isAllDay ) | ||
294 | if ( m_start != oc.m_start || | ||
295 | m_end != oc.m_end ) | ||
296 | return false; | ||
297 | if ( data->summary != oc.data->summary ) | ||
298 | return false; | ||
299 | if ( data->note != oc.data->note ) | ||
300 | return false; | ||
301 | if ( data->location != oc.data->location ) | ||
302 | return false; | ||
303 | |||
304 | return true; | ||
305 | } | ||
306 | |||
307 | bool OPimOccurrence::operator!=( const OPimOccurrence& oc )const { | ||
308 | return !( *this == oc ); | ||
309 | } | ||
310 | |||
311 | bool OPimOccurrence::operator>( const OPimOccurrence& oc )const { | ||
312 | return !( *this <= oc ); | ||
313 | } | ||
314 | |||
315 | bool OPimOccurrence::operator>=( const OPimOccurrence& oc )const { | ||
316 | return !( *this < oc ); | ||
317 | } | ||
318 | |||
319 | } | ||
diff --git a/libopie2/opiepim/core/opimoccurrence.h b/libopie2/opiepim/core/opimoccurrence.h new file mode 100644 index 0000000..902638b --- a/dev/null +++ b/libopie2/opiepim/core/opimoccurrence.h | |||
@@ -0,0 +1,142 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) 2003, 2004 Holger Freyther <zecke@handhelds.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | |||
30 | #ifndef OPIE_PIM_OCCURRENCE_H | ||
31 | #define OPIE_PIM_OCCURRENCE_H | ||
32 | |||
33 | #include <opie2/osharedpointer.h> | ||
34 | #include <opie2/opimrecord.h> | ||
35 | #include <opie2/opimevent.h> | ||
36 | #include <opie2/opimtodo.h> | ||
37 | #include <opie2/opimcontact.h> | ||
38 | |||
39 | #include <qdatetime.h> | ||
40 | #include <qstringlist.h> | ||
41 | |||
42 | namespace Opie { | ||
43 | |||
44 | template<class T> class OPimAccessTemplate; | ||
45 | /** | ||
46 | * \brief An OPimOccurrence represents a occurence for one day of a OPimRecord | ||
47 | * | ||
48 | * An OPimOccurrence represents the occurrence of one OPimRecord | ||
49 | * for a period of Time for one day. An occurrence can spawn | ||
50 | * more then one day and then is splitted into multiple OPimOccurrence. | ||
51 | * By attributes you can find if a OPimOccurrence is the beginning and | ||
52 | * end, begin, end or is midway of a multiday occurrence. | ||
53 | * | ||
54 | */ | ||
55 | class OPimOccurrence { | ||
56 | friend class OPimBase; | ||
57 | public: | ||
58 | typedef QValueList<OPimOccurrence> List; | ||
59 | /** | ||
60 | * The position of the OPimOccurrence in a possible | ||
61 | * MultiDay Occurrence. | ||
62 | */ | ||
63 | enum Position { | ||
64 | MidWay, /* This OPimOccurrence is somewhere in between Start and End */ | ||
65 | Start, /* This OPimOccurrence is the Start of a multi day Occurrence */ | ||
66 | End, /* This OPimOccurrence is the End of a multi day Occurrence */ | ||
67 | StartEnd /* This OPimOccurrence only spans one day */ | ||
68 | }; | ||
69 | |||
70 | //@{ | ||
71 | OPimOccurrence(); | ||
72 | OPimOccurrence( const OPimOccurrence& ); | ||
73 | ~OPimOccurrence(); | ||
74 | //@} | ||
75 | |||
76 | //@{ | ||
77 | void setPeriod( const QDate& from ); | ||
78 | void setPeriod( const QDateTime& from, const QDateTime& to ); | ||
79 | void setPeriod( const QDate& from, const QTime& start, const QTime& end ); | ||
80 | //@} | ||
81 | |||
82 | //@{ | ||
83 | bool isAllDay()const; | ||
84 | QDate date()const; | ||
85 | QTime startTime()const; | ||
86 | QTime endTime()const; | ||
87 | QDateTime startDateTime()const; | ||
88 | QDateTime endDateTime()const; | ||
89 | //@} | ||
90 | |||
91 | //@{ | ||
92 | QString summary()const; | ||
93 | QString location()const; | ||
94 | QString note()const; | ||
95 | //@} | ||
96 | |||
97 | //@{ | ||
98 | int length()const; | ||
99 | Position position()const; | ||
100 | void setPosition( enum Position& ); | ||
101 | //@} | ||
102 | |||
103 | //@{ | ||
104 | Opie::Core::OSharedPointer<OPimRecord> record()const; | ||
105 | OPimEvent toEvent()const; | ||
106 | OPimTodo toTodo()const; | ||
107 | OPimContact toContact()const; | ||
108 | //@} | ||
109 | |||
110 | |||
111 | //@{ | ||
112 | bool operator< ( const OPimOccurrence& )const; | ||
113 | bool operator<=( const OPimOccurrence& )const; | ||
114 | bool operator==( const OPimOccurrence& )const; | ||
115 | bool operator!=( const OPimOccurrence& )const; | ||
116 | bool operator> ( const OPimOccurrence& )const; | ||
117 | bool operator>=( const OPimOccurrence& )const; | ||
118 | OPimOccurrence &operator=( const OPimOccurrence& ); | ||
119 | //@} | ||
120 | |||
121 | private: | ||
122 | QDate m_occurrence; | ||
123 | QTime m_start, m_end; | ||
124 | bool m_isAllDay : 1; | ||
125 | enum Position m_pos; | ||
126 | |||
127 | void deref(); | ||
128 | inline void changeOrModify(); | ||
129 | |||
130 | struct Private; | ||
131 | struct Data; | ||
132 | |||
133 | Data *data; | ||
134 | Private *d; | ||
135 | |||
136 | private: // ctor | ||
137 | OPimOccurrence( OPimOccurrence::Data *, enum Position ); | ||
138 | template<class T> T internalToRecord()const; | ||
139 | }; | ||
140 | } | ||
141 | |||
142 | #endif | ||
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp index 6546d99..60946e0 100644 --- a/libopie2/opiepim/core/opimrecord.cpp +++ b/libopie2/opiepim/core/opimrecord.cpp | |||
@@ -102,4 +102,2 @@ void OPimRecord::addCategoryName( const QString& ) | |||
102 | catDB.load( categoryFileName() ); | 102 | catDB.load( categoryFileName() ); |
103 | |||
104 | |||
105 | } | 103 | } |
@@ -113,16 +111,2 @@ bool OPimRecord::isEmpty() const | |||
113 | 111 | ||
114 | /*QString OPimRecord::crossToString()const { | ||
115 | QString str; | ||
116 | QMap<QString, QArray<int> >::ConstIterator it; | ||
117 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { | ||
118 | QArray<int> id = it.data(); | ||
119 | for ( uint i = 0; i < id.size(); ++i ) { | ||
120 | str += it.key() + "," + QString::number( i ) + ";"; | ||
121 | } | ||
122 | } | ||
123 | str = str.remove( str.length()-1, 1); // strip the ; | ||
124 | //owarn << "IDS " + str << oendl; | ||
125 | |||
126 | return str; | ||
127 | }*/ | ||
128 | /* if uid = 1 assign a new one */ | 112 | /* if uid = 1 assign a new one */ |
@@ -272,2 +256,9 @@ void OPimRecord::setExtraMap( const QMap<QString, QString>& map ) | |||
272 | 256 | ||
257 | #if 0 | ||
258 | QString OPimRecord::recordAttributeTranslated( int field )const | ||
259 | { | ||
260 | return recordAttributeTranslated()[field]; | ||
261 | } | ||
262 | #endif | ||
263 | |||
273 | } | 264 | } |
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h index 127439a..363cc78 100644 --- a/libopie2/opiepim/core/opimrecord.h +++ b/libopie2/opiepim/core/opimrecord.h | |||
@@ -34,2 +34,4 @@ | |||
34 | #include <opie2/opimxrefmanager.h> | 34 | #include <opie2/opimxrefmanager.h> |
35 | #include <opie2/opimglobal.h> | ||
36 | |||
35 | /* | 37 | /* |
@@ -62,3 +64,3 @@ class OPimRecord : public Qtopia::Record | |||
62 | */ | 64 | */ |
63 | OPimRecord( int uid = 0 ); | 65 | OPimRecord( UID uid = 0 ); |
64 | ~OPimRecord(); | 66 | ~OPimRecord(); |
@@ -140,2 +142,3 @@ class OPimRecord : public Qtopia::Record | |||
140 | 142 | ||
143 | //@{ | ||
141 | /** | 144 | /** |
@@ -143,3 +146,7 @@ class OPimRecord : public Qtopia::Record | |||
143 | */ | 146 | */ |
144 | virtual QString recordField( int ) const = 0; | 147 | virtual QString recordField( int ) const = 0; |
148 | // virtual QArray<int> recordAttributes()const = 0; | ||
149 | // virtual QMap<int,QString> recordAttributesTranslated() const = 0; | ||
150 | // QString recordAttributeTranslated(int field)const; | ||
151 | //@} | ||
145 | 152 | ||
diff --git a/libopie2/opiepim/core/opimrecordlist.h b/libopie2/opiepim/core/opimrecordlist.h index 1d5027f..0459f41 100644 --- a/libopie2/opiepim/core/opimrecordlist.h +++ b/libopie2/opiepim/core/opimrecordlist.h | |||
@@ -43,2 +43,3 @@ namespace Opie | |||
43 | 43 | ||
44 | template<class T> class OPimAccessTemplate; | ||
44 | class OPimRecordListIteratorPrivate; | 45 | class OPimRecordListIteratorPrivate; |
@@ -122,2 +123,3 @@ class OPimRecordList | |||
122 | { | 123 | { |
124 | template<class> friend class OPimAccessTemplate; | ||
123 | public: | 125 | public: |
@@ -129,6 +131,5 @@ class OPimRecordList | |||
129 | */ | 131 | */ |
130 | OPimRecordList () | 132 | OPimRecordList (){} |
131 | {} | ||
132 | OPimRecordList( const QArray<int>& ids, | 133 | OPimRecordList( const QArray<int>& ids, |
133 | const Base* ); | 134 | const Base* ); |
134 | ~OPimRecordList(); | 135 | ~OPimRecordList(); |
@@ -162,2 +163,5 @@ class OPimRecordList | |||
162 | */ | 163 | */ |
164 | protected: | ||
165 | UIDArray uids()const; | ||
166 | |||
163 | private: | 167 | private: |
@@ -192,3 +196,2 @@ OPimRecordListIterator<T>::OPimRecordListIterator( const OPimRecordListIterator< | |||
192 | { | 196 | { |
193 | //owarn << "OPimRecordListIterator copy c'tor" << oendl; | ||
194 | m_uids = it.m_uids; | 197 | m_uids = it.m_uids; |
@@ -218,3 +221,2 @@ T OPimRecordListIterator<T>::operator*() | |||
218 | { | 221 | { |
219 | //owarn << "operator* " << m_current << " " << m_uids[m_current] << oendl; | ||
220 | if ( !m_end ) | 222 | if ( !m_end ) |
@@ -401,2 +403,7 @@ bool OPimRecordList<T>::remove( int uid ) | |||
401 | 403 | ||
404 | template<class T> | ||
405 | UIDArray OPimRecordList<T>::uids()const { | ||
406 | return m_ids; | ||
407 | } | ||
408 | |||
402 | } | 409 | } |
diff --git a/libopie2/opiepim/core/opimresolver.h b/libopie2/opiepim/core/opimresolver.h index 0a6dddf..088474b 100644 --- a/libopie2/opiepim/core/opimresolver.h +++ b/libopie2/opiepim/core/opimresolver.h | |||
@@ -47,4 +47,2 @@ namespace Opie { | |||
47 | * and to more stuff | 47 | * and to more stuff |
48 | * THE PERFORMANCE will depend on THE BACKEND | ||
49 | * USING XML is a waste of memory!!!!! | ||
50 | */ | 48 | */ |
diff --git a/libopie2/opiepim/core/opimstate.h b/libopie2/opiepim/core/opimstate.h index 8336b3e..ae1e0d2 100644 --- a/libopie2/opiepim/core/opimstate.h +++ b/libopie2/opiepim/core/opimstate.h | |||
@@ -40,8 +40,2 @@ namespace Opie { | |||
40 | */ | 40 | */ |
41 | /* | ||
42 | * in c a simple struct would be enough ;) | ||
43 | * g_new_state(); | ||
44 | * g_do_some_thing( state_t* ); | ||
45 | * ;) | ||
46 | */ | ||
47 | class OPimState { | 41 | class OPimState { |
diff --git a/libopie2/opiepim/core/opimtemplatebase.cpp b/libopie2/opiepim/core/opimtemplatebase.cpp new file mode 100644 index 0000000..0a07320 --- a/dev/null +++ b/libopie2/opiepim/core/opimtemplatebase.cpp | |||
@@ -0,0 +1,112 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) 2004 Holger Freyther <zecke@handhelds.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | |||
30 | #include "opimtemplatebase.h" | ||
31 | |||
32 | #include <opie2/opimoccurrence.h> | ||
33 | #include <opie2/private/opimoccurrence_p.h> | ||
34 | |||
35 | namespace Opie { | ||
36 | |||
37 | static void setPeriod( OPimOccurrence& oc, bool period, const QDate& d, | ||
38 | const QTime& s, const QTime& t ) { | ||
39 | if ( period ) | ||
40 | oc.setPeriod( d ); | ||
41 | else | ||
42 | oc.setPeriod( d, s, t ); | ||
43 | } | ||
44 | |||
45 | // namespace Opie { | ||
46 | OPimBase::OPimBase() {} | ||
47 | OPimBase::~OPimBase() {} | ||
48 | |||
49 | /** | ||
50 | * @internal Convert internal Occurrence representation | ||
51 | * to the external | ||
52 | */ | ||
53 | OPimOccurrence::List OPimBase::convertOccurrenceFromBackend( const OPimBackendOccurrence::List& lst )const { | ||
54 | OPimOccurrence::List oc_lst; | ||
55 | |||
56 | /* | ||
57 | * Split multiday events up. Create the internal data structure | ||
58 | * and then iterate over the days and create the OPimOccurrecne. | ||
59 | */ | ||
60 | for ( OPimBackendOccurrence::List::ConstIterator it = lst.begin(); it != lst.end(); ++it ) { | ||
61 | OPimBackendOccurrence boc = *it; | ||
62 | |||
63 | /* | ||
64 | * Create the Shared Data Structure | ||
65 | */ | ||
66 | OPimOccurrence::Data *data = new OPimOccurrence::Data(); | ||
67 | data->summary = boc.summary(); | ||
68 | data->location = boc.location(); | ||
69 | data->note = boc.note(); | ||
70 | data->uid = boc.uid(); | ||
71 | data->backend = const_cast<OPimBase*>(this); | ||
72 | |||
73 | QDateTime start = boc.startDateTime(); | ||
74 | QDateTime end = boc.endDateTime(); | ||
75 | |||
76 | /* | ||
77 | * Start and End are on the same day | ||
78 | * Start and End are on two different ways. | ||
79 | * - Add Start and End and the days inbetween | ||
80 | */ | ||
81 | int dto = start.daysTo( end ); | ||
82 | bool allDay = boc.isAllDay(); | ||
83 | |||
84 | if ( dto == 0 ) { | ||
85 | OPimOccurrence oc = OPimOccurrence( data, OPimOccurrence::StartEnd ); | ||
86 | setPeriod( oc, allDay, start.date(), start.time(), end.time() ); | ||
87 | oc_lst.append( oc ); | ||
88 | }else { | ||
89 | |||
90 | OPimOccurrence oc = OPimOccurrence( data, OPimOccurrence::Start ); | ||
91 | setPeriod( oc, allDay, start.date(), start.time(), QTime(23,59,59)); | ||
92 | oc_lst.append( oc ); | ||
93 | |||
94 | QDate next = start.addDays( 1 ).date(); | ||
95 | while ( next != end.date() ) { | ||
96 | oc = OPimOccurrence( data, OPimOccurrence::MidWay ); | ||
97 | setPeriod( oc, allDay, next, QTime(0, 0, 0), QTime(23, 59, 59)); | ||
98 | oc_lst.append( oc ); | ||
99 | next = next.addDays( 1 ); | ||
100 | } | ||
101 | |||
102 | oc = OPimOccurrence( data, OPimOccurrence::End ); | ||
103 | setPeriod( oc, allDay, end.date(), QTime(0, 0, 0 ), end.time() ); | ||
104 | oc_lst.append( oc ); | ||
105 | } | ||
106 | } | ||
107 | |||
108 | return oc_lst; | ||
109 | } | ||
110 | // } | ||
111 | |||
112 | } | ||
diff --git a/libopie2/opiepim/core/opimtemplatebase.h b/libopie2/opiepim/core/opimtemplatebase.h index 787486c..b238a68 100644 --- a/libopie2/opiepim/core/opimtemplatebase.h +++ b/libopie2/opiepim/core/opimtemplatebase.h | |||
@@ -34,2 +34,4 @@ | |||
34 | #include <opie2/opimcache.h> | 34 | #include <opie2/opimcache.h> |
35 | #include <opie2/opimoccurrence.h> | ||
36 | #include <opie2/opimbackendoccurrence.h> | ||
35 | 37 | ||
@@ -37,14 +39,21 @@ | |||
37 | #include <qarray.h> | 39 | #include <qarray.h> |
40 | #include <qdatetime.h> | ||
38 | 41 | ||
39 | namespace Opie { | 42 | namespace Opie { |
43 | |||
44 | class OPimBasePrivate; | ||
45 | |||
40 | /** | 46 | /** |
41 | * Templates do not have a base class, This is why | 47 | * This is the base class for all our Interfaces to the |
42 | * we've this class | 48 | * PIM Records. It is pointer based and can be used |
43 | * this is here to give us the possibility | 49 | * generically for all types of Records. |
44 | * to have a common base class | 50 | * |
45 | * You may not want to use that interface internaly | ||
46 | * POOR mans interface | ||
47 | */ | 51 | */ |
48 | class OPimBasePrivate; | ||
49 | struct OPimBase { | 52 | struct OPimBase { |
53 | //@{ | ||
54 | OPimBase(); | ||
55 | virtual ~OPimBase(); | ||
56 | //@} | ||
57 | |||
58 | //@{ | ||
50 | /** | 59 | /** |
@@ -55,6 +64,13 @@ struct OPimBase { | |||
55 | virtual OPimRecord* record(int uid)const = 0; | 64 | virtual OPimRecord* record(int uid)const = 0; |
65 | //@} | ||
66 | |||
67 | //@{ | ||
56 | virtual bool add( const OPimRecord& ) = 0; | 68 | virtual bool add( const OPimRecord& ) = 0; |
57 | virtual bool add( const OPimRecord* ) = 0; | 69 | virtual bool add( const OPimRecord* ) = 0; |
70 | |||
58 | virtual bool remove( int uid ) = 0; | 71 | virtual bool remove( int uid ) = 0; |
59 | virtual bool remove( const OPimRecord& ) = 0; | 72 | virtual bool remove( const OPimRecord& ) = 0; |
73 | //@} | ||
74 | |||
75 | //@{ | ||
60 | virtual void clear() = 0; | 76 | virtual void clear() = 0; |
@@ -62,11 +78,72 @@ struct OPimBase { | |||
62 | virtual bool save() = 0; | 78 | virtual bool save() = 0; |
63 | virtual QArray<int> records()const = 0; | 79 | //@} |
64 | /* | 80 | |
65 | * ADD editing here? | 81 | //@{ |
66 | * -zecke | 82 | virtual QArray<UID> records()const = 0; |
83 | |||
84 | /** Constants for query. | ||
85 | * Use this constants to set the query parameters. | ||
86 | * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! | ||
87 | * @see queryByExample() | ||
67 | */ | 88 | */ |
68 | private: | 89 | enum QuerySettings { |
69 | OPimBasePrivate* d; | 90 | WildCards = 0x0001, /** Use Wildcards */ |
91 | IgnoreCase = 0x0002, /** Ignore the Case */ | ||
92 | RegExp = 0x0004, /** Do a Regular Expression match */ | ||
93 | ExactMatch = 0x0008, /** It needs to exactly match */ | ||
94 | MatchOne = 0x0010, /** Only one Entry must match */ | ||
95 | DateDiff = 0x0020, /** Find all entries from today until given date */ | ||
96 | DateYear = 0x0040, /** The year matches */ | ||
97 | DateMonth = 0x0080, /** The month matches */ | ||
98 | DateDay = 0x0100, /** The day matches */ | ||
99 | LastItem = 0xffff /** the last possible name */ | ||
100 | }; | ||
70 | 101 | ||
102 | /** | ||
103 | * Common Attributes for the Sort Order | ||
104 | */ | ||
105 | enum SortOrderBase { | ||
106 | SortSummary = 0, /** Sort by a Summary of the records */ | ||
107 | SortByCategory = 1, /** Sort by Category */ | ||
108 | SortByDate = 2, /** Sort by Date */ | ||
109 | SortCustom = 10, /** The First available sort number for the OPimAccessTemplates */ | ||
110 | LastSortOrderBase = 0xffff /** make this enum 16bit large */ | ||
111 | }; | ||
112 | |||
113 | /** | ||
114 | * Sort with the help of the \sa sorted function | ||
115 | * a list of Items. | ||
116 | * The Item you provide in SortOrder will be used | ||
117 | * for sorting. | ||
118 | * | ||
119 | * @see sorted | ||
120 | */ | ||
121 | enum SortFilterBase { | ||
122 | FilterCategory = 1, | ||
123 | FilterCustom = 1024, | ||
124 | LastSortFilterBase = 0xffffffff | ||
125 | }; | ||
126 | |||
127 | virtual UIDArray matchRegexpSimple( const QRegExp& r )const = 0; | ||
128 | virtual UIDArray queryByExampleSimple( const OPimRecord*, int settings, | ||
129 | const QDateTime& d = QDateTime() )const = 0; | ||
130 | virtual UIDArray sortedSimple( const UIDArray& uid, bool ascending, | ||
131 | int sortOrder, int sortFilter, int cat)const = 0; | ||
132 | virtual UIDArray sortedSimple( const UIDArray& uid, bool ascending, | ||
133 | int sortOrder, int sortFilter, const QArray<UID>& cats )const = 0; | ||
134 | virtual UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, int cat)const = 0; | ||
135 | virtual UIDArray sortedSimple( bool ascending, int sortOrder, int sortFilter, const QArray<UID>& cats )const = 0; | ||
136 | virtual OPimOccurrence::List occurrences( const QDate& start, const QDate& end )const = 0; | ||
137 | virtual OPimOccurrence::List occurrences( const QDateTime& dt )const = 0; | ||
138 | //@} | ||
139 | |||
140 | |||
141 | protected: | ||
142 | OPimOccurrence::List convertOccurrenceFromBackend( const OPimBackendOccurrence::List& )const; | ||
143 | |||
144 | private: | ||
145 | OPimBasePrivate* d; | ||
71 | }; | 146 | }; |
147 | |||
148 | |||
72 | /** | 149 | /** |
@@ -79,9 +156,23 @@ class OTemplateBase : public OPimBase { | |||
79 | public: | 156 | public: |
80 | /** Look ahead direction of cache */ | 157 | /** |
81 | enum CacheDirection { Forward=0, Reverse }; | 158 | * The Direction for ReadAhead/ReadBehind which will |
82 | 159 | * be used by the backends to Cache Items in | |
83 | OTemplateBase() { | 160 | * advance. |
161 | * For example if you know that you will access the | ||
162 | * next ten items you can give the backend a hint | ||
163 | * to read ahead or read before. | ||
164 | */ | ||
165 | enum CacheDirection { | ||
166 | Forward=0, /** Go forward when caching (++ to the index) */ | ||
167 | Reverse /** Go backward when caching (-- to the index) */ | ||
84 | }; | 168 | }; |
85 | virtual ~OTemplateBase() { | 169 | |
86 | } | 170 | |
171 | //@{ | ||
172 | OTemplateBase() {}; | ||
173 | virtual ~OTemplateBase() {} | ||
174 | //@} | ||
175 | |||
176 | |||
177 | //@{ | ||
87 | virtual T find( int uid )const = 0; | 178 | virtual T find( int uid )const = 0; |
@@ -93,3 +184,5 @@ public: | |||
93 | uint current, CacheDirection dir = Forward )const = 0; | 184 | uint current, CacheDirection dir = Forward )const = 0; |
185 | //@} | ||
94 | 186 | ||
187 | //@{ | ||
95 | /** | 188 | /** |
@@ -103,6 +196,6 @@ public: | |||
103 | static T* rec(); | 196 | static T* rec(); |
197 | //@} | ||
104 | 198 | ||
105 | |||
106 | private: | 199 | private: |
107 | OTemplateBasePrivate *d; | 200 | OTemplateBasePrivate *d; |
108 | }; | 201 | }; |
@@ -121,3 +214,4 @@ OPimRecord* OTemplateBase<T>::record(int uid )const { | |||
121 | return t1; | 214 | return t1; |
122 | }; | 215 | } |
216 | |||
123 | template <class T> | 217 | template <class T> |
@@ -126,3 +220,2 @@ T* OTemplateBase<T>::rec() { | |||
126 | } | 220 | } |
127 | |||
128 | } | 221 | } |
diff --git a/libopie2/opiepim/core/opimtimezone.cpp b/libopie2/opiepim/core/opimtimezone.cpp index 5b32b1f..1dc36b4 100644 --- a/libopie2/opiepim/core/opimtimezone.cpp +++ b/libopie2/opiepim/core/opimtimezone.cpp | |||
@@ -42,3 +42,24 @@ namespace Opie | |||
42 | 42 | ||
43 | QDateTime utcTime( time_t t ) | 43 | /* |
44 | * Save the old timeZone in a secure way (NULL Pointer check), | ||
45 | * set the new timeZone from the parameter, call tzset | ||
46 | * and then return the old timezone | ||
47 | */ | ||
48 | static QString setTimeZone( const QString& zone) { | ||
49 | QString old; | ||
50 | char *org = ::getenv( "TZ" ); | ||
51 | if( org ) | ||
52 | old = QString::fromLocal8Bit( org ); | ||
53 | |||
54 | ::setenv( "TZ", zone.local8Bit(), true ); | ||
55 | ::tzset(); | ||
56 | |||
57 | return old; | ||
58 | } | ||
59 | |||
60 | static void resetTimeZone( const QString& zone ) { | ||
61 | ::setenv( "TZ", zone.local8Bit(), true ); | ||
62 | } | ||
63 | |||
64 | static QDateTime utcTime( time_t t ) | ||
44 | { | 65 | { |
@@ -51,12 +72,9 @@ QDateTime utcTime( time_t t ) | |||
51 | 72 | ||
52 | QDateTime utcTime( time_t t, const QString& zone ) | 73 | static QDateTime utcTime( time_t t, const QString& zone ) |
53 | { | 74 | { |
54 | QCString org = ::getenv( "TZ" ); | ||
55 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac | ||
56 | |||
57 | ::setenv( "TZ", zone.latin1(), true ); | ||
58 | ::tzset(); | ||
59 | 75 | ||
76 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac | ||
77 | QString old = setTimeZone( zone ); | ||
60 | tm* broken = ::localtime( &t ); | 78 | tm* broken = ::localtime( &t ); |
61 | ::setenv( "TZ", org, true ); | 79 | resetTimeZone( old ); |
62 | #else | 80 | #else |
@@ -75,3 +93,3 @@ QDateTime utcTime( time_t t, const QString& zone ) | |||
75 | 93 | ||
76 | time_t to_Time_t( const QDateTime& utc, const QString& str ) | 94 | static time_t to_Time_t( const QDateTime& utc, const QString& str ) |
77 | { | 95 | { |
@@ -88,10 +106,6 @@ time_t to_Time_t( const QDateTime& utc, const QString& str ) | |||
88 | 106 | ||
89 | QCString org = ::getenv( "TZ" ); | ||
90 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac | 107 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac |
91 | 108 | QString old = setTimeZone( str ); | |
92 | ::setenv( "TZ", str.latin1(), true ); | ||
93 | ::tzset(); | ||
94 | |||
95 | time_t ti = ::mktime( &broken ); | 109 | time_t ti = ::mktime( &broken ); |
96 | ::setenv( "TZ", org, true ); | 110 | resetTimeZone( old ); |
97 | #else | 111 | #else |
diff --git a/libopie2/opiepim/core/opimtodo.cpp b/libopie2/opiepim/core/opimtodo.cpp index 27b36a6..16ca987 100644 --- a/libopie2/opiepim/core/opimtodo.cpp +++ b/libopie2/opiepim/core/opimtodo.cpp | |||
@@ -66,2 +66,3 @@ struct OPimTodo::OPimTodoData : public QShared | |||
66 | delete notifiers; | 66 | delete notifiers; |
67 | delete state; | ||
67 | } | 68 | } |
@@ -89,3 +90,2 @@ OPimTodo::OPimTodo( const OPimTodo &event ) | |||
89 | data->ref(); | 90 | data->ref(); |
90 | // owarn << "ref up" << oendl; | ||
91 | } | 91 | } |
@@ -96,6 +96,4 @@ OPimTodo::~OPimTodo() | |||
96 | 96 | ||
97 | // owarn << "~OPimTodo " << oendl; | ||
98 | if ( data->deref() ) | 97 | if ( data->deref() ) |
99 | { | 98 | { |
100 | // owarn << "OPimTodo::dereffing" << oendl; | ||
101 | delete data; | 99 | delete data; |
@@ -114,3 +112,2 @@ OPimTodo::OPimTodo( bool completed, int priority, | |||
114 | { | 112 | { |
115 | // owarn << "OPimTodoData " + summary << oendl; | ||
116 | setCategories( category ); | 113 | setCategories( category ); |
@@ -137,3 +134,2 @@ OPimTodo::OPimTodo( bool completed, int priority, | |||
137 | { | 134 | { |
138 | // owarn << "OPimTodoData" + summary << oendl; | ||
139 | setCategories( idsFromString( category.join( ";" ) ) ); | 135 | setCategories( idsFromString( category.join( ";" ) ) ); |
@@ -189,3 +185,14 @@ bool OPimTodo::hasDueDate() const | |||
189 | 185 | ||
190 | 186 | /** | |
187 | * \brief Does this Todo have a start date | ||
188 | * | ||
189 | * Does this Todo have a start date. The decision | ||
190 | * is based on if the internal startDate isValid | ||
191 | * in the sense of QDate::isValid. | ||
192 | * | ||
193 | * @return True if the startDate isValid | ||
194 | * @see startDate | ||
195 | * @see setStartDate | ||
196 | * @see QDate::isValid() | ||
197 | */ | ||
191 | bool OPimTodo::hasStartDate() const | 198 | bool OPimTodo::hasStartDate() const |
@@ -195,3 +202,12 @@ bool OPimTodo::hasStartDate() const | |||
195 | 202 | ||
196 | 203 | /** | |
204 | * \brief Does this Todo have a Date when it was completed | ||
205 | * | ||
206 | * As in \sa hasStartDate() it is determined if there | ||
207 | * is a completed date by looking if the internal date | ||
208 | * isValid \sa QDate::isValid. | ||
209 | * | ||
210 | * @see hasStartDate | ||
211 | * @return True if the completedDate is set and valid. | ||
212 | */ | ||
197 | bool OPimTodo::hasCompletedDate() const | 213 | bool OPimTodo::hasCompletedDate() const |
@@ -310,3 +326,2 @@ void OPimTodo::setDescription( const QString &desc ) | |||
310 | { | 326 | { |
311 | // owarn << "desc " + desc << oendl; | ||
312 | changeOrModify(); | 327 | changeOrModify(); |
@@ -382,3 +397,3 @@ void OPimTodo::setMaintainer( const OPimMaintainer& pim ) | |||
382 | 397 | ||
383 | bool OPimTodo::isOverdue( ) | 398 | bool OPimTodo::isOverdue( )const |
384 | { | 399 | { |
@@ -595,6 +610,4 @@ void OPimTodo::deref() | |||
595 | 610 | ||
596 | // owarn << "deref in ToDoEvent" << oendl; | ||
597 | if ( data->deref() ) | 611 | if ( data->deref() ) |
598 | { | 612 | { |
599 | // owarn << "deleting" << oendl; | ||
600 | delete data; | 613 | delete data; |
@@ -610,3 +623,2 @@ OPimTodo &OPimTodo::operator=( const OPimTodo &item ) | |||
610 | OPimRecord::operator=( item ); | 623 | OPimRecord::operator=( item ); |
611 | //owarn << "operator= ref " << oendl; | ||
612 | item.data->ref(); | 624 | item.data->ref(); |
@@ -653,3 +665,2 @@ void OPimTodo::changeOrModify() | |||
653 | { | 665 | { |
654 | owarn << "changeOrModify" << oendl; | ||
655 | data->deref(); | 666 | data->deref(); |
@@ -701,5 +712,74 @@ QString OPimTodo::type() const | |||
701 | 712 | ||
702 | QString OPimTodo::recordField( int /*id*/ ) const | 713 | QString OPimTodo::recordField( int id) const |
703 | { | 714 | { |
704 | return QString::null; | 715 | QString res; |
716 | Q_UNUSED( id ) | ||
717 | #if 0 | ||
718 | switch( id ) { | ||
719 | case HasDate: | ||
720 | res = (hasDueDate() ? | ||
721 | QObject::tr( "Has a due-date" ) | ||
722 | : QObject::tr( "No due-date" )); | ||
723 | break; | ||
724 | case Completed: | ||
725 | res = ( isCompleted() ? | ||
726 | QObject::tr( "Completed" ) : | ||
727 | QObject::tr( "Not completed" )); | ||
728 | break; | ||
729 | case Description: | ||
730 | res = description(); | ||
731 | break; | ||
732 | case Summary: | ||
733 | res = summary(); | ||
734 | break; | ||
735 | case Priority: | ||
736 | res = QString::number( priority() ); | ||
737 | break; | ||
738 | case DateDay: | ||
739 | res = QString::number( dueDate().day() ); | ||
740 | break; | ||
741 | case DateMonth: | ||
742 | res = QString::number( dueDate().month() ); | ||
743 | break; | ||
744 | case DateYear: | ||
745 | res = QString::number( dueDate().year() ); | ||
746 | break; | ||
747 | case Progress: | ||
748 | res = QString::number( progress() ); | ||
749 | break; | ||
750 | case State: | ||
751 | res = QString::number( state().state() ); | ||
752 | break; | ||
753 | case Recurrence: | ||
754 | res = ( hasRecurrence() ? | ||
755 | QString::null /*recurrence().summary()*/ : | ||
756 | QObject::tr("No reccurrence")); | ||
757 | break; | ||
758 | case Alarms: | ||
759 | break; | ||
760 | case Reminders: | ||
761 | break; | ||
762 | case Maintainer: | ||
763 | break; | ||
764 | case StartDate: | ||
765 | res = ( hasStartDate() ? | ||
766 | /*TimeString::()*/ QString::null : | ||
767 | QObject::tr( "No start-date" ) ); | ||
768 | break; | ||
769 | case CompletedDate: | ||
770 | res = ( hasCompletedDate() ? | ||
771 | /*TimeString::()*/ QString::null : | ||
772 | QObject::tr( "No completed-date" ) ); | ||
773 | break; | ||
774 | case DueDate: | ||
775 | res = ( hasDueDate() ? | ||
776 | /*TimeString::()*/ QString::null : | ||
777 | QObject::tr( "No due-date" ); | ||
778 | break; | ||
779 | default: | ||
780 | res = OPimRecord::recordField( id ); | ||
781 | } | ||
782 | |||
783 | #endif | ||
784 | return res; | ||
705 | } | 785 | } |
@@ -712,2 +792,19 @@ int OPimTodo::rtti() const | |||
712 | 792 | ||
793 | /** | ||
794 | * \brief Provide a SafeCast to OPimTodo from a OPimRecord | ||
795 | * | ||
796 | * Provide a safe cast that will return 0 if the record | ||
797 | * type is not OPimTodo. In the other case it will | ||
798 | * be casted to OPimTodo and returned | ||
799 | * | ||
800 | * @param rec The OPimRecord to be casted | ||
801 | * | ||
802 | * @return a pointer to OPimTodo or 0l | ||
803 | */ | ||
804 | OPimTodo* OPimTodo::safeCast( const OPimRecord* rec ) { | ||
805 | return (rec && rec->rtti() == OPimResolver::TodoList ) ? | ||
806 | static_cast<OPimTodo*>( const_cast<OPimRecord*>(rec) ) : | ||
807 | 0l; | ||
808 | } | ||
809 | |||
713 | } | 810 | } |
diff --git a/libopie2/opiepim/core/opimtodo.h b/libopie2/opiepim/core/opimtodo.h index e17fe6a..f4f9926 100644 --- a/libopie2/opiepim/core/opimtodo.h +++ b/libopie2/opiepim/core/opimtodo.h | |||
@@ -72,7 +72,8 @@ class OPimTodo : public OPimRecord | |||
72 | Alarms, | 72 | Alarms, |
73 | Reminders, | 73 | Reminders, |
74 | Notifiers, | ||
75 | Maintainer, | 74 | Maintainer, |
76 | StartDate, | 75 | StartDate, |
77 | CompletedDate | 76 | CompletedDate, |
77 | //ADDITIONAL FOR RECORDFIELD | ||
78 | DueDate, | ||
78 | }; | 79 | }; |
@@ -284,3 +285,3 @@ class OPimTodo : public OPimRecord | |||
284 | 285 | ||
285 | bool isOverdue(); | 286 | bool isOverdue()const; |
286 | 287 | ||
@@ -297,3 +298,7 @@ class OPimTodo : public OPimRecord | |||
297 | 298 | ||
299 | //@{ | ||
298 | int rtti() const; | 300 | int rtti() const; |
301 | static OPimTodo* safeCast( const OPimRecord* ); | ||
302 | //@} | ||
303 | |||
299 | 304 | ||
diff --git a/libopie2/opiepim/core/otodoaccess.cpp b/libopie2/opiepim/core/otodoaccess.cpp index 26a68a0..4ad5950 100644 --- a/libopie2/opiepim/core/otodoaccess.cpp +++ b/libopie2/opiepim/core/otodoaccess.cpp | |||
@@ -52,4 +52,4 @@ OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access ) | |||
52 | OPimTodoAccess::~OPimTodoAccess() { | 52 | OPimTodoAccess::~OPimTodoAccess() { |
53 | // owarn << "~OPimTodoAccess" << oendl; | ||
54 | } | 53 | } |
54 | |||
55 | void OPimTodoAccess::mergeWith( const QValueList<OPimTodo>& list ) { | 55 | void OPimTodoAccess::mergeWith( const QValueList<OPimTodo>& list ) { |
@@ -62,3 +62,3 @@ OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start, | |||
62 | const QDate& end, | 62 | const QDate& end, |
63 | bool includeNoDates ) { | 63 | bool includeNoDates )const { |
64 | QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); | 64 | QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); |
@@ -69,3 +69,3 @@ OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start, | |||
69 | OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start, | 69 | OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start, |
70 | bool includeNoDates ) { | 70 | bool includeNoDates )const { |
71 | return effectiveToDos( start, QDate::currentDate(), | 71 | return effectiveToDos( start, QDate::currentDate(), |
@@ -73,3 +73,3 @@ OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start, | |||
73 | } | 73 | } |
74 | OPimTodoAccess::List OPimTodoAccess::overDue() { | 74 | OPimTodoAccess::List OPimTodoAccess::overDue()const { |
75 | List lis( m_todoBackEnd->overDue(), this ); | 75 | List lis( m_todoBackEnd->overDue(), this ); |
@@ -77,9 +77,3 @@ OPimTodoAccess::List OPimTodoAccess::overDue() { | |||
77 | } | 77 | } |
78 | /* sort order */ | 78 | |
79 | OPimTodoAccess::List OPimTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { | ||
80 | QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, | ||
81 | filter, cat ); | ||
82 | OPimTodoAccess::List list( ints, this ); | ||
83 | return list; | ||
84 | } | ||
85 | void OPimTodoAccess::removeAllCompleted() { | 79 | void OPimTodoAccess::removeAllCompleted() { |
@@ -87,9 +81,2 @@ void OPimTodoAccess::removeAllCompleted() { | |||
87 | } | 81 | } |
88 | QBitArray OPimTodoAccess::backendSupport( const QString& ) const{ | ||
89 | return m_todoBackEnd->supports(); | ||
90 | } | ||
91 | bool OPimTodoAccess::backendSupports( int attr, const QString& ar) const{ | ||
92 | return backendSupport(ar).testBit( attr ); | ||
93 | } | ||
94 | |||
95 | 82 | ||
diff --git a/libopie2/opiepim/core/otodoaccess.h b/libopie2/opiepim/core/otodoaccess.h index 3f5af30..8338586 100644 --- a/libopie2/opiepim/core/otodoaccess.h +++ b/libopie2/opiepim/core/otodoaccess.h | |||
@@ -48,9 +48,7 @@ class OPimTodoAccess : public QObject, public OPimAccessTemplate<OPimTodo> { | |||
48 | public: | 48 | public: |
49 | enum SortOrder { Completed = 0, | 49 | enum SortOrder { Completed = SortCustom, |
50 | Priority, | 50 | Priority, |
51 | Description, | ||
52 | Deadline }; | 51 | Deadline }; |
53 | enum SortFilter{ Category =1, | 52 | enum SortFilter{ OnlyOverDue= FilterCustom, |
54 | OnlyOverDue= 2, | 53 | DoNotShowCompleted = FilterCustom<<1 }; |
55 | DoNotShowCompleted =4 }; | ||
56 | /** | 54 | /** |
@@ -72,3 +70,3 @@ public: | |||
72 | const QDate& end, | 70 | const QDate& end, |
73 | bool includeNoDates = true ); | 71 | bool includeNoDates = true )const; |
74 | 72 | ||
@@ -79,3 +77,3 @@ public: | |||
79 | List effectiveToDos( const QDate& start, | 77 | List effectiveToDos( const QDate& start, |
80 | bool includeNoDates = true ); | 78 | bool includeNoDates = true )const; |
81 | 79 | ||
@@ -85,8 +83,3 @@ public: | |||
85 | */ | 83 | */ |
86 | List overDue(); | 84 | List overDue()const; |
87 | |||
88 | /** | ||
89 | * | ||
90 | */ | ||
91 | List sorted( bool ascending, int sortOrder, int sortFilter, int cat ); | ||
92 | 85 | ||
@@ -104,19 +97,2 @@ public: | |||
104 | /** | 97 | /** |
105 | * request information about what a backend supports. | ||
106 | * Supports in the sense of beeing able to store. | ||
107 | * This is related to the enum in OPimTodo | ||
108 | * | ||
109 | * @param backend Will be used in the future when we support multiple backend | ||
110 | */ | ||
111 | QBitArray backendSupport( const QString& backend = QString::null )const; | ||
112 | |||
113 | /** | ||
114 | * see above but for a specefic attribute. This method was added for convience | ||
115 | * @param attr The attribute to be queried for | ||
116 | * @param backend Will be used in the future when we support multiple backends | ||
117 | */ | ||
118 | bool backendSupports( int attr, const QString& backend = QString::null )const; | ||
119 | |||
120 | |||
121 | /** | ||
122 | * Return identification of used records | 98 | * Return identification of used records |