author | zecke <zecke> | 2004-11-18 21:45:49 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-11-18 21:45:49 (UTC) |
commit | 7484344ff5be1f7c54e51715776d0e3cadeb1ed0 (patch) (unidiff) | |
tree | 96f427f7a1fb1c8ca0a6efbd72b51e916cb1651d | |
parent | 3302eb30390e6053637929316670da3e8fbe279e (diff) | |
download | opie-7484344ff5be1f7c54e51715776d0e3cadeb1ed0.zip opie-7484344ff5be1f7c54e51715776d0e3cadeb1ed0.tar.gz opie-7484344ff5be1f7c54e51715776d0e3cadeb1ed0.tar.bz2 |
Big PIM API Update Core Part (1/2 of what should be implemented):
OPimRecords:
-Add a so called safeCast using the rtti value
OPimTodo:
-Fix memleak with OPimState
OPimOccurrence:
-New class. Every 'Access' can give occurrences
for a period of time
Move Documentation
26 files changed, 1244 insertions, 328 deletions
diff --git a/libopie2/opiepim/core/core.pro b/libopie2/opiepim/core/core.pro index b1b5655..f943318 100644 --- a/libopie2/opiepim/core/core.pro +++ b/libopie2/opiepim/core/core.pro | |||
@@ -1,48 +1,51 @@ | |||
1 | HEADERS += \ | 1 | HEADERS += \ |
2 | core/ocontactaccess.h \ | 2 | core/ocontactaccess.h \ |
3 | core/odatebookaccess.h \ | 3 | core/odatebookaccess.h \ |
4 | core/opimaccessfactory.h \ | 4 | core/opimaccessfactory.h \ |
5 | core/opimaccesstemplate.h \ | 5 | core/opimaccesstemplate.h \ |
6 | core/opimcache.h \ | 6 | core/opimcache.h \ |
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 \ |
23 | core/opimxref.h \ | 24 | core/opimxref.h \ |
24 | core/opimxrefmanager.h \ | 25 | core/opimxrefmanager.h \ |
25 | core/opimxrefpartner.h \ | 26 | core/opimxrefpartner.h \ |
26 | core/otodoaccess.h | 27 | core/otodoaccess.h |
27 | 28 | ||
28 | SOURCES += \ | 29 | SOURCES += \ |
29 | core/ocontactaccess.cpp \ | 30 | core/ocontactaccess.cpp \ |
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 | |||
@@ -25,140 +25,139 @@ | |||
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 | /* | 29 | /* |
30 | * ===================================================================== | 30 | * ===================================================================== |
31 | * ToDo: XML-Backend: Automatic reload if something was changed... | 31 | * ToDo: XML-Backend: Automatic reload if something was changed... |
32 | * | 32 | * |
33 | * | 33 | * |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include <opie2/ocontactaccess.h> | 36 | #include <opie2/ocontactaccess.h> |
37 | #include <opie2/obackendfactory.h> | 37 | #include <opie2/obackendfactory.h> |
38 | 38 | ||
39 | /* OPIE */ | 39 | /* OPIE */ |
40 | #include <opie2/ocontactaccessbackend_xml.h> | 40 | #include <opie2/ocontactaccessbackend_xml.h> |
41 | #include <opie2/opimresolver.h> | 41 | #include <opie2/opimresolver.h> |
42 | #include <opie2/opimglobal.h> | 42 | #include <opie2/opimglobal.h> |
43 | #include <opie2/odebug.h> | 43 | #include <opie2/odebug.h> |
44 | 44 | ||
45 | //#include <qpe/qcopenvelope_qws.h> | 45 | //#include <qpe/qcopenvelope_qws.h> |
46 | #include <qpe/global.h> | 46 | #include <qpe/global.h> |
47 | 47 | ||
48 | /* QT */ | 48 | /* QT */ |
49 | #include <qasciidict.h> | 49 | #include <qasciidict.h> |
50 | #include <qdatetime.h> | 50 | #include <qdatetime.h> |
51 | #include <qfile.h> | 51 | #include <qfile.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qlist.h> | 53 | #include <qlist.h> |
54 | #include <qcopchannel_qws.h> | 54 | #include <qcopchannel_qws.h> |
55 | 55 | ||
56 | /* STD */ | 56 | /* STD */ |
57 | #include <errno.h> | 57 | #include <errno.h> |
58 | #include <fcntl.h> | 58 | #include <fcntl.h> |
59 | #include <unistd.h> | 59 | #include <unistd.h> |
60 | #include <stdlib.h> | 60 | #include <stdlib.h> |
61 | 61 | ||
62 | 62 | ||
63 | namespace Opie { | 63 | namespace Opie { |
64 | 64 | ||
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 */ |
82 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); | 81 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); |
83 | connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)), | 82 | connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)), |
84 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); | 83 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); |
85 | if ( autosync ){ | 84 | if ( autosync ){ |
86 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); | 85 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); |
87 | connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)), | 86 | connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)), |
88 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); | 87 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); |
89 | } | 88 | } |
90 | 89 | ||
91 | 90 | ||
92 | } | 91 | } |
93 | OPimContactAccess::~OPimContactAccess () | 92 | OPimContactAccess::~OPimContactAccess () |
94 | { | 93 | { |
95 | /* The user may forget to save the changed database, therefore try to | 94 | /* The user may forget to save the changed database, therefore try to |
96 | * do it for him.. | 95 | * do it for him.. |
97 | */ | 96 | */ |
98 | save(); | 97 | save(); |
99 | // delete m_backEnd; is done by template.. | 98 | // delete m_backEnd; is done by template.. |
100 | } | 99 | } |
101 | 100 | ||
102 | 101 | ||
103 | bool OPimContactAccess::save () | 102 | bool OPimContactAccess::save () |
104 | { | 103 | { |
105 | /* If the database was changed externally, we could not save the | 104 | /* If the database was changed externally, we could not save the |
106 | * Data. This will remove added items which is unacceptable ! | 105 | * Data. This will remove added items which is unacceptable ! |
107 | * Therefore: Reload database and merge the data... | 106 | * Therefore: Reload database and merge the data... |
108 | */ | 107 | */ |
109 | if ( OPimAccessTemplate<OPimContact>::wasChangedExternally() ) | 108 | if ( OPimAccessTemplate<OPimContact>::wasChangedExternally() ) |
110 | reload(); | 109 | reload(); |
111 | 110 | ||
112 | bool status = OPimAccessTemplate<OPimContact>::save(); | 111 | bool status = OPimAccessTemplate<OPimContact>::save(); |
113 | if ( !status ) return false; | 112 | if ( !status ) return false; |
114 | 113 | ||
115 | /* Now tell everyone that new data is available. | 114 | /* Now tell everyone that new data is available. |
116 | */ | 115 | */ |
117 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); | 116 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); |
118 | 117 | ||
119 | return true; | 118 | return true; |
120 | } | 119 | } |
121 | 120 | ||
122 | const uint OPimContactAccess::querySettings() | 121 | 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; |
162 | } | 161 | } |
163 | 162 | ||
164 | } | 163 | } |
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 | |||
@@ -15,149 +15,142 @@ | |||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
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 | /* | 29 | /* |
30 | * ===================================================================== | 30 | * ===================================================================== |
31 | * ToDo: Define enum for query settings | 31 | * ToDo: Define enum for query settings |
32 | * ===================================================================== | 32 | * ===================================================================== |
33 | */ | 33 | */ |
34 | #ifndef _OCONTACTACCESS_H | 34 | #ifndef _OCONTACTACCESS_H |
35 | #define _OCONTACTACCESS_H | 35 | #define _OCONTACTACCESS_H |
36 | 36 | ||
37 | #include <qobject.h> | 37 | #include <qobject.h> |
38 | 38 | ||
39 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
40 | 40 | ||
41 | #include <qvaluelist.h> | 41 | #include <qvaluelist.h> |
42 | #include <qfileinfo.h> | 42 | #include <qfileinfo.h> |
43 | 43 | ||
44 | #include <opie2/opimcontact.h> | 44 | #include <opie2/opimcontact.h> |
45 | #include <opie2/ocontactaccessbackend.h> | 45 | #include <opie2/ocontactaccessbackend.h> |
46 | #include <opie2/opimaccesstemplate.h> | 46 | #include <opie2/opimaccesstemplate.h> |
47 | 47 | ||
48 | namespace Opie { | 48 | namespace Opie { |
49 | /** | 49 | /** |
50 | * Class to access the contacts database. | 50 | * Class to access the contacts database. |
51 | * This is just a frontend for the real database handling which is | 51 | * This is just a frontend for the real database handling which is |
52 | * done by the backend. | 52 | * done by the backend. |
53 | * This class is used to access the Contacts on a system. This class as any OPIE PIM | 53 | * This class is used to access the Contacts on a system. This class as any OPIE PIM |
54 | * class is backend independent. | 54 | * class is backend independent. |
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. |
114 | * @return <i>true</i> if the given settings are correct and possible. | 109 | * @return <i>true</i> if the given settings are correct and possible. |
115 | */ | 110 | */ |
116 | bool hasQuerySettings ( int querySettings ) const; | 111 | bool hasQuerySettings ( int querySettings ) const; |
117 | 112 | ||
118 | /** | 113 | /** |
119 | * if the resource was changed externally. | 114 | * if the resource was changed externally. |
120 | * You should use the signal instead of polling possible changes ! | 115 | * You should use the signal instead of polling possible changes ! |
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; |
157 | Private *d; | 150 | Private *d; |
158 | 151 | ||
159 | }; | 152 | }; |
160 | 153 | ||
161 | } | 154 | } |
162 | 155 | ||
163 | #endif | 156 | #endif |
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 | |||
@@ -1,118 +1,95 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | 3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
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 | #include <opie2/obackendfactory.h> | 29 | #include <opie2/obackendfactory.h> |
30 | #include <opie2/odatebookaccess.h> | 30 | #include <opie2/odatebookaccess.h> |
31 | #include <opie2/opimresolver.h> | 31 | #include <opie2/opimresolver.h> |
32 | #include <opie2/opimglobal.h> | 32 | #include <opie2/opimglobal.h> |
33 | 33 | ||
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 ); |
71 | return lis; | 62 | return lis; |
72 | } | 63 | } |
73 | 64 | ||
74 | /** | 65 | /** |
75 | * @return all non repeating events | 66 | * @return all non repeating events |
76 | */ | 67 | */ |
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 | |||
@@ -4,78 +4,73 @@ | |||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
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 OPIE_DATE_BOOK_ACCESS_H | 29 | #ifndef OPIE_DATE_BOOK_ACCESS_H |
30 | #define OPIE_DATE_BOOK_ACCESS_H | 30 | #define OPIE_DATE_BOOK_ACCESS_H |
31 | 31 | ||
32 | #include "odatebookaccessbackend.h" | 32 | #include "odatebookaccessbackend.h" |
33 | #include "opimaccesstemplate.h" | 33 | #include "opimaccesstemplate.h" |
34 | 34 | ||
35 | #include <opie2/opimevent.h> | 35 | #include <opie2/opimevent.h> |
36 | 36 | ||
37 | namespace Opie { | 37 | namespace Opie { |
38 | /** | 38 | /** |
39 | * This is the object orientated datebook database. It'll use OBackendFactory | 39 | * This is the object orientated datebook database. It'll use OBackendFactory |
40 | * to query for a backend. | 40 | * to query for a backend. |
41 | * All access to the datebook should be done via this class. | 41 | * All access to the datebook should be done via this class. |
42 | * Make sure to load and save the datebook this is not part of | 42 | * Make sure to load and save the datebook this is not part of |
43 | * destructing and creating the object | 43 | * destructing and creating the object |
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; |
76 | Private* d; | 71 | Private* d; |
77 | }; | 72 | }; |
78 | 73 | ||
79 | } | 74 | } |
80 | 75 | ||
81 | #endif | 76 | #endif |
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,373 +1,522 @@ | |||
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, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H | 30 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H |
31 | #define OPIE_PIM_ACCESS_TEMPLATE_H | 31 | #define OPIE_PIM_ACCESS_TEMPLATE_H |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/opimrecord.h> | 34 | #include <opie2/opimrecord.h> |
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 | /** |
193 | * returns the backend | 145 | * returns the backend |
194 | */ | 146 | */ |
195 | BackEnd* backEnd(); | 147 | BackEnd* backEnd(); |
196 | BackEnd* m_backEnd; | 148 | BackEnd* m_backEnd; |
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 ) { |
297 | /* same type */ | 310 | /* same type */ |
298 | T tempInstance; | 311 | T tempInstance; |
299 | if ( rec.rtti() == tempInstance.rtti() ) { | 312 | if ( rec.rtti() == tempInstance.rtti() ) { |
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 ) |
355 | m_backEnd->setFrontend( this ); | 401 | m_backEnd->setFrontend( this ); |
356 | } | 402 | } |
357 | template <class T> | 403 | template <class T> |
358 | void OPimAccessTemplate<T>::cache( const T& t ) const{ | 404 | void OPimAccessTemplate<T>::cache( const T& t ) const{ |
359 | /* hacky we need to work around the const*/ | 405 | /* hacky we need to work around the const*/ |
360 | ((OPimAccessTemplate<T>*)this)->m_cache.add( t ); | 406 | ((OPimAccessTemplate<T>*)this)->m_cache.add( t ); |
361 | } | 407 | } |
362 | template <class T> | 408 | 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 | |||
@@ -36,97 +36,96 @@ | |||
36 | #include <opie2/opimdateconversion.h> | 36 | #include <opie2/opimdateconversion.h> |
37 | #include <opie2/odebug.h> | 37 | #include <opie2/odebug.h> |
38 | 38 | ||
39 | #include <qpe/stringutil.h> | 39 | #include <qpe/stringutil.h> |
40 | #include <qpe/timestring.h> | 40 | #include <qpe/timestring.h> |
41 | #include <qpe/config.h> | 41 | #include <qpe/config.h> |
42 | 42 | ||
43 | /* QT */ | 43 | /* QT */ |
44 | #include <qstylesheet.h> | 44 | #include <qstylesheet.h> |
45 | 45 | ||
46 | /* STD */ | 46 | /* STD */ |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | 48 | ||
49 | /*! | 49 | /*! |
50 | \class Contact contact.h | 50 | \class Contact contact.h |
51 | \brief The Contact class holds the data of an address book entry. | 51 | \brief The Contact class holds the data of an address book entry. |
52 | 52 | ||
53 | This data includes information the name of the person, contact | 53 | This data includes information the name of the person, contact |
54 | information, and business information such as deparment and job title. | 54 | information, and business information such as deparment and job title. |
55 | 55 | ||
56 | \ingroup qtopiaemb | 56 | \ingroup qtopiaemb |
57 | \ingroup qtopiadesktop | 57 | \ingroup qtopiadesktop |
58 | */ | 58 | */ |
59 | 59 | ||
60 | 60 | ||
61 | namespace Opie | 61 | namespace Opie |
62 | { | 62 | { |
63 | /*! | 63 | /*! |
64 | Creates a new, empty contact. | 64 | Creates a new, empty contact. |
65 | */ | 65 | */ |
66 | OPimContact::OPimContact():OPimRecord(), mMap(), d( 0 ) | 66 | OPimContact::OPimContact():OPimRecord(), mMap(), d( 0 ) |
67 | {} | 67 | {} |
68 | 68 | ||
69 | /*! | 69 | /*! |
70 | \internal | 70 | \internal |
71 | Creates a new contact. The properties of the contact are | 71 | Creates a new contact. The properties of the contact are |
72 | set from \a fromMap. | 72 | set from \a fromMap. |
73 | */ | 73 | */ |
74 | OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 ) | 74 | OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 ) |
75 | { | 75 | { |
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 | } |
93 | 92 | ||
94 | /*! | 93 | /*! |
95 | Destroys a contact. | 94 | Destroys a contact. |
96 | */ | 95 | */ |
97 | OPimContact::~OPimContact() | 96 | OPimContact::~OPimContact() |
98 | {} | 97 | {} |
99 | 98 | ||
100 | /*! \fn void OPimContact::setTitle( const QString &str ) | 99 | /*! \fn void OPimContact::setTitle( const QString &str ) |
101 | Sets the title of the contact to \a str. | 100 | Sets the title of the contact to \a str. |
102 | */ | 101 | */ |
103 | 102 | ||
104 | /*! \fn void OPimContact::setFirstName( const QString &str ) | 103 | /*! \fn void OPimContact::setFirstName( const QString &str ) |
105 | Sets the first name of the contact to \a str. | 104 | Sets the first name of the contact to \a str. |
106 | */ | 105 | */ |
107 | 106 | ||
108 | /*! \fn void OPimContact::setMiddleName( const QString &str ) | 107 | /*! \fn void OPimContact::setMiddleName( const QString &str ) |
109 | Sets the middle name of the contact to \a str. | 108 | Sets the middle name of the contact to \a str. |
110 | */ | 109 | */ |
111 | 110 | ||
112 | /*! \fn void OPimContact::setLastName( const QString &str ) | 111 | /*! \fn void OPimContact::setLastName( const QString &str ) |
113 | Sets the last name of the contact to \a str. | 112 | Sets the last name of the contact to \a str. |
114 | */ | 113 | */ |
115 | 114 | ||
116 | /*! \fn void OPimContact::setSuffix( const QString &str ) | 115 | /*! \fn void OPimContact::setSuffix( const QString &str ) |
117 | Sets the suffix of the contact to \a str. | 116 | Sets the suffix of the contact to \a str. |
118 | */ | 117 | */ |
119 | 118 | ||
120 | /*! \fn void OPimContact::setFileAs( const QString &str ) | 119 | /*! \fn void OPimContact::setFileAs( const QString &str ) |
121 | Sets the contact to filed as \a str. | 120 | Sets the contact to filed as \a str. |
122 | */ | 121 | */ |
123 | 122 | ||
124 | /*! \fn void OPimContact::setDefaultEmail( const QString &str ) | 123 | /*! \fn void OPimContact::setDefaultEmail( const QString &str ) |
125 | Sets the default email of the contact to \a str. | 124 | Sets the default email of the contact to \a str. |
126 | */ | 125 | */ |
127 | 126 | ||
128 | /*! \fn void OPimContact::setHomeStreet( const QString &str ) | 127 | /*! \fn void OPimContact::setHomeStreet( const QString &str ) |
129 | Sets the home street address of the contact to \a str. | 128 | Sets the home street address of the contact to \a str. |
130 | */ | 129 | */ |
131 | 130 | ||
132 | /*! \fn void OPimContact::setHomeCity( const QString &str ) | 131 | /*! \fn void OPimContact::setHomeCity( const QString &str ) |
@@ -1093,199 +1092,214 @@ bool OPimContact::match( const QRegExp &r ) const | |||
1093 | { | 1092 | { |
1094 | setLastHitField( -1 ); | 1093 | setLastHitField( -1 ); |
1095 | bool match; | 1094 | bool match; |
1096 | match = false; | 1095 | match = false; |
1097 | QMap<int, QString>::ConstIterator it; | 1096 | QMap<int, QString>::ConstIterator it; |
1098 | for ( it = mMap.begin(); it != mMap.end(); ++it ) | 1097 | for ( it = mMap.begin(); it != mMap.end(); ++it ) |
1099 | { | 1098 | { |
1100 | if ( ( *it ).find( r ) > -1 ) | 1099 | if ( ( *it ).find( r ) > -1 ) |
1101 | { | 1100 | { |
1102 | setLastHitField( it.key() ); | 1101 | setLastHitField( it.key() ); |
1103 | match = true; | 1102 | match = true; |
1104 | break; | 1103 | break; |
1105 | } | 1104 | } |
1106 | } | 1105 | } |
1107 | return match; | 1106 | return match; |
1108 | } | 1107 | } |
1109 | 1108 | ||
1110 | 1109 | ||
1111 | QString OPimContact::toShortText() const | 1110 | QString OPimContact::toShortText() const |
1112 | { | 1111 | { |
1113 | return ( fullName() ); | 1112 | return ( fullName() ); |
1114 | } | 1113 | } |
1115 | 1114 | ||
1116 | 1115 | ||
1117 | QString OPimContact::type() const | 1116 | QString OPimContact::type() const |
1118 | { | 1117 | { |
1119 | return QString::fromLatin1( "OPimContact" ); | 1118 | return QString::fromLatin1( "OPimContact" ); |
1120 | } | 1119 | } |
1121 | 1120 | ||
1122 | 1121 | ||
1123 | class QString OPimContact::recordField( int pos ) const | 1122 | class QString OPimContact::recordField( int pos ) const |
1124 | { | 1123 | { |
1125 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 1124 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
1126 | return SLFIELDS[ pos ]; | 1125 | return SLFIELDS[ pos ]; |
1127 | } | 1126 | } |
1128 | 1127 | ||
1129 | // In future releases, we should store birthday and anniversary | 1128 | // In future releases, we should store birthday and anniversary |
1130 | // internally as QDate instead of QString ! | 1129 | // internally as QDate instead of QString ! |
1131 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 1130 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
1132 | 1131 | ||
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 | } |
1150 | 1148 | ||
1151 | 1149 | ||
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 ) |
1200 | { | 1195 | { |
1201 | //odebug << "insertEmail " << v << "" << oendl; | 1196 | //odebug << "insertEmail " << v << "" << oendl; |
1202 | QString e = v.simplifyWhiteSpace(); | 1197 | QString e = v.simplifyWhiteSpace(); |
1203 | QString def = defaultEmail(); | 1198 | QString def = defaultEmail(); |
1204 | 1199 | ||
1205 | // if no default, set it as the default email and don't insert | 1200 | // if no default, set it as the default email and don't insert |
1206 | if ( def.isEmpty() ) | 1201 | if ( def.isEmpty() ) |
1207 | { | 1202 | { |
1208 | setDefaultEmail( e ); // will insert into the list for us | 1203 | setDefaultEmail( e ); // will insert into the list for us |
1209 | return ; | 1204 | return ; |
1210 | } | 1205 | } |
1211 | 1206 | ||
1212 | // otherwise, insert assuming doesn't already exist | 1207 | // otherwise, insert assuming doesn't already exist |
1213 | QString emailsStr = find( Qtopia::Emails ); | 1208 | QString emailsStr = find( Qtopia::Emails ); |
1214 | if ( emailsStr.contains( e ) ) | 1209 | if ( emailsStr.contains( e ) ) |
1215 | return ; | 1210 | return ; |
1216 | if ( !emailsStr.isEmpty() ) | 1211 | if ( !emailsStr.isEmpty() ) |
1217 | emailsStr += emailSeparator(); | 1212 | emailsStr += emailSeparator(); |
1218 | emailsStr += e; | 1213 | emailsStr += e; |
1219 | replace( Qtopia::Emails, emailsStr ); | 1214 | replace( Qtopia::Emails, emailsStr ); |
1220 | } | 1215 | } |
1221 | 1216 | ||
1222 | 1217 | ||
1223 | void OPimContact::removeEmail( const QString &v ) | 1218 | void OPimContact::removeEmail( const QString &v ) |
1224 | { | 1219 | { |
1225 | QString e = v.simplifyWhiteSpace(); | 1220 | QString e = v.simplifyWhiteSpace(); |
1226 | QString def = defaultEmail(); | 1221 | QString def = defaultEmail(); |
1227 | QString emailsStr = find( Qtopia::Emails ); | 1222 | QString emailsStr = find( Qtopia::Emails ); |
1228 | QStringList emails = emailList(); | 1223 | QStringList emails = emailList(); |
1229 | 1224 | ||
1230 | // otherwise, must first contain it | 1225 | // otherwise, must first contain it |
1231 | if ( !emailsStr.contains( e ) ) | 1226 | if ( !emailsStr.contains( e ) ) |
1232 | return ; | 1227 | return ; |
1233 | 1228 | ||
1234 | // remove it | 1229 | // remove it |
1235 | //odebug << " removing email from list " << e << "" << oendl; | 1230 | //odebug << " removing email from list " << e << "" << oendl; |
1236 | emails.remove( e ); | 1231 | emails.remove( e ); |
1237 | // reset the string | 1232 | // reset the string |
1238 | emailsStr = emails.join( emailSeparator() ); // Sharp's brain dead separator | 1233 | emailsStr = emails.join( emailSeparator() ); // Sharp's brain dead separator |
1239 | replace( Qtopia::Emails, emailsStr ); | 1234 | replace( Qtopia::Emails, emailsStr ); |
1240 | 1235 | ||
1241 | // if default, then replace the default email with the first one | 1236 | // if default, then replace the default email with the first one |
1242 | if ( def == e ) | 1237 | if ( def == e ) |
1243 | { | 1238 | { |
1244 | //odebug << "removeEmail is default; setting new default" << oendl; | 1239 | //odebug << "removeEmail is default; setting new default" << oendl; |
1245 | if ( !emails.count() ) | 1240 | if ( !emails.count() ) |
1246 | clearEmails(); | 1241 | clearEmails(); |
1247 | else // setDefaultEmail will remove e from the list | 1242 | else // setDefaultEmail will remove e from the list |
1248 | setDefaultEmail( emails.first() ); | 1243 | setDefaultEmail( emails.first() ); |
1249 | } | 1244 | } |
1250 | } | 1245 | } |
1251 | 1246 | ||
1252 | 1247 | ||
1253 | void OPimContact::clearEmails() | 1248 | void OPimContact::clearEmails() |
1254 | { | 1249 | { |
1255 | mMap.remove( Qtopia::DefaultEmail ); | 1250 | mMap.remove( Qtopia::DefaultEmail ); |
1256 | mMap.remove( Qtopia::Emails ); | 1251 | mMap.remove( Qtopia::Emails ); |
1257 | } | 1252 | } |
1258 | 1253 | ||
1259 | 1254 | ||
1260 | void OPimContact::setDefaultEmail( const QString &v ) | 1255 | void OPimContact::setDefaultEmail( const QString &v ) |
1261 | { | 1256 | { |
1262 | QString e = v.simplifyWhiteSpace(); | 1257 | QString e = v.simplifyWhiteSpace(); |
1263 | 1258 | ||
1264 | //odebug << "OPimContact::setDefaultEmail " << e << "" << oendl; | 1259 | //odebug << "OPimContact::setDefaultEmail " << e << "" << oendl; |
1265 | replace( Qtopia::DefaultEmail, e ); | 1260 | replace( Qtopia::DefaultEmail, e ); |
1266 | 1261 | ||
1267 | if ( !e.isEmpty() ) | 1262 | if ( !e.isEmpty() ) |
1268 | insertEmail( e ); | 1263 | insertEmail( e ); |
1269 | 1264 | ||
1270 | } | 1265 | } |
1271 | 1266 | ||
1272 | 1267 | ||
1273 | void OPimContact::insertEmails( const QStringList &v ) | 1268 | void OPimContact::insertEmails( const QStringList &v ) |
1274 | { | 1269 | { |
1275 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) | 1270 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) |
1276 | insertEmail( *it ); | 1271 | insertEmail( *it ); |
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 | |||
@@ -183,74 +183,78 @@ class QPC_EXPORT OPimContact : public OPimRecord | |||
183 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 183 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
184 | QString department() const { return find( Qtopia::Department ); } | 184 | QString department() const { return find( Qtopia::Department ); } |
185 | QString office() const { return find( Qtopia::Office ); } | 185 | QString office() const { return find( Qtopia::Office ); } |
186 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 186 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
187 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 187 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
188 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 188 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
189 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 189 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
190 | QString profession() const { return find( Qtopia::Profession ); } | 190 | QString profession() const { return find( Qtopia::Profession ); } |
191 | QString assistant() const { return find( Qtopia::Assistant ); } | 191 | QString assistant() const { return find( Qtopia::Assistant ); } |
192 | QString manager() const { return find( Qtopia::Manager ); } | 192 | QString manager() const { return find( Qtopia::Manager ); } |
193 | /** Multi line string containing all non-empty address info in the form | 193 | /** Multi line string containing all non-empty address info in the form |
194 | * Street | 194 | * Street |
195 | * City, State Zip | 195 | * City, State Zip |
196 | * Country | 196 | * Country |
197 | */ | 197 | */ |
198 | QString displayBusinessAddress() const; | 198 | QString displayBusinessAddress() const; |
199 | 199 | ||
200 | //personal | 200 | //personal |
201 | QString spouse() const { return find( Qtopia::Spouse ); } | 201 | QString spouse() const { return find( Qtopia::Spouse ); } |
202 | QString gender() const { return find( Qtopia::Gender ); } | 202 | QString gender() const { return find( Qtopia::Gender ); } |
203 | QDate birthday() const; | 203 | QDate birthday() const; |
204 | QDate anniversary() const; | 204 | QDate anniversary() const; |
205 | QString nickname() const { return find( Qtopia::Nickname ); } | 205 | QString nickname() const { return find( Qtopia::Nickname ); } |
206 | QString children() const { return find( Qtopia::Children ); } | 206 | QString children() const { return find( Qtopia::Children ); } |
207 | QStringList childrenList() const; | 207 | QStringList childrenList() const; |
208 | 208 | ||
209 | // other | 209 | // other |
210 | QString notes() const { return find( Qtopia::Notes ); } | 210 | QString notes() const { return find( Qtopia::Notes ); } |
211 | QString groups() const { return find( Qtopia::Groups ); } | 211 | QString groups() const { return find( Qtopia::Groups ); } |
212 | QStringList groupList() const; | 212 | QStringList groupList() const; |
213 | 213 | ||
214 | QString toRichText() const; | 214 | QString toRichText() const; |
215 | QMap<int, QString> toMap() const; | 215 | QMap<int, QString> toMap() const; |
216 | QString field( int key ) const { return find( key ); } | 216 | QString field( int key ) const { return find( key ); } |
217 | 217 | ||
218 | 218 | ||
219 | void setUid( int i ); | 219 | void setUid( int i ); |
220 | 220 | ||
221 | QString toShortText() const; | 221 | QString toShortText() const; |
222 | QString type() const; | 222 | QString type() const; |
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; |
240 | static QStringList fields(); | 244 | static QStringList fields(); |
241 | 245 | ||
242 | void save( QString &buf ) const; | 246 | void save( QString &buf ) const; |
243 | 247 | ||
244 | QString displayAddress( const QString &street, | 248 | QString displayAddress( const QString &street, |
245 | const QString &city, | 249 | const QString &city, |
246 | const QString &state, | 250 | const QString &state, |
247 | const QString &zip, | 251 | const QString &zip, |
248 | const QString &country ) const; | 252 | const QString &country ) const; |
249 | 253 | ||
250 | QMap<int, QString> mMap; | 254 | QMap<int, QString> mMap; |
251 | OPimContactPrivate *d; | 255 | OPimContactPrivate *d; |
252 | }; | 256 | }; |
253 | 257 | ||
254 | } | 258 | } |
255 | 259 | ||
256 | #endif | 260 | #endif |
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 | |||
@@ -444,96 +444,115 @@ QString OPimEvent::toRichText() const | |||
444 | 444 | ||
445 | //notes | 445 | //notes |
446 | if ( !note().isEmpty() ) | 446 | if ( !note().isEmpty() ) |
447 | { | 447 | { |
448 | text += "<b>" + QObject::tr( "Note:" ) + "</b><br>"; | 448 | text += "<b>" + QObject::tr( "Note:" ) + "</b><br>"; |
449 | text += note(); | 449 | text += note(); |
450 | // text += Qtopia::escapeString(note() ). | 450 | // text += Qtopia::escapeString(note() ). |
451 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 451 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
452 | } | 452 | } |
453 | return text; | 453 | return text; |
454 | } | 454 | } |
455 | 455 | ||
456 | 456 | ||
457 | QString OPimEvent::toShortText() const | 457 | QString OPimEvent::toShortText() const |
458 | { | 458 | { |
459 | QString text; | 459 | QString text; |
460 | text += QString::number( startDateTime().date().day() ); | 460 | text += QString::number( startDateTime().date().day() ); |
461 | text += "."; | 461 | text += "."; |
462 | text += QString::number( startDateTime().date().month() ); | 462 | text += QString::number( startDateTime().date().month() ); |
463 | text += "."; | 463 | text += "."; |
464 | text += QString::number( startDateTime().date().year() ); | 464 | text += QString::number( startDateTime().date().year() ); |
465 | text += " "; | 465 | text += " "; |
466 | text += QString::number( startDateTime().time().hour() ); | 466 | text += QString::number( startDateTime().time().hour() ); |
467 | text += ":"; | 467 | text += ":"; |
468 | text += QString::number( startDateTime().time().minute() ); | 468 | text += QString::number( startDateTime().time().minute() ); |
469 | text += " - "; | 469 | text += " - "; |
470 | text += description(); | 470 | text += description(); |
471 | return text; | 471 | return text; |
472 | } | 472 | } |
473 | 473 | ||
474 | 474 | ||
475 | QString OPimEvent::type() const | 475 | QString OPimEvent::type() const |
476 | { | 476 | { |
477 | return QString::fromLatin1( "OPimEvent" ); | 477 | return QString::fromLatin1( "OPimEvent" ); |
478 | } | 478 | } |
479 | 479 | ||
480 | 480 | ||
481 | QString OPimEvent::recordField( int /*id */ ) const | 481 | QString OPimEvent::recordField( int /*id */ ) const |
482 | { | 482 | { |
483 | return QString::null; | 483 | return QString::null; |
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 |
500 | { | 519 | { |
501 | return true; | 520 | return true; |
502 | } | 521 | } |
503 | 522 | ||
504 | 523 | ||
505 | void OPimEvent::changeOrModify() | 524 | void OPimEvent::changeOrModify() |
506 | { | 525 | { |
507 | if ( data->count != 1 ) | 526 | if ( data->count != 1 ) |
508 | { | 527 | { |
509 | data->deref(); | 528 | data->deref(); |
510 | Data* d2 = new Data; | 529 | Data* d2 = new Data; |
511 | d2->description = data->description; | 530 | d2->description = data->description; |
512 | d2->location = data->location; | 531 | d2->location = data->location; |
513 | 532 | ||
514 | if ( data->manager ) | 533 | if ( data->manager ) |
515 | d2->manager = new OPimNotifyManager( *data->manager ); | 534 | d2->manager = new OPimNotifyManager( *data->manager ); |
516 | 535 | ||
517 | if ( data->recur ) | 536 | if ( data->recur ) |
518 | d2->recur = new OPimRecurrence( *data->recur ); | 537 | d2->recur = new OPimRecurrence( *data->recur ); |
519 | 538 | ||
520 | d2->note = data->note; | 539 | d2->note = data->note; |
521 | d2->created = data->created; | 540 | d2->created = data->created; |
522 | d2->start = data->start; | 541 | d2->start = data->start; |
523 | d2->end = data->end; | 542 | d2->end = data->end; |
524 | d2->isAllDay = data->isAllDay; | 543 | d2->isAllDay = data->isAllDay; |
525 | d2->timezone = data->timezone; | 544 | d2->timezone = data->timezone; |
526 | d2->parent = data->parent; | 545 | d2->parent = data->parent; |
527 | 546 | ||
528 | if ( data->child ) | 547 | if ( data->child ) |
529 | { | 548 | { |
530 | d2->child = new QArray<int>( *data->child ); | 549 | d2->child = new QArray<int>( *data->child ); |
531 | d2->child->detach(); | 550 | d2->child->detach(); |
532 | } | 551 | } |
533 | 552 | ||
534 | data = d2; | 553 | data = d2; |
535 | } | 554 | } |
536 | } | 555 | } |
537 | 556 | ||
538 | 557 | ||
539 | void OPimEvent::deref() | 558 | void OPimEvent::deref() |
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 | |||
@@ -73,167 +73,181 @@ class OPimEvent : public OPimRecord | |||
73 | public: | 73 | public: |
74 | typedef QValueList<OPimEvent> ValueList; | 74 | typedef QValueList<OPimEvent> ValueList; |
75 | /** | 75 | /** |
76 | * RecordFields contain possible attributes | 76 | * RecordFields contain possible attributes |
77 | * used in the Results of toMap().. | 77 | * used in the Results of toMap().. |
78 | */ | 78 | */ |
79 | enum RecordFields { | 79 | enum RecordFields { |
80 | FUid = Qtopia::UID_ID, | 80 | FUid = Qtopia::UID_ID, |
81 | FCategories = Qtopia::CATEGORY_ID, | 81 | FCategories = Qtopia::CATEGORY_ID, |
82 | FDescription /* = 0 Why this ? (eilers) */, | 82 | FDescription /* = 0 Why this ? (eilers) */, |
83 | FLocation, | 83 | FLocation, |
84 | FType, | 84 | FType, |
85 | FAlarm, | 85 | FAlarm, |
86 | FSound, | 86 | FSound, |
87 | FRType, | 87 | FRType, |
88 | FRWeekdays, | 88 | FRWeekdays, |
89 | FRPosition, | 89 | FRPosition, |
90 | FRFreq, | 90 | FRFreq, |
91 | FRHasEndDate, | 91 | FRHasEndDate, |
92 | FREndDate, | 92 | FREndDate, |
93 | FRCreated, | 93 | FRCreated, |
94 | FRExceptions, | 94 | FRExceptions, |
95 | FStart, | 95 | FStart, |
96 | FEnd, | 96 | FEnd, |
97 | FNote, | 97 | FNote, |
98 | FTimeZone, | 98 | FTimeZone, |
99 | FRecParent, | 99 | FRecParent, |
100 | FRecChildren, | 100 | FRecChildren, |
101 | }; | 101 | }; |
102 | 102 | ||
103 | /** | 103 | /** |
104 | * Start with an Empty OPimEvent. UID == 0 means that it is empty | 104 | * Start with an Empty OPimEvent. UID == 0 means that it is empty |
105 | */ | 105 | */ |
106 | OPimEvent( int uid = 0 ); | 106 | OPimEvent( int uid = 0 ); |
107 | 107 | ||
108 | /** | 108 | /** |
109 | * copy c'tor | 109 | * copy c'tor |
110 | */ | 110 | */ |
111 | OPimEvent( const OPimEvent& ); | 111 | OPimEvent( const OPimEvent& ); |
112 | 112 | ||
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 */ |
144 | QDateTime startDateTime() const; | 152 | QDateTime startDateTime() const; |
145 | 153 | ||
146 | /** returns the start datetime in the current zone */ | 154 | /** returns the start datetime in the current zone */ |
147 | QDateTime startDateTimeInZone() const; | 155 | QDateTime startDateTimeInZone() const; |
148 | 156 | ||
149 | /** in current timezone */ | 157 | /** in current timezone */ |
150 | void setEndDateTime( const QDateTime& ); | 158 | void setEndDateTime( const QDateTime& ); |
151 | /** in current timezone */ | 159 | /** in current timezone */ |
152 | QDateTime endDateTime() const; | 160 | QDateTime endDateTime() const; |
153 | QDateTime endDateTimeInZone() const; | 161 | QDateTime endDateTimeInZone() const; |
154 | 162 | ||
155 | bool isMultipleDay() const; | 163 | bool isMultipleDay() const; |
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: |
200 | inline void changeOrModify(); | 214 | inline void changeOrModify(); |
201 | void deref(); | 215 | void deref(); |
202 | struct Data; | 216 | struct Data; |
203 | Data* data; | 217 | Data* data; |
204 | class Private; | 218 | class Private; |
205 | Private* priv; | 219 | Private* priv; |
206 | 220 | ||
207 | }; | 221 | }; |
208 | 222 | ||
209 | /** | 223 | /** |
210 | * AN Event can span through multiple days. We split up a multiday eve | 224 | * AN Event can span through multiple days. We split up a multiday eve |
211 | */ | 225 | */ |
212 | class OEffectiveEvent | 226 | class OEffectiveEvent |
213 | { | 227 | { |
214 | 228 | ||
215 | public: | 229 | public: |
216 | typedef QValueList<OEffectiveEvent> ValueList; | 230 | typedef QValueList<OEffectiveEvent> ValueList; |
217 | enum Position { MidWay, Start, End, StartEnd }; | 231 | enum Position { MidWay, Start, End, StartEnd }; |
218 | // If we calculate the effective event of a multi-day event | 232 | // If we calculate the effective event of a multi-day event |
219 | // we have to figure out whether we are at the first day, | 233 | // we have to figure out whether we are at the first day, |
220 | // at the end, or anywhere else ("middle"). This is important | 234 | // at the end, or anywhere else ("middle"). This is important |
221 | // for the start/end times (00:00/23:59) | 235 | // for the start/end times (00:00/23:59) |
222 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- | 236 | // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- |
223 | // day event | 237 | // day event |
224 | // Start: start time -> 23:59 | 238 | // Start: start time -> 23:59 |
225 | // End: 00:00 -> end time | 239 | // End: 00:00 -> end time |
226 | // Start | End == StartEnd: for single-day events (default) | 240 | // Start | End == StartEnd: for single-day events (default) |
227 | // here we draw start time -> end time | 241 | // here we draw start time -> end time |
228 | OEffectiveEvent(); | 242 | OEffectiveEvent(); |
229 | OEffectiveEvent( const OPimEvent& event, const QDate& startDate, Position pos = StartEnd ); | 243 | OEffectiveEvent( const OPimEvent& event, const QDate& startDate, Position pos = StartEnd ); |
230 | OEffectiveEvent( const OEffectiveEvent& ); | 244 | OEffectiveEvent( const OEffectiveEvent& ); |
231 | OEffectiveEvent &operator=( const OEffectiveEvent& ); | 245 | OEffectiveEvent &operator=( const OEffectiveEvent& ); |
232 | ~OEffectiveEvent(); | 246 | ~OEffectiveEvent(); |
233 | 247 | ||
234 | void setStartTime( const QTime& ); | 248 | void setStartTime( const QTime& ); |
235 | void setEndTime( const QTime& ); | 249 | void setEndTime( const QTime& ); |
236 | void setEvent( const OPimEvent& ); | 250 | void setEvent( const OPimEvent& ); |
237 | void setDate( const QDate& ); | 251 | void setDate( const QDate& ); |
238 | 252 | ||
239 | void setEffectiveDates( const QDate& from, const QDate& to ); | 253 | void setEffectiveDates( const QDate& from, const QDate& to ); |
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 | |||
@@ -1,64 +1,76 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> | 3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
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 | }; |
56 | 68 | ||
57 | 69 | ||
58 | }; | 70 | }; |
59 | 71 | ||
60 | } | 72 | } |
61 | } | 73 | } |
62 | 74 | ||
63 | 75 | ||
64 | #endif | 76 | #endif |
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 | |||
@@ -119,132 +119,127 @@ OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found | |||
119 | return ( *it ); | 119 | return ( *it ); |
120 | } | 120 | } |
121 | 121 | ||
122 | // Fall through if nothing could be found | 122 | // Fall through if nothing could be found |
123 | found = false; | 123 | found = false; |
124 | OPimAlarm empty; | 124 | OPimAlarm empty; |
125 | return empty; | 125 | return empty; |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | void OPimNotifyManager::setAlarms( const Alarms& al ) | 129 | void OPimNotifyManager::setAlarms( const Alarms& al ) |
130 | { | 130 | { |
131 | m_al = al; | 131 | m_al = al; |
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | void OPimNotifyManager::setReminders( const Reminders& rem ) | 135 | void OPimNotifyManager::setReminders( const Reminders& rem ) |
136 | { | 136 | { |
137 | m_rem = rem; | 137 | m_rem = rem; |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | /* FIXME!!! */ | 141 | /* FIXME!!! */ |
142 | /** | 142 | /** |
143 | * The idea is to check if the provider for our service | 143 | * The idea is to check if the provider for our service |
144 | * is online | 144 | * is online |
145 | * if it is we will use QCOP | 145 | * if it is we will use QCOP |
146 | * if not the Factory to get the backend... | 146 | * if not the Factory to get the backend... |
147 | * Qtopia1.6 services would be kewl to have here.... | 147 | * Qtopia1.6 services would be kewl to have here.... |
148 | */ | 148 | */ |
149 | void OPimNotifyManager::registerNotify( const OPimNotify& ) | 149 | void OPimNotifyManager::registerNotify( const OPimNotify& ) |
150 | { | 150 | { |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
154 | /* FIXME!!! */ | 154 | /* FIXME!!! */ |
155 | /** | 155 | /** |
156 | * same as above... | 156 | * same as above... |
157 | * Also implement Url model | 157 | * Also implement Url model |
158 | * have a MainWindow.... | 158 | * have a MainWindow.... |
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 | { |
176 | QString str; | 175 | QString str; |
177 | 176 | ||
178 | OPimNotifyManager::Alarms alarms = m_al; | 177 | OPimNotifyManager::Alarms alarms = m_al; |
179 | if ( !alarms.isEmpty() ) | 178 | if ( !alarms.isEmpty() ) |
180 | { | 179 | { |
181 | QStringList als; | 180 | QStringList als; |
182 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); | 181 | OPimNotifyManager::Alarms::Iterator it = alarms.begin(); |
183 | for ( ; it != alarms.end(); ++it ) | 182 | for ( ; it != alarms.end(); ++it ) |
184 | { | 183 | { |
185 | /* only if time is valid */ | 184 | /* only if time is valid */ |
186 | if ( ( *it ).dateTime().isValid() ) | 185 | if ( ( *it ).dateTime().isValid() ) |
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 |
204 | { | 202 | { |
205 | QString str; | 203 | QString str; |
206 | 204 | ||
207 | OPimNotifyManager::Reminders reminders = m_rem; | 205 | OPimNotifyManager::Reminders reminders = m_rem; |
208 | if ( !reminders.isEmpty() ) | 206 | if ( !reminders.isEmpty() ) |
209 | { | 207 | { |
210 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); | 208 | OPimNotifyManager::Reminders::Iterator it = reminders.begin(); |
211 | QStringList records; | 209 | QStringList records; |
212 | for ( ; it != reminders.end(); ++it ) | 210 | for ( ; it != reminders.end(); ++it ) |
213 | { | 211 | { |
214 | records << QString::number( ( *it ).recordUid() ); | 212 | records << QString::number( ( *it ).recordUid() ); |
215 | } | 213 | } |
216 | str = records.join( ";" ); | 214 | str = records.join( ";" ); |
217 | } | 215 | } |
218 | 216 | ||
219 | return str; | 217 | return str; |
220 | } | 218 | } |
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 ) |
240 | { | 235 | { |
241 | 236 | ||
242 | QStringList rems = QStringList::split( ";", str ); | 237 | QStringList rems = QStringList::split( ";", str ); |
243 | for ( QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) | 238 | for ( QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) |
244 | { | 239 | { |
245 | OPimReminder rem( ( *it ).toInt() ); | 240 | OPimReminder rem( ( *it ).toInt() ); |
246 | add( rem ); | 241 | add( rem ); |
247 | } | 242 | } |
248 | 243 | ||
249 | } | 244 | } |
250 | } | 245 | } |
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 | |||
@@ -55,121 +55,105 @@ OPimRecord::~OPimRecord() | |||
55 | 55 | ||
56 | OPimRecord::OPimRecord( const OPimRecord& rec ) | 56 | OPimRecord::OPimRecord( const OPimRecord& rec ) |
57 | : Qtopia::Record( rec ) | 57 | : Qtopia::Record( rec ) |
58 | { | 58 | { |
59 | ( *this ) = rec; | 59 | ( *this ) = rec; |
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec ) | 63 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec ) |
64 | { | 64 | { |
65 | if ( this == &rec ) return * this; | 65 | if ( this == &rec ) return * this; |
66 | 66 | ||
67 | Qtopia::Record::operator=( rec ); | 67 | Qtopia::Record::operator=( rec ); |
68 | m_xrefman = rec.m_xrefman; | 68 | m_xrefman = rec.m_xrefman; |
69 | m_lastHit = rec.m_lastHit; | 69 | m_lastHit = rec.m_lastHit; |
70 | 70 | ||
71 | return *this; | 71 | return *this; |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | /* | 75 | /* |
76 | * category names | 76 | * category names |
77 | */ | 77 | */ |
78 | QStringList OPimRecord::categoryNames( const QString& appname ) const | 78 | QStringList OPimRecord::categoryNames( const QString& appname ) const |
79 | { | 79 | { |
80 | QStringList list; | 80 | QStringList list; |
81 | QArray<int> cats = categories(); | 81 | QArray<int> cats = categories(); |
82 | Categories catDB; | 82 | Categories catDB; |
83 | catDB.load( categoryFileName() ); | 83 | catDB.load( categoryFileName() ); |
84 | 84 | ||
85 | for ( uint i = 0; i < cats.count(); i++ ) | 85 | for ( uint i = 0; i < cats.count(); i++ ) |
86 | { | 86 | { |
87 | list << catDB.label( appname, cats[ i ] ); | 87 | list << catDB.label( appname, cats[ i ] ); |
88 | } | 88 | } |
89 | 89 | ||
90 | return list; | 90 | return list; |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | void OPimRecord::setCategoryNames( const QStringList& ) | 94 | 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 | }; |
136 | 120 | ||
137 | 121 | ||
138 | Qtopia::UidGen &OPimRecord::uidGen() | 122 | Qtopia::UidGen &OPimRecord::uidGen() |
139 | { | 123 | { |
140 | return m_uidGen; | 124 | return m_uidGen; |
141 | } | 125 | } |
142 | 126 | ||
143 | 127 | ||
144 | OPimXRefManager &OPimRecord::xrefmanager() | 128 | OPimXRefManager &OPimRecord::xrefmanager() |
145 | { | 129 | { |
146 | return m_xrefman; | 130 | return m_xrefman; |
147 | } | 131 | } |
148 | 132 | ||
149 | 133 | ||
150 | int OPimRecord::rtti() const | 134 | int OPimRecord::rtti() const |
151 | { | 135 | { |
152 | return 0; | 136 | return 0; |
153 | } | 137 | } |
154 | 138 | ||
155 | /** | 139 | /** |
156 | * now let's put our data into the stream | 140 | * now let's put our data into the stream |
157 | */ | 141 | */ |
158 | /* | 142 | /* |
159 | * First read UID | 143 | * First read UID |
160 | * Categories | 144 | * Categories |
161 | * XRef | 145 | * XRef |
162 | */ | 146 | */ |
163 | bool OPimRecord::loadFromStream( QDataStream& stream ) | 147 | bool OPimRecord::loadFromStream( QDataStream& stream ) |
164 | { | 148 | { |
165 | int Int; | 149 | int Int; |
166 | uint UInt; | 150 | uint UInt; |
167 | stream >> Int; | 151 | stream >> Int; |
168 | setUid( Int ); | 152 | setUid( Int ); |
169 | 153 | ||
170 | /** Categories */ | 154 | /** Categories */ |
171 | stream >> UInt; | 155 | stream >> UInt; |
172 | QArray<int> array( UInt ); | 156 | QArray<int> array( UInt ); |
173 | for ( uint i = 0; i < UInt; i++ ) | 157 | for ( uint i = 0; i < UInt; i++ ) |
174 | { | 158 | { |
175 | stream >> array[ i ]; | 159 | stream >> array[ i ]; |
@@ -225,49 +209,56 @@ void OPimRecord::flush( const OPimXRefPartner& par, QDataStream& str ) const | |||
225 | str << par.service(); | 209 | str << par.service(); |
226 | str << par.uid(); | 210 | str << par.uid(); |
227 | str << par.field(); | 211 | str << par.field(); |
228 | } | 212 | } |
229 | 213 | ||
230 | 214 | ||
231 | OPimXRefPartner OPimRecord::partner( QDataStream& stream ) | 215 | OPimXRefPartner OPimRecord::partner( QDataStream& stream ) |
232 | { | 216 | { |
233 | OPimXRefPartner par; | 217 | OPimXRefPartner par; |
234 | QString str; | 218 | QString str; |
235 | int i; | 219 | int i; |
236 | 220 | ||
237 | stream >> str; | 221 | stream >> str; |
238 | par.setService( str ); | 222 | par.setService( str ); |
239 | 223 | ||
240 | stream >> i; | 224 | stream >> i; |
241 | par.setUid( i ); | 225 | par.setUid( i ); |
242 | 226 | ||
243 | stream >> i ; | 227 | stream >> i ; |
244 | par.setField( i ); | 228 | par.setField( i ); |
245 | 229 | ||
246 | return par; | 230 | return par; |
247 | } | 231 | } |
248 | 232 | ||
249 | 233 | ||
250 | void OPimRecord::setLastHitField( int lastHit ) const | 234 | void OPimRecord::setLastHitField( int lastHit ) const |
251 | { | 235 | { |
252 | m_lastHit = lastHit; | 236 | m_lastHit = lastHit; |
253 | } | 237 | } |
254 | 238 | ||
255 | 239 | ||
256 | int OPimRecord::lastHitField() const | 240 | int OPimRecord::lastHitField() const |
257 | { | 241 | { |
258 | return m_lastHit; | 242 | return m_lastHit; |
259 | } | 243 | } |
260 | 244 | ||
261 | 245 | ||
262 | QMap<QString, QString> OPimRecord::toExtraMap() const | 246 | QMap<QString, QString> OPimRecord::toExtraMap() const |
263 | { | 247 | { |
264 | return customMap; | 248 | return customMap; |
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 | |||
@@ -1,192 +1,199 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
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 | 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 */ |
43 | #include <qdatastream.h> | 45 | #include <qdatastream.h> |
44 | #include <qmap.h> | 46 | #include <qmap.h> |
45 | #include <qstring.h> | 47 | #include <qstring.h> |
46 | #include <qstringlist.h> | 48 | #include <qstringlist.h> |
47 | 49 | ||
48 | namespace Opie | 50 | namespace Opie |
49 | { | 51 | { |
50 | /** | 52 | /** |
51 | * This is the base class for | 53 | * This is the base class for |
52 | * all PIM Records | 54 | * all PIM Records |
53 | * | 55 | * |
54 | */ | 56 | */ |
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 | /** |
72 | * copy operator | 74 | * copy operator |
73 | */ | 75 | */ |
74 | OPimRecord &operator=( const OPimRecord& ); | 76 | OPimRecord &operator=( const OPimRecord& ); |
75 | 77 | ||
76 | /** | 78 | /** |
77 | * category names resolved | 79 | * category names resolved |
78 | */ | 80 | */ |
79 | QStringList categoryNames( const QString& appname ) const; | 81 | QStringList categoryNames( const QString& appname ) const; |
80 | 82 | ||
81 | /** | 83 | /** |
82 | * set category names they will be resolved | 84 | * set category names they will be resolved |
83 | */ | 85 | */ |
84 | void setCategoryNames( const QStringList& ); | 86 | void setCategoryNames( const QStringList& ); |
85 | 87 | ||
86 | /** | 88 | /** |
87 | * addCategoryName adds a name | 89 | * addCategoryName adds a name |
88 | * to the internal category list | 90 | * to the internal category list |
89 | */ | 91 | */ |
90 | void addCategoryName( const QString& ); | 92 | void addCategoryName( const QString& ); |
91 | 93 | ||
92 | /** | 94 | /** |
93 | * if a Record isEmpty | 95 | * if a Record isEmpty |
94 | * it's empty if it's 0 | 96 | * it's empty if it's 0 |
95 | */ | 97 | */ |
96 | virtual bool isEmpty() const; | 98 | virtual bool isEmpty() const; |
97 | 99 | ||
98 | /** | 100 | /** |
99 | * toRichText summary | 101 | * toRichText summary |
100 | */ | 102 | */ |
101 | virtual QString toRichText() const = 0; | 103 | virtual QString toRichText() const = 0; |
102 | 104 | ||
103 | /** | 105 | /** |
104 | * a small one line summary | 106 | * a small one line summary |
105 | */ | 107 | */ |
106 | virtual QString toShortText() const = 0; | 108 | virtual QString toShortText() const = 0; |
107 | 109 | ||
108 | /** | 110 | /** |
109 | * the name of the Record | 111 | * the name of the Record |
110 | */ | 112 | */ |
111 | virtual QString type() const = 0; | 113 | virtual QString type() const = 0; |
112 | 114 | ||
113 | /** | 115 | /** |
114 | * matches the Records the regular expression? | 116 | * matches the Records the regular expression? |
115 | */ | 117 | */ |
116 | virtual bool match( const QString ®exp ) const | 118 | virtual bool match( const QString ®exp ) const |
117 | { | 119 | { |
118 | setLastHitField( -1 ); | 120 | setLastHitField( -1 ); |
119 | return Qtopia::Record::match( QRegExp( regexp ) ); | 121 | return Qtopia::Record::match( QRegExp( regexp ) ); |
120 | }; | 122 | }; |
121 | 123 | ||
122 | /** | 124 | /** |
123 | * if implemented this function returns which item has been | 125 | * if implemented this function returns which item has been |
124 | * last hit by the match() function. | 126 | * last hit by the match() function. |
125 | * or -1 if not implemented or no hit has occured | 127 | * or -1 if not implemented or no hit has occured |
126 | */ | 128 | */ |
127 | int lastHitField() const; | 129 | int lastHitField() const; |
128 | 130 | ||
129 | /** | 131 | /** |
130 | * converts the internal structure to a map | 132 | * converts the internal structure to a map |
131 | */ | 133 | */ |
132 | virtual QMap<int, QString> toMap() const = 0; | 134 | virtual QMap<int, QString> toMap() const = 0; |
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(); |
153 | 160 | ||
154 | /** | 161 | /** |
155 | * set the uid | 162 | * set the uid |
156 | */ | 163 | */ |
157 | virtual void setUid( int uid ); | 164 | virtual void setUid( int uid ); |
158 | 165 | ||
159 | /* | 166 | /* |
160 | * used inside the Templates for casting | 167 | * used inside the Templates for casting |
161 | * REIMPLEMENT in your .... | 168 | * REIMPLEMENT in your .... |
162 | */ | 169 | */ |
163 | virtual int rtti() const; | 170 | virtual int rtti() const; |
164 | 171 | ||
165 | /** | 172 | /** |
166 | * some marshalling and de marshalling code | 173 | * some marshalling and de marshalling code |
167 | * saves the OPimRecord | 174 | * saves the OPimRecord |
168 | * to and from a DataStream | 175 | * to and from a DataStream |
169 | */ | 176 | */ |
170 | virtual bool loadFromStream( QDataStream& ); | 177 | virtual bool loadFromStream( QDataStream& ); |
171 | virtual bool saveToStream( QDataStream& stream ) const; | 178 | virtual bool saveToStream( QDataStream& stream ) const; |
172 | 179 | ||
173 | protected: | 180 | protected: |
174 | // need to be const cause it is called from const methods | 181 | // need to be const cause it is called from const methods |
175 | mutable int m_lastHit; | 182 | mutable int m_lastHit; |
176 | void setLastHitField( int lastHit ) const; | 183 | void setLastHitField( int lastHit ) const; |
177 | Qtopia::UidGen &uidGen(); | 184 | Qtopia::UidGen &uidGen(); |
178 | // QString crossToString()const; | 185 | // QString crossToString()const; |
179 | 186 | ||
180 | private: | 187 | private: |
181 | class OPimRecordPrivate; | 188 | class OPimRecordPrivate; |
182 | OPimRecordPrivate *d; | 189 | OPimRecordPrivate *d; |
183 | OPimXRefManager m_xrefman; | 190 | OPimXRefManager m_xrefman; |
184 | static Qtopia::UidGen m_uidGen; | 191 | static Qtopia::UidGen m_uidGen; |
185 | 192 | ||
186 | private: | 193 | private: |
187 | void flush( const OPimXRefPartner&, QDataStream& stream ) const; | 194 | void flush( const OPimXRefPartner&, QDataStream& stream ) const; |
188 | OPimXRefPartner partner( QDataStream& ); | 195 | OPimXRefPartner partner( QDataStream& ); |
189 | }; | 196 | }; |
190 | 197 | ||
191 | } | 198 | } |
192 | 199 | ||
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 | |||
@@ -1,267 +1,269 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
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 | 29 | ||
30 | #ifndef ORECORDLIST_H | 30 | #ifndef ORECORDLIST_H |
31 | #define ORECORDLIST_H | 31 | #define ORECORDLIST_H |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/opimtemplatebase.h> | 34 | #include <opie2/opimtemplatebase.h> |
35 | #include <opie2/opimrecord.h> | 35 | #include <opie2/opimrecord.h> |
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 | */ |
52 | template <class T> class OPimRecordList; | 53 | template <class T> class OPimRecordList; |
53 | template <class T = OPimRecord> | 54 | template <class T = OPimRecord> |
54 | class OPimRecordListIterator | 55 | class OPimRecordListIterator |
55 | { | 56 | { |
56 | friend class OPimRecordList<T>; | 57 | friend class OPimRecordList<T>; |
57 | 58 | ||
58 | public: | 59 | public: |
59 | typedef OTemplateBase<T> Base; | 60 | typedef OTemplateBase<T> Base; |
60 | 61 | ||
61 | /** | 62 | /** |
62 | * The c'tor used internally from | 63 | * The c'tor used internally from |
63 | * OPimRecordList | 64 | * OPimRecordList |
64 | */ | 65 | */ |
65 | OPimRecordListIterator( const QArray<int>, const Base* ); | 66 | OPimRecordListIterator( const QArray<int>, const Base* ); |
66 | 67 | ||
67 | /** | 68 | /** |
68 | * The standard c'tor | 69 | * The standard c'tor |
69 | */ | 70 | */ |
70 | OPimRecordListIterator(); | 71 | OPimRecordListIterator(); |
71 | ~OPimRecordListIterator(); | 72 | ~OPimRecordListIterator(); |
72 | 73 | ||
73 | OPimRecordListIterator( const OPimRecordListIterator& ); | 74 | OPimRecordListIterator( const OPimRecordListIterator& ); |
74 | OPimRecordListIterator &operator=( const OPimRecordListIterator& ); | 75 | OPimRecordListIterator &operator=( const OPimRecordListIterator& ); |
75 | 76 | ||
76 | /** | 77 | /** |
77 | * a * operator ;) | 78 | * a * operator ;) |
78 | * use it like this T = (*it); | 79 | * use it like this T = (*it); |
79 | */ | 80 | */ |
80 | T operator*(); | 81 | T operator*(); |
81 | OPimRecordListIterator &operator++(); | 82 | OPimRecordListIterator &operator++(); |
82 | OPimRecordListIterator &operator--(); | 83 | OPimRecordListIterator &operator--(); |
83 | 84 | ||
84 | bool operator==( const OPimRecordListIterator& it ); | 85 | bool operator==( const OPimRecordListIterator& it ); |
85 | bool operator!=( const OPimRecordListIterator& it ); | 86 | bool operator!=( const OPimRecordListIterator& it ); |
86 | 87 | ||
87 | /** | 88 | /** |
88 | * the current item | 89 | * the current item |
89 | */ | 90 | */ |
90 | uint current() const; | 91 | uint current() const; |
91 | 92 | ||
92 | /** | 93 | /** |
93 | * the number of items | 94 | * the number of items |
94 | */ | 95 | */ |
95 | uint count() const; | 96 | uint count() const; |
96 | 97 | ||
97 | /** | 98 | /** |
98 | * sets the current item | 99 | * sets the current item |
99 | */ | 100 | */ |
100 | void setCurrent( uint cur ); | 101 | void setCurrent( uint cur ); |
101 | 102 | ||
102 | private: | 103 | private: |
103 | QArray<int> m_uids; | 104 | QArray<int> m_uids; |
104 | uint m_current; | 105 | uint m_current; |
105 | const Base* m_temp; | 106 | const Base* m_temp; |
106 | bool m_end : 1; | 107 | bool m_end : 1; |
107 | T m_record; | 108 | T m_record; |
108 | bool m_direction : 1; | 109 | bool m_direction : 1; |
109 | 110 | ||
110 | /* d pointer for future versions */ | 111 | /* d pointer for future versions */ |
111 | OPimRecordListIteratorPrivate *d; | 112 | OPimRecordListIteratorPrivate *d; |
112 | }; | 113 | }; |
113 | 114 | ||
114 | 115 | ||
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 | /** |
142 | * the end | 143 | * the end |
143 | */ | 144 | */ |
144 | Iterator end(); | 145 | Iterator end(); |
145 | 146 | ||
146 | /** | 147 | /** |
147 | * the number of items in the list | 148 | * the number of items in the list |
148 | */ | 149 | */ |
149 | uint count() const; | 150 | uint count() const; |
150 | 151 | ||
151 | T operator[] ( uint i ); | 152 | T operator[] ( uint i ); |
152 | int uidAt( uint i ); | 153 | int uidAt( uint i ); |
153 | 154 | ||
154 | /** | 155 | /** |
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 */ |
171 | template <class T> | 175 | template <class T> |
172 | OPimRecordListIterator<T>::OPimRecordListIterator() | 176 | OPimRecordListIterator<T>::OPimRecordListIterator() |
173 | { | 177 | { |
174 | m_current = 0; | 178 | m_current = 0; |
175 | m_temp = 0l; | 179 | m_temp = 0l; |
176 | m_end = true; | 180 | m_end = true; |
177 | m_record = T(); | 181 | m_record = T(); |
178 | /* forward */ | 182 | /* forward */ |
179 | m_direction = TRUE; | 183 | m_direction = TRUE; |
180 | } | 184 | } |
181 | 185 | ||
182 | 186 | ||
183 | template <class T> | 187 | template <class T> |
184 | OPimRecordListIterator<T>::~OPimRecordListIterator() | 188 | 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 | ||
202 | 205 | ||
203 | template <class T> | 206 | template <class T> |
204 | OPimRecordListIterator<T> &OPimRecordListIterator<T>::operator=( const OPimRecordListIterator<T>& it ) | 207 | OPimRecordListIterator<T> &OPimRecordListIterator<T>::operator=( const OPimRecordListIterator<T>& it ) |
205 | { | 208 | { |
206 | m_uids = it.m_uids; | 209 | m_uids = it.m_uids; |
207 | m_current = it.m_current; | 210 | m_current = it.m_current; |
208 | m_temp = it.m_temp; | 211 | m_temp = it.m_temp; |
209 | m_end = it.m_end; | 212 | m_end = it.m_end; |
210 | m_record = it.m_record; | 213 | m_record = it.m_record; |
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; |
228 | } | 230 | } |
229 | 231 | ||
230 | 232 | ||
231 | template <class T> | 233 | template <class T> |
232 | OPimRecordListIterator<T> &OPimRecordListIterator<T>::operator++() | 234 | OPimRecordListIterator<T> &OPimRecordListIterator<T>::operator++() |
233 | { | 235 | { |
234 | m_direction = true; | 236 | m_direction = true; |
235 | if ( m_current < m_uids.count() ) | 237 | if ( m_current < m_uids.count() ) |
236 | { | 238 | { |
237 | m_end = false; | 239 | m_end = false; |
238 | ++m_current; | 240 | ++m_current; |
239 | } | 241 | } |
240 | else | 242 | else |
241 | m_end = true; | 243 | m_end = true; |
242 | 244 | ||
243 | return *this; | 245 | return *this; |
244 | } | 246 | } |
245 | 247 | ||
246 | 248 | ||
247 | template <class T> | 249 | template <class T> |
248 | OPimRecordListIterator<T> &OPimRecordListIterator<T>::operator--() | 250 | OPimRecordListIterator<T> &OPimRecordListIterator<T>::operator--() |
249 | { | 251 | { |
250 | m_direction = false; | 252 | m_direction = false; |
251 | if ( m_current > 0 ) | 253 | if ( m_current > 0 ) |
252 | { | 254 | { |
253 | --m_current; | 255 | --m_current; |
254 | m_end = false; | 256 | m_end = false; |
255 | } | 257 | } |
256 | else | 258 | else |
257 | m_end = true; | 259 | m_end = true; |
258 | 260 | ||
259 | return *this; | 261 | return *this; |
260 | } | 262 | } |
261 | 263 | ||
262 | 264 | ||
263 | template <class T> | 265 | template <class T> |
264 | bool OPimRecordListIterator<T>::operator==( const OPimRecordListIterator<T>& it ) | 266 | bool OPimRecordListIterator<T>::operator==( const OPimRecordListIterator<T>& it ) |
265 | { | 267 | { |
266 | 268 | ||
267 | /* if both are at we're the same.... */ | 269 | /* if both are at we're the same.... */ |
@@ -354,50 +356,55 @@ template <class T> | |||
354 | uint OPimRecordList<T>::count() const | 356 | uint OPimRecordList<T>::count() const |
355 | { | 357 | { |
356 | return m_ids.count(); | 358 | return m_ids.count(); |
357 | } | 359 | } |
358 | 360 | ||
359 | 361 | ||
360 | template <class T> | 362 | template <class T> |
361 | T OPimRecordList<T>::operator[] ( uint i ) | 363 | T OPimRecordList<T>::operator[] ( uint i ) |
362 | { | 364 | { |
363 | if ( i >= m_ids.count() ) | 365 | if ( i >= m_ids.count() ) |
364 | return T(); | 366 | return T(); |
365 | /* forward */ | 367 | /* forward */ |
366 | return m_acc->find( m_ids[ i ], m_ids, i ); | 368 | return m_acc->find( m_ids[ i ], m_ids, i ); |
367 | } | 369 | } |
368 | 370 | ||
369 | 371 | ||
370 | template <class T> | 372 | template <class T> |
371 | int OPimRecordList<T>::uidAt( uint i ) | 373 | int OPimRecordList<T>::uidAt( uint i ) |
372 | { | 374 | { |
373 | return m_ids[ i ]; | 375 | return m_ids[ i ]; |
374 | } | 376 | } |
375 | 377 | ||
376 | 378 | ||
377 | template <class T> | 379 | template <class T> |
378 | bool OPimRecordList<T>::remove( int uid ) | 380 | bool OPimRecordList<T>::remove( int uid ) |
379 | { | 381 | { |
380 | QArray<int> copy( m_ids.count() ); | 382 | QArray<int> copy( m_ids.count() ); |
381 | int counter = 0; | 383 | int counter = 0; |
382 | bool ret_val = false; | 384 | bool ret_val = false; |
383 | 385 | ||
384 | for ( uint i = 0; i < m_ids.count(); i++ ) | 386 | for ( uint i = 0; i < m_ids.count(); i++ ) |
385 | { | 387 | { |
386 | if ( m_ids[ i ] != uid ) | 388 | if ( m_ids[ i ] != uid ) |
387 | { | 389 | { |
388 | copy[ counter++ ] = m_ids[ i ]; | 390 | copy[ counter++ ] = m_ids[ i ]; |
389 | 391 | ||
390 | } | 392 | } |
391 | else | 393 | else |
392 | ret_val = true; | 394 | ret_val = true; |
393 | } | 395 | } |
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 | |||
@@ -1,97 +1,95 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
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 OPIMRESOLVER_H | 29 | #ifndef OPIMRESOLVER_H |
30 | #define OPIMRESOLVER_H | 30 | #define OPIMRESOLVER_H |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/opimtemplatebase.h> | 33 | #include <opie2/opimtemplatebase.h> |
34 | 34 | ||
35 | /* QT */ | 35 | /* QT */ |
36 | #include <qstring.h> | 36 | #include <qstring.h> |
37 | #include <qvaluelist.h> | 37 | #include <qvaluelist.h> |
38 | 38 | ||
39 | namespace Opie { | 39 | 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 | }; |
58 | static OPimResolver* self(); | 56 | static OPimResolver* self(); |
59 | 57 | ||
60 | 58 | ||
61 | /** | 59 | /** |
62 | * return a record for a uid | 60 | * return a record for a uid |
63 | * and an service | 61 | * and an service |
64 | * You've THE OWNERSHIP NOW! | 62 | * You've THE OWNERSHIP NOW! |
65 | */ | 63 | */ |
66 | OPimRecord *record( const QString& service, int uid ); | 64 | OPimRecord *record( const QString& service, int uid ); |
67 | 65 | ||
68 | /** | 66 | /** |
69 | * return the QCopChannel for service | 67 | * return the QCopChannel for service |
70 | * When we will use Qtopia Services it will be used here | 68 | * When we will use Qtopia Services it will be used here |
71 | */ | 69 | */ |
72 | QCString qcopChannel( enum BuiltIn& )const; | 70 | QCString qcopChannel( enum BuiltIn& )const; |
73 | QCString qcopChannel( const QString& service )const; | 71 | QCString qcopChannel( const QString& service )const; |
74 | 72 | ||
75 | /** | 73 | /** |
76 | * The Application channel (QPE/Application/name) | 74 | * The Application channel (QPE/Application/name) |
77 | */ | 75 | */ |
78 | QCString applicationChannel( enum BuiltIn& )const; | 76 | QCString applicationChannel( enum BuiltIn& )const; |
79 | QCString applicationChannel( const QString& service )const; | 77 | QCString applicationChannel( const QString& service )const; |
80 | 78 | ||
81 | /** | 79 | /** |
82 | * return a list of available services | 80 | * return a list of available services |
83 | */ | 81 | */ |
84 | QStringList services()const; | 82 | QStringList services()const; |
85 | inline QString serviceName(int rrti )const; | 83 | inline QString serviceName(int rrti )const; |
86 | int serviceId( const QString& Service); | 84 | int serviceId( const QString& Service); |
87 | /** | 85 | /** |
88 | * add a record to a service... ;) | 86 | * add a record to a service... ;) |
89 | */ | 87 | */ |
90 | bool add( const QString& service, const OPimRecord& ); | 88 | bool add( const QString& service, const OPimRecord& ); |
91 | 89 | ||
92 | 90 | ||
93 | /** | 91 | /** |
94 | * record returns an empty record for a given service. | 92 | * record returns an empty record for a given service. |
95 | * Be sure to delete it!!! | 93 | * Be sure to delete it!!! |
96 | * | 94 | * |
97 | */ | 95 | */ |
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 | |||
@@ -1,78 +1,72 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
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 OPIMSTATE_H | 29 | #ifndef OPIMSTATE_H |
30 | #define OPIMSTATE_H | 30 | #define OPIMSTATE_H |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
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, |
55 | Undefined | 49 | Undefined |
56 | }; | 50 | }; |
57 | OPimState( int state = Undefined ); | 51 | OPimState( int state = Undefined ); |
58 | OPimState( const OPimState& ); | 52 | OPimState( const OPimState& ); |
59 | ~OPimState(); | 53 | ~OPimState(); |
60 | 54 | ||
61 | bool operator==( const OPimState& ); | 55 | bool operator==( const OPimState& ); |
62 | OPimState &operator=( const OPimState& ); | 56 | OPimState &operator=( const OPimState& ); |
63 | void setState( int state); | 57 | void setState( int state); |
64 | int state()const; | 58 | int state()const; |
65 | 59 | ||
66 | private: | 60 | private: |
67 | void deref(); | 61 | void deref(); |
68 | inline void copyInternally(); | 62 | inline void copyInternally(); |
69 | 63 | ||
70 | struct Data; | 64 | struct Data; |
71 | Data* data; | 65 | Data* data; |
72 | 66 | ||
73 | class Private; | 67 | class Private; |
74 | Private *d; | 68 | Private *d; |
75 | }; | 69 | }; |
76 | 70 | ||
77 | } | 71 | } |
78 | #endif | 72 | #endif |
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 | |||
@@ -1,130 +1,223 @@ | |||
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) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
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 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 | |||
@@ -1,144 +1,158 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
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 | 29 | ||
30 | #include "opimtimezone.h" | 30 | #include "opimtimezone.h" |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/odebug.h> | 33 | #include <opie2/odebug.h> |
34 | 34 | ||
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 | } |
105 | } | 119 | } |
106 | 120 | ||
107 | namespace Opie | 121 | namespace Opie |
108 | { | 122 | { |
109 | OPimTimeZone::OPimTimeZone( const ZoneName& zone ) | 123 | OPimTimeZone::OPimTimeZone( const ZoneName& zone ) |
110 | : m_name( zone ) | 124 | : m_name( zone ) |
111 | {} | 125 | {} |
112 | 126 | ||
113 | 127 | ||
114 | OPimTimeZone::~OPimTimeZone() | 128 | OPimTimeZone::~OPimTimeZone() |
115 | {} | 129 | {} |
116 | 130 | ||
117 | 131 | ||
118 | bool OPimTimeZone::isValid() const | 132 | bool OPimTimeZone::isValid() const |
119 | { | 133 | { |
120 | return !m_name.isEmpty(); | 134 | return !m_name.isEmpty(); |
121 | } | 135 | } |
122 | 136 | ||
123 | /* | 137 | /* |
124 | * we will get the current timezone | 138 | * we will get the current timezone |
125 | * and ask it to convert to the timezone date | 139 | * and ask it to convert to the timezone date |
126 | */ | 140 | */ |
127 | QDateTime OPimTimeZone::toLocalDateTime( const QDateTime& dt ) | 141 | QDateTime OPimTimeZone::toLocalDateTime( const QDateTime& dt ) |
128 | { | 142 | { |
129 | return OPimTimeZone::current().toDateTime( dt, *this ); | 143 | return OPimTimeZone::current().toDateTime( dt, *this ); |
130 | } | 144 | } |
131 | 145 | ||
132 | 146 | ||
133 | QDateTime OPimTimeZone::toUTCDateTime( const QDateTime& dt ) | 147 | QDateTime OPimTimeZone::toUTCDateTime( const QDateTime& dt ) |
134 | { | 148 | { |
135 | return OPimTimeZone::utc().toDateTime( dt, *this ); | 149 | return OPimTimeZone::utc().toDateTime( dt, *this ); |
136 | } | 150 | } |
137 | 151 | ||
138 | 152 | ||
139 | QDateTime OPimTimeZone::fromUTCDateTime( time_t t ) | 153 | QDateTime OPimTimeZone::fromUTCDateTime( time_t t ) |
140 | { | 154 | { |
141 | return utcTime( t ); | 155 | return utcTime( t ); |
142 | } | 156 | } |
143 | 157 | ||
144 | 158 | ||
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 | |||
@@ -19,226 +19,242 @@ | |||
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
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 | 29 | ||
30 | #include "opimtodo.h" | 30 | #include "opimtodo.h" |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <opie2/opimstate.h> | 33 | #include <opie2/opimstate.h> |
34 | #include <opie2/opimrecurrence.h> | 34 | #include <opie2/opimrecurrence.h> |
35 | #include <opie2/opimmaintainer.h> | 35 | #include <opie2/opimmaintainer.h> |
36 | #include <opie2/opimnotifymanager.h> | 36 | #include <opie2/opimnotifymanager.h> |
37 | #include <opie2/opimresolver.h> | 37 | #include <opie2/opimresolver.h> |
38 | #include <opie2/odebug.h> | 38 | #include <opie2/odebug.h> |
39 | 39 | ||
40 | #include <qpe/palmtopuidgen.h> | 40 | #include <qpe/palmtopuidgen.h> |
41 | #include <qpe/palmtoprecord.h> | 41 | #include <qpe/palmtoprecord.h> |
42 | #include <qpe/categories.h> | 42 | #include <qpe/categories.h> |
43 | #include <qpe/categoryselect.h> | 43 | #include <qpe/categoryselect.h> |
44 | #include <qpe/stringutil.h> | 44 | #include <qpe/stringutil.h> |
45 | 45 | ||
46 | /* QT */ | 46 | /* QT */ |
47 | #include <qobject.h> | 47 | #include <qobject.h> |
48 | #include <qshared.h> | 48 | #include <qshared.h> |
49 | 49 | ||
50 | namespace Opie | 50 | namespace Opie |
51 | { | 51 | { |
52 | 52 | ||
53 | struct OPimTodo::OPimTodoData : public QShared | 53 | struct OPimTodo::OPimTodoData : public QShared |
54 | { | 54 | { |
55 | OPimTodoData() : QShared() | 55 | OPimTodoData() : QShared() |
56 | { | 56 | { |
57 | recur = 0; | 57 | recur = 0; |
58 | state = 0; | 58 | state = 0; |
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; |
75 | QMap<QString, QString> extra; | 76 | QMap<QString, QString> extra; |
76 | ushort prog; | 77 | ushort prog; |
77 | OPimState *state; | 78 | OPimState *state; |
78 | OPimRecurrence *recur; | 79 | OPimRecurrence *recur; |
79 | OPimMaintainer *maintainer; | 80 | OPimMaintainer *maintainer; |
80 | QDate start; | 81 | QDate start; |
81 | QDate completed; | 82 | QDate completed; |
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; |
124 | data->sum = summary; | 121 | data->sum = summary; |
125 | data->prog = progress; | 122 | data->prog = progress; |
126 | data->desc = Qtopia::simplifyMultiLineSpace( description ); | 123 | data->desc = Qtopia::simplifyMultiLineSpace( description ); |
127 | } | 124 | } |
128 | 125 | ||
129 | 126 | ||
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; |
147 | data->sum = summary; | 143 | data->sum = summary; |
148 | data->prog = progress; | 144 | data->prog = progress; |
149 | data->desc = Qtopia::simplifyMultiLineSpace( description ); | 145 | data->desc = Qtopia::simplifyMultiLineSpace( description ); |
150 | } | 146 | } |
151 | 147 | ||
152 | 148 | ||
153 | bool OPimTodo::match( const QRegExp ®Exp ) const | 149 | bool OPimTodo::match( const QRegExp ®Exp ) const |
154 | { | 150 | { |
155 | if ( QString::number( data->priority ).find( regExp ) != -1 ) | 151 | if ( QString::number( data->priority ).find( regExp ) != -1 ) |
156 | { | 152 | { |
157 | setLastHitField( Priority ); | 153 | setLastHitField( Priority ); |
158 | return true; | 154 | return true; |
159 | } | 155 | } |
160 | else if ( data->hasDate && data->date.toString().find( regExp ) != -1 ) | 156 | else if ( data->hasDate && data->date.toString().find( regExp ) != -1 ) |
161 | { | 157 | { |
162 | setLastHitField( HasDate ); | 158 | setLastHitField( HasDate ); |
163 | return true; | 159 | return true; |
164 | } | 160 | } |
165 | else if ( data->desc.find( regExp ) != -1 ) | 161 | else if ( data->desc.find( regExp ) != -1 ) |
166 | { | 162 | { |
167 | setLastHitField( Description ); | 163 | setLastHitField( Description ); |
168 | return true; | 164 | return true; |
169 | } | 165 | } |
170 | else if ( data->sum.find( regExp ) != -1 ) | 166 | else if ( data->sum.find( regExp ) != -1 ) |
171 | { | 167 | { |
172 | setLastHitField( Summary ); | 168 | setLastHitField( Summary ); |
173 | return true; | 169 | return true; |
174 | } | 170 | } |
175 | return false; | 171 | return false; |
176 | } | 172 | } |
177 | 173 | ||
178 | 174 | ||
179 | bool OPimTodo::isCompleted() const | 175 | bool OPimTodo::isCompleted() const |
180 | { | 176 | { |
181 | return data->isCompleted; | 177 | return data->isCompleted; |
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 | { |
205 | return data->priority; | 221 | return data->priority; |
206 | } | 222 | } |
207 | 223 | ||
208 | 224 | ||
209 | QString OPimTodo::summary() const | 225 | QString OPimTodo::summary() const |
210 | { | 226 | { |
211 | return data->sum; | 227 | return data->sum; |
212 | } | 228 | } |
213 | 229 | ||
214 | 230 | ||
215 | ushort OPimTodo::progress() const | 231 | ushort OPimTodo::progress() const |
216 | { | 232 | { |
217 | return data->prog; | 233 | return data->prog; |
218 | } | 234 | } |
219 | 235 | ||
220 | 236 | ||
221 | QDate OPimTodo::dueDate() const | 237 | QDate OPimTodo::dueDate() const |
222 | { | 238 | { |
223 | return data->date; | 239 | return data->date; |
224 | } | 240 | } |
225 | 241 | ||
226 | 242 | ||
227 | QDate OPimTodo::startDate() const | 243 | QDate OPimTodo::startDate() const |
228 | { | 244 | { |
229 | return data->start; | 245 | return data->start; |
230 | } | 246 | } |
231 | 247 | ||
232 | 248 | ||
233 | QDate OPimTodo::completedDate() const | 249 | QDate OPimTodo::completedDate() const |
234 | { | 250 | { |
235 | return data->completed; | 251 | return data->completed; |
236 | } | 252 | } |
237 | 253 | ||
238 | 254 | ||
239 | QString OPimTodo::description() const | 255 | QString OPimTodo::description() const |
240 | { | 256 | { |
241 | return data->desc; | 257 | return data->desc; |
242 | } | 258 | } |
243 | 259 | ||
244 | 260 | ||
@@ -263,169 +279,168 @@ OPimState OPimTodo::state() const | |||
263 | 279 | ||
264 | bool OPimTodo::hasRecurrence() const | 280 | bool OPimTodo::hasRecurrence() const |
265 | { | 281 | { |
266 | if ( !data->recur ) return false; | 282 | if ( !data->recur ) return false; |
267 | return data->recur->doesRecur(); | 283 | return data->recur->doesRecur(); |
268 | } | 284 | } |
269 | 285 | ||
270 | 286 | ||
271 | OPimRecurrence OPimTodo::recurrence() const | 287 | OPimRecurrence OPimTodo::recurrence() const |
272 | { | 288 | { |
273 | if ( !data->recur ) return OPimRecurrence(); | 289 | if ( !data->recur ) return OPimRecurrence(); |
274 | 290 | ||
275 | return ( *data->recur ); | 291 | return ( *data->recur ); |
276 | } | 292 | } |
277 | 293 | ||
278 | 294 | ||
279 | bool OPimTodo::hasMaintainer() const | 295 | bool OPimTodo::hasMaintainer() const |
280 | { | 296 | { |
281 | if ( !data->maintainer ) return false; | 297 | if ( !data->maintainer ) return false; |
282 | 298 | ||
283 | return ( data->maintainer->mode() != OPimMaintainer::Undefined ); | 299 | return ( data->maintainer->mode() != OPimMaintainer::Undefined ); |
284 | } | 300 | } |
285 | 301 | ||
286 | 302 | ||
287 | OPimMaintainer OPimTodo::maintainer() const | 303 | OPimMaintainer OPimTodo::maintainer() const |
288 | { | 304 | { |
289 | if ( !data->maintainer ) return OPimMaintainer(); | 305 | if ( !data->maintainer ) return OPimMaintainer(); |
290 | 306 | ||
291 | return ( *data->maintainer ); | 307 | return ( *data->maintainer ); |
292 | } | 308 | } |
293 | 309 | ||
294 | 310 | ||
295 | void OPimTodo::setCompleted( bool completed ) | 311 | void OPimTodo::setCompleted( bool completed ) |
296 | { | 312 | { |
297 | changeOrModify(); | 313 | changeOrModify(); |
298 | data->isCompleted = completed; | 314 | data->isCompleted = completed; |
299 | } | 315 | } |
300 | 316 | ||
301 | 317 | ||
302 | void OPimTodo::setHasDueDate( bool hasDate ) | 318 | 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(); |
320 | data->sum = sum; | 335 | data->sum = sum; |
321 | } | 336 | } |
322 | 337 | ||
323 | 338 | ||
324 | void OPimTodo::setPriority( int prio ) | 339 | void OPimTodo::setPriority( int prio ) |
325 | { | 340 | { |
326 | changeOrModify(); | 341 | changeOrModify(); |
327 | data->priority = prio; | 342 | data->priority = prio; |
328 | } | 343 | } |
329 | 344 | ||
330 | 345 | ||
331 | void OPimTodo::setDueDate( const QDate& date ) | 346 | void OPimTodo::setDueDate( const QDate& date ) |
332 | { | 347 | { |
333 | changeOrModify(); | 348 | changeOrModify(); |
334 | data->date = date; | 349 | data->date = date; |
335 | } | 350 | } |
336 | 351 | ||
337 | 352 | ||
338 | void OPimTodo::setStartDate( const QDate& date ) | 353 | void OPimTodo::setStartDate( const QDate& date ) |
339 | { | 354 | { |
340 | changeOrModify(); | 355 | changeOrModify(); |
341 | data->start = date; | 356 | data->start = date; |
342 | } | 357 | } |
343 | 358 | ||
344 | 359 | ||
345 | void OPimTodo::setCompletedDate( const QDate& date ) | 360 | void OPimTodo::setCompletedDate( const QDate& date ) |
346 | { | 361 | { |
347 | changeOrModify(); | 362 | changeOrModify(); |
348 | data->completed = date; | 363 | data->completed = date; |
349 | } | 364 | } |
350 | 365 | ||
351 | 366 | ||
352 | void OPimTodo::setState( const OPimState& state ) | 367 | void OPimTodo::setState( const OPimState& state ) |
353 | { | 368 | { |
354 | changeOrModify(); | 369 | changeOrModify(); |
355 | if ( data->state ) | 370 | if ( data->state ) |
356 | ( *data->state ) = state; | 371 | ( *data->state ) = state; |
357 | else | 372 | else |
358 | data->state = new OPimState( state ); | 373 | data->state = new OPimState( state ); |
359 | } | 374 | } |
360 | 375 | ||
361 | 376 | ||
362 | void OPimTodo::setRecurrence( const OPimRecurrence& rec ) | 377 | void OPimTodo::setRecurrence( const OPimRecurrence& rec ) |
363 | { | 378 | { |
364 | changeOrModify(); | 379 | changeOrModify(); |
365 | if ( data->recur ) | 380 | if ( data->recur ) |
366 | ( *data->recur ) = rec; | 381 | ( *data->recur ) = rec; |
367 | else | 382 | else |
368 | data->recur = new OPimRecurrence( rec ); | 383 | data->recur = new OPimRecurrence( rec ); |
369 | } | 384 | } |
370 | 385 | ||
371 | 386 | ||
372 | void OPimTodo::setMaintainer( const OPimMaintainer& pim ) | 387 | void OPimTodo::setMaintainer( const OPimMaintainer& pim ) |
373 | { | 388 | { |
374 | changeOrModify(); | 389 | changeOrModify(); |
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 ) |
392 | { | 407 | { |
393 | changeOrModify(); | 408 | changeOrModify(); |
394 | data->prog = progress; | 409 | data->prog = progress; |
395 | } | 410 | } |
396 | 411 | ||
397 | 412 | ||
398 | QString OPimTodo::toShortText() const | 413 | QString OPimTodo::toShortText() const |
399 | { | 414 | { |
400 | return summary(); | 415 | return summary(); |
401 | } | 416 | } |
402 | 417 | ||
403 | 418 | ||
404 | /*! | 419 | /*! |
405 | Returns a richt text string | 420 | Returns a richt text string |
406 | */ | 421 | */ |
407 | QString OPimTodo::toRichText() const | 422 | QString OPimTodo::toRichText() const |
408 | { | 423 | { |
409 | QString text; | 424 | QString text; |
410 | QStringList catlist; | 425 | QStringList catlist; |
411 | 426 | ||
412 | // summary | 427 | // summary |
413 | text += "<b><h3><img src=\"todo/TodoList\"> "; | 428 | text += "<b><h3><img src=\"todo/TodoList\"> "; |
414 | if ( !summary().isEmpty() ) | 429 | if ( !summary().isEmpty() ) |
415 | { | 430 | { |
416 | text += Qtopia::escapeString( summary() ).replace( QRegExp( "[\n]" ), "" ); | 431 | text += Qtopia::escapeString( summary() ).replace( QRegExp( "[\n]" ), "" ); |
417 | } | 432 | } |
418 | text += "</h3></b><br><hr><br>"; | 433 | text += "</h3></b><br><hr><br>"; |
419 | 434 | ||
420 | // description | 435 | // description |
421 | if ( !description().isEmpty() ) | 436 | if ( !description().isEmpty() ) |
422 | { | 437 | { |
423 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 438 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
424 | text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "<br>" ) + "<br>"; | 439 | text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "<br>" ) + "<br>"; |
425 | } | 440 | } |
426 | 441 | ||
427 | // priority | 442 | // priority |
428 | int priorityval = priority(); | 443 | int priorityval = priority(); |
429 | text += "<b>" + QObject::tr( "Priority:" ) + " </b><img src=\"todo/priority" + | 444 | text += "<b>" + QObject::tr( "Priority:" ) + " </b><img src=\"todo/priority" + |
430 | QString::number( priorityval ) + "\"> "; | 445 | QString::number( priorityval ) + "\"> "; |
431 | 446 | ||
@@ -548,166 +563,248 @@ bool OPimTodo::operator>( const OPimTodo &toDoEvent ) const | |||
548 | } | 563 | } |
549 | else | 564 | else |
550 | { | 565 | { |
551 | return dueDate() > toDoEvent.dueDate(); | 566 | return dueDate() > toDoEvent.dueDate(); |
552 | } | 567 | } |
553 | } | 568 | } |
554 | return false; | 569 | return false; |
555 | } | 570 | } |
556 | 571 | ||
557 | 572 | ||
558 | bool OPimTodo::operator>=( const OPimTodo &toDoEvent ) const | 573 | bool OPimTodo::operator>=( const OPimTodo &toDoEvent ) const |
559 | { | 574 | { |
560 | if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 575 | if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
561 | if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 576 | if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
562 | if ( hasDueDate() && toDoEvent.hasDueDate() ) | 577 | if ( hasDueDate() && toDoEvent.hasDueDate() ) |
563 | { | 578 | { |
564 | if ( dueDate() == toDoEvent.dueDate() ) | 579 | if ( dueDate() == toDoEvent.dueDate() ) |
565 | { // let's the priority decide | 580 | { // let's the priority decide |
566 | return priority() > toDoEvent.priority(); | 581 | return priority() > toDoEvent.priority(); |
567 | } | 582 | } |
568 | else | 583 | else |
569 | { | 584 | { |
570 | return dueDate() > toDoEvent.dueDate(); | 585 | return dueDate() > toDoEvent.dueDate(); |
571 | } | 586 | } |
572 | } | 587 | } |
573 | return true; | 588 | return true; |
574 | } | 589 | } |
575 | 590 | ||
576 | 591 | ||
577 | bool OPimTodo::operator==( const OPimTodo &toDoEvent ) const | 592 | bool OPimTodo::operator==( const OPimTodo &toDoEvent ) const |
578 | { | 593 | { |
579 | if ( data->priority != toDoEvent.data->priority ) return false; | 594 | if ( data->priority != toDoEvent.data->priority ) return false; |
580 | if ( data->priority != toDoEvent.data->prog ) return false; | 595 | if ( data->priority != toDoEvent.data->prog ) return false; |
581 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; | 596 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; |
582 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; | 597 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; |
583 | if ( data->date != toDoEvent.data->date ) return false; | 598 | if ( data->date != toDoEvent.data->date ) return false; |
584 | if ( data->sum != toDoEvent.data->sum ) return false; | 599 | if ( data->sum != toDoEvent.data->sum ) return false; |
585 | if ( data->desc != toDoEvent.data->desc ) return false; | 600 | if ( data->desc != toDoEvent.data->desc ) return false; |
586 | if ( data->maintainer != toDoEvent.data->maintainer ) | 601 | if ( data->maintainer != toDoEvent.data->maintainer ) |
587 | return false; | 602 | return false; |
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 | ||
620 | QMap<int, QString> OPimTodo::toMap() const | 632 | QMap<int, QString> OPimTodo::toMap() const |
621 | { | 633 | { |
622 | QMap<int, QString> map; | 634 | QMap<int, QString> map; |
623 | 635 | ||
624 | map.insert( Uid, QString::number( uid() ) ); | 636 | map.insert( Uid, QString::number( uid() ) ); |
625 | map.insert( Category, idsToString( categories() ) ); | 637 | map.insert( Category, idsToString( categories() ) ); |
626 | map.insert( HasDate, QString::number( data->hasDate ) ); | 638 | map.insert( HasDate, QString::number( data->hasDate ) ); |
627 | map.insert( Completed, QString::number( data->isCompleted ) ); | 639 | map.insert( Completed, QString::number( data->isCompleted ) ); |
628 | map.insert( Description, data->desc ); | 640 | map.insert( Description, data->desc ); |
629 | map.insert( Summary, data->sum ); | 641 | map.insert( Summary, data->sum ); |
630 | map.insert( Priority, QString::number( data->priority ) ); | 642 | map.insert( Priority, QString::number( data->priority ) ); |
631 | map.insert( DateDay, QString::number( data->date.day() ) ); | 643 | map.insert( DateDay, QString::number( data->date.day() ) ); |
632 | map.insert( DateMonth, QString::number( data->date.month() ) ); | 644 | map.insert( DateMonth, QString::number( data->date.month() ) ); |
633 | map.insert( DateYear, QString::number( data->date.year() ) ); | 645 | map.insert( DateYear, QString::number( data->date.year() ) ); |
634 | map.insert( Progress, QString::number( data->prog ) ); | 646 | map.insert( Progress, QString::number( data->prog ) ); |
635 | // map.insert( CrossReference, crossToString() ); | 647 | // map.insert( CrossReference, crossToString() ); |
636 | /* FIXME!!! map.insert( State, ); | 648 | /* FIXME!!! map.insert( State, ); |
637 | map.insert( Recurrence, ); | 649 | map.insert( Recurrence, ); |
638 | map.insert( Reminders, ); | 650 | map.insert( Reminders, ); |
639 | map. | 651 | map. |
640 | */ | 652 | */ |
641 | return map; | 653 | return map; |
642 | } | 654 | } |
643 | 655 | ||
644 | 656 | ||
645 | /** | 657 | /** |
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 | ||
663 | // WATCHOUT | 674 | // WATCHOUT |
664 | /* | 675 | /* |
665 | * if you add something to the Data struct | 676 | * if you add something to the Data struct |
666 | * be sure to copy it here | 677 | * be sure to copy it here |
667 | */ | 678 | */ |
668 | void OPimTodo::copy( OPimTodoData* src, OPimTodoData* dest ) | 679 | void OPimTodo::copy( OPimTodoData* src, OPimTodoData* dest ) |
669 | { | 680 | { |
670 | dest->date = src->date; | 681 | dest->date = src->date; |
671 | dest->isCompleted = src->isCompleted; | 682 | dest->isCompleted = src->isCompleted; |
672 | dest->hasDate = src->hasDate; | 683 | dest->hasDate = src->hasDate; |
673 | dest->priority = src->priority; | 684 | dest->priority = src->priority; |
674 | dest->desc = src->desc; | 685 | dest->desc = src->desc; |
675 | dest->sum = src->sum; | 686 | dest->sum = src->sum; |
676 | dest->extra = src->extra; | 687 | dest->extra = src->extra; |
677 | dest->prog = src->prog; | 688 | dest->prog = src->prog; |
678 | 689 | ||
679 | if ( src->state ) | 690 | if ( src->state ) |
680 | dest->state = new OPimState( *src->state ); | 691 | dest->state = new OPimState( *src->state ); |
681 | 692 | ||
682 | if ( src->recur ) | 693 | if ( src->recur ) |
683 | dest->recur = new OPimRecurrence( *src->recur ); | 694 | dest->recur = new OPimRecurrence( *src->recur ); |
684 | 695 | ||
685 | if ( src->maintainer ) | 696 | if ( src->maintainer ) |
686 | dest->maintainer = new OPimMaintainer( *src->maintainer ) | 697 | dest->maintainer = new OPimMaintainer( *src->maintainer ) |
687 | ; | 698 | ; |
688 | dest->start = src->start; | 699 | dest->start = src->start; |
689 | dest->completed = src->completed; | 700 | dest->completed = src->completed; |
690 | 701 | ||
691 | if ( src->notifiers ) | 702 | if ( src->notifiers ) |
692 | dest->notifiers = new OPimNotifyManager( *src->notifiers ); | 703 | dest->notifiers = new OPimNotifyManager( *src->notifiers ); |
693 | } | 704 | } |
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 | |||
@@ -25,101 +25,102 @@ _;:, .> :=|. This program is free software; you can | |||
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 | 29 | ||
30 | #ifndef OTODOEVENT_H | 30 | #ifndef OTODOEVENT_H |
31 | #define OTODOEVENT_H | 31 | #define OTODOEVENT_H |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/opimrecord.h> | 34 | #include <opie2/opimrecord.h> |
35 | #include <qpe/recordfields.h> | 35 | #include <qpe/recordfields.h> |
36 | #include <qpe/palmtopuidgen.h> | 36 | #include <qpe/palmtopuidgen.h> |
37 | 37 | ||
38 | /* QT */ | 38 | /* QT */ |
39 | #include <qarray.h> | 39 | #include <qarray.h> |
40 | #include <qmap.h> | 40 | #include <qmap.h> |
41 | #include <qregexp.h> | 41 | #include <qregexp.h> |
42 | #include <qstringlist.h> | 42 | #include <qstringlist.h> |
43 | #include <qdatetime.h> | 43 | #include <qdatetime.h> |
44 | #include <qvaluelist.h> | 44 | #include <qvaluelist.h> |
45 | 45 | ||
46 | namespace Opie | 46 | namespace Opie |
47 | { | 47 | { |
48 | 48 | ||
49 | class OPimState; | 49 | class OPimState; |
50 | class OPimRecurrence; | 50 | class OPimRecurrence; |
51 | class OPimMaintainer; | 51 | class OPimMaintainer; |
52 | class OPimNotifyManager; | 52 | class OPimNotifyManager; |
53 | class OPimTodo : public OPimRecord | 53 | class OPimTodo : public OPimRecord |
54 | { | 54 | { |
55 | public: | 55 | public: |
56 | typedef QValueList<OPimTodo> ValueList; | 56 | typedef QValueList<OPimTodo> ValueList; |
57 | enum RecordFields { | 57 | enum RecordFields { |
58 | Uid = Qtopia::UID_ID, | 58 | Uid = Qtopia::UID_ID, |
59 | Category = Qtopia::CATEGORY_ID, | 59 | Category = Qtopia::CATEGORY_ID, |
60 | HasDate, | 60 | HasDate, |
61 | Completed, | 61 | Completed, |
62 | Description, | 62 | Description, |
63 | Summary, | 63 | Summary, |
64 | Priority, | 64 | Priority, |
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 |
86 | @param category Which category does it belong( uid ) | 87 | @param category Which category does it belong( uid ) |
87 | @param summary A small summary of the todo | 88 | @param summary A small summary of the todo |
88 | @param description What is this ToDoEvent about | 89 | @param description What is this ToDoEvent about |
89 | @param hasDate Does this Event got a deadline | 90 | @param hasDate Does this Event got a deadline |
90 | @param date what is the deadline? | 91 | @param date what is the deadline? |
91 | @param uid what is the UUID of this Event | 92 | @param uid what is the UUID of this Event |
92 | **/ | 93 | **/ |
93 | OPimTodo( bool completed = false, int priority = Normal, | 94 | OPimTodo( bool completed = false, int priority = Normal, |
94 | const QStringList &category = QStringList(), | 95 | const QStringList &category = QStringList(), |
95 | const QString &summary = QString::null , | 96 | const QString &summary = QString::null , |
96 | const QString &description = QString::null, | 97 | const QString &description = QString::null, |
97 | ushort progress = 0, | 98 | ushort progress = 0, |
98 | bool hasDate = false, QDate date = QDate::currentDate(), | 99 | bool hasDate = false, QDate date = QDate::currentDate(), |
99 | int uid = 0 /*empty*/ ); | 100 | int uid = 0 /*empty*/ ); |
100 | 101 | ||
101 | OPimTodo( bool completed, int priority, | 102 | OPimTodo( bool completed, int priority, |
102 | const QArray<int>& category, | 103 | const QArray<int>& category, |
103 | const QString& summary = QString::null, | 104 | const QString& summary = QString::null, |
104 | const QString& description = QString::null, | 105 | const QString& description = QString::null, |
105 | ushort progress = 0, | 106 | ushort progress = 0, |
106 | bool hasDate = false, QDate date = QDate::currentDate(), | 107 | bool hasDate = false, QDate date = QDate::currentDate(), |
107 | int uid = 0 /* empty */ ); | 108 | int uid = 0 /* empty */ ); |
108 | 109 | ||
109 | /** Copy c'tor | 110 | /** Copy c'tor |
110 | * | 111 | * |
111 | */ | 112 | */ |
112 | OPimTodo( const OPimTodo & ); | 113 | OPimTodo( const OPimTodo & ); |
113 | 114 | ||
114 | /** | 115 | /** |
115 | *destructor | 116 | *destructor |
116 | */ | 117 | */ |
117 | ~OPimTodo(); | 118 | ~OPimTodo(); |
118 | 119 | ||
119 | /** | 120 | /** |
120 | * Is this event completed? | 121 | * Is this event completed? |
121 | */ | 122 | */ |
122 | bool isCompleted() const; | 123 | bool isCompleted() const; |
123 | 124 | ||
124 | /** | 125 | /** |
125 | * Does this Event have a deadline | 126 | * Does this Event have a deadline |
@@ -237,84 +238,88 @@ class OPimTodo : public OPimRecord | |||
237 | */ | 238 | */ |
238 | void setHasDueDate( bool hasDate ); | 239 | void setHasDueDate( bool hasDate ); |
239 | // FIXME we do not have these for start, completed | 240 | // FIXME we do not have these for start, completed |
240 | // cause we'll use the isNull() of QDate for figuring | 241 | // cause we'll use the isNull() of QDate for figuring |
241 | // out if it's has a date... | 242 | // out if it's has a date... |
242 | // decide what to do here? -zecke | 243 | // decide what to do here? -zecke |
243 | 244 | ||
244 | /** | 245 | /** |
245 | * Set the priority of the Todo | 246 | * Set the priority of the Todo |
246 | */ | 247 | */ |
247 | void setPriority( int priority ); | 248 | void setPriority( int priority ); |
248 | 249 | ||
249 | /** | 250 | /** |
250 | * Set the progress. | 251 | * Set the progress. |
251 | */ | 252 | */ |
252 | void setProgress( ushort progress ); | 253 | void setProgress( ushort progress ); |
253 | 254 | ||
254 | /** | 255 | /** |
255 | * set the end date | 256 | * set the end date |
256 | */ | 257 | */ |
257 | void setDueDate( const QDate& date ); | 258 | void setDueDate( const QDate& date ); |
258 | 259 | ||
259 | /** | 260 | /** |
260 | * set the start date | 261 | * set the start date |
261 | */ | 262 | */ |
262 | void setStartDate( const QDate& date ); | 263 | void setStartDate( const QDate& date ); |
263 | 264 | ||
264 | /** | 265 | /** |
265 | * set the completed date | 266 | * set the completed date |
266 | */ | 267 | */ |
267 | void setCompletedDate( const QDate& date ); | 268 | void setCompletedDate( const QDate& date ); |
268 | 269 | ||
269 | void setRecurrence( const OPimRecurrence& ); | 270 | void setRecurrence( const OPimRecurrence& ); |
270 | 271 | ||
271 | void setDescription( const QString& ); | 272 | void setDescription( const QString& ); |
272 | void setSummary( const QString& ); | 273 | void setSummary( const QString& ); |
273 | 274 | ||
274 | /** | 275 | /** |
275 | * set the state of a Todo | 276 | * set the state of a Todo |
276 | * @param state State what the todo should take | 277 | * @param state State what the todo should take |
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 ); |
307 | OPimTodoPrivate *d; | 312 | OPimTodoPrivate *d; |
308 | OPimTodoData *data; | 313 | OPimTodoData *data; |
309 | 314 | ||
310 | }; | 315 | }; |
311 | 316 | ||
312 | 317 | ||
313 | inline bool OPimTodo::operator!=( const OPimTodo &toDoEvent ) const | 318 | inline bool OPimTodo::operator!=( const OPimTodo &toDoEvent ) const |
314 | { | 319 | { |
315 | return !( *this == toDoEvent ); | 320 | return !( *this == toDoEvent ); |
316 | } | 321 | } |
317 | 322 | ||
318 | } | 323 | } |
319 | 324 | ||
320 | #endif | 325 | #endif |
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 | |||
@@ -5,97 +5,84 @@ | |||
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
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 | #include <qdatetime.h> | 29 | #include <qdatetime.h> |
30 | 30 | ||
31 | #include <qpe/alarmserver.h> | 31 | #include <qpe/alarmserver.h> |
32 | 32 | ||
33 | // #include "otodoaccesssql.h" | 33 | // #include "otodoaccesssql.h" |
34 | #include <opie2/otodoaccess.h> | 34 | #include <opie2/otodoaccess.h> |
35 | #include <opie2/obackendfactory.h> | 35 | #include <opie2/obackendfactory.h> |
36 | #include <opie2/opimresolver.h> | 36 | #include <opie2/opimresolver.h> |
37 | #include <opie2/opimglobal.h> | 37 | #include <opie2/opimglobal.h> |
38 | 38 | ||
39 | namespace Opie { | 39 | namespace Opie { |
40 | OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access ) | 40 | OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access ) |
41 | : QObject(), OPimAccessTemplate<OPimTodo>( end ), m_todoBackEnd( end ) | 41 | : QObject(), OPimAccessTemplate<OPimTodo>( end ), m_todoBackEnd( end ) |
42 | { | 42 | { |
43 | // if (end == 0l ) | 43 | // if (end == 0l ) |
44 | // m_todoBackEnd = new OPimTodoAccessBackendSQL( QString::null); | 44 | // m_todoBackEnd = new OPimTodoAccessBackendSQL( QString::null); |
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 | |||
@@ -1,142 +1,118 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
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 OPIE_TODO_ACCESS_H | 29 | #ifndef OPIE_TODO_ACCESS_H |
30 | #define OPIE_TODO_ACCESS_H | 30 | #define OPIE_TODO_ACCESS_H |
31 | 31 | ||
32 | #include <qobject.h> | 32 | #include <qobject.h> |
33 | #include <qvaluelist.h> | 33 | #include <qvaluelist.h> |
34 | 34 | ||
35 | #include <opie2/opimtodo.h> | 35 | #include <opie2/opimtodo.h> |
36 | #include <opie2/otodoaccessbackend.h> | 36 | #include <opie2/otodoaccessbackend.h> |
37 | #include <opie2/opimaccesstemplate.h> | 37 | #include <opie2/opimaccesstemplate.h> |
38 | 38 | ||
39 | namespace Opie { | 39 | namespace Opie { |
40 | 40 | ||
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 | ||
64 | 62 | ||
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* ); |
130 | void changed( const OPimTodoAccess*, int uid ); | 106 | void changed( const OPimTodoAccess*, int uid ); |
131 | void added( const OPimTodoAccess*, int uid ); | 107 | void added( const OPimTodoAccess*, int uid ); |
132 | void removed( const OPimTodoAccess*, int uid ); | 108 | void removed( const OPimTodoAccess*, int uid ); |
133 | private: | 109 | private: |
134 | int m_cat; | 110 | int m_cat; |
135 | OPimTodoAccessBackend* m_todoBackEnd; | 111 | OPimTodoAccessBackend* m_todoBackEnd; |
136 | class OPimTodoAccessPrivate; | 112 | class OPimTodoAccessPrivate; |
137 | OPimTodoAccessPrivate* d; | 113 | OPimTodoAccessPrivate* d; |
138 | }; | 114 | }; |
139 | 115 | ||
140 | } | 116 | } |
141 | 117 | ||
142 | #endif | 118 | #endif |