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 | |||
@@ -7,16 +7,17 @@ HEADERS += \ | |||
7 | core/opimcontactfields.h \ | 7 | core/opimcontactfields.h \ |
8 | core/opimcontact.h \ | 8 | core/opimcontact.h \ |
9 | core/opimdateconversion.h \ | 9 | core/opimdateconversion.h \ |
10 | core/opimevent.h \ | 10 | core/opimevent.h \ |
11 | core/opimglobal.h \ | 11 | core/opimglobal.h \ |
12 | core/opimmaintainer.h \ | 12 | core/opimmaintainer.h \ |
13 | core/opimnotify.h \ | 13 | core/opimnotify.h \ |
14 | core/opimnotifymanager.h \ | 14 | core/opimnotifymanager.h \ |
15 | core/opimoccurrence.h \ | ||
15 | core/opimrecord.h \ | 16 | core/opimrecord.h \ |
16 | core/opimrecordlist.h \ | 17 | core/opimrecordlist.h \ |
17 | core/opimrecurrence.h \ | 18 | core/opimrecurrence.h \ |
18 | core/opimresolver.h \ | 19 | core/opimresolver.h \ |
19 | core/opimstate.h \ | 20 | core/opimstate.h \ |
20 | core/opimtemplatebase.h \ | 21 | core/opimtemplatebase.h \ |
21 | core/opimtimezone.h \ | 22 | core/opimtimezone.h \ |
22 | core/opimtodo.h \ | 23 | core/opimtodo.h \ |
@@ -30,19 +31,21 @@ SOURCES += \ | |||
30 | core/odatebookaccess.cpp \ | 31 | core/odatebookaccess.cpp \ |
31 | core/opimcontactfields.cpp \ | 32 | core/opimcontactfields.cpp \ |
32 | core/opimcontact.cpp \ | 33 | core/opimcontact.cpp \ |
33 | core/opimdateconversion.cpp \ | 34 | core/opimdateconversion.cpp \ |
34 | core/opimevent.cpp \ | 35 | core/opimevent.cpp \ |
35 | core/opimmaintainer.cpp \ | 36 | core/opimmaintainer.cpp \ |
36 | core/opimnotify.cpp \ | 37 | core/opimnotify.cpp \ |
37 | core/opimnotifymanager.cpp \ | 38 | core/opimnotifymanager.cpp \ |
39 | core/opimoccurrence.cpp \ | ||
38 | core/opimrecord.cpp \ | 40 | core/opimrecord.cpp \ |
39 | core/opimrecurrence.cpp \ | 41 | core/opimrecurrence.cpp \ |
40 | core/opimresolver.cpp \ | 42 | core/opimresolver.cpp \ |
41 | core/opimstate.cpp \ | 43 | core/opimstate.cpp \ |
44 | core/opimtemplatebase.cpp \ | ||
42 | core/opimtimezone.cpp \ | 45 | core/opimtimezone.cpp \ |
43 | core/opimtodo.cpp \ | 46 | core/opimtodo.cpp \ |
44 | core/opimxref.cpp \ | 47 | core/opimxref.cpp \ |
45 | core/opimxrefmanager.cpp \ | 48 | core/opimxrefmanager.cpp \ |
46 | core/opimxrefpartner.cpp \ | 49 | core/opimxrefpartner.cpp \ |
47 | core/otodoaccess.cpp | 50 | core/otodoaccess.cpp |
48 | 51 | ||
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 | |||
@@ -65,17 +65,16 @@ namespace Opie { | |||
65 | OPimContactAccess::OPimContactAccess ( const QString appname, const QString , | 65 | OPimContactAccess::OPimContactAccess ( const QString appname, const QString , |
66 | OPimContactAccessBackend* end, bool autosync ): | 66 | OPimContactAccessBackend* end, bool autosync ): |
67 | OPimAccessTemplate<OPimContact>( end ) | 67 | OPimAccessTemplate<OPimContact>( end ) |
68 | { | 68 | { |
69 | /* take care of the backend. If there is no one defined, we | 69 | /* take care of the backend. If there is no one defined, we |
70 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). | 70 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). |
71 | */ | 71 | */ |
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 ); |
75 | } | 74 | } |
76 | // Set backend locally and in template | 75 | // Set backend locally and in template |
77 | m_backEnd = end; | 76 | m_backEnd = end; |
78 | OPimAccessTemplate<OPimContact>::setBackEnd (end); | 77 | OPimAccessTemplate<OPimContact>::setBackEnd (end); |
79 | 78 | ||
80 | 79 | ||
81 | /* Connect signal of external db change to function */ | 80 | /* Connect signal of external db change to function */ |
@@ -123,39 +122,39 @@ const uint OPimContactAccess::querySettings() | |||
123 | { | 122 | { |
124 | return ( m_backEnd->querySettings() ); | 123 | return ( m_backEnd->querySettings() ); |
125 | } | 124 | } |
126 | 125 | ||
127 | bool OPimContactAccess::hasQuerySettings ( int querySettings ) const | 126 | bool OPimContactAccess::hasQuerySettings ( int querySettings ) const |
128 | { | 127 | { |
129 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); | 128 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); |
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 |
132 | { | 133 | { |
133 | QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); | 134 | QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); |
134 | return ( OPimRecordList<OPimContact>(matchingContacts, this) ); | 135 | return ( OPimRecordList<OPimContact>(matchingContacts, this) ); |
135 | } | 136 | } |
137 | #endif | ||
136 | 138 | ||
137 | 139 | ||
138 | bool OPimContactAccess::wasChangedExternally()const | 140 | bool OPimContactAccess::wasChangedExternally()const |
139 | { | 141 | { |
140 | return ( m_backEnd->wasChangedExternally() ); | 142 | return ( m_backEnd->wasChangedExternally() ); |
141 | } | 143 | } |
142 | 144 | ||
143 | 145 | ||
144 | void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & ) | 146 | void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & ) |
145 | { | 147 | { |
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 (); |
155 | emit signalChanged ( this ); | 154 | emit signalChanged ( this ); |
156 | } | 155 | } |
157 | } | 156 | } |
158 | 157 | ||
159 | int OPimContactAccess::rtti() const | 158 | int OPimContactAccess::rtti() const |
160 | { | 159 | { |
161 | return OPimResolver::AddressBook; | 160 | return OPimResolver::AddressBook; |
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 | |||
@@ -55,59 +55,54 @@ namespace Opie { | |||
55 | * @author Stefan Eilers, Holger Freyther | 55 | * @author Stefan Eilers, Holger Freyther |
56 | * @see OPimAccessTemplate | 56 | * @see OPimAccessTemplate |
57 | */ | 57 | */ |
58 | class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact> | 58 | class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact> |
59 | { | 59 | { |
60 | Q_OBJECT | 60 | Q_OBJECT |
61 | 61 | ||
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 | /** |
64 | * Create Database with contacts (addressbook). | 84 | * Create Database with contacts (addressbook). |
65 | * @param appname Name of application which wants access to the database | 85 | * @param appname Name of application which wants access to the database |
66 | * (i.e. "todolist") | 86 | * (i.e. "todolist") |
67 | * @param filename The name of the database file. If not set, the default one | 87 | * @param filename The name of the database file. If not set, the default one |
68 | * is used. | 88 | * is used. |
69 | * @param backend Pointer to an alternative Backend. If not set, we will use | 89 | * @param backend Pointer to an alternative Backend. If not set, we will use |
70 | * the default backend. | 90 | * the default backend. |
71 | * @param handlesync If <b>true</b> the database stores the current state | 91 | * @param handlesync If <b>true</b> the database stores the current state |
72 | * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> | 92 | * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> |
73 | * which are used before and after synchronisation. If the application wants | 93 | * which are used before and after synchronisation. If the application wants |
74 | * to react itself, it should be disabled by setting it to <b>false</b> | 94 | * to react itself, it should be disabled by setting it to <b>false</b> |
75 | * @see OPimContactAccessBackend | 95 | * @see OPimContactAccessBackend |
76 | */ | 96 | */ |
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 | ||
107 | /** Return all possible settings. | 102 | /** Return all possible settings. |
108 | * @return All settings provided by the current backend | 103 | * @return All settings provided by the current backend |
109 | * (i.e.: query_WildCards & query_IgnoreCase) | 104 | * (i.e.: query_WildCards & query_IgnoreCase) |
110 | */ | 105 | */ |
111 | const uint querySettings(); | 106 | const uint querySettings(); |
112 | 107 | ||
113 | /** Check whether settings are correct. | 108 | /** Check whether settings are correct. |
@@ -121,36 +116,34 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact> | |||
121 | */ | 116 | */ |
122 | bool wasChangedExternally()const; | 117 | bool wasChangedExternally()const; |
123 | 118 | ||
124 | 119 | ||
125 | /** Save contacts database. | 120 | /** Save contacts database. |
126 | * Save is more a "commit". After calling this function, all changes are public available. | 121 | * Save is more a "commit". After calling this function, all changes are public available. |
127 | * @return true if successful | 122 | * @return true if successful |
128 | */ | 123 | */ |
129 | bool save(); | 124 | bool save(); |
130 | 125 | ||
131 | /** | 126 | /** |
132 | * Return identification of used records | 127 | * Return identification of used records |
133 | */ | 128 | */ |
134 | int rtti() const; | 129 | int rtti() const; |
135 | 130 | ||
136 | signals: | 131 | signals: |
137 | /* Signal is emitted if the database was changed. Therefore | 132 | /* Signal is emitted if the database was changed. Therefore |
138 | * we may need to reload to stay consistent. | 133 | * we may need to reload to stay consistent. |
139 | * @param which Pointer to the database who created this event. This pointer | 134 | * @param which Pointer to the database who created this event. This pointer |
140 | * is useful if an application has to handle multiple databases at the same time. | 135 | * is useful if an application has to handle multiple databases at the same time. |
141 | * @see reload() | 136 | * @see reload() |
142 | */ | 137 | */ |
143 | void signalChanged ( const OPimContactAccess *which ); | 138 | void signalChanged ( const OPimContactAccess *which ); |
144 | 139 | ||
145 | 140 | ||
146 | private: | 141 | private: |
147 | // class OPimContactAccessPrivate; | ||
148 | // OPimContactAccessPrivate* d; | ||
149 | OPimContactAccessBackend *m_backEnd; | 142 | OPimContactAccessBackend *m_backEnd; |
150 | bool m_loading:1; | 143 | bool m_loading:1; |
151 | 144 | ||
152 | private slots: | 145 | private slots: |
153 | void copMessage( const QCString &msg, const QByteArray &data ); | 146 | void copMessage( const QCString &msg, const QByteArray &data ); |
154 | 147 | ||
155 | private: | 148 | private: |
156 | class Private; | 149 | class Private; |
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 | |||
@@ -34,37 +34,28 @@ | |||
34 | namespace Opie { | 34 | namespace Opie { |
35 | /** | 35 | /** |
36 | * Simple constructor | 36 | * Simple constructor |
37 | * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation | 37 | * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation |
38 | * will be used! | 38 | * will be used! |
39 | * @param back The backend to be used or 0 for the default backend | 39 | * @param back The backend to be used or 0 for the default backend |
40 | * @param ac What kind of access is intended | 40 | * @param ac What kind of access is intended |
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 ) |
44 | { | 44 | { |
45 | if (!back ) | 45 | if (!back ) |
46 | back = OBackendFactory<ODateBookAccessBackend>::defaultBackend( OPimGlobal::DATEBOOK, QString::null ); | 46 | back = OBackendFactory<ODateBookAccessBackend>::defaultBackend( OPimGlobal::DATEBOOK, QString::null ); |
47 | 47 | ||
48 | m_backEnd = back; | 48 | m_backEnd = back; |
49 | setBackEnd( m_backEnd ); | 49 | setBackEnd( m_backEnd ); |
50 | } | 50 | } |
51 | ODateBookAccess::~ODateBookAccess() { | 51 | ODateBookAccess::~ODateBookAccess() { |
52 | } | 52 | } |
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 | ||
64 | /** | 55 | /** |
65 | * @return all repeating events | 56 | * @return all repeating events |
66 | */ | 57 | */ |
67 | ODateBookAccess::List ODateBookAccess::rawRepeats()const { | 58 | ODateBookAccess::List ODateBookAccess::rawRepeats()const { |
68 | QArray<int> ints = m_backEnd->rawRepeats(); | 59 | QArray<int> ints = m_backEnd->rawRepeats(); |
69 | 60 | ||
70 | List lis( ints, this ); | 61 | List lis( ints, this ); |
@@ -77,42 +68,28 @@ ODateBookAccess::List ODateBookAccess::rawRepeats()const { | |||
77 | ODateBookAccess::List ODateBookAccess::nonRepeats()const { | 68 | ODateBookAccess::List ODateBookAccess::nonRepeats()const { |
78 | QArray<int> ints = m_backEnd->nonRepeats(); | 69 | QArray<int> ints = m_backEnd->nonRepeats(); |
79 | 70 | ||
80 | List lis( ints, this ); | 71 | List lis( ints, this ); |
81 | return lis; | 72 | return lis; |
82 | } | 73 | } |
83 | 74 | ||
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 |
101 | * @param from Include all events from... | 77 | * @param from Include all events from... |
102 | * @param to Include all events to... | 78 | * @param to Include all events to... |
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 | } |
107 | /** | 83 | /** |
108 | * @return all non repeating events at a given datetime | 84 | * @return all non repeating events at a given datetime |
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 |
114 | { | 91 | { |
115 | return OPimResolver::DateBook; | 92 | return OPimResolver::DateBook; |
116 | } | 93 | } |
117 | 94 | ||
118 | } | 95 | } |
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 | |||
@@ -44,32 +44,27 @@ namespace Opie { | |||
44 | * | 44 | * |
45 | * @author Holger Freyther, Stefan Eilers | 45 | * @author Holger Freyther, Stefan Eilers |
46 | */ | 46 | */ |
47 | class ODateBookAccess : public OPimAccessTemplate<OPimEvent> { | 47 | class ODateBookAccess : public OPimAccessTemplate<OPimEvent> { |
48 | public: | 48 | public: |
49 | ODateBookAccess( ODateBookAccessBackend* = 0l, enum Access acc = Random ); | 49 | ODateBookAccess( ODateBookAccessBackend* = 0l, enum Access acc = Random ); |
50 | ~ODateBookAccess(); | 50 | ~ODateBookAccess(); |
51 | 51 | ||
52 | /* return all events */ | ||
53 | List rawEvents()const; | ||
54 | |||
55 | /* return repeating events */ | 52 | /* return repeating events */ |
56 | List rawRepeats()const; | 53 | List rawRepeats()const; |
57 | 54 | ||
58 | /* return non repeating events */ | 55 | /* return non repeating events */ |
59 | List nonRepeats()const; | 56 | List nonRepeats()const; |
60 | 57 | ||
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 |
69 | */ | 64 | */ |
70 | int rtti() const; | 65 | int rtti() const; |
71 | 66 | ||
72 | 67 | ||
73 | private: | 68 | private: |
74 | ODateBookAccessBackend* m_backEnd; | 69 | ODateBookAccessBackend* m_backEnd; |
75 | class Private; | 70 | class Private; |
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 | |||
@@ -1,12 +1,12 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
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> |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
@@ -35,158 +35,110 @@ | |||
35 | #include <opie2/opimaccessbackend.h> | 35 | #include <opie2/opimaccessbackend.h> |
36 | #include <opie2/opimrecordlist.h> | 36 | #include <opie2/opimrecordlist.h> |
37 | 37 | ||
38 | #include <opie2/opimtemplatebase.h> | 38 | #include <opie2/opimtemplatebase.h> |
39 | #include <opie2/odebug.h> | 39 | #include <opie2/odebug.h> |
40 | 40 | ||
41 | /* QT */ | 41 | /* QT */ |
42 | #include <qarray.h> | 42 | #include <qarray.h> |
43 | #include <qdatetime.h> | ||
43 | 44 | ||
44 | namespace Opie { | 45 | namespace Opie { |
45 | 46 | ||
46 | class OPimAccessTemplatePrivate; | 47 | class OPimAccessTemplatePrivate; |
47 | /** | 48 | /** |
48 | * Thats the frontend to our OPIE PIM | 49 | * Thats the frontend to our OPIE PIM |
49 | * Library. Either you want to use it's | 50 | * Library. Either you want to use it's |
50 | * interface or you want to implement | 51 | * interface or you want to implement |
51 | * your own Access lib | 52 | * your own Access lib |
52 | * Just create a OPimRecord and inherit from | 53 | * Just create a OPimRecord and inherit from |
53 | * the templates | 54 | * the templates |
54 | */ | 55 | */ |
55 | 56 | ||
56 | template <class T = OPimRecord > | 57 | template <class T = OPimRecord > |
57 | class OPimAccessTemplate : public OTemplateBase<T> { | 58 | class OPimAccessTemplate : public OTemplateBase<T> { |
58 | public: | 59 | public: |
60 | /** | ||
61 | * | ||
62 | */ | ||
59 | enum Access { | 63 | enum Access { |
60 | Random = 0, | 64 | Random = 0, |
61 | SortedAccess | 65 | SortedAccess |
62 | }; | 66 | }; |
63 | typedef OPimRecordList<T> List; | 67 | typedef OPimRecordList<T> List; |
64 | typedef OPimAccessBackend<T> BackEnd; | 68 | typedef OPimAccessBackend<T> BackEnd; |
65 | typedef OPimCache<T> Cache; | 69 | typedef OPimCache<T> Cache; |
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; |
182 | void setSaneCacheSize( int ); | 134 | void setSaneCacheSize( int ); |
183 | 135 | ||
184 | QArray<int> records()const; | 136 | QArray<UID> records()const; |
185 | protected: | 137 | protected: |
186 | /** | 138 | /** |
187 | * invalidate the cache | 139 | * invalidate the cache |
188 | */ | 140 | */ |
189 | void invalidateCache(); | 141 | void invalidateCache(); |
190 | 142 | ||
191 | void setBackEnd( BackEnd* end ); | 143 | void setBackEnd( BackEnd* end ); |
192 | /** | 144 | /** |
@@ -197,100 +149,161 @@ protected: | |||
197 | 149 | ||
198 | Cache m_cache; | 150 | Cache m_cache; |
199 | 151 | ||
200 | private: | 152 | private: |
201 | OPimAccessTemplatePrivate *d; | 153 | OPimAccessTemplatePrivate *d; |
202 | 154 | ||
203 | }; | 155 | }; |
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> |
206 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) | 162 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) |
207 | : OTemplateBase<T>(), m_backEnd( end ) | 163 | : OTemplateBase<T>(), m_backEnd( end ) |
208 | { | 164 | { |
209 | if (end ) | 165 | if (end ) |
210 | end->setFrontend( this ); | 166 | end->setFrontend( this ); |
211 | } | 167 | } |
212 | template <class T> | 168 | 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> |
218 | bool OPimAccessTemplate<T>::load() { | 177 | bool OPimAccessTemplate<T>::load() { |
219 | invalidateCache(); | 178 | invalidateCache(); |
220 | return m_backEnd->load(); | 179 | return m_backEnd->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> |
223 | bool OPimAccessTemplate<T>::reload() { | 189 | bool OPimAccessTemplate<T>::reload() { |
224 | invalidateCache(); | 190 | invalidateCache(); |
225 | return m_backEnd->reload(); | 191 | return m_backEnd->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> |
228 | bool OPimAccessTemplate<T>::save() { | 200 | bool OPimAccessTemplate<T>::save() { |
229 | return m_backEnd->save(); | 201 | return m_backEnd->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> |
232 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { | 210 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { |
233 | QArray<int> ints = m_backEnd->allRecords(); | 211 | QArray<int> ints = m_backEnd->allRecords(); |
234 | List lis(ints, this ); | 212 | List lis(ints, this ); |
235 | return lis; | 213 | return lis; |
236 | } | 214 | } |
215 | |||
216 | /** | ||
217 | * return a List of records | ||
218 | * that match the regex | ||
219 | */ | ||
237 | template <class T> | 220 | template <class T> |
238 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const { | 221 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const { |
239 | QArray<int> ints = m_backEnd->matchRegexp( r ); | 222 | QArray<int> ints = m_backEnd->matchRegexp( r ); |
240 | List lis(ints, this ); | 223 | List lis(ints, this ); |
241 | return lis; | 224 | return lis; |
242 | } | 225 | } |
226 | |||
227 | /** | ||
228 | * find the OPimRecord uid | ||
229 | */ | ||
243 | template <class T> | 230 | template <class T> |
244 | QArray<int> OPimAccessTemplate<T>::records()const { | 231 | QArray<int> OPimAccessTemplate<T>::records()const { |
245 | return m_backEnd->allRecords(); | 232 | return m_backEnd->allRecords(); |
246 | } | 233 | } |
234 | |||
235 | |||
236 | /** | ||
237 | * queryByExample. | ||
238 | * @see otodoaccess, ocontactaccess | ||
239 | */ | ||
247 | template <class T> | 240 | template <class T> |
248 | typename OPimAccessTemplate<T>::List | 241 | typename OPimAccessTemplate<T>::List |
249 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { | 242 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { |
250 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); | 243 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); |
251 | 244 | ||
252 | List lis(ints, this ); | 245 | List lis(ints, this ); |
253 | return lis; | 246 | return lis; |
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.. |
258 | if ( m_cache.contains( uid ) ) | 252 | if ( m_cache.contains( uid ) ) |
259 | return m_cache.find( uid ); | 253 | return m_cache.find( uid ); |
260 | 254 | ||
261 | T t = m_backEnd->find( uid ); | 255 | T t = m_backEnd->find( uid ); |
262 | cache( t ); | 256 | cache( t ); |
263 | 257 | ||
264 | return t; | 258 | return t; |
265 | } | 259 | } |
266 | 260 | ||
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 { |
270 | /* | 273 | /* |
271 | * better do T.isEmpty() | 274 | * better do T.isEmpty() |
272 | * after a find this way we would | 275 | * after a find this way we would |
273 | * avoid two finds in QCache... | 276 | * avoid two finds in QCache... |
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 | ||
280 | T t = m_backEnd->find( uid, ar, current, dir ); | 282 | T t = m_backEnd->find( uid, ar, current, dir ); |
281 | cache( t ); | 283 | cache( t ); |
282 | return t; | 284 | return t; |
283 | } | 285 | } |
286 | |||
287 | /** | ||
288 | * clears the backend and invalidates the backend | ||
289 | */ | ||
284 | template <class T> | 290 | template <class T> |
285 | void OPimAccessTemplate<T>::clear() { | 291 | void OPimAccessTemplate<T>::clear() { |
286 | invalidateCache(); | 292 | invalidateCache(); |
287 | m_backEnd->clear(); | 293 | m_backEnd->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> |
290 | bool OPimAccessTemplate<T>::add( const T& t ) { | 303 | bool OPimAccessTemplate<T>::add( const T& t ) { |
291 | cache( t ); | 304 | cache( t ); |
292 | return m_backEnd->add( t ); | 305 | return m_backEnd->add( t ); |
293 | } | 306 | } |
294 | 307 | ||
295 | template <class T> | 308 | template <class T> |
296 | bool OPimAccessTemplate<T>::add( const OPimRecord& rec ) { | 309 | bool OPimAccessTemplate<T>::add( const OPimRecord& rec ) { |
@@ -300,55 +313,88 @@ bool OPimAccessTemplate<T>::add( const OPimRecord& rec ) { | |||
300 | const T& t = static_cast<const T&>(rec); | 313 | const T& t = static_cast<const T&>(rec); |
301 | return add(t); | 314 | return add(t); |
302 | } else { | 315 | } else { |
303 | owarn << "Adding not possible: Objecttype mismatch" << oendl; | 316 | owarn << "Adding not possible: Objecttype mismatch" << oendl; |
304 | } | 317 | } |
305 | return false; | 318 | return false; |
306 | } | 319 | } |
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> |
309 | bool OPimAccessTemplate<T>::add( const OPimRecord* rec) { | 328 | bool OPimAccessTemplate<T>::add( const OPimRecord* rec) { |
310 | /* same type, but pointer */ | 329 | /* same type, but pointer */ |
311 | T tempInstance; | 330 | T tempInstance; |
312 | if ( rec -> rtti() == tempInstance.rtti() ) { | 331 | if ( rec -> rtti() == tempInstance.rtti() ) { |
313 | const T* t = static_cast<const T*>(rec); | 332 | const T* t = static_cast<const T*>(rec); |
314 | return add( *t ); | 333 | return add( *t ); |
315 | } else { | 334 | } else { |
316 | owarn << "Adding not possible: Objecttype mismatch" << oendl; | 335 | owarn << "Adding not possible: Objecttype mismatch" << oendl; |
317 | } | 336 | } |
318 | return false; | 337 | return false; |
319 | } | 338 | } |
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> |
322 | bool OPimAccessTemplate<T>::remove( const T& t ) { | 346 | bool OPimAccessTemplate<T>::remove( const T& t ) { |
323 | return remove( t.uid() ); | 347 | return remove( t.uid() ); |
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 ); |
328 | return m_backEnd->remove( uid ); | 358 | return m_backEnd->remove( uid ); |
329 | } | 359 | } |
330 | template <class T> | 360 | template <class T> |
331 | bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { | 361 | bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { |
332 | return remove( rec.uid() ); | 362 | return remove( rec.uid() ); |
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> |
335 | bool OPimAccessTemplate<T>::replace( const T& t ) { | 371 | bool OPimAccessTemplate<T>::replace( const T& t ) { |
336 | m_cache.replace( t ); | 372 | m_cache.replace( t ); |
337 | return m_backEnd->replace( t ); | 373 | return m_backEnd->replace( t ); |
338 | } | 374 | } |
375 | |||
376 | /** | ||
377 | * @internal | ||
378 | */ | ||
339 | template <class T> | 379 | template <class T> |
340 | void OPimAccessTemplate<T>::invalidateCache() { | 380 | void OPimAccessTemplate<T>::invalidateCache() { |
341 | m_cache.invalidate(); | 381 | m_cache.invalidate(); |
342 | } | 382 | } |
343 | template <class T> | 383 | template <class T> |
344 | typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { | 384 | typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { |
345 | return m_backEnd; | 385 | return m_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> |
348 | bool OPimAccessTemplate<T>::wasChangedExternally()const { | 394 | bool OPimAccessTemplate<T>::wasChangedExternally()const { |
349 | return false; | 395 | return false; |
350 | } | 396 | } |
351 | template <class T> | 397 | template <class T> |
352 | void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) { | 398 | void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) { |
353 | m_backEnd = end; | 399 | m_backEnd = end; |
354 | if (m_backEnd ) | 400 | if (m_backEnd ) |
@@ -363,11 +409,114 @@ template <class T> | |||
363 | void OPimAccessTemplate<T>::setSaneCacheSize( int size ) { | 409 | void OPimAccessTemplate<T>::setSaneCacheSize( int size ) { |
364 | m_cache.setSize( size ); | 410 | m_cache.setSize( size ); |
365 | } | 411 | } |
366 | template <class T> | 412 | template <class T> |
367 | void OPimAccessTemplate<T>::setReadAhead( uint count ) { | 413 | void OPimAccessTemplate<T>::setReadAhead( uint count ) { |
368 | m_backEnd->setReadAhead( count ); | 414 | m_backEnd->setReadAhead( count ); |
369 | } | 415 | } |
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 | } |
372 | 521 | ||
373 | #endif | 522 | #endif |
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 | |||
@@ -76,17 +76,16 @@ OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap | |||
76 | QString cats = mMap[ Qtopia::AddressCategory ]; | 76 | QString cats = mMap[ Qtopia::AddressCategory ]; |
77 | if ( !cats.isEmpty() ) | 77 | if ( !cats.isEmpty() ) |
78 | setCategories( idsFromString( cats ) ); | 78 | setCategories( idsFromString( cats ) ); |
79 | 79 | ||
80 | QString uidStr = find( Qtopia::AddressUid ); | 80 | QString uidStr = find( Qtopia::AddressUid ); |
81 | 81 | ||
82 | if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) ) | 82 | if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) ) |
83 | { | 83 | { |
84 | owarn << "Invalid UID found. Generate new one.." << oendl; | ||
85 | setUid( uidGen().generate() ); | 84 | setUid( uidGen().generate() ); |
86 | } | 85 | } |
87 | else | 86 | else |
88 | setUid( uidStr.toInt() ); | 87 | setUid( uidStr.toInt() ); |
89 | 88 | ||
90 | // if ( !uidStr.isEmpty() ) | 89 | // if ( !uidStr.isEmpty() ) |
91 | // setUid( uidStr.toInt() ); | 90 | // setUid( uidStr.toInt() ); |
92 | } | 91 | } |
@@ -1133,17 +1132,16 @@ class QString OPimContact::recordField( int pos ) const | |||
1133 | /*! \fn void OPimContact::setBirthday( const QDate& date ) | 1132 | /*! \fn void OPimContact::setBirthday( const QDate& date ) |
1134 | Sets the birthday for the contact to \a date. If date is null | 1133 | Sets the birthday for the contact to \a date. If date is null |
1135 | the current stored date will be removed. | 1134 | the current stored date will be removed. |
1136 | */ | 1135 | */ |
1137 | void OPimContact::setBirthday( const QDate &v ) | 1136 | void OPimContact::setBirthday( const QDate &v ) |
1138 | { | 1137 | { |
1139 | if ( v.isNull() ) | 1138 | if ( v.isNull() ) |
1140 | { | 1139 | { |
1141 | owarn << "Remove Birthday" << oendl; | ||
1142 | replace( Qtopia::Birthday, QString::null ); | 1140 | replace( Qtopia::Birthday, QString::null ); |
1143 | return ; | 1141 | return ; |
1144 | } | 1142 | } |
1145 | 1143 | ||
1146 | if ( v.isValid() ) | 1144 | if ( v.isValid() ) |
1147 | replace( Qtopia::Birthday, OPimDateConversion::dateToString( v ) ); | 1145 | replace( Qtopia::Birthday, OPimDateConversion::dateToString( v ) ); |
1148 | 1146 | ||
1149 | } | 1147 | } |
@@ -1152,48 +1150,45 @@ void OPimContact::setBirthday( const QDate &v ) | |||
1152 | /*! \fn void OPimContact::setAnniversary( const QDate &date ) | 1150 | /*! \fn void OPimContact::setAnniversary( const QDate &date ) |
1153 | Sets the anniversary of the contact to \a date. If date is | 1151 | Sets the anniversary of the contact to \a date. If date is |
1154 | null, the current stored date will be removed. | 1152 | null, the current stored date will be removed. |
1155 | */ | 1153 | */ |
1156 | void OPimContact::setAnniversary( const QDate &v ) | 1154 | void OPimContact::setAnniversary( const QDate &v ) |
1157 | { | 1155 | { |
1158 | if ( v.isNull() ) | 1156 | if ( v.isNull() ) |
1159 | { | 1157 | { |
1160 | owarn << "Remove Anniversary" << oendl; | ||
1161 | replace( Qtopia::Anniversary, QString::null ); | 1158 | replace( Qtopia::Anniversary, QString::null ); |
1162 | return ; | 1159 | return ; |
1163 | } | 1160 | } |
1164 | 1161 | ||
1165 | if ( v.isValid() ) | 1162 | if ( v.isValid() ) |
1166 | replace( Qtopia::Anniversary, OPimDateConversion::dateToString( v ) ); | 1163 | replace( Qtopia::Anniversary, OPimDateConversion::dateToString( v ) ); |
1167 | } | 1164 | } |
1168 | 1165 | ||
1169 | 1166 | ||
1170 | /*! \fn QDate OPimContact::birthday() const | 1167 | /*! \fn QDate OPimContact::birthday() const |
1171 | Returns the birthday of the contact. | 1168 | Returns the birthday of the contact. |
1172 | */ | 1169 | */ |
1173 | QDate OPimContact::birthday() const | 1170 | QDate OPimContact::birthday() const |
1174 | { | 1171 | { |
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() ) |
1178 | return OPimDateConversion::dateFromString ( str ); | 1174 | return OPimDateConversion::dateFromString ( str ); |
1179 | else | 1175 | else |
1180 | return QDate(); | 1176 | return QDate(); |
1181 | } | 1177 | } |
1182 | 1178 | ||
1183 | 1179 | ||
1184 | /*! \fn QDate OPimContact::anniversary() const | 1180 | /*! \fn QDate OPimContact::anniversary() const |
1185 | Returns the anniversary of the contact. | 1181 | Returns the anniversary of the contact. |
1186 | */ | 1182 | */ |
1187 | QDate OPimContact::anniversary() const | 1183 | QDate OPimContact::anniversary() const |
1188 | { | 1184 | { |
1189 | QDate empty; | 1185 | QDate empty; |
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() ) |
1193 | return OPimDateConversion::dateFromString ( str ); | 1188 | return OPimDateConversion::dateFromString ( str ); |
1194 | else | 1189 | else |
1195 | return empty; | 1190 | return empty; |
1196 | } | 1191 | } |
1197 | 1192 | ||
1198 | 1193 | ||
1199 | void OPimContact::insertEmail( const QString &v ) | 1194 | void OPimContact::insertEmail( const QString &v ) |
@@ -1277,15 +1272,34 @@ void OPimContact::insertEmails( const QStringList &v ) | |||
1277 | } | 1272 | } |
1278 | 1273 | ||
1279 | 1274 | ||
1280 | int OPimContact::rtti() const | 1275 | int OPimContact::rtti() const |
1281 | { | 1276 | { |
1282 | return OPimResolver::AddressBook; | 1277 | return OPimResolver::AddressBook; |
1283 | } | 1278 | } |
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 | ||
1286 | void OPimContact::setUid( int i ) | 1300 | void OPimContact::setUid( int i ) |
1287 | { | 1301 | { |
1288 | OPimRecord::setUid( i ); | 1302 | OPimRecord::setUid( i ); |
1289 | replace( Qtopia::AddressUid , QString::number( i ) ); | 1303 | replace( Qtopia::AddressUid , QString::number( i ) ); |
1290 | } | 1304 | } |
1291 | } | 1305 | } |
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 | |||
@@ -223,17 +223,21 @@ class QPC_EXPORT OPimContact : public OPimRecord | |||
223 | class QString recordField( int ) const; | 223 | class QString recordField( int ) const; |
224 | 224 | ||
225 | // Why private ? (eilers,se) | 225 | // Why private ? (eilers,se) |
226 | QString emailSeparator() const { return " "; } | 226 | QString emailSeparator() const { return " "; } |
227 | 227 | ||
228 | // the emails should be seperated by a comma | 228 | // the emails should be seperated by a comma |
229 | void setEmails( const QString &v ); | 229 | void setEmails( const QString &v ); |
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 | ||
233 | private: | 237 | private: |
234 | // The XML Backend needs some access to the private functions | 238 | // The XML Backend needs some access to the private functions |
235 | friend class OPimContactAccessBackend_XML; | 239 | friend class OPimContactAccessBackend_XML; |
236 | 240 | ||
237 | void insert( int key, const QString &value ); | 241 | void insert( int key, const QString &value ); |
238 | void replace( int key, const QString &value ); | 242 | void replace( int key, const QString &value ); |
239 | QString find( int key ) const; | 243 | QString find( int key ) const; |
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 | |||
@@ -484,16 +484,35 @@ QString OPimEvent::recordField( int /*id */ ) const | |||
484 | } | 484 | } |
485 | 485 | ||
486 | 486 | ||
487 | int OPimEvent::rtti() const | 487 | int OPimEvent::rtti() const |
488 | { | 488 | { |
489 | return OPimResolver::DateBook; | 489 | return OPimResolver::DateBook; |
490 | } | 490 | } |
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 | ||
493 | bool OPimEvent::loadFromStream( QDataStream& ) | 512 | bool OPimEvent::loadFromStream( QDataStream& ) |
494 | { | 513 | { |
495 | return true; | 514 | return true; |
496 | } | 515 | } |
497 | 516 | ||
498 | 517 | ||
499 | bool OPimEvent::saveToStream( QDataStream& ) const | 518 | bool OPimEvent::saveToStream( QDataStream& ) const |
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 | |||
@@ -113,31 +113,39 @@ class OPimEvent : public OPimRecord | |||
113 | /** | 113 | /** |
114 | * Create OPimEvent, initialized by map | 114 | * Create OPimEvent, initialized by map |
115 | * @see enum RecordFields | 115 | * @see enum RecordFields |
116 | */ | 116 | */ |
117 | OPimEvent( const QMap<int, QString> map ); | 117 | OPimEvent( const QMap<int, QString> map ); |
118 | ~OPimEvent(); | 118 | ~OPimEvent(); |
119 | OPimEvent &operator=( const OPimEvent& ); | 119 | OPimEvent &operator=( const OPimEvent& ); |
120 | 120 | ||
121 | //@{ | ||
121 | QString description() const; | 122 | QString description() const; |
122 | void setDescription( const QString& description ); | 123 | void setDescription( const QString& description ); |
123 | 124 | ||
124 | QString location() const; | 125 | QString location() const; |
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; |
131 | void setRecurrence( const OPimRecurrence& ); | 136 | void setRecurrence( const OPimRecurrence& ); |
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 | ||
137 | 145 | ||
138 | QDateTime createdDateTime() const; | 146 | QDateTime createdDateTime() const; |
139 | void setCreatedDateTime( const QDateTime& dt ); | 147 | void setCreatedDateTime( const QDateTime& dt ); |
140 | 148 | ||
141 | /** set the date to dt. dt is the QDateTime in localtime */ | 149 | /** set the date to dt. dt is the QDateTime in localtime */ |
142 | void setStartDateTime( const QDateTime& ); | 150 | void setStartDateTime( const QDateTime& ); |
143 | /** returns the datetime in the local timeZone */ | 151 | /** returns the datetime in the local timeZone */ |
@@ -156,44 +164,50 @@ class OPimEvent : public OPimRecord | |||
156 | bool isAllDay() const; | 164 | bool isAllDay() const; |
157 | void setAllDay( bool isAllDay ); | 165 | void setAllDay( bool isAllDay ); |
158 | 166 | ||
159 | /* pin this event to a timezone! FIXME */ | 167 | /* pin this event to a timezone! FIXME */ |
160 | void setTimeZone( const QString& timeZone ); | 168 | void setTimeZone( const QString& timeZone ); |
161 | QString timeZone() const; | 169 | QString timeZone() const; |
162 | 170 | ||
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... */ |
167 | QArray<int> children() const; | 174 | QArray<int> children() const; |
168 | void setChildren( const QArray<int>& ); | 175 | void setChildren( const QArray<int>& ); |
169 | void addChild( int uid ); | 176 | void addChild( int uid ); |
170 | void removeChild( int uid ); | 177 | void removeChild( int uid ); |
178 | //@} | ||
171 | 179 | ||
172 | /** return the parent OPimEvent */ | 180 | /** return the parent OPimEvent */ |
173 | int parent() const; | 181 | int parent() const; |
174 | void setParent( int uid ); | 182 | void setParent( int uid ); |
175 | 183 | ||
176 | 184 | ||
177 | /* needed reimp */ | 185 | /* needed reimp */ |
186 | //@{ Reimplementations | ||
187 | virtual bool match( const QRegExp& ) const; | ||
178 | QString toRichText() const; | 188 | QString toRichText() const; |
179 | QString toShortText() const; | 189 | QString toShortText() const; |
180 | QString type() const; | 190 | QString type() const; |
181 | 191 | ||
182 | QMap<int, QString> toMap() const; | 192 | QMap<int, QString> toMap() const; |
183 | void fromMap( const QMap<int, QString>& map ); | 193 | void fromMap( const QMap<int, QString>& map ); |
184 | QString recordField( int ) const; | 194 | QString recordField( int ) const; |
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& ); |
193 | bool operator<( const OPimEvent& ); | 207 | bool operator<( const OPimEvent& ); |
194 | bool operator<=( const OPimEvent& ); | 208 | bool operator<=( const OPimEvent& ); |
195 | bool operator>( const OPimEvent& ); | 209 | bool operator>( const OPimEvent& ); |
196 | bool operator>=(const OPimEvent& ); | 210 | bool operator>=(const OPimEvent& ); |
197 | */ | 211 | */ |
198 | 212 | ||
199 | private: | 213 | private: |
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 | |||
@@ -24,32 +24,44 @@ | |||
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef __OPIMGLOBAL_H_ | 29 | #ifndef __OPIMGLOBAL_H_ |
30 | #define __OPIMGLOBAL_H_ | 30 | #define __OPIMGLOBAL_H_ |
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{ |
34 | 46 | ||
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 | */ |
39 | class OPimGlobal{ | 51 | class OPimGlobal{ |
40 | public: | 52 | public: |
41 | enum PimType { | 53 | enum PimType { |
42 | TODOLIST, | 54 | TODOLIST, |
43 | CONTACTLIST, | 55 | CONTACTLIST, |
44 | DATEBOOK, | 56 | DATEBOOK, |
45 | _END_PimType | 57 | _END_PimType |
46 | }; | 58 | }; |
47 | 59 | ||
48 | enum DatabaseStyle { | 60 | enum DatabaseStyle { |
49 | DEFAULT, // Use default Database | 61 | DEFAULT, // Use default Database |
50 | UNKNOWN, // Unknown database style | 62 | UNKNOWN, // Unknown database style |
51 | XML, | 63 | XML, |
52 | SQL, | 64 | SQL, |
53 | VCARD, // Also used for VCAL ! | 65 | VCARD, // Also used for VCAL ! |
54 | _END_DatabaseStyle | 66 | _END_DatabaseStyle |
55 | }; | 67 | }; |
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 | |||
@@ -159,17 +159,16 @@ void OPimNotifyManager::registerNotify( const OPimNotify& ) | |||
159 | */ | 159 | */ |
160 | void OPimNotifyManager::deregister( const OPimNotify& ) | 160 | void OPimNotifyManager::deregister( const OPimNotify& ) |
161 | { | 161 | { |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | bool OPimNotifyManager::isEmpty() const | 165 | 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; |
169 | else return false; | 168 | else return false; |
170 | } | 169 | } |
171 | 170 | ||
172 | 171 | ||
173 | // Taken from otodoaccessxml.. code duplication bad. any alternative? | 172 | // Taken from otodoaccessxml.. code duplication bad. any alternative? |
174 | QString OPimNotifyManager::alarmsToString() const | 173 | QString OPimNotifyManager::alarmsToString() const |
175 | { | 174 | { |
@@ -187,17 +186,16 @@ QString OPimNotifyManager::alarmsToString() const | |||
187 | { | 186 | { |
188 | als << OPimDateConversion::dateTimeToString( ( *it ).dateTime() ) | 187 | als << OPimDateConversion::dateTimeToString( ( *it ).dateTime() ) |
189 | + ":" + QString::number( ( *it ).duration() ) | 188 | + ":" + QString::number( ( *it ).duration() ) |
190 | + ":" + QString::number( ( *it ).sound() ) | 189 | + ":" + QString::number( ( *it ).sound() ) |
191 | + ":"; | 190 | + ":"; |
192 | } | 191 | } |
193 | } | 192 | } |
194 | // now write the list | 193 | // now write the list |
195 | owarn << "als: " << als.join( "____________" ) << "" << oendl; | ||
196 | str = als.join( ";" ); | 194 | str = als.join( ";" ); |
197 | } | 195 | } |
198 | 196 | ||
199 | return str; | 197 | return str; |
200 | } | 198 | } |
201 | 199 | ||
202 | 200 | ||
203 | QString OPimNotifyManager::remindersToString() const | 201 | QString OPimNotifyManager::remindersToString() const |
@@ -221,19 +219,16 @@ QString OPimNotifyManager::remindersToString() const | |||
221 | 219 | ||
222 | 220 | ||
223 | void OPimNotifyManager::alarmsFromString( const QString& str ) | 221 | void OPimNotifyManager::alarmsFromString( const QString& str ) |
224 | { | 222 | { |
225 | QStringList als = QStringList::split( ";", str ); | 223 | QStringList als = QStringList::split( ";", str ); |
226 | for ( QStringList::Iterator it = als.begin(); it != als.end(); ++it ) | 224 | for ( QStringList::Iterator it = als.begin(); it != als.end(); ++it ) |
227 | { | 225 | { |
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 ] ), |
233 | alarm[ 1 ].toInt() ); | 228 | alarm[ 1 ].toInt() ); |
234 | add( al ); | 229 | add( al ); |
235 | } | 230 | } |
236 | } | 231 | } |
237 | 232 | ||
238 | 233 | ||
239 | void OPimNotifyManager::remindersFromString( const QString& str ) | 234 | void OPimNotifyManager::remindersFromString( const QString& str ) |
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 | |||
@@ -95,41 +95,25 @@ void OPimRecord::setCategoryNames( const QStringList& ) | |||
95 | { | 95 | { |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | void OPimRecord::addCategoryName( const QString& ) | 99 | void OPimRecord::addCategoryName( const QString& ) |
100 | { | 100 | { |
101 | Categories catDB; | 101 | Categories catDB; |
102 | catDB.load( categoryFileName() ); | 102 | catDB.load( categoryFileName() ); |
103 | |||
104 | |||
105 | } | 103 | } |
106 | 104 | ||
107 | 105 | ||
108 | bool OPimRecord::isEmpty() const | 106 | bool OPimRecord::isEmpty() const |
109 | { | 107 | { |
110 | return ( uid() == 0 ); | 108 | return ( uid() == 0 ); |
111 | } | 109 | } |
112 | 110 | ||
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 */ |
129 | void OPimRecord::setUid( int uid ) | 113 | void OPimRecord::setUid( int uid ) |
130 | { | 114 | { |
131 | if ( uid == 1 ) | 115 | if ( uid == 1 ) |
132 | uid = uidGen().generate(); | 116 | uid = uidGen().generate(); |
133 | 117 | ||
134 | Qtopia::Record::setUid( uid ); | 118 | Qtopia::Record::setUid( uid ); |
135 | }; | 119 | }; |
@@ -265,9 +249,16 @@ QMap<QString, QString> OPimRecord::toExtraMap() const | |||
265 | } | 249 | } |
266 | 250 | ||
267 | 251 | ||
268 | void OPimRecord::setExtraMap( const QMap<QString, QString>& map ) | 252 | void OPimRecord::setExtraMap( const QMap<QString, QString>& map ) |
269 | { | 253 | { |
270 | customMap = map; | 254 | customMap = map; |
271 | } | 255 | } |
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 | |||
@@ -27,16 +27,18 @@ | |||
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef OPIMRECORD_H | 30 | #ifndef OPIMRECORD_H |
31 | #define OPIMRECORD_H | 31 | #define OPIMRECORD_H |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/opimxrefmanager.h> | 34 | #include <opie2/opimxrefmanager.h> |
35 | #include <opie2/opimglobal.h> | ||
36 | |||
35 | /* | 37 | /* |
36 | * we need to get customMap which is private... | 38 | * we need to get customMap which is private... |
37 | */ | 39 | */ |
38 | #define private protected | 40 | #define private protected |
39 | #include <qpe/palmtoprecord.h> | 41 | #include <qpe/palmtoprecord.h> |
40 | #undef private | 42 | #undef private |
41 | 43 | ||
42 | /* QT */ | 44 | /* QT */ |
@@ -55,17 +57,17 @@ namespace Opie | |||
55 | class OPimRecord : public Qtopia::Record | 57 | class OPimRecord : public Qtopia::Record |
56 | { | 58 | { |
57 | public: | 59 | public: |
58 | /** | 60 | /** |
59 | * c'tor | 61 | * c'tor |
60 | * uid of 0 isEmpty | 62 | * uid of 0 isEmpty |
61 | * uid of 1 will be assigned a new one | 63 | * uid of 1 will be assigned a new one |
62 | */ | 64 | */ |
63 | OPimRecord( int uid = 0 ); | 65 | OPimRecord( UID uid = 0 ); |
64 | ~OPimRecord(); | 66 | ~OPimRecord(); |
65 | 67 | ||
66 | /** | 68 | /** |
67 | * copy c'tor | 69 | * copy c'tor |
68 | */ | 70 | */ |
69 | OPimRecord( const OPimRecord& rec ); | 71 | OPimRecord( const OPimRecord& rec ); |
70 | 72 | ||
71 | /** | 73 | /** |
@@ -133,20 +135,25 @@ class OPimRecord : public Qtopia::Record | |||
133 | // virtual fromMap( const <int, QString>& map ) = 0; // Should be added in the future (eilers) | 135 | // virtual fromMap( const <int, QString>& map ) = 0; // Should be added in the future (eilers) |
134 | 136 | ||
135 | /** | 137 | /** |
136 | * key value representation of extra items | 138 | * key value representation of extra items |
137 | */ | 139 | */ |
138 | QMap<QString, QString> toExtraMap() const; | 140 | QMap<QString, QString> toExtraMap() const; |
139 | void setExtraMap( const QMap<QString, QString>& ); | 141 | void setExtraMap( const QMap<QString, QString>& ); |
140 | 142 | ||
143 | //@{ | ||
141 | /** | 144 | /** |
142 | * the name for a recordField | 145 | * the name for a recordField |
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 | ||
146 | /** | 153 | /** |
147 | * returns a reference of the | 154 | * returns a reference of the |
148 | * Cross Reference Manager | 155 | * Cross Reference Manager |
149 | * Partner 'One' is THIS PIM RECORD! | 156 | * Partner 'One' is THIS PIM RECORD! |
150 | * 'Two' is the Partner where we link to | 157 | * 'Two' is the Partner where we link to |
151 | */ | 158 | */ |
152 | OPimXRefManager& xrefmanager(); | 159 | OPimXRefManager& xrefmanager(); |
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 | |||
@@ -36,16 +36,17 @@ | |||
36 | //#include <opie2/odebug.h> | 36 | //#include <opie2/odebug.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | #include <qarray.h> | 39 | #include <qarray.h> |
40 | 40 | ||
41 | namespace Opie | 41 | namespace Opie |
42 | { | 42 | { |
43 | 43 | ||
44 | template<class T> class OPimAccessTemplate; | ||
44 | class OPimRecordListIteratorPrivate; | 45 | class OPimRecordListIteratorPrivate; |
45 | /** | 46 | /** |
46 | * Our List Iterator | 47 | * Our List Iterator |
47 | * it behaves like STL or Qt | 48 | * it behaves like STL or Qt |
48 | * | 49 | * |
49 | * for(it = list.begin(); it != list.end(); ++it ) | 50 | * for(it = list.begin(); it != list.end(); ++it ) |
50 | * doSomeCoolStuff( (*it) ); | 51 | * doSomeCoolStuff( (*it) ); |
51 | */ | 52 | */ |
@@ -115,27 +116,27 @@ class OPimRecordListIterator | |||
115 | class OPimRecordListPrivate; | 116 | class OPimRecordListPrivate; |
116 | /** | 117 | /** |
117 | * The recordlist used as a return type | 118 | * The recordlist used as a return type |
118 | * from OPimAccessTemplate | 119 | * from OPimAccessTemplate |
119 | */ | 120 | */ |
120 | template <class T = OPimRecord > | 121 | template <class T = OPimRecord > |
121 | class OPimRecordList | 122 | class OPimRecordList |
122 | { | 123 | { |
124 | template<class> friend class OPimAccessTemplate; | ||
123 | public: | 125 | public: |
124 | typedef OTemplateBase<T> Base; | 126 | typedef OTemplateBase<T> Base; |
125 | typedef OPimRecordListIterator<T> Iterator; | 127 | typedef OPimRecordListIterator<T> Iterator; |
126 | 128 | ||
127 | /** | 129 | /** |
128 | * c'tor | 130 | * c'tor |
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(); |
135 | 136 | ||
136 | /** | 137 | /** |
137 | * the first iterator | 138 | * the first iterator |
138 | */ | 139 | */ |
139 | Iterator begin(); | 140 | Iterator begin(); |
140 | 141 | ||
141 | /** | 142 | /** |
@@ -155,16 +156,19 @@ class OPimRecordList | |||
155 | * Remove the contact with given uid | 156 | * Remove the contact with given uid |
156 | */ | 157 | */ |
157 | bool remove( int uid ); | 158 | bool remove( int uid ); |
158 | 159 | ||
159 | /* | 160 | /* |
160 | ConstIterator begin()const; | 161 | ConstIterator begin()const; |
161 | ConstIterator end()const; | 162 | ConstIterator end()const; |
162 | */ | 163 | */ |
164 | protected: | ||
165 | UIDArray uids()const; | ||
166 | |||
163 | private: | 167 | private: |
164 | QArray<int> m_ids; | 168 | QArray<int> m_ids; |
165 | const Base* m_acc; | 169 | const Base* m_acc; |
166 | OPimRecordListPrivate *d; | 170 | OPimRecordListPrivate *d; |
167 | }; | 171 | }; |
168 | 172 | ||
169 | 173 | ||
170 | /* ok now implement it */ | 174 | /* ok now implement it */ |
@@ -185,17 +189,16 @@ OPimRecordListIterator<T>::~OPimRecordListIterator() | |||
185 | { | 189 | { |
186 | /* nothing to delete */ | 190 | /* nothing to delete */ |
187 | } | 191 | } |
188 | 192 | ||
189 | 193 | ||
190 | template <class T> | 194 | template <class T> |
191 | OPimRecordListIterator<T>::OPimRecordListIterator( const OPimRecordListIterator<T>& it ) | 195 | OPimRecordListIterator<T>::OPimRecordListIterator( const OPimRecordListIterator<T>& it ) |
192 | { | 196 | { |
193 | //owarn << "OPimRecordListIterator copy c'tor" << oendl; | ||
194 | m_uids = it.m_uids; | 197 | m_uids = it.m_uids; |
195 | m_current = it.m_current; | 198 | m_current = it.m_current; |
196 | m_temp = it.m_temp; | 199 | m_temp = it.m_temp; |
197 | m_end = it.m_end; | 200 | m_end = it.m_end; |
198 | m_record = it.m_record; | 201 | m_record = it.m_record; |
199 | m_direction = it.m_direction; | 202 | m_direction = it.m_direction; |
200 | } | 203 | } |
201 | 204 | ||
@@ -211,17 +214,16 @@ OPimRecordListIterator<T> &OPimRecordListIterator<T>::operator=( const OPimRecor | |||
211 | 214 | ||
212 | return *this; | 215 | return *this; |
213 | } | 216 | } |
214 | 217 | ||
215 | 218 | ||
216 | template <class T> | 219 | template <class T> |
217 | T OPimRecordListIterator<T>::operator*() | 220 | T OPimRecordListIterator<T>::operator*() |
218 | { | 221 | { |
219 | //owarn << "operator* " << m_current << " " << m_uids[m_current] << oendl; | ||
220 | if ( !m_end ) | 222 | if ( !m_end ) |
221 | m_record = m_temp->find( m_uids[ m_current ], m_uids, m_current, | 223 | m_record = m_temp->find( m_uids[ m_current ], m_uids, m_current, |
222 | m_direction ? Base::Forward : | 224 | m_direction ? Base::Forward : |
223 | Base::Reverse ); | 225 | Base::Reverse ); |
224 | else | 226 | else |
225 | m_record = T(); | 227 | m_record = T(); |
226 | 228 | ||
227 | return m_record; | 229 | return m_record; |
@@ -394,10 +396,15 @@ bool OPimRecordList<T>::remove( int uid ) | |||
394 | 396 | ||
395 | copy.resize( counter ); | 397 | copy.resize( counter ); |
396 | m_ids = copy; | 398 | m_ids = copy; |
397 | 399 | ||
398 | 400 | ||
399 | return ret_val; | 401 | return ret_val; |
400 | } | 402 | } |
401 | 403 | ||
404 | template<class T> | ||
405 | UIDArray OPimRecordList<T>::uids()const { | ||
406 | return m_ids; | ||
407 | } | ||
408 | |||
402 | } | 409 | } |
403 | #endif | 410 | #endif |
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 | |||
@@ -40,18 +40,16 @@ namespace Opie { | |||
40 | /** | 40 | /** |
41 | * OPimResolver is a MetaClass to access | 41 | * OPimResolver is a MetaClass to access |
42 | * available backends read only. | 42 | * available backends read only. |
43 | * It will be used to resolve uids + app names | 43 | * It will be used to resolve uids + app names |
44 | * to full informations | 44 | * to full informations |
45 | * to traverse through a list of alarms, reminders | 45 | * to traverse through a list of alarms, reminders |
46 | * to get access to built in PIM functionality | 46 | * to get access to built in PIM functionality |
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 | */ |
51 | class OPimResolver { | 49 | class OPimResolver { |
52 | 50 | ||
53 | public: | 51 | public: |
54 | enum BuiltIn { TodoList = 0, | 52 | enum BuiltIn { TodoList = 0, |
55 | DateBook, | 53 | DateBook, |
56 | AddressBook | 54 | AddressBook |
57 | }; | 55 | }; |
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 | |||
@@ -33,22 +33,16 @@ | |||
33 | #include <qstring.h> | 33 | #include <qstring.h> |
34 | 34 | ||
35 | namespace Opie { | 35 | namespace Opie { |
36 | /** | 36 | /** |
37 | * The State of a Task | 37 | * The State of a Task |
38 | * This class encapsules the state of a todo | 38 | * This class encapsules the state of a todo |
39 | * and it's shared too | 39 | * and it's shared too |
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 { |
48 | 42 | ||
49 | public: | 43 | public: |
50 | enum State { | 44 | enum State { |
51 | Started = 0, | 45 | Started = 0, |
52 | Postponed, | 46 | Postponed, |
53 | Finished, | 47 | Finished, |
54 | NotStarted, | 48 | NotStarted, |
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 | |||
@@ -27,104 +27,197 @@ | |||
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef OTEMPLATEBASE_H | 29 | #ifndef OTEMPLATEBASE_H |
30 | #define OTEMPLATEBASE_H | 30 | #define OTEMPLATEBASE_H |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/opimrecord.h> | 33 | #include <opie2/opimrecord.h> |
34 | #include <opie2/opimcache.h> | 34 | #include <opie2/opimcache.h> |
35 | #include <opie2/opimoccurrence.h> | ||
36 | #include <opie2/opimbackendoccurrence.h> | ||
35 | 37 | ||
36 | /* QT */ | 38 | /* QT */ |
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 | /** |
51 | * return the rtti | 60 | * return the rtti |
52 | */ | 61 | */ |
53 | virtual int rtti() const = 0; | 62 | virtual int rtti() const = 0; |
54 | virtual OPimRecord* record()const = 0; | 63 | virtual OPimRecord* record()const = 0; |
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; |
61 | virtual bool load() = 0; | 77 | virtual bool load() = 0; |
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 | /** |
73 | * internal template base | 150 | * internal template base |
74 | * Attention: T needs to implement the copy c'tor!!! | 151 | * Attention: T needs to implement the copy c'tor!!! |
75 | */ | 152 | */ |
76 | class OTemplateBasePrivate; | 153 | class OTemplateBasePrivate; |
77 | template <class T = OPimRecord> | 154 | template <class T = OPimRecord> |
78 | class OTemplateBase : public OPimBase { | 155 | 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; |
88 | 179 | ||
89 | /** | 180 | /** |
90 | * read ahead find | 181 | * read ahead find |
91 | */ | 182 | */ |
92 | virtual T find( int uid, const QArray<int>& items, | 183 | virtual T find( int uid, const QArray<int>& items, |
93 | uint current, CacheDirection dir = Forward )const = 0; | 184 | uint current, CacheDirection dir = Forward )const = 0; |
185 | //@} | ||
94 | 186 | ||
187 | //@{ | ||
95 | /** | 188 | /** |
96 | * Put element into Cache | 189 | * Put element into Cache |
97 | */ | 190 | */ |
98 | virtual void cache( const T& )const = 0; | 191 | virtual void cache( const T& )const = 0; |
99 | virtual void setSaneCacheSize( int ) = 0; | 192 | virtual void setSaneCacheSize( int ) = 0; |
100 | 193 | ||
101 | OPimRecord* record()const; | 194 | OPimRecord* record()const; |
102 | OPimRecord* record(int uid )const; | 195 | OPimRecord* record(int uid )const; |
103 | static T* rec(); | 196 | static T* rec(); |
197 | //@} | ||
104 | 198 | ||
105 | |||
106 | private: | 199 | private: |
107 | OTemplateBasePrivate *d; | 200 | OTemplateBasePrivate *d; |
108 | }; | 201 | }; |
109 | 202 | ||
110 | 203 | ||
111 | template <class T> | 204 | template <class T> |
112 | OPimRecord* OTemplateBase<T>::record()const { | 205 | OPimRecord* OTemplateBase<T>::record()const { |
113 | T* t = new T; | 206 | T* t = new T; |
114 | return t; | 207 | return t; |
115 | } | 208 | } |
116 | template <class T> | 209 | template <class T> |
117 | OPimRecord* OTemplateBase<T>::record(int uid )const { | 210 | OPimRecord* OTemplateBase<T>::record(int uid )const { |
118 | T t2 = find(uid ); | 211 | T t2 = find(uid ); |
119 | T* t1 = new T(t2); | 212 | T* t1 = new T(t2); |
120 | 213 | ||
121 | return t1; | 214 | return t1; |
122 | }; | 215 | } |
216 | |||
123 | template <class T> | 217 | template <class T> |
124 | T* OTemplateBase<T>::rec() { | 218 | T* OTemplateBase<T>::rec() { |
125 | return new T; | 219 | return new T; |
126 | } | 220 | } |
127 | |||
128 | } | 221 | } |
129 | 222 | ||
130 | #endif | 223 | #endif |
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 | |||
@@ -35,70 +35,84 @@ | |||
35 | /* STD */ | 35 | /* STD */ |
36 | #include <stdio.h> | 36 | #include <stdio.h> |
37 | #include <stdlib.h> | 37 | #include <stdlib.h> |
38 | #include <sys/types.h> | 38 | #include <sys/types.h> |
39 | 39 | ||
40 | namespace Opie | 40 | namespace Opie |
41 | { | 41 | { |
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 | { |
45 | tm * broken = ::gmtime( &t ); | 66 | tm * broken = ::gmtime( &t ); |
46 | QDateTime ret; | 67 | QDateTime ret; |
47 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) ); | 68 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) ); |
48 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); | 69 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); |
49 | return ret; | 70 | return ret; |
50 | } | 71 | } |
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 |
63 | #warning "Need a replacement for MacOSX!!" | 81 | #warning "Need a replacement for MacOSX!!" |
64 | 82 | ||
65 | tm* broken = ::localtime( &t ); | 83 | tm* broken = ::localtime( &t ); |
66 | #endif | 84 | #endif |
67 | 85 | ||
68 | QDateTime ret; | 86 | QDateTime ret; |
69 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) ); | 87 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) ); |
70 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); | 88 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); |
71 | 89 | ||
72 | return ret; | 90 | return ret; |
73 | } | 91 | } |
74 | 92 | ||
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 | { |
78 | QDate d = utc.date(); | 96 | QDate d = utc.date(); |
79 | QTime t = utc.time(); | 97 | QTime t = utc.time(); |
80 | 98 | ||
81 | tm broken; | 99 | tm broken; |
82 | broken.tm_year = d.year() - 1900; | 100 | broken.tm_year = d.year() - 1900; |
83 | broken.tm_mon = d.month() - 1; | 101 | broken.tm_mon = d.month() - 1; |
84 | broken.tm_mday = d.day(); | 102 | broken.tm_mday = d.day(); |
85 | broken.tm_hour = t.hour(); | 103 | broken.tm_hour = t.hour(); |
86 | broken.tm_min = t.minute(); | 104 | broken.tm_min = t.minute(); |
87 | broken.tm_sec = t.second(); | 105 | broken.tm_sec = t.second(); |
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 |
98 | #warning "Need a replacement for MacOSX!!" | 112 | #warning "Need a replacement for MacOSX!!" |
99 | 113 | ||
100 | time_t ti = ::mktime( &broken ); | 114 | time_t ti = ::mktime( &broken ); |
101 | #endif | 115 | #endif |
102 | 116 | ||
103 | return ti; | 117 | return ti; |
104 | } | 118 | } |
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 | |||
@@ -59,16 +59,17 @@ struct OPimTodo::OPimTodoData : public QShared | |||
59 | maintainer = 0; | 59 | maintainer = 0; |
60 | notifiers = 0; | 60 | notifiers = 0; |
61 | }; | 61 | }; |
62 | ~OPimTodoData() | 62 | ~OPimTodoData() |
63 | { | 63 | { |
64 | delete recur; | 64 | delete recur; |
65 | delete maintainer; | 65 | delete maintainer; |
66 | delete notifiers; | 66 | delete notifiers; |
67 | delete state; | ||
67 | } | 68 | } |
68 | 69 | ||
69 | QDate date; | 70 | QDate date; |
70 | bool isCompleted: 1; | 71 | bool isCompleted: 1; |
71 | bool hasDate: 1; | 72 | bool hasDate: 1; |
72 | int priority; | 73 | int priority; |
73 | QString desc; | 74 | QString desc; |
74 | QString sum; | 75 | QString sum; |
@@ -82,42 +83,38 @@ struct OPimTodo::OPimTodoData : public QShared | |||
82 | OPimNotifyManager *notifiers; | 83 | OPimNotifyManager *notifiers; |
83 | }; | 84 | }; |
84 | 85 | ||
85 | 86 | ||
86 | OPimTodo::OPimTodo( const OPimTodo &event ) | 87 | OPimTodo::OPimTodo( const OPimTodo &event ) |
87 | : OPimRecord( event ), data( event.data ) | 88 | : OPimRecord( event ), data( event.data ) |
88 | { | 89 | { |
89 | data->ref(); | 90 | data->ref(); |
90 | // owarn << "ref up" << oendl; | ||
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | OPimTodo::~OPimTodo() | 94 | OPimTodo::~OPimTodo() |
95 | { | 95 | { |
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; |
102 | data = 0l; | 100 | data = 0l; |
103 | } | 101 | } |
104 | } | 102 | } |
105 | 103 | ||
106 | 104 | ||
107 | OPimTodo::OPimTodo( bool completed, int priority, | 105 | OPimTodo::OPimTodo( bool completed, int priority, |
108 | const QArray<int> &category, | 106 | const QArray<int> &category, |
109 | const QString& summary, | 107 | const QString& summary, |
110 | const QString &description, | 108 | const QString &description, |
111 | ushort progress, | 109 | ushort progress, |
112 | bool hasDate, QDate date, int uid ) | 110 | bool hasDate, QDate date, int uid ) |
113 | : OPimRecord( uid ) | 111 | : OPimRecord( uid ) |
114 | { | 112 | { |
115 | // owarn << "OPimTodoData " + summary << oendl; | ||
116 | setCategories( category ); | 113 | setCategories( category ); |
117 | 114 | ||
118 | data = new OPimTodoData; | 115 | data = new OPimTodoData; |
119 | 116 | ||
120 | data->date = date; | 117 | data->date = date; |
121 | data->isCompleted = completed; | 118 | data->isCompleted = completed; |
122 | data->hasDate = hasDate; | 119 | data->hasDate = hasDate; |
123 | data->priority = priority; | 120 | data->priority = priority; |
@@ -130,17 +127,16 @@ OPimTodo::OPimTodo( bool completed, int priority, | |||
130 | OPimTodo::OPimTodo( bool completed, int priority, | 127 | OPimTodo::OPimTodo( bool completed, int priority, |
131 | const QStringList &category, | 128 | const QStringList &category, |
132 | const QString& summary, | 129 | const QString& summary, |
133 | const QString &description, | 130 | const QString &description, |
134 | ushort progress, | 131 | ushort progress, |
135 | bool hasDate, QDate date, int uid ) | 132 | bool hasDate, QDate date, int uid ) |
136 | : OPimRecord( uid ) | 133 | : OPimRecord( uid ) |
137 | { | 134 | { |
138 | // owarn << "OPimTodoData" + summary << oendl; | ||
139 | setCategories( idsFromString( category.join( ";" ) ) ); | 135 | setCategories( idsFromString( category.join( ";" ) ) ); |
140 | 136 | ||
141 | data = new OPimTodoData; | 137 | data = new OPimTodoData; |
142 | 138 | ||
143 | data->date = date; | 139 | data->date = date; |
144 | data->isCompleted = completed; | 140 | data->isCompleted = completed; |
145 | data->hasDate = hasDate; | 141 | data->hasDate = hasDate; |
146 | data->priority = priority; | 142 | data->priority = priority; |
@@ -182,23 +178,43 @@ bool OPimTodo::isCompleted() const | |||
182 | } | 178 | } |
183 | 179 | ||
184 | 180 | ||
185 | bool OPimTodo::hasDueDate() const | 181 | bool OPimTodo::hasDueDate() const |
186 | { | 182 | { |
187 | return data->hasDate; | 183 | return data->hasDate; |
188 | } | 184 | } |
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 |
192 | { | 199 | { |
193 | return data->start.isValid(); | 200 | return data->start.isValid(); |
194 | } | 201 | } |
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 |
198 | { | 214 | { |
199 | return data->completed.isValid(); | 215 | return data->completed.isValid(); |
200 | } | 216 | } |
201 | 217 | ||
202 | 218 | ||
203 | int OPimTodo::priority() const | 219 | int OPimTodo::priority() const |
204 | { | 220 | { |
@@ -303,17 +319,16 @@ void OPimTodo::setHasDueDate( bool hasDate ) | |||
303 | { | 319 | { |
304 | changeOrModify(); | 320 | changeOrModify(); |
305 | data->hasDate = hasDate; | 321 | data->hasDate = hasDate; |
306 | } | 322 | } |
307 | 323 | ||
308 | 324 | ||
309 | void OPimTodo::setDescription( const QString &desc ) | 325 | void OPimTodo::setDescription( const QString &desc ) |
310 | { | 326 | { |
311 | // owarn << "desc " + desc << oendl; | ||
312 | changeOrModify(); | 327 | changeOrModify(); |
313 | data->desc = Qtopia::simplifyMultiLineSpace( desc ); | 328 | data->desc = Qtopia::simplifyMultiLineSpace( desc ); |
314 | } | 329 | } |
315 | 330 | ||
316 | 331 | ||
317 | void OPimTodo::setSummary( const QString& sum ) | 332 | void OPimTodo::setSummary( const QString& sum ) |
318 | { | 333 | { |
319 | changeOrModify(); | 334 | changeOrModify(); |
@@ -375,17 +390,17 @@ void OPimTodo::setMaintainer( const OPimMaintainer& pim ) | |||
375 | 390 | ||
376 | if ( data->maintainer ) | 391 | if ( data->maintainer ) |
377 | ( *data->maintainer ) = pim; | 392 | ( *data->maintainer ) = pim; |
378 | else | 393 | else |
379 | data->maintainer = new OPimMaintainer( pim ); | 394 | data->maintainer = new OPimMaintainer( pim ); |
380 | } | 395 | } |
381 | 396 | ||
382 | 397 | ||
383 | bool OPimTodo::isOverdue( ) | 398 | bool OPimTodo::isOverdue( )const |
384 | { | 399 | { |
385 | if ( data->hasDate && !data->isCompleted ) | 400 | if ( data->hasDate && !data->isCompleted ) |
386 | return QDate::currentDate() > data->date; | 401 | return QDate::currentDate() > data->date; |
387 | return false; | 402 | return false; |
388 | } | 403 | } |
389 | 404 | ||
390 | 405 | ||
391 | void OPimTodo::setProgress( ushort progress ) | 406 | void OPimTodo::setProgress( ushort progress ) |
@@ -588,32 +603,29 @@ bool OPimTodo::operator==( const OPimTodo &toDoEvent ) const | |||
588 | 603 | ||
589 | return OPimRecord::operator==( toDoEvent ); | 604 | return OPimRecord::operator==( toDoEvent ); |
590 | } | 605 | } |
591 | 606 | ||
592 | 607 | ||
593 | void OPimTodo::deref() | 608 | void OPimTodo::deref() |
594 | { | 609 | { |
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; |
601 | data = 0; | 614 | data = 0; |
602 | } | 615 | } |
603 | } | 616 | } |
604 | 617 | ||
605 | 618 | ||
606 | OPimTodo &OPimTodo::operator=( const OPimTodo &item ) | 619 | OPimTodo &OPimTodo::operator=( const OPimTodo &item ) |
607 | { | 620 | { |
608 | if ( this == &item ) return * this; | 621 | if ( this == &item ) return * this; |
609 | 622 | ||
610 | OPimRecord::operator=( item ); | 623 | OPimRecord::operator=( item ); |
611 | //owarn << "operator= ref " << oendl; | ||
612 | item.data->ref(); | 624 | item.data->ref(); |
613 | deref(); | 625 | deref(); |
614 | data = item.data; | 626 | data = item.data; |
615 | 627 | ||
616 | return *this; | 628 | return *this; |
617 | } | 629 | } |
618 | 630 | ||
619 | 631 | ||
@@ -646,17 +658,16 @@ QMap<int, QString> OPimTodo::toMap() const | |||
646 | * change or modify looks at the ref count and either | 658 | * change or modify looks at the ref count and either |
647 | * creates a new QShared Object or it can modify it | 659 | * creates a new QShared Object or it can modify it |
648 | * right in place | 660 | * right in place |
649 | */ | 661 | */ |
650 | void OPimTodo::changeOrModify() | 662 | void OPimTodo::changeOrModify() |
651 | { | 663 | { |
652 | if ( data->count != 1 ) | 664 | if ( data->count != 1 ) |
653 | { | 665 | { |
654 | owarn << "changeOrModify" << oendl; | ||
655 | data->deref(); | 666 | data->deref(); |
656 | OPimTodoData* d2 = new OPimTodoData(); | 667 | OPimTodoData* d2 = new OPimTodoData(); |
657 | copy( data, d2 ); | 668 | copy( data, d2 ); |
658 | data = d2; | 669 | data = d2; |
659 | } | 670 | } |
660 | } | 671 | } |
661 | 672 | ||
662 | 673 | ||
@@ -694,20 +705,106 @@ void OPimTodo::copy( OPimTodoData* src, OPimTodoData* dest ) | |||
694 | 705 | ||
695 | 706 | ||
696 | QString OPimTodo::type() const | 707 | QString OPimTodo::type() const |
697 | { | 708 | { |
698 | return QString::fromLatin1( "OPimTodo" ); | 709 | return QString::fromLatin1( "OPimTodo" ); |
699 | } | 710 | } |
700 | 711 | ||
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 | } |
706 | 786 | ||
707 | 787 | ||
708 | int OPimTodo::rtti() const | 788 | int OPimTodo::rtti() const |
709 | { | 789 | { |
710 | return OPimResolver::TodoList; | 790 | return OPimResolver::TodoList; |
711 | } | 791 | } |
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 | |||
@@ -65,21 +65,22 @@ class OPimTodo : public OPimRecord | |||
65 | DateDay, | 65 | DateDay, |
66 | DateMonth, | 66 | DateMonth, |
67 | DateYear, | 67 | DateYear, |
68 | Progress, | 68 | Progress, |
69 | CrossReference, | 69 | CrossReference, |
70 | State, | 70 | State, |
71 | Recurrence, | 71 | Recurrence, |
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 | }; |
79 | public: | 80 | public: |
80 | // priorities from Very low to very high | 81 | // priorities from Very low to very high |
81 | enum TaskPriority { VeryHigh = 1, High, Normal, Low, VeryLow }; | 82 | enum TaskPriority { VeryHigh = 1, High, Normal, Low, VeryLow }; |
82 | 83 | ||
83 | /* Constructs a new ToDoEvent | 84 | /* Constructs a new ToDoEvent |
84 | @param completed Is the TodoEvent completed | 85 | @param completed Is the TodoEvent completed |
85 | @param priority What is the priority of this ToDoEvent | 86 | @param priority What is the priority of this ToDoEvent |
@@ -277,30 +278,34 @@ class OPimTodo : public OPimRecord | |||
277 | */ | 278 | */ |
278 | void setState( const OPimState& state ); | 279 | void setState( const OPimState& state ); |
279 | 280 | ||
280 | /** | 281 | /** |
281 | * set the Maintainer Mode | 282 | * set the Maintainer Mode |
282 | */ | 283 | */ |
283 | void setMaintainer( const OPimMaintainer& ); | 284 | void setMaintainer( const OPimMaintainer& ); |
284 | 285 | ||
285 | bool isOverdue(); | 286 | bool isOverdue()const; |
286 | 287 | ||
287 | 288 | ||
288 | virtual bool match( const QRegExp &r ) const; | 289 | virtual bool match( const QRegExp &r ) const; |
289 | 290 | ||
290 | bool operator<( const OPimTodo &toDoEvent ) const; | 291 | bool operator<( const OPimTodo &toDoEvent ) const; |
291 | bool operator<=( const OPimTodo &toDoEvent ) const; | 292 | bool operator<=( const OPimTodo &toDoEvent ) const; |
292 | bool operator!=( const OPimTodo &toDoEvent ) const; | 293 | bool operator!=( const OPimTodo &toDoEvent ) const; |
293 | bool operator>( const OPimTodo &toDoEvent ) const; | 294 | bool operator>( const OPimTodo &toDoEvent ) const; |
294 | bool operator>=( const OPimTodo &toDoEvent ) const; | 295 | bool operator>=( const OPimTodo &toDoEvent ) const; |
295 | bool operator==( const OPimTodo &toDoEvent ) const; | 296 | bool operator==( const OPimTodo &toDoEvent ) const; |
296 | OPimTodo &operator=( const OPimTodo &toDoEvent ); | 297 | OPimTodo &operator=( const OPimTodo &toDoEvent ); |
297 | 298 | ||
299 | //@{ | ||
298 | int rtti() const; | 300 | int rtti() const; |
301 | static OPimTodo* safeCast( const OPimRecord* ); | ||
302 | //@} | ||
303 | |||
299 | 304 | ||
300 | private: | 305 | private: |
301 | class OPimTodoPrivate; | 306 | class OPimTodoPrivate; |
302 | struct OPimTodoData; | 307 | struct OPimTodoData; |
303 | 308 | ||
304 | void deref(); | 309 | void deref(); |
305 | inline void changeOrModify(); | 310 | inline void changeOrModify(); |
306 | void copy( OPimTodoData* src, OPimTodoData* dest ); | 311 | void copy( OPimTodoData* src, OPimTodoData* dest ); |
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 | |||
@@ -45,57 +45,44 @@ OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access ) | |||
45 | 45 | ||
46 | // Zecke: Du musst hier noch fr das XML-Backend einen Appnamen bergeben ! | 46 | // Zecke: Du musst hier noch fr das XML-Backend einen Appnamen bergeben ! |
47 | if (end == 0l ) | 47 | if (end == 0l ) |
48 | m_todoBackEnd = OBackendFactory<OPimTodoAccessBackend>::defaultBackend (OPimGlobal::TODOLIST, QString::null); | 48 | m_todoBackEnd = OBackendFactory<OPimTodoAccessBackend>::defaultBackend (OPimGlobal::TODOLIST, QString::null); |
49 | 49 | ||
50 | setBackEnd( m_todoBackEnd ); | 50 | setBackEnd( m_todoBackEnd ); |
51 | } | 51 | } |
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 ) { |
56 | QValueList<OPimTodo>::ConstIterator it; | 56 | QValueList<OPimTodo>::ConstIterator it; |
57 | for ( it = list.begin(); it != list.end(); ++it ) { | 57 | for ( it = list.begin(); it != list.end(); ++it ) { |
58 | replace( (*it) ); | 58 | replace( (*it) ); |
59 | } | 59 | } |
60 | } | 60 | } |
61 | OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start, | 61 | 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 ); |
65 | 65 | ||
66 | List lis( ints, this ); | 66 | List lis( ints, this ); |
67 | return lis; | 67 | return lis; |
68 | } | 68 | } |
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(), |
72 | includeNoDates ); | 72 | includeNoDates ); |
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 ); |
76 | return lis; | 76 | return lis; |
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() { |
86 | m_todoBackEnd->removeAllCompleted(); | 80 | m_todoBackEnd->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 | ||
96 | int OPimTodoAccess::rtti() const | 83 | int OPimTodoAccess::rtti() const |
97 | { | 84 | { |
98 | return OPimResolver::TodoList; | 85 | return OPimResolver::TodoList; |
99 | } | 86 | } |
100 | 87 | ||
101 | } | 88 | } |
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 | |||
@@ -41,23 +41,21 @@ namespace Opie { | |||
41 | /** | 41 | /** |
42 | * OPimTodoAccess | 42 | * OPimTodoAccess |
43 | * the class to get access to | 43 | * the class to get access to |
44 | * the todolist | 44 | * the todolist |
45 | */ | 45 | */ |
46 | class OPimTodoAccess : public QObject, public OPimAccessTemplate<OPimTodo> { | 46 | class OPimTodoAccess : public QObject, public OPimAccessTemplate<OPimTodo> { |
47 | Q_OBJECT | 47 | Q_OBJECT |
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 | /** |
57 | * if you use 0l | 55 | * if you use 0l |
58 | * the default resource will be | 56 | * the default resource will be |
59 | * picked up | 57 | * picked up |
60 | */ | 58 | */ |
61 | OPimTodoAccess( OPimTodoAccessBackend* = 0l, enum Access acc = Random ); | 59 | OPimTodoAccess( OPimTodoAccessBackend* = 0l, enum Access acc = Random ); |
62 | ~OPimTodoAccess(); | 60 | ~OPimTodoAccess(); |
63 | 61 | ||
@@ -65,65 +63,43 @@ public: | |||
65 | /* our functions here */ | 63 | /* our functions here */ |
66 | /** | 64 | /** |
67 | * include todos from start to end | 65 | * include todos from start to end |
68 | * includeNoDates whether or not to include | 66 | * includeNoDates whether or not to include |
69 | * events with no dates | 67 | * events with no dates |
70 | */ | 68 | */ |
71 | List effectiveToDos( const QDate& start, | 69 | List effectiveToDos( const QDate& start, |
72 | const QDate& end, | 70 | const QDate& end, |
73 | bool includeNoDates = true ); | 71 | bool includeNoDates = true )const; |
74 | 72 | ||
75 | /** | 73 | /** |
76 | * start | 74 | * start |
77 | * end date taken from the currentDate() | 75 | * end date taken from the currentDate() |
78 | */ | 76 | */ |
79 | List effectiveToDos( const QDate& start, | 77 | List effectiveToDos( const QDate& start, |
80 | bool includeNoDates = true ); | 78 | bool includeNoDates = true )const; |
81 | 79 | ||
82 | 80 | ||
83 | /** | 81 | /** |
84 | * return overdue OPimTodos | 82 | * return overdue OPimTodos |
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 | ||
93 | /** | 86 | /** |
94 | * merge a list of OPimTodos into | 87 | * merge a list of OPimTodos into |
95 | * the resource | 88 | * the resource |
96 | */ | 89 | */ |
97 | void mergeWith( const QValueList<OPimTodo>& ); | 90 | void mergeWith( const QValueList<OPimTodo>& ); |
98 | 91 | ||
99 | /** | 92 | /** |
100 | * delete all already completed items | 93 | * delete all already completed items |
101 | */ | 94 | */ |
102 | void removeAllCompleted(); | 95 | void removeAllCompleted(); |
103 | 96 | ||
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 |
123 | */ | 99 | */ |
124 | int rtti() const; | 100 | int rtti() const; |
125 | signals: | 101 | signals: |
126 | /** | 102 | /** |
127 | * if the OPimTodoAccess was changed | 103 | * if the OPimTodoAccess was changed |
128 | */ | 104 | */ |
129 | void changed( const OPimTodoAccess* ); | 105 | void changed( const OPimTodoAccess* ); |