34 files changed, 1096 insertions, 192 deletions
diff --git a/libopie2/opiepim/core/core.pro b/libopie2/opiepim/core/core.pro new file mode 100644 index 0000000..dae37f1 --- a/dev/null +++ b/libopie2/opiepim/core/core.pro | |||
@@ -0,0 +1,21 @@ | |||
1 | HEADERS += core/oconversion.h \ | ||
2 | core/opimcache.h \ | ||
3 | core/opimmaintainer.h \ | ||
4 | core/opimresolver.h \ | ||
5 | core/opimstate.h \ | ||
6 | core/opimxref.h \ | ||
7 | core/opimxrefmanager.h \ | ||
8 | core/opimxrefpartner.h \ | ||
9 | core/orecur.h \ | ||
10 | core/otemplatebase.h \ | ||
11 | core/otimezone.h \ | ||
12 | |||
13 | SOURCES += core/oconversion.cpp \ | ||
14 | core/opimmaintainer.cpp \ | ||
15 | core/opimresolver.cpp \ | ||
16 | core/opimstate.cpp \ | ||
17 | core/opimxref.cpp \ | ||
18 | core/opimxrefmanager.cpp \ | ||
19 | core/opimxrefpartner.cpp \ | ||
20 | core/orecur.cpp \ | ||
21 | core/otimezone.cpp \ | ||
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp index 2e3ec1f..f67a40c 100644 --- a/libopie2/opiepim/core/ocontactaccess.cpp +++ b/libopie2/opiepim/core/ocontactaccess.cpp | |||
@@ -1,98 +1,80 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage the Contacts. | 2 | This file is part of the Opie Project |
3 | * | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | * | 5 | .=l. |
6 | * ===================================================================== | 6 | .>+-= |
7 | *This program is free software; you can redistribute it and/or | 7 | _;:, .> :=|. This program is free software; you can |
8 | *modify it under the terms of the GNU Library General Public | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | * License as published by the Free Software Foundation; either | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | * version 2 of the License, or (at your option) any later version. | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | * ===================================================================== | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | * Info: This class could just work with a change in the header-file | 12 | ._= =} : or (at your option) any later version. |
13 | * of the Contact class ! Therefore our libopie only compiles | 13 | .%`+i> _;_. |
14 | * with our version of libqpe | 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 | /* | ||
15 | * ===================================================================== | 30 | * ===================================================================== |
16 | * ToDo: XML-Backend: Automatic reload if something was changed... | 31 | * ToDo: XML-Backend: Automatic reload if something was changed... |
17 | * | 32 | * |
18 | * | 33 | * |
19 | * ===================================================================== | ||
20 | * Version: $Id$ | ||
21 | * ===================================================================== | ||
22 | * History: | ||
23 | * $Log$ | ||
24 | * Revision 1.8 2003/05/08 13:55:09 tille | ||
25 | * search stuff | ||
26 | * and match, toRichText & toShortText in oevent | ||
27 | * | ||
28 | * Revision 1.7 2002/11/13 14:14:51 eilers | ||
29 | * Added sorted for Contacts.. | ||
30 | * | ||
31 | * Revision 1.6 2002/11/01 15:10:42 eilers | ||
32 | * Added regExp-search in database for all fields in a contact. | ||
33 | * | ||
34 | * Revision 1.5 2002/10/16 10:52:40 eilers | ||
35 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | ||
36 | * | ||
37 | * Revision 1.4 2002/10/14 16:21:54 eilers | ||
38 | * Some minor interface updates | ||
39 | * | ||
40 | * Revision 1.3 2002/10/07 17:34:24 eilers | ||
41 | * added OBackendFactory for advanced backend access | ||
42 | * | ||
43 | * Revision 1.2 2002/10/02 16:18:11 eilers | ||
44 | * debugged and seems to work almost perfectly .. | ||
45 | * | ||
46 | * Revision 1.1 2002/09/27 17:11:44 eilers | ||
47 | * Added API for accessing the Contact-Database ! It is compiling, but | ||
48 | * please do not expect that anything is working ! | ||
49 | * I will debug that stuff in the next time .. | ||
50 | * Please read README_COMPILE for compiling ! | ||
51 | * | ||
52 | * | ||
53 | */ | 34 | */ |
54 | 35 | ||
55 | #include "ocontactaccess.h" | 36 | #include "ocontactaccess.h" |
56 | #include "obackendfactory.h" | 37 | #include "obackendfactory.h" |
57 | 38 | ||
58 | #include <qasciidict.h> | 39 | #include <qasciidict.h> |
59 | #include <qdatetime.h> | 40 | #include <qdatetime.h> |
60 | #include <qfile.h> | 41 | #include <qfile.h> |
61 | #include <qregexp.h> | 42 | #include <qregexp.h> |
62 | #include <qlist.h> | 43 | #include <qlist.h> |
63 | #include <qcopchannel_qws.h> | 44 | #include <qcopchannel_qws.h> |
64 | 45 | ||
65 | //#include <qpe/qcopenvelope_qws.h> | 46 | //#include <qpe/qcopenvelope_qws.h> |
66 | #include <qpe/global.h> | 47 | #include <qpe/global.h> |
67 | 48 | ||
68 | #include <errno.h> | 49 | #include <errno.h> |
69 | #include <fcntl.h> | 50 | #include <fcntl.h> |
70 | #include <unistd.h> | 51 | #include <unistd.h> |
71 | #include <stdlib.h> | 52 | #include <stdlib.h> |
72 | 53 | ||
73 | #include "ocontactaccessbackend_xml.h" | 54 | #include <opie2/ocontactaccessbackend_xml.h> |
74 | 55 | ||
56 | namespace Opie { | ||
75 | 57 | ||
76 | OContactAccess::OContactAccess ( const QString appname, const QString , | 58 | OContactAccess::OContactAccess ( const QString appname, const QString , |
77 | OContactAccessBackend* end, bool autosync ): | 59 | OContactAccessBackend* end, bool autosync ): |
78 | OPimAccessTemplate<OContact>( end ) | 60 | OPimAccessTemplate<OContact>( end ) |
79 | { | 61 | { |
80 | /* take care of the backend. If there is no one defined, we | 62 | /* take care of the backend. If there is no one defined, we |
81 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). | 63 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). |
82 | */ | 64 | */ |
83 | if( end == 0 ) { | 65 | if( end == 0 ) { |
84 | qWarning ("Using BackendFactory !"); | 66 | qWarning ("Using BackendFactory !"); |
85 | end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); | 67 | end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); |
86 | } | 68 | } |
87 | // Set backend locally and in template | 69 | // Set backend locally and in template |
88 | m_backEnd = end; | 70 | m_backEnd = end; |
89 | OPimAccessTemplate<OContact>::setBackEnd (end); | 71 | OPimAccessTemplate<OContact>::setBackEnd (end); |
90 | 72 | ||
91 | 73 | ||
92 | /* Connect signal of external db change to function */ | 74 | /* Connect signal of external db change to function */ |
93 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); | 75 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); |
94 | connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), | 76 | connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), |
95 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); | 77 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); |
96 | if ( autosync ){ | 78 | if ( autosync ){ |
97 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); | 79 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); |
98 | connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), | 80 | connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), |
@@ -145,24 +127,26 @@ ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int | |||
145 | return ( ORecordList<OContact>(matchingContacts, this) ); | 127 | return ( ORecordList<OContact>(matchingContacts, this) ); |
146 | } | 128 | } |
147 | 129 | ||
148 | 130 | ||
149 | bool OContactAccess::wasChangedExternally()const | 131 | bool OContactAccess::wasChangedExternally()const |
150 | { | 132 | { |
151 | return ( m_backEnd->wasChangedExternally() ); | 133 | return ( m_backEnd->wasChangedExternally() ); |
152 | } | 134 | } |
153 | 135 | ||
154 | 136 | ||
155 | void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) | 137 | void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) |
156 | { | 138 | { |
157 | if ( msg == "addressbookUpdated()" ){ | 139 | if ( msg == "addressbookUpdated()" ){ |
158 | qWarning ("OContactAccess: Received addressbokUpdated()"); | 140 | qWarning ("OContactAccess: Received addressbokUpdated()"); |
159 | emit signalChanged ( this ); | 141 | emit signalChanged ( this ); |
160 | } else if ( msg == "flush()" ) { | 142 | } else if ( msg == "flush()" ) { |
161 | qWarning ("OContactAccess: Received flush()"); | 143 | qWarning ("OContactAccess: Received flush()"); |
162 | save (); | 144 | save (); |
163 | } else if ( msg == "reload()" ) { | 145 | } else if ( msg == "reload()" ) { |
164 | qWarning ("OContactAccess: Received reload()"); | 146 | qWarning ("OContactAccess: Received reload()"); |
165 | reload (); | 147 | reload (); |
166 | emit signalChanged ( this ); | 148 | emit signalChanged ( this ); |
167 | } | 149 | } |
168 | } | 150 | } |
151 | |||
152 | } | ||
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h index bd6da40..505c87b 100644 --- a/libopie2/opiepim/core/ocontactaccess.h +++ b/libopie2/opiepim/core/ocontactaccess.h | |||
@@ -1,110 +1,72 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage the Contacts. | 2 | This file is part of the Opie Project |
3 | * | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) | 5 | .=l. |
6 | * | 6 | .>+-= |
7 | * ===================================================================== | 7 | _;:, .> :=|. This program is free software; you can |
8 | *This program is free software; you can redistribute it and/or | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | *modify it under the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | * License as published by the Free Software Foundation; | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | * either version 2 of the License, or (at your option) any later | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | * version. | 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 | /* | ||
13 | * ===================================================================== | 30 | * ===================================================================== |
14 | * ToDo: Define enum for query settings | 31 | * ToDo: Define enum for query settings |
15 | * ===================================================================== | 32 | * ===================================================================== |
16 | * Version: $Id$ | ||
17 | * ===================================================================== | ||
18 | * History: | ||
19 | * $Log$ | ||
20 | * Revision 1.10 2003/12/22 10:19:26 eilers | ||
21 | * Finishing implementation of sql-backend for datebook. But I have to | ||
22 | * port the PIM datebook application to use it, before I could debug the | ||
23 | * whole stuff. | ||
24 | * Thus, PIM-Database backend is finished, but highly experimental. And some | ||
25 | * parts are still generic. For instance, the "queryByExample()" methods are | ||
26 | * not (or not fully) implemented. Todo: custom-entries not stored. | ||
27 | * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular | ||
28 | * expression search in the database, which is not supported by sqlite ! | ||
29 | * Therefore we need either an extended sqlite or a workaround which would | ||
30 | * be very slow and memory consuming.. | ||
31 | * | ||
32 | * Revision 1.9 2003/08/01 12:30:16 eilers | ||
33 | * Merging changes from BRANCH_1_0 to HEAD | ||
34 | * | ||
35 | * Revision 1.8.2.1 2003/06/30 14:34:19 eilers | ||
36 | * Patches from Zecke: | ||
37 | * Fixing and cleaning up extraMap handling | ||
38 | * Adding d_ptr for binary compatibility in the future | ||
39 | * | ||
40 | * Revision 1.8 2003/05/08 13:55:09 tille | ||
41 | * search stuff | ||
42 | * and match, toRichText & toShortText in oevent | ||
43 | * | ||
44 | * Revision 1.7 2003/04/13 18:07:10 zecke | ||
45 | * More API doc | ||
46 | * QString -> const QString& | ||
47 | * QString = 0l -> QString::null | ||
48 | * | ||
49 | * Revision 1.6 2003/01/02 14:27:12 eilers | ||
50 | * Improved query by example: Search by date is possible.. First step | ||
51 | * for a today plugin for birthdays.. | ||
52 | * | ||
53 | * Revision 1.5 2002/11/13 14:14:51 eilers | ||
54 | * Added sorted for Contacts.. | ||
55 | * | ||
56 | * Revision 1.4 2002/11/01 15:10:42 eilers | ||
57 | * Added regExp-search in database for all fields in a contact. | ||
58 | * | ||
59 | * Revision 1.3 2002/10/16 10:52:40 eilers | ||
60 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | ||
61 | * | ||
62 | * Revision 1.2 2002/10/14 16:21:54 eilers | ||
63 | * Some minor interface updates | ||
64 | * | ||
65 | * Revision 1.1 2002/09/27 17:11:44 eilers | ||
66 | * Added API for accessing the Contact-Database ! It is compiling, but | ||
67 | * please do not expect that anything is working ! | ||
68 | * I will debug that stuff in the next time .. | ||
69 | * Please read README_COMPILE for compiling ! | ||
70 | * | ||
71 | * ===================================================================== | ||
72 | */ | 33 | */ |
73 | #ifndef _OCONTACTACCESS_H | 34 | #ifndef _OCONTACTACCESS_H |
74 | #define _OCONTACTACCESS_H | 35 | #define _OCONTACTACCESS_H |
75 | 36 | ||
76 | #include <qobject.h> | 37 | #include <qobject.h> |
77 | 38 | ||
78 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
79 | 40 | ||
80 | #include <qvaluelist.h> | 41 | #include <qvaluelist.h> |
81 | #include <qfileinfo.h> | 42 | #include <qfileinfo.h> |
82 | 43 | ||
83 | #include "ocontact.h" | 44 | #include <opie2/ocontact.h> |
84 | #include "ocontactaccessbackend.h" | 45 | #include <opie2/ocontactaccessbackend.h> |
85 | #include "opimaccesstemplate.h" | 46 | #include <opie2/opimaccesstemplate.h> |
86 | 47 | ||
48 | namespace Opie { | ||
87 | /** | 49 | /** |
88 | * Class to access the contacts database. | 50 | * Class to access the contacts database. |
89 | * 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 |
90 | * done by the backend. | 52 | * done by the backend. |
91 | * 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 |
92 | * class is backend independent. | 54 | * class is backend independent. |
93 | * @author Stefan Eilers, Holger Freyther | 55 | * @author Stefan Eilers, Holger Freyther |
94 | * @see OPimAccessTemplate | 56 | * @see OPimAccessTemplate |
95 | */ | 57 | */ |
96 | class OContactAccess: public QObject, public OPimAccessTemplate<OContact> | 58 | class OContactAccess: public QObject, public OPimAccessTemplate<OContact> |
97 | { | 59 | { |
98 | Q_OBJECT | 60 | Q_OBJECT |
99 | 61 | ||
100 | public: | 62 | public: |
101 | /** | 63 | /** |
102 | * Create Database with contacts (addressbook). | 64 | * Create Database with contacts (addressbook). |
103 | * @param appname Name of application which wants access to the database | 65 | * @param appname Name of application which wants access to the database |
104 | * (i.e. "todolist") | 66 | * (i.e. "todolist") |
105 | * @param filename The name of the database file. If not set, the default one | 67 | * @param filename The name of the database file. If not set, the default one |
106 | * is used. | 68 | * is used. |
107 | * @param backend Pointer to an alternative Backend. If not set, we will use | 69 | * @param backend Pointer to an alternative Backend. If not set, we will use |
108 | * the default backend. | 70 | * the default backend. |
109 | * @param handlesync If <b>true</b> the database stores the current state | 71 | * @param handlesync If <b>true</b> the database stores the current state |
110 | * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> | 72 | * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> |
@@ -169,25 +131,28 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact> | |||
169 | signals: | 131 | signals: |
170 | /* Signal is emitted if the database was changed. Therefore | 132 | /* Signal is emitted if the database was changed. Therefore |
171 | * we may need to reload to stay consistent. | 133 | * we may need to reload to stay consistent. |
172 | * @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 |
173 | * 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. |
174 | * @see reload() | 136 | * @see reload() |
175 | */ | 137 | */ |
176 | void signalChanged ( const OContactAccess *which ); | 138 | void signalChanged ( const OContactAccess *which ); |
177 | 139 | ||
178 | 140 | ||
179 | private: | 141 | private: |
180 | // class OContactAccessPrivate; | 142 | // class OContactAccessPrivate; |
181 | // OContactAccessPrivate* d; | 143 | // OContactAccessPrivate* d; |
182 | OContactAccessBackend *m_backEnd; | 144 | OContactAccessBackend *m_backEnd; |
183 | bool m_loading:1; | 145 | bool m_loading:1; |
184 | 146 | ||
185 | private slots: | 147 | private slots: |
186 | void copMessage( const QCString &msg, const QByteArray &data ); | 148 | void copMessage( const QCString &msg, const QByteArray &data ); |
187 | 149 | ||
188 | private: | 150 | private: |
189 | class Private; | 151 | class Private; |
190 | Private *d; | 152 | Private *d; |
191 | 153 | ||
192 | }; | 154 | }; |
155 | |||
156 | } | ||
157 | |||
193 | #endif | 158 | #endif |
diff --git a/libopie2/opiepim/core/oconversion.cpp b/libopie2/opiepim/core/oconversion.cpp index 0d15414..b7eebef 100644 --- a/libopie2/opiepim/core/oconversion.cpp +++ b/libopie2/opiepim/core/oconversion.cpp | |||
@@ -1,41 +1,59 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2003 by Stefan Eilers (eilers.stefan@epost.de) | 2 | This file is part of the Opie Project |
3 | ** | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | ** This file may be distributed and/or modified under the terms of the | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | ** GNU Lesser General Public License version 2 as published by the Free Software | 5 | .=l. |
6 | ** Foundation and appearing in the file LICENSE.GPL included in the | 6 | .>+-= |
7 | ** packaging of this file. | 7 | _;:, .> :=|. This program is free software; you can |
8 | ** | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | ** | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | **********************************************************************/ | 12 | ._= =} : or (at your option) any later version. |
13 | 13 | .%`+i> _;_. | |
14 | #include "oconversion.h" | 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 <opie2/oconversion.h> | ||
15 | #include <qpe/timeconversion.h> | 31 | #include <qpe/timeconversion.h> |
16 | 32 | ||
17 | 33 | ||
34 | namespace Opie { | ||
35 | |||
18 | QString OConversion::dateToString( const QDate &d ) | 36 | QString OConversion::dateToString( const QDate &d ) |
19 | { | 37 | { |
20 | if ( d.isNull() || !d.isValid() ) | 38 | if ( d.isNull() || !d.isValid() ) |
21 | return QString::null; | 39 | return QString::null; |
22 | 40 | ||
23 | // ISO format in year, month, day (YYYYMMDD); e.g. 20021231 | 41 | // ISO format in year, month, day (YYYYMMDD); e.g. 20021231 |
24 | QString year = QString::number( d.year() ); | 42 | QString year = QString::number( d.year() ); |
25 | QString month = QString::number( d.month() ); | 43 | QString month = QString::number( d.month() ); |
26 | month = month.rightJustify( 2, '0' ); | 44 | month = month.rightJustify( 2, '0' ); |
27 | QString day = QString::number( d.day() ); | 45 | QString day = QString::number( d.day() ); |
28 | day = day.rightJustify( 2, '0' ); | 46 | day = day.rightJustify( 2, '0' ); |
29 | 47 | ||
30 | QString str = year + month + day; | 48 | QString str = year + month + day; |
31 | //qDebug( "\tPimContact dateToStr = %s", str.latin1() ); | 49 | //qDebug( "\tPimContact dateToStr = %s", str.latin1() ); |
32 | 50 | ||
33 | return str; | 51 | return str; |
34 | } | 52 | } |
35 | 53 | ||
36 | QDate OConversion::dateFromString( const QString& s ) | 54 | QDate OConversion::dateFromString( const QString& s ) |
37 | { | 55 | { |
38 | QDate date; | 56 | QDate date; |
39 | 57 | ||
40 | if ( s.isEmpty() ) | 58 | if ( s.isEmpty() ) |
41 | return date; | 59 | return date; |
@@ -90,24 +108,25 @@ QString OConversion::dateTimeToString( const QDateTime& dt ) { | |||
90 | hour = hour. rightJustify( 2, '0' ); | 108 | hour = hour. rightJustify( 2, '0' ); |
91 | min = min. rightJustify( 2, '0' ); | 109 | min = min. rightJustify( 2, '0' ); |
92 | sec = sec. rightJustify( 2, '0' ); | 110 | sec = sec. rightJustify( 2, '0' ); |
93 | 111 | ||
94 | QString str = day + month + year + hour + min + sec; | 112 | QString str = day + month + year + hour + min + sec; |
95 | 113 | ||
96 | return str; | 114 | return str; |
97 | } | 115 | } |
98 | QDateTime OConversion::dateTimeFromString( const QString& str) { | 116 | QDateTime OConversion::dateTimeFromString( const QString& str) { |
99 | 117 | ||
100 | if ( str.isEmpty() ) return QDateTime(); | 118 | if ( str.isEmpty() ) return QDateTime(); |
101 | int day = str.mid(0, 2).toInt(); | 119 | int day = str.mid(0, 2).toInt(); |
102 | int month = str.mid(2, 2).toInt(); | 120 | int month = str.mid(2, 2).toInt(); |
103 | int year = str.mid(4, 4).toInt(); | 121 | int year = str.mid(4, 4).toInt(); |
104 | int hour = str.mid(8, 2).toInt(); | 122 | int hour = str.mid(8, 2).toInt(); |
105 | int min = str.mid(10, 2).toInt(); | 123 | int min = str.mid(10, 2).toInt(); |
106 | int sec = str.mid(12, 2).toInt(); | 124 | int sec = str.mid(12, 2).toInt(); |
107 | 125 | ||
108 | QDate date( year, month, day ); | 126 | QDate date( year, month, day ); |
109 | QTime time( hour, min, sec ); | 127 | QTime time( hour, min, sec ); |
110 | QDateTime dt( date, time ); | 128 | QDateTime dt( date, time ); |
111 | return dt; | 129 | return dt; |
112 | } | 130 | } |
113 | 131 | ||
132 | } \ No newline at end of file | ||
diff --git a/libopie2/opiepim/core/oconversion.h b/libopie2/opiepim/core/oconversion.h index 4c0a497..3c4fdf3 100644 --- a/libopie2/opiepim/core/oconversion.h +++ b/libopie2/opiepim/core/oconversion.h | |||
@@ -1,48 +1,62 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | ** | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | .=l. |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | .>+-= |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | _;:, .> :=|. This program is free software; you can |
8 | ** packaging of this file. | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | ** | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ** | 12 | ._= =} : or (at your option) any later version. |
13 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 13 | .%`+i> _;_. |
14 | ** | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | ** Contact info@trolltech.com if any conditions of this licensing are | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | ** not clear to you. | 16 | : .. .:, . . . without even the implied warranty of |
17 | **********************************************************************/ | 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 | */ | ||
18 | 29 | ||
19 | #ifndef __oconversion_h__ | 30 | #ifndef __oconversion_h__ |
20 | #define __oconversion_h__ | 31 | #define __oconversion_h__ |
21 | 32 | ||
22 | /* #include <time.h> */ | 33 | /* #include <time.h> */ |
23 | /* #include <sys/types.h> */ | 34 | /* #include <sys/types.h> */ |
24 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
25 | 36 | ||
26 | /* FIXME namespace? -zecke */ | 37 | namespace Opie { |
38 | |||
27 | class OConversion | 39 | class OConversion |
28 | { | 40 | { |
29 | public: | 41 | public: |
30 | static QString dateToString( const QDate &d ); | 42 | static QString dateToString( const QDate &d ); |
31 | static QDate dateFromString( const QString &datestr ); | 43 | static QDate dateFromString( const QString &datestr ); |
32 | 44 | ||
33 | /** | 45 | /** |
34 | * simple function to store DateTime as string and read from string | 46 | * simple function to store DateTime as string and read from string |
35 | * no timezone changing is done | 47 | * no timezone changing is done |
36 | * DDMMYYYYHHMMSS is the simple format | 48 | * DDMMYYYYHHMMSS is the simple format |
37 | */ | 49 | */ |
38 | static QString dateTimeToString( const QDateTime& ); | 50 | static QString dateTimeToString( const QDateTime& ); |
39 | static QDateTime dateTimeFromString( const QString& ); | 51 | static QDateTime dateTimeFromString( const QString& ); |
40 | 52 | ||
41 | private: | 53 | private: |
42 | class Private; | 54 | class Private; |
43 | Private* d; | 55 | Private* d; |
44 | 56 | ||
45 | }; | 57 | }; |
46 | 58 | ||
59 | } | ||
60 | |||
47 | #endif // __oconversion_h__ | 61 | #endif // __oconversion_h__ |
48 | 62 | ||
diff --git a/libopie2/opiepim/core/odatebookaccess.cpp b/libopie2/opiepim/core/odatebookaccess.cpp index d95fed6..8c527f6 100644 --- a/libopie2/opiepim/core/odatebookaccess.cpp +++ b/libopie2/opiepim/core/odatebookaccess.cpp | |||
@@ -1,27 +1,56 @@ | |||
1 | #include "obackendfactory.h" | 1 | /* |
2 | #include "odatebookaccess.h" | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
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 | #include <opie2/obackendfactory.h> | ||
30 | #include <opie2/odatebookaccess.h> | ||
3 | 31 | ||
32 | namespace Opie { | ||
4 | /** | 33 | /** |
5 | * Simple constructor | 34 | * Simple constructor |
6 | * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation | 35 | * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation |
7 | * will be used! | 36 | * will be used! |
8 | * @param back The backend to be used or 0 for the default backend | 37 | * @param back The backend to be used or 0 for the default backend |
9 | * @param ac What kind of access is intended | 38 | * @param ac What kind of access is intended |
10 | */ | 39 | */ |
11 | ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac ) | 40 | ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac ) |
12 | : OPimAccessTemplate<OEvent>( back ) | 41 | : OPimAccessTemplate<OEvent>( back ) |
13 | { | 42 | { |
14 | if (!back ) | 43 | if (!back ) |
15 | back = OBackendFactory<ODateBookAccessBackend>::Default("datebook", QString::null ); | 44 | back = OBackendFactory<ODateBookAccessBackend>::Default("datebook", QString::null ); |
16 | 45 | ||
17 | m_backEnd = back; | 46 | m_backEnd = back; |
18 | setBackEnd( m_backEnd ); | 47 | setBackEnd( m_backEnd ); |
19 | } | 48 | } |
20 | ODateBookAccess::~ODateBookAccess() { | 49 | ODateBookAccess::~ODateBookAccess() { |
21 | } | 50 | } |
22 | 51 | ||
23 | /** | 52 | /** |
24 | * @return all events available | 53 | * @return all events available |
25 | */ | 54 | */ |
26 | ODateBookAccess::List ODateBookAccess::rawEvents()const { | 55 | ODateBookAccess::List ODateBookAccess::rawEvents()const { |
27 | QArray<int> ints = m_backEnd->rawEvents(); | 56 | QArray<int> ints = m_backEnd->rawEvents(); |
@@ -58,24 +87,26 @@ ODateBookAccess::List ODateBookAccess::nonRepeats()const { | |||
58 | OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) const { | 87 | OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) const { |
59 | return m_backEnd->effectiveEvents( from, to ); | 88 | return m_backEnd->effectiveEvents( from, to ); |
60 | } | 89 | } |
61 | /** | 90 | /** |
62 | * @return all events at a given datetime | 91 | * @return all events at a given datetime |
63 | */ | 92 | */ |
64 | OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) const { | 93 | OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) const { |
65 | return m_backEnd->effectiveEvents( start ); | 94 | return m_backEnd->effectiveEvents( start ); |
66 | } | 95 | } |
67 | 96 | ||
68 | /** | 97 | /** |
69 | * @return non repeating dates in the time span between from and to | 98 | * @return non repeating dates in the time span between from and to |
70 | * @param from Include all events from... | 99 | * @param from Include all events from... |
71 | * @param to Include all events to... | 100 | * @param to Include all events to... |
72 | */ | 101 | */ |
73 | OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const { | 102 | OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const { |
74 | return m_backEnd->effectiveNonRepeatingEvents( from, to ); | 103 | return m_backEnd->effectiveNonRepeatingEvents( from, to ); |
75 | } | 104 | } |
76 | /** | 105 | /** |
77 | * @return all non repeating events at a given datetime | 106 | * @return all non repeating events at a given datetime |
78 | */ | 107 | */ |
79 | OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const { | 108 | OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const { |
80 | return m_backEnd->effectiveNonRepeatingEvents( start ); | 109 | return m_backEnd->effectiveNonRepeatingEvents( start ); |
81 | } | 110 | } |
111 | |||
112 | } | ||
diff --git a/libopie2/opiepim/core/odatebookaccess.h b/libopie2/opiepim/core/odatebookaccess.h index 62196da..38dc754 100644 --- a/libopie2/opiepim/core/odatebookaccess.h +++ b/libopie2/opiepim/core/odatebookaccess.h | |||
@@ -1,44 +1,75 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
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 | */ | ||
1 | #ifndef OPIE_DATE_BOOK_ACCESS_H | 29 | #ifndef OPIE_DATE_BOOK_ACCESS_H |
2 | #define OPIE_DATE_BOOK_ACCESS_H | 30 | #define OPIE_DATE_BOOK_ACCESS_H |
3 | 31 | ||
4 | #include "odatebookaccessbackend.h" | 32 | #include "odatebookaccessbackend.h" |
5 | #include "opimaccesstemplate.h" | 33 | #include "opimaccesstemplate.h" |
6 | 34 | ||
7 | #include "oevent.h" | 35 | #include <opie2/oevent.h> |
8 | 36 | ||
37 | namespace Opie { | ||
9 | /** | 38 | /** |
10 | * This is the object orientated datebook database. It'll use OBackendFactory | 39 | * This is the object orientated datebook database. It'll use OBackendFactory |
11 | * to query for a backend. | 40 | * to query for a backend. |
12 | * All access to the datebook should be done via this class. | 41 | * All access to the datebook should be done via this class. |
13 | * 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 |
14 | * destructing and creating the object | 43 | * destructing and creating the object |
15 | * | 44 | * |
16 | * @author Holger Freyther, Stefan Eilers | 45 | * @author Holger Freyther, Stefan Eilers |
17 | */ | 46 | */ |
18 | class ODateBookAccess : public OPimAccessTemplate<OEvent> { | 47 | class ODateBookAccess : public OPimAccessTemplate<OEvent> { |
19 | public: | 48 | public: |
20 | ODateBookAccess( ODateBookAccessBackend* = 0l, enum Access acc = Random ); | 49 | ODateBookAccess( ODateBookAccessBackend* = 0l, enum Access acc = Random ); |
21 | ~ODateBookAccess(); | 50 | ~ODateBookAccess(); |
22 | 51 | ||
23 | /* return all events */ | 52 | /* return all events */ |
24 | List rawEvents()const; | 53 | List rawEvents()const; |
25 | 54 | ||
26 | /* return repeating events */ | 55 | /* return repeating events */ |
27 | List rawRepeats()const; | 56 | List rawRepeats()const; |
28 | 57 | ||
29 | /* return non repeating events */ | 58 | /* return non repeating events */ |
30 | List nonRepeats()const; | 59 | List nonRepeats()const; |
31 | 60 | ||
32 | /* return non repeating events (from,to) */ | 61 | /* return non repeating events (from,to) */ |
33 | OEffectiveEvent::ValueList effectiveEvents( const QDate& from, const QDate& to ) const; | 62 | OEffectiveEvent::ValueList effectiveEvents( const QDate& from, const QDate& to ) const; |
34 | OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start ) const; | 63 | OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start ) const; |
35 | OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const; | 64 | OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const; |
36 | OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start ) const; | 65 | OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start ) const; |
37 | 66 | ||
38 | private: | 67 | private: |
39 | ODateBookAccessBackend* m_backEnd; | 68 | ODateBookAccessBackend* m_backEnd; |
40 | class Private; | 69 | class Private; |
41 | Private* d; | 70 | Private* d; |
42 | }; | 71 | }; |
43 | 72 | ||
73 | } | ||
74 | |||
44 | #endif | 75 | #endif |
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index ecbeb68..5826cbc 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h | |||
@@ -1,35 +1,65 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H | 29 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H |
2 | #define OPIE_PIM_ACCESS_TEMPLATE_H | 30 | #define OPIE_PIM_ACCESS_TEMPLATE_H |
3 | 31 | ||
4 | #include <qarray.h> | 32 | #include <qarray.h> |
5 | 33 | ||
6 | #include <opie/opimrecord.h> | 34 | #include <opie2/opimrecord.h> |
7 | #include <opie/opimaccessbackend.h> | 35 | #include <opie2/opimaccessbackend.h> |
8 | #include <opie/orecordlist.h> | 36 | #include <opie2/orecordlist.h> |
9 | 37 | ||
10 | #include "opimcache.h" | 38 | #include <opie2/opimcache.h> |
11 | #include "otemplatebase.h" | 39 | #include <opie2/otemplatebase.h> |
40 | |||
41 | namespace Opie { | ||
12 | 42 | ||
13 | class OPimAccessTemplatePrivate; | 43 | class OPimAccessTemplatePrivate; |
14 | /** | 44 | /** |
15 | * Thats the frontend to our OPIE PIM | 45 | * Thats the frontend to our OPIE PIM |
16 | * Library. Either you want to use it's | 46 | * Library. Either you want to use it's |
17 | * interface or you want to implement | 47 | * interface or you want to implement |
18 | * your own Access lib | 48 | * your own Access lib |
19 | * Just create a OPimRecord and inherit from | 49 | * Just create a OPimRecord and inherit from |
20 | * the plugins | 50 | * the plugins |
21 | */ | 51 | */ |
22 | 52 | ||
23 | template <class T = OPimRecord > | 53 | template <class T = OPimRecord > |
24 | class OPimAccessTemplate : public OTemplateBase<T> { | 54 | class OPimAccessTemplate : public OTemplateBase<T> { |
25 | public: | 55 | public: |
26 | enum Access { | 56 | enum Access { |
27 | Random = 0, | 57 | Random = 0, |
28 | SortedAccess | 58 | SortedAccess |
29 | }; | 59 | }; |
30 | typedef ORecordList<T> List; | 60 | typedef ORecordList<T> List; |
31 | typedef OPimAccessBackend<T> BackEnd; | 61 | typedef OPimAccessBackend<T> BackEnd; |
32 | typedef OPimCache<T> Cache; | 62 | typedef OPimCache<T> Cache; |
33 | 63 | ||
34 | /** | 64 | /** |
35 | * c'tor BackEnd | 65 | * c'tor BackEnd |
@@ -278,25 +308,28 @@ typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { | |||
278 | } | 308 | } |
279 | template <class T> | 309 | template <class T> |
280 | bool OPimAccessTemplate<T>::wasChangedExternally()const { | 310 | bool OPimAccessTemplate<T>::wasChangedExternally()const { |
281 | return false; | 311 | return false; |
282 | } | 312 | } |
283 | template <class T> | 313 | template <class T> |
284 | void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) { | 314 | void OPimAccessTemplate<T>::setBackEnd( BackEnd* end ) { |
285 | m_backEnd = end; | 315 | m_backEnd = end; |
286 | if (m_backEnd ) | 316 | if (m_backEnd ) |
287 | m_backEnd->setFrontend( this ); | 317 | m_backEnd->setFrontend( this ); |
288 | } | 318 | } |
289 | template <class T> | 319 | template <class T> |
290 | void OPimAccessTemplate<T>::cache( const T& t ) const{ | 320 | void OPimAccessTemplate<T>::cache( const T& t ) const{ |
291 | /* hacky we need to work around the const*/ | 321 | /* hacky we need to work around the const*/ |
292 | ((OPimAccessTemplate<T>*)this)->m_cache.add( t ); | 322 | ((OPimAccessTemplate<T>*)this)->m_cache.add( t ); |
293 | } | 323 | } |
294 | template <class T> | 324 | template <class T> |
295 | void OPimAccessTemplate<T>::setSaneCacheSize( int size ) { | 325 | void OPimAccessTemplate<T>::setSaneCacheSize( int size ) { |
296 | m_cache.setSize( size ); | 326 | m_cache.setSize( size ); |
297 | } | 327 | } |
298 | template <class T> | 328 | template <class T> |
299 | void OPimAccessTemplate<T>::setReadAhead( uint count ) { | 329 | void OPimAccessTemplate<T>::setReadAhead( uint count ) { |
300 | m_backEnd->setReadAhead( count ); | 330 | m_backEnd->setReadAhead( count ); |
301 | } | 331 | } |
332 | |||
333 | } | ||
334 | |||
302 | #endif | 335 | #endif |
diff --git a/libopie2/opiepim/core/opimcache.h b/libopie2/opiepim/core/opimcache.h index 7f7cff5..e70a910 100644 --- a/libopie2/opiepim/core/opimcache.h +++ b/libopie2/opiepim/core/opimcache.h | |||
@@ -1,31 +1,60 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #ifndef OPIE_PIM_CACHE_H | 29 | #ifndef OPIE_PIM_CACHE_H |
2 | #define OPIE_PIM_CACHE_H | 30 | #define OPIE_PIM_CACHE_H |
3 | 31 | ||
4 | #include <qintcache.h> | 32 | #include <qintcache.h> |
5 | 33 | ||
6 | #include "opimrecord.h" | 34 | #include <opie2/opimrecord.h> |
7 | 35 | ||
36 | namespace Opie { | ||
8 | class OPimCacheItemPrivate; | 37 | class OPimCacheItemPrivate; |
9 | 38 | ||
10 | template <class T = OPimRecord> | 39 | template <class T = OPimRecord> |
11 | class OPimCacheItem { | 40 | class OPimCacheItem { |
12 | public: | 41 | public: |
13 | OPimCacheItem( const T& t = T() ); | 42 | OPimCacheItem( const T& t = T() ); |
14 | OPimCacheItem( const OPimCacheItem& ); | 43 | OPimCacheItem( const OPimCacheItem& ); |
15 | ~OPimCacheItem(); | 44 | ~OPimCacheItem(); |
16 | 45 | ||
17 | OPimCacheItem &operator=( const OPimCacheItem& ); | 46 | OPimCacheItem &operator=( const OPimCacheItem& ); |
18 | 47 | ||
19 | T record()const; | 48 | T record()const; |
20 | void setRecord( const T& ); | 49 | void setRecord( const T& ); |
21 | private: | 50 | private: |
22 | T m_t; | 51 | T m_t; |
23 | OPimCacheItemPrivate *d; | 52 | OPimCacheItemPrivate *d; |
24 | }; | 53 | }; |
25 | 54 | ||
26 | 55 | ||
27 | class OPimCachePrivate; | 56 | class OPimCachePrivate; |
28 | /** | 57 | /** |
29 | * OPimCache for caching the items | 58 | * OPimCache for caching the items |
30 | * We support adding, removing | 59 | * We support adding, removing |
31 | * and finding | 60 | * and finding |
@@ -107,25 +136,27 @@ T OPimCache<T>::find(int uid )const { | |||
107 | template <class T> | 136 | template <class T> |
108 | void OPimCache<T>::add( const T& t ) { | 137 | void OPimCache<T>::add( const T& t ) { |
109 | Item* it = 0l; | 138 | Item* it = 0l; |
110 | it = m_cache.find(t.uid(), FALSE ); | 139 | it = m_cache.find(t.uid(), FALSE ); |
111 | 140 | ||
112 | if (it ) | 141 | if (it ) |
113 | it->setRecord( t ); | 142 | it->setRecord( t ); |
114 | 143 | ||
115 | it = new Item( t ); | 144 | it = new Item( t ); |
116 | if (!m_cache.insert( t.uid(), it ) ) | 145 | if (!m_cache.insert( t.uid(), it ) ) |
117 | delete it; | 146 | delete it; |
118 | } | 147 | } |
119 | template <class T> | 148 | template <class T> |
120 | void OPimCache<T>::remove( int uid ) { | 149 | void OPimCache<T>::remove( int uid ) { |
121 | m_cache.remove( uid ); | 150 | m_cache.remove( uid ); |
122 | } | 151 | } |
123 | template <class T> | 152 | template <class T> |
124 | void OPimCache<T>::replace( const T& t) { | 153 | void OPimCache<T>::replace( const T& t) { |
125 | Item *it = m_cache.find( t.uid() ); | 154 | Item *it = m_cache.find( t.uid() ); |
126 | if ( it ) { | 155 | if ( it ) { |
127 | it->setRecord( t ); | 156 | it->setRecord( t ); |
128 | } | 157 | } |
129 | } | 158 | } |
130 | 159 | ||
160 | } | ||
161 | |||
131 | #endif | 162 | #endif |
diff --git a/libopie2/opiepim/core/opimmaintainer.cpp b/libopie2/opiepim/core/opimmaintainer.cpp index 92cb25a..b2eff12 100644 --- a/libopie2/opiepim/core/opimmaintainer.cpp +++ b/libopie2/opiepim/core/opimmaintainer.cpp | |||
@@ -1,37 +1,69 @@ | |||
1 | #include "opimmaintainer.h" | 1 | /* |
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
2 | 29 | ||
30 | #include <opie2/opimmaintainer.h> | ||
31 | |||
32 | namespace Opie { | ||
3 | OPimMaintainer::OPimMaintainer( int mode, int uid ) | 33 | OPimMaintainer::OPimMaintainer( int mode, int uid ) |
4 | : m_mode(mode), m_uid(uid ) | 34 | : m_mode(mode), m_uid(uid ) |
5 | {} | 35 | {} |
6 | OPimMaintainer::~OPimMaintainer() { | 36 | OPimMaintainer::~OPimMaintainer() { |
7 | } | 37 | } |
8 | OPimMaintainer::OPimMaintainer( const OPimMaintainer& main ) { | 38 | OPimMaintainer::OPimMaintainer( const OPimMaintainer& main ) { |
9 | *this = main; | 39 | *this = main; |
10 | } | 40 | } |
11 | OPimMaintainer &OPimMaintainer::operator=( const OPimMaintainer& main ) { | 41 | OPimMaintainer &OPimMaintainer::operator=( const OPimMaintainer& main ) { |
12 | m_mode = main.m_mode; | 42 | m_mode = main.m_mode; |
13 | m_uid = main.m_uid; | 43 | m_uid = main.m_uid; |
14 | 44 | ||
15 | return *this; | 45 | return *this; |
16 | } | 46 | } |
17 | bool OPimMaintainer::operator==( const OPimMaintainer& main ) { | 47 | bool OPimMaintainer::operator==( const OPimMaintainer& main ) { |
18 | if (m_mode != main.m_mode ) return false; | 48 | if (m_mode != main.m_mode ) return false; |
19 | if (m_uid != main.m_uid ) return false; | 49 | if (m_uid != main.m_uid ) return false; |
20 | 50 | ||
21 | return true; | 51 | return true; |
22 | } | 52 | } |
23 | bool OPimMaintainer::operator!=( const OPimMaintainer& main ) { | 53 | bool OPimMaintainer::operator!=( const OPimMaintainer& main ) { |
24 | return !(*this == main ); | 54 | return !(*this == main ); |
25 | } | 55 | } |
26 | int OPimMaintainer::mode()const { | 56 | int OPimMaintainer::mode()const { |
27 | return m_mode; | 57 | return m_mode; |
28 | } | 58 | } |
29 | int OPimMaintainer::uid()const { | 59 | int OPimMaintainer::uid()const { |
30 | return m_uid; | 60 | return m_uid; |
31 | } | 61 | } |
32 | void OPimMaintainer::setMode( int mo) { | 62 | void OPimMaintainer::setMode( int mo) { |
33 | m_mode = mo; | 63 | m_mode = mo; |
34 | } | 64 | } |
35 | void OPimMaintainer::setUid( int uid ) { | 65 | void OPimMaintainer::setUid( int uid ) { |
36 | m_uid = uid; | 66 | m_uid = uid; |
37 | } | 67 | } |
68 | |||
69 | } | ||
diff --git a/libopie2/opiepim/core/opimmaintainer.h b/libopie2/opiepim/core/opimmaintainer.h index 793d066..46bc9d2 100644 --- a/libopie2/opiepim/core/opimmaintainer.h +++ b/libopie2/opiepim/core/opimmaintainer.h | |||
@@ -1,40 +1,71 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #ifndef OPIE_PIM_MAINTAINER_H | 29 | #ifndef OPIE_PIM_MAINTAINER_H |
2 | #define OPIE_PIM_MAINTAINER_H | 30 | #define OPIE_PIM_MAINTAINER_H |
3 | 31 | ||
4 | #include <qstring.h> | 32 | #include <qstring.h> |
5 | 33 | ||
34 | namespace Opie { | ||
6 | /** | 35 | /** |
7 | * Who maintains what? | 36 | * Who maintains what? |
8 | */ | 37 | */ |
9 | class OPimMaintainer { | 38 | class OPimMaintainer { |
10 | public: | 39 | public: |
11 | enum Mode { Undefined = -1, | 40 | enum Mode { Undefined = -1, |
12 | Nothing = 0, | 41 | Nothing = 0, |
13 | Responsible, | 42 | Responsible, |
14 | DoneBy, | 43 | DoneBy, |
15 | Coordinating, | 44 | Coordinating, |
16 | }; | 45 | }; |
17 | OPimMaintainer( int mode = Undefined, int uid = 0); | 46 | OPimMaintainer( int mode = Undefined, int uid = 0); |
18 | OPimMaintainer( const OPimMaintainer& ); | 47 | OPimMaintainer( const OPimMaintainer& ); |
19 | ~OPimMaintainer(); | 48 | ~OPimMaintainer(); |
20 | 49 | ||
21 | OPimMaintainer &operator=( const OPimMaintainer& ); | 50 | OPimMaintainer &operator=( const OPimMaintainer& ); |
22 | bool operator==( const OPimMaintainer& ); | 51 | bool operator==( const OPimMaintainer& ); |
23 | bool operator!=( const OPimMaintainer& ); | 52 | bool operator!=( const OPimMaintainer& ); |
24 | 53 | ||
25 | 54 | ||
26 | int mode()const; | 55 | int mode()const; |
27 | int uid()const; | 56 | int uid()const; |
28 | 57 | ||
29 | void setMode( int mode ); | 58 | void setMode( int mode ); |
30 | void setUid( int uid ); | 59 | void setUid( int uid ); |
31 | 60 | ||
32 | private: | 61 | private: |
33 | int m_mode; | 62 | int m_mode; |
34 | int m_uid; | 63 | int m_uid; |
35 | class Private; | 64 | class Private; |
36 | Private *d; | 65 | Private *d; |
37 | 66 | ||
38 | }; | 67 | }; |
39 | 68 | ||
69 | } | ||
70 | |||
40 | #endif | 71 | #endif |
diff --git a/libopie2/opiepim/core/opimnotify.cpp b/libopie2/opiepim/core/opimnotify.cpp index af5514b..c61f9da 100644 --- a/libopie2/opiepim/core/opimnotify.cpp +++ b/libopie2/opiepim/core/opimnotify.cpp | |||
@@ -1,27 +1,57 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #include <qshared.h> | 29 | #include <qshared.h> |
2 | 30 | ||
3 | #include "opimnotify.h" | 31 | #include <opie2/opimnotify.h> |
32 | |||
33 | namespace Opie { | ||
4 | 34 | ||
5 | struct OPimNotify::Data : public QShared { | 35 | struct OPimNotify::Data : public QShared { |
6 | Data() : QShared(),dur(-1),parent(0) { | 36 | Data() : QShared(),dur(-1),parent(0) { |
7 | 37 | ||
8 | } | 38 | } |
9 | QDateTime start; | 39 | QDateTime start; |
10 | int dur; | 40 | int dur; |
11 | QString application; | 41 | QString application; |
12 | int parent; | 42 | int parent; |
13 | }; | 43 | }; |
14 | 44 | ||
15 | OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) { | 45 | OPimNotify::OPimNotify( const QDateTime& start, int duration, int parent ) { |
16 | data = new Data; | 46 | data = new Data; |
17 | data->start = start; | 47 | data->start = start; |
18 | data->dur = duration; | 48 | data->dur = duration; |
19 | data->parent = parent; | 49 | data->parent = parent; |
20 | } | 50 | } |
21 | OPimNotify::OPimNotify( const OPimNotify& noti) | 51 | OPimNotify::OPimNotify( const OPimNotify& noti) |
22 | : data( noti.data ) | 52 | : data( noti.data ) |
23 | { | 53 | { |
24 | data->ref(); | 54 | data->ref(); |
25 | } | 55 | } |
26 | OPimNotify::~OPimNotify() { | 56 | OPimNotify::~OPimNotify() { |
27 | if ( data->deref() ) { | 57 | if ( data->deref() ) { |
@@ -204,24 +234,25 @@ bool OPimReminder::operator==( const OPimReminder& rem) { | |||
204 | } | 234 | } |
205 | QString OPimReminder::type()const { | 235 | QString OPimReminder::type()const { |
206 | return QString::fromLatin1("OPimReminder"); | 236 | return QString::fromLatin1("OPimReminder"); |
207 | } | 237 | } |
208 | int OPimReminder::recordUid()const { | 238 | int OPimReminder::recordUid()const { |
209 | return data->record; | 239 | return data->record; |
210 | } | 240 | } |
211 | void OPimReminder::setRecordUid( int uid ) { | 241 | void OPimReminder::setRecordUid( int uid ) { |
212 | copyIntern(); | 242 | copyIntern(); |
213 | data->record = uid; | 243 | data->record = uid; |
214 | } | 244 | } |
215 | void OPimReminder::deref() { | 245 | void OPimReminder::deref() { |
216 | if ( data->deref() ) { | 246 | if ( data->deref() ) { |
217 | delete data; | 247 | delete data; |
218 | data = 0l; | 248 | data = 0l; |
219 | } | 249 | } |
220 | } | 250 | } |
221 | void OPimReminder::copyIntern() { | 251 | void OPimReminder::copyIntern() { |
222 | if ( data->count != 1 ) { | 252 | if ( data->count != 1 ) { |
223 | Data* da = new Data; | 253 | Data* da = new Data; |
224 | da->record = data->record; | 254 | da->record = data->record; |
225 | data = da; | 255 | data = da; |
226 | } | 256 | } |
227 | } | 257 | } |
258 | } | ||
diff --git a/libopie2/opiepim/core/opimnotify.h b/libopie2/opiepim/core/opimnotify.h index 58417db..fed3970 100644 --- a/libopie2/opiepim/core/opimnotify.h +++ b/libopie2/opiepim/core/opimnotify.h | |||
@@ -1,30 +1,60 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #ifndef OPIE_PIM_NOTIFY_H | 29 | #ifndef OPIE_PIM_NOTIFY_H |
2 | #define OPIE_PIM_NOTIFY_H | 30 | #define OPIE_PIM_NOTIFY_H |
3 | 31 | ||
4 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
5 | #include <qvaluelist.h> | 33 | #include <qvaluelist.h> |
6 | 34 | ||
35 | |||
36 | namespace Opie { | ||
7 | /** | 37 | /** |
8 | * This is the base class of Notifiers. Possible | 38 | * This is the base class of Notifiers. Possible |
9 | * notifiers would be Alarms, Reminders | 39 | * notifiers would be Alarms, Reminders |
10 | * What they share is that they have | 40 | * What they share is that they have |
11 | * A DateTime, Type, Duration | 41 | * A DateTime, Type, Duration |
12 | * This is what this base class takes care of | 42 | * This is what this base class takes care of |
13 | * on top of that it's shared | 43 | * on top of that it's shared |
14 | */ | 44 | */ |
15 | /* | 45 | /* |
16 | * TALK to eilers: have a class OPimDuration which sets the Duration | 46 | * TALK to eilers: have a class OPimDuration which sets the Duration |
17 | * given on the Due/Start Date? -zecke | 47 | * given on the Due/Start Date? -zecke |
18 | * discuss: do we need a uid for the notify? -zecke | 48 | * discuss: do we need a uid for the notify? -zecke |
19 | */ | 49 | */ |
20 | class OPimNotify { | 50 | class OPimNotify { |
21 | public: | 51 | public: |
22 | typedef QValueList<OPimNotify> ValueList; | 52 | typedef QValueList<OPimNotify> ValueList; |
23 | OPimNotify( const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 ); | 53 | OPimNotify( const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 ); |
24 | OPimNotify( const OPimNotify& ); | 54 | OPimNotify( const OPimNotify& ); |
25 | virtual ~OPimNotify(); | 55 | virtual ~OPimNotify(); |
26 | 56 | ||
27 | OPimNotify &operator=(const OPimNotify& ); | 57 | OPimNotify &operator=(const OPimNotify& ); |
28 | bool operator==( const OPimNotify& ); | 58 | bool operator==( const OPimNotify& ); |
29 | 59 | ||
30 | virtual QString type()const = 0; | 60 | virtual QString type()const = 0; |
@@ -120,25 +150,27 @@ public: | |||
120 | OPimReminder( const OPimReminder& ); | 150 | OPimReminder( const OPimReminder& ); |
121 | OPimReminder &operator=(const OPimReminder& ); | 151 | OPimReminder &operator=(const OPimReminder& ); |
122 | 152 | ||
123 | QString type()const; | 153 | QString type()const; |
124 | 154 | ||
125 | bool operator==( const OPimReminder& ); | 155 | bool operator==( const OPimReminder& ); |
126 | 156 | ||
127 | /** | 157 | /** |
128 | * the uid of the alarm | 158 | * the uid of the alarm |
129 | * inside the 'datebook' application | 159 | * inside the 'datebook' application |
130 | */ | 160 | */ |
131 | int recordUid()const; | 161 | int recordUid()const; |
132 | void setRecordUid( int uid ); | 162 | void setRecordUid( int uid ); |
133 | 163 | ||
134 | private: | 164 | private: |
135 | void deref(); | 165 | void deref(); |
136 | void copyIntern(); | 166 | void copyIntern(); |
137 | 167 | ||
138 | struct Data; | 168 | struct Data; |
139 | Data* data; | 169 | Data* data; |
140 | class Private; | 170 | class Private; |
141 | Private *d; | 171 | Private *d; |
142 | }; | 172 | }; |
143 | 173 | ||
174 | } | ||
175 | |||
144 | #endif | 176 | #endif |
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp index d6f0ead..1771fad 100644 --- a/libopie2/opiepim/core/opimnotifymanager.cpp +++ b/libopie2/opiepim/core/opimnotifymanager.cpp | |||
@@ -1,30 +1,60 @@ | |||
1 | #include "opimnotifymanager.h" | 1 | /* |
2 | 2 | This file is part of the Opie Project | |
3 | #include "oconversion.h" | 3 | Copyright (C) The Main Author <main-author@whereever.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 | #include <opie2/opimnotifymanager.h> | ||
30 | |||
31 | #include <opie2/oconversion.h> | ||
4 | 32 | ||
5 | #include <qstringlist.h> | 33 | #include <qstringlist.h> |
6 | 34 | ||
35 | namespace Opie { | ||
36 | |||
7 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) | 37 | OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al) |
8 | : m_rem( rem ), m_al( al ) | 38 | : m_rem( rem ), m_al( al ) |
9 | {} | 39 | {} |
10 | OPimNotifyManager::~OPimNotifyManager() { | 40 | OPimNotifyManager::~OPimNotifyManager() { |
11 | } | 41 | } |
12 | /* use static_cast and type instead of dynamic... */ | 42 | /* use static_cast and type instead of dynamic... */ |
13 | void OPimNotifyManager::add( const OPimNotify& noti) { | 43 | void OPimNotifyManager::add( const OPimNotify& noti) { |
14 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { | 44 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { |
15 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); | 45 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); |
16 | m_rem.append( rem ); | 46 | m_rem.append( rem ); |
17 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { | 47 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { |
18 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); | 48 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); |
19 | m_al.append( al ); | 49 | m_al.append( al ); |
20 | } | 50 | } |
21 | } | 51 | } |
22 | void OPimNotifyManager::remove( const OPimNotify& noti) { | 52 | void OPimNotifyManager::remove( const OPimNotify& noti) { |
23 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { | 53 | if ( noti.type() == QString::fromLatin1("OPimReminder") ) { |
24 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); | 54 | const OPimReminder& rem = static_cast<const OPimReminder&>(noti); |
25 | m_rem.remove( rem ); | 55 | m_rem.remove( rem ); |
26 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { | 56 | }else if ( noti.type() == QString::fromLatin1("OPimAlarm") ) { |
27 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); | 57 | const OPimAlarm& al = static_cast<const OPimAlarm&>(noti); |
28 | m_al.remove( al ); | 58 | m_al.remove( al ); |
29 | } | 59 | } |
30 | } | 60 | } |
@@ -139,24 +169,25 @@ QString OPimNotifyManager::remindersToString() const | |||
139 | void OPimNotifyManager::alarmsFromString( const QString& str ) | 169 | void OPimNotifyManager::alarmsFromString( const QString& str ) |
140 | { | 170 | { |
141 | QStringList als = QStringList::split(";", str ); | 171 | QStringList als = QStringList::split(";", str ); |
142 | for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { | 172 | for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { |
143 | QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty | 173 | QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty |
144 | qWarning("alarm: %s", alarm.join("___").latin1() ); | 174 | qWarning("alarm: %s", alarm.join("___").latin1() ); |
145 | qWarning("alarm[0]: %s %s", alarm[0].latin1(), | 175 | qWarning("alarm[0]: %s %s", alarm[0].latin1(), |
146 | OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); | 176 | OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); |
147 | OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), | 177 | OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), |
148 | alarm[1].toInt() ); | 178 | alarm[1].toInt() ); |
149 | add( al ); | 179 | add( al ); |
150 | } | 180 | } |
151 | } | 181 | } |
152 | 182 | ||
153 | void OPimNotifyManager::remindersFromString( const QString& str ) | 183 | void OPimNotifyManager::remindersFromString( const QString& str ) |
154 | { | 184 | { |
155 | 185 | ||
156 | QStringList rems = QStringList::split(";", str ); | 186 | QStringList rems = QStringList::split(";", str ); |
157 | for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { | 187 | for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { |
158 | OPimReminder rem( (*it).toInt() ); | 188 | OPimReminder rem( (*it).toInt() ); |
159 | add( rem ); | 189 | add( rem ); |
160 | } | 190 | } |
161 | 191 | ||
162 | } | 192 | } |
193 | } | ||
diff --git a/libopie2/opiepim/core/opimnotifymanager.h b/libopie2/opiepim/core/opimnotifymanager.h index f3c22f9..0272e5d 100644 --- a/libopie2/opiepim/core/opimnotifymanager.h +++ b/libopie2/opiepim/core/opimnotifymanager.h | |||
@@ -1,31 +1,60 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #ifndef OPIE_PIM_NOTIFY_MANAGER_H | 29 | #ifndef OPIE_PIM_NOTIFY_MANAGER_H |
2 | #define OPIE_PIM_NOTIFY_MANAGER_H | 30 | #define OPIE_PIM_NOTIFY_MANAGER_H |
3 | 31 | ||
4 | #include <qvaluelist.h> | 32 | #include <qvaluelist.h> |
5 | 33 | ||
6 | #include <opie/opimnotify.h> | 34 | #include <opie2/opimnotify.h> |
7 | 35 | ||
36 | namespace Opie { | ||
8 | /** | 37 | /** |
9 | * The notify manager keeps track of the Notifiers.... | 38 | * The notify manager keeps track of the Notifiers.... |
10 | */ | 39 | */ |
11 | class OPimNotifyManager { | 40 | class OPimNotifyManager { |
12 | public: | 41 | public: |
13 | typedef QValueList<OPimReminder> Reminders; | 42 | typedef QValueList<OPimReminder> Reminders; |
14 | typedef QValueList<OPimAlarm> Alarms; | 43 | typedef QValueList<OPimAlarm> Alarms; |
15 | OPimNotifyManager( const Reminders& rems = Reminders(), const Alarms& alarms = Alarms() ); | 44 | OPimNotifyManager( const Reminders& rems = Reminders(), const Alarms& alarms = Alarms() ); |
16 | ~OPimNotifyManager(); | 45 | ~OPimNotifyManager(); |
17 | 46 | ||
18 | /* we will cast it for you ;) */ | 47 | /* we will cast it for you ;) */ |
19 | void add( const OPimNotify& ); | 48 | void add( const OPimNotify& ); |
20 | void remove( const OPimNotify& ); | 49 | void remove( const OPimNotify& ); |
21 | /* replaces all with this one! */ | 50 | /* replaces all with this one! */ |
22 | void replace( const OPimNotify& ); | 51 | void replace( const OPimNotify& ); |
23 | 52 | ||
24 | Reminders reminders()const; | 53 | Reminders reminders()const; |
25 | 54 | ||
26 | /** | 55 | /** |
27 | * Return | 56 | * Return |
28 | */ | 57 | */ |
29 | Alarms alarms()const; | 58 | Alarms alarms()const; |
30 | 59 | ||
31 | /** | 60 | /** |
@@ -67,25 +96,27 @@ public: | |||
67 | 96 | ||
68 | /** | 97 | /** |
69 | * Convert string to alarms | 98 | * Convert string to alarms |
70 | * @param str String created by alarmsToString() | 99 | * @param str String created by alarmsToString() |
71 | */ | 100 | */ |
72 | void alarmsFromString( const QString& str ); | 101 | void alarmsFromString( const QString& str ); |
73 | 102 | ||
74 | /** | 103 | /** |
75 | * Convert string to reminders | 104 | * Convert string to reminders |
76 | * @param str String created by remindersToString() | 105 | * @param str String created by remindersToString() |
77 | */ | 106 | */ |
78 | void remindersFromString( const QString& str ); | 107 | void remindersFromString( const QString& str ); |
79 | 108 | ||
80 | 109 | ||
81 | 110 | ||
82 | private: | 111 | private: |
83 | Reminders m_rem; | 112 | Reminders m_rem; |
84 | Alarms m_al; | 113 | Alarms m_al; |
85 | 114 | ||
86 | class Private; | 115 | class Private; |
87 | Private *d; | 116 | Private *d; |
88 | 117 | ||
89 | }; | 118 | }; |
90 | 119 | ||
120 | } | ||
121 | |||
91 | #endif | 122 | #endif |
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp index 2365748..72bb372 100644 --- a/libopie2/opiepim/core/opimrecord.cpp +++ b/libopie2/opiepim/core/opimrecord.cpp | |||
@@ -1,31 +1,60 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #include <qarray.h> | 29 | #include <qarray.h> |
2 | 30 | ||
3 | #include <qpe/categories.h> | 31 | #include <qpe/categories.h> |
4 | #include <qpe/categoryselect.h> | 32 | #include <qpe/categoryselect.h> |
5 | 33 | ||
6 | #include "opimrecord.h" | 34 | #include <opie2/opimrecord.h> |
7 | 35 | ||
36 | namespace Opie { | ||
8 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); | 37 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); |
9 | 38 | ||
10 | 39 | ||
11 | OPimRecord::OPimRecord( int uid ) | 40 | OPimRecord::OPimRecord( int uid ) |
12 | : Qtopia::Record() { | 41 | : Qtopia::Record() { |
13 | 42 | ||
14 | m_lastHit = -1; | 43 | m_lastHit = -1; |
15 | setUid( uid ); | 44 | setUid( uid ); |
16 | } | 45 | } |
17 | OPimRecord::~OPimRecord() { | 46 | OPimRecord::~OPimRecord() { |
18 | } | 47 | } |
19 | OPimRecord::OPimRecord( const OPimRecord& rec ) | 48 | OPimRecord::OPimRecord( const OPimRecord& rec ) |
20 | : Qtopia::Record( rec ) | 49 | : Qtopia::Record( rec ) |
21 | { | 50 | { |
22 | (*this) = rec; | 51 | (*this) = rec; |
23 | } | 52 | } |
24 | 53 | ||
25 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { | 54 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { |
26 | if ( this == &rec ) return *this; | 55 | if ( this == &rec ) return *this; |
27 | 56 | ||
28 | Qtopia::Record::operator=( rec ); | 57 | Qtopia::Record::operator=( rec ); |
29 | m_xrefman = rec.m_xrefman; | 58 | m_xrefman = rec.m_xrefman; |
30 | m_lastHit = rec.m_lastHit; | 59 | m_lastHit = rec.m_lastHit; |
31 | 60 | ||
@@ -159,24 +188,26 @@ OPimXRefPartner OPimRecord::partner( QDataStream& stream ) { | |||
159 | 188 | ||
160 | stream >> str; | 189 | stream >> str; |
161 | par.setService( str ); | 190 | par.setService( str ); |
162 | 191 | ||
163 | stream >> i; | 192 | stream >> i; |
164 | par.setUid( i ); | 193 | par.setUid( i ); |
165 | 194 | ||
166 | stream >> i ; | 195 | stream >> i ; |
167 | par.setField( i ); | 196 | par.setField( i ); |
168 | 197 | ||
169 | return par; | 198 | return par; |
170 | } | 199 | } |
171 | void OPimRecord::setLastHitField( int lastHit )const { | 200 | void OPimRecord::setLastHitField( int lastHit )const { |
172 | m_lastHit = lastHit; | 201 | m_lastHit = lastHit; |
173 | } | 202 | } |
174 | int OPimRecord::lastHitField()const{ | 203 | int OPimRecord::lastHitField()const{ |
175 | return m_lastHit; | 204 | return m_lastHit; |
176 | } | 205 | } |
177 | QMap<QString, QString> OPimRecord::toExtraMap()const { | 206 | QMap<QString, QString> OPimRecord::toExtraMap()const { |
178 | return customMap; | 207 | return customMap; |
179 | } | 208 | } |
180 | void OPimRecord::setExtraMap( const QMap<QString, QString>& map) { | 209 | void OPimRecord::setExtraMap( const QMap<QString, QString>& map) { |
181 | customMap = map; | 210 | customMap = map; |
182 | } | 211 | } |
212 | |||
213 | } | ||
diff --git a/libopie2/opiepim/core/opimrecord.h b/libopie2/opiepim/core/opimrecord.h index 3d774e2..63a3a98 100644 --- a/libopie2/opiepim/core/opimrecord.h +++ b/libopie2/opiepim/core/opimrecord.h | |||
@@ -1,41 +1,70 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #ifndef OPIE_PIM_RECORD_H | 29 | #ifndef OPIE_PIM_RECORD_H |
2 | #define OPIE_PIM_RECORD_H | 30 | #define OPIE_PIM_RECORD_H |
3 | 31 | ||
4 | #include <qdatastream.h> | 32 | #include <qdatastream.h> |
5 | #include <qmap.h> | 33 | #include <qmap.h> |
6 | #include <qstring.h> | 34 | #include <qstring.h> |
7 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
8 | 36 | ||
9 | /* | 37 | /* |
10 | * we need to get customMap which is private... | 38 | * we need to get customMap which is private... |
11 | */ | 39 | */ |
12 | #define private protected | 40 | #define private protected |
13 | #include <qpe/palmtoprecord.h> | 41 | #include <qpe/palmtoprecord.h> |
14 | #undef private | 42 | #undef private |
15 | 43 | ||
16 | #include <opie/opimxrefmanager.h> | 44 | #include <opie2/opimxrefmanager.h> |
17 | 45 | ||
46 | namespace Opie { | ||
18 | /** | 47 | /** |
19 | * This is the base class for | 48 | * This is the base class for |
20 | * all PIM Records | 49 | * all PIM Records |
21 | * | 50 | * |
22 | */ | 51 | */ |
23 | class OPimRecord : public Qtopia::Record { | 52 | class OPimRecord : public Qtopia::Record { |
24 | public: | 53 | public: |
25 | /** | 54 | /** |
26 | * c'tor | 55 | * c'tor |
27 | * uid of 0 isEmpty | 56 | * uid of 0 isEmpty |
28 | * uid of 1 will be assigned a new one | 57 | * uid of 1 will be assigned a new one |
29 | */ | 58 | */ |
30 | OPimRecord(int uid = 0); | 59 | OPimRecord(int uid = 0); |
31 | ~OPimRecord(); | 60 | ~OPimRecord(); |
32 | 61 | ||
33 | /** | 62 | /** |
34 | * copy c'tor | 63 | * copy c'tor |
35 | */ | 64 | */ |
36 | OPimRecord( const OPimRecord& rec ); | 65 | OPimRecord( const OPimRecord& rec ); |
37 | 66 | ||
38 | /** | 67 | /** |
39 | * copy operator | 68 | * copy operator |
40 | */ | 69 | */ |
41 | OPimRecord &operator=( const OPimRecord& ); | 70 | OPimRecord &operator=( const OPimRecord& ); |
@@ -132,27 +161,27 @@ public: | |||
132 | * saves the OPimRecord | 161 | * saves the OPimRecord |
133 | * to and from a DataStream | 162 | * to and from a DataStream |
134 | */ | 163 | */ |
135 | virtual bool loadFromStream(QDataStream& ); | 164 | virtual bool loadFromStream(QDataStream& ); |
136 | virtual bool saveToStream( QDataStream& stream )const; | 165 | virtual bool saveToStream( QDataStream& stream )const; |
137 | 166 | ||
138 | protected: | 167 | protected: |
139 | // need to be const cause it is called from const methods | 168 | // need to be const cause it is called from const methods |
140 | mutable int m_lastHit; | 169 | mutable int m_lastHit; |
141 | void setLastHitField( int lastHit )const; | 170 | void setLastHitField( int lastHit )const; |
142 | Qtopia::UidGen &uidGen(); | 171 | Qtopia::UidGen &uidGen(); |
143 | // QString crossToString()const; | 172 | // QString crossToString()const; |
144 | 173 | ||
145 | private: | 174 | private: |
146 | class OPimRecordPrivate; | 175 | class OPimRecordPrivate; |
147 | OPimRecordPrivate *d; | 176 | OPimRecordPrivate *d; |
148 | OPimXRefManager m_xrefman; | 177 | OPimXRefManager m_xrefman; |
149 | static Qtopia::UidGen m_uidGen; | 178 | static Qtopia::UidGen m_uidGen; |
150 | 179 | ||
151 | private: | 180 | private: |
152 | void flush( const OPimXRefPartner&, QDataStream& stream )const; | 181 | void flush( const OPimXRefPartner&, QDataStream& stream )const; |
153 | OPimXRefPartner partner( QDataStream& ); | 182 | OPimXRefPartner partner( QDataStream& ); |
154 | }; | 183 | }; |
155 | 184 | ||
156 | 185 | } | |
157 | 186 | ||
158 | #endif | 187 | #endif |
diff --git a/libopie2/opiepim/core/opimresolver.cpp b/libopie2/opiepim/core/opimresolver.cpp index 4ebbd6e..eceabcb 100644 --- a/libopie2/opiepim/core/opimresolver.cpp +++ b/libopie2/opiepim/core/opimresolver.cpp | |||
@@ -1,33 +1,63 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #include <qcopchannel_qws.h> | 29 | #include <qcopchannel_qws.h> |
2 | 30 | ||
3 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
4 | 32 | ||
5 | #include "otodoaccess.h" | 33 | #include <opie2/otodoaccess.h> |
6 | #include "ocontactaccess.h" | 34 | #include <opie2/ocontactaccess.h> |
7 | 35 | ||
8 | //#include "opimfactory.h" | 36 | //#include "opimfactory.h" |
9 | #include "opimresolver.h" | 37 | #include <opie2/opimresolver.h> |
38 | |||
39 | namespace Opie { | ||
10 | 40 | ||
11 | OPimResolver* OPimResolver::m_self = 0l; | 41 | OPimResolver* OPimResolver::m_self = 0l; |
12 | 42 | ||
13 | OPimResolver::OPimResolver() { | 43 | OPimResolver::OPimResolver() { |
14 | /* the built in channels */ | 44 | /* the built in channels */ |
15 | m_builtIns << "Todolist" << "Addressbook" << "Datebook"; | 45 | m_builtIns << "Todolist" << "Addressbook" << "Datebook"; |
16 | } | 46 | } |
17 | OPimResolver* OPimResolver::self() { | 47 | OPimResolver* OPimResolver::self() { |
18 | if (!m_self) | 48 | if (!m_self) |
19 | m_self = new OPimResolver(); | 49 | m_self = new OPimResolver(); |
20 | 50 | ||
21 | return m_self; | 51 | return m_self; |
22 | } | 52 | } |
23 | 53 | ||
24 | /* | 54 | /* |
25 | * FIXME use a cache here too | 55 | * FIXME use a cache here too |
26 | */ | 56 | */ |
27 | OPimRecord* OPimResolver::record( const QString& service, int uid ) { | 57 | OPimRecord* OPimResolver::record( const QString& service, int uid ) { |
28 | OPimRecord* rec = 0l; | 58 | OPimRecord* rec = 0l; |
29 | OPimBase* base = backend( service ); | 59 | OPimBase* base = backend( service ); |
30 | 60 | ||
31 | if ( base ) | 61 | if ( base ) |
32 | rec = base->record( uid ); | 62 | rec = base->record( uid ); |
33 | delete base; | 63 | delete base; |
@@ -175,24 +205,26 @@ bool OPimResolver::add( const QString& service, const OPimRecord& rec) { | |||
175 | } | 205 | } |
176 | OPimBase* OPimResolver::backend( const QString& service ) { | 206 | OPimBase* OPimResolver::backend( const QString& service ) { |
177 | return backend( serviceId( service ) ); | 207 | return backend( serviceId( service ) ); |
178 | } | 208 | } |
179 | OPimBase* OPimResolver::backend( int rtti ) { | 209 | OPimBase* OPimResolver::backend( int rtti ) { |
180 | OPimBase* base = 0l; | 210 | OPimBase* base = 0l; |
181 | switch( rtti ) { | 211 | switch( rtti ) { |
182 | case TodoList: | 212 | case TodoList: |
183 | base = new OTodoAccess(); | 213 | base = new OTodoAccess(); |
184 | break; | 214 | break; |
185 | case DateBook: | 215 | case DateBook: |
186 | break; | 216 | break; |
187 | case AddressBook: | 217 | case AddressBook: |
188 | base = new OContactAccess("Resolver"); | 218 | base = new OContactAccess("Resolver"); |
189 | break; | 219 | break; |
190 | default: | 220 | default: |
191 | break; | 221 | break; |
192 | } | 222 | } |
193 | // FIXME for 3rd party | 223 | // FIXME for 3rd party |
194 | if (!base ) | 224 | if (!base ) |
195 | ; | 225 | ; |
196 | 226 | ||
197 | return base; | 227 | return base; |
198 | } | 228 | } |
229 | |||
230 | } | ||
diff --git a/libopie2/opiepim/core/opimresolver.h b/libopie2/opiepim/core/opimresolver.h index 1ce1619..adc7c16 100644 --- a/libopie2/opiepim/core/opimresolver.h +++ b/libopie2/opiepim/core/opimresolver.h | |||
@@ -1,32 +1,61 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #ifndef OPIE_PIM_RESOLVER | 29 | #ifndef OPIE_PIM_RESOLVER |
2 | #define OPIE_PIM_RESOLVER | 30 | #define OPIE_PIM_RESOLVER |
3 | 31 | ||
4 | #include <qstring.h> | 32 | #include <qstring.h> |
5 | #include <qvaluelist.h> | 33 | #include <qvaluelist.h> |
6 | 34 | ||
7 | #include <opie/otemplatebase.h> | 35 | #include <opie2/otemplatebase.h> |
8 | 36 | ||
37 | namespace Opie { | ||
9 | /** | 38 | /** |
10 | * OPimResolver is a MetaClass to access | 39 | * OPimResolver is a MetaClass to access |
11 | * available backends read only. | 40 | * available backends read only. |
12 | * It will be used to resolve uids + app names | 41 | * It will be used to resolve uids + app names |
13 | * to full informations | 42 | * to full informations |
14 | * to traverse through a list of alarms, reminders | 43 | * to traverse through a list of alarms, reminders |
15 | * to get access to built in PIM functionality | 44 | * to get access to built in PIM functionality |
16 | * and to more stuff | 45 | * and to more stuff |
17 | * THE PERFORMANCE will depend on THE BACKEND | 46 | * THE PERFORMANCE will depend on THE BACKEND |
18 | * USING XML is a waste of memory!!!!! | 47 | * USING XML is a waste of memory!!!!! |
19 | */ | 48 | */ |
20 | class OPimResolver { | 49 | class OPimResolver { |
21 | public: | 50 | public: |
22 | enum BuiltIn { TodoList = 0, | 51 | enum BuiltIn { TodoList = 0, |
23 | DateBook, | 52 | DateBook, |
24 | AddressBook | 53 | AddressBook |
25 | }; | 54 | }; |
26 | static OPimResolver* self(); | 55 | static OPimResolver* self(); |
27 | 56 | ||
28 | 57 | ||
29 | /** | 58 | /** |
30 | * return a record for a uid | 59 | * return a record for a uid |
31 | * and an service | 60 | * and an service |
32 | * You've THE OWNERSHIP NOW! | 61 | * You've THE OWNERSHIP NOW! |
@@ -66,25 +95,27 @@ public: | |||
66 | OPimRecord* record( const QString& service ); | 95 | OPimRecord* record( const QString& service ); |
67 | OPimRecord* record( int rtti ); | 96 | OPimRecord* record( int rtti ); |
68 | 97 | ||
69 | /** | 98 | /** |
70 | * you can cast to your | 99 | * you can cast to your |
71 | */ | 100 | */ |
72 | OPimBase* backend( const QString& service ); | 101 | OPimBase* backend( const QString& service ); |
73 | OPimBase* backend( int rtti ); | 102 | OPimBase* backend( int rtti ); |
74 | private: | 103 | private: |
75 | OPimResolver(); | 104 | OPimResolver(); |
76 | void loadData(); | 105 | void loadData(); |
77 | inline bool isBuiltIn( const QString& )const; | 106 | inline bool isBuiltIn( const QString& )const; |
78 | OPimRecord* recordExtern( const QString&, int ); | 107 | OPimRecord* recordExtern( const QString&, int ); |
79 | OPimRecord* recordExtern( const QString& ); | 108 | OPimRecord* recordExtern( const QString& ); |
80 | 109 | ||
81 | static OPimResolver* m_self; | 110 | static OPimResolver* m_self; |
82 | struct Data; | 111 | struct Data; |
83 | class Private; | 112 | class Private; |
84 | 113 | ||
85 | Data* data; | 114 | Data* data; |
86 | Private* d; | 115 | Private* d; |
87 | QStringList m_builtIns; | 116 | QStringList m_builtIns; |
88 | }; | 117 | }; |
89 | 118 | ||
119 | } | ||
120 | |||
90 | #endif | 121 | #endif |
diff --git a/libopie2/opiepim/core/opimstate.cpp b/libopie2/opiepim/core/opimstate.cpp index 6fb2feb..1013a1c 100644 --- a/libopie2/opiepim/core/opimstate.cpp +++ b/libopie2/opiepim/core/opimstate.cpp | |||
@@ -1,28 +1,57 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #include <qshared.h> | 29 | #include <qshared.h> |
2 | 30 | ||
3 | #include "opimstate.h" | 31 | #include "opimstate.h" |
4 | 32 | ||
33 | namespace Opie { | ||
5 | /* | 34 | /* |
6 | * for one int this does not make | 35 | * for one int this does not make |
7 | * much sense but never the less | 36 | * much sense but never the less |
8 | * we will do it for the future | 37 | * we will do it for the future |
9 | */ | 38 | */ |
10 | struct OPimState::Data : public QShared { | 39 | struct OPimState::Data : public QShared { |
11 | Data() : QShared(),state(Undefined) { | 40 | Data() : QShared(),state(Undefined) { |
12 | } | 41 | } |
13 | int state; | 42 | int state; |
14 | }; | 43 | }; |
15 | 44 | ||
16 | OPimState::OPimState( int state ) { | 45 | OPimState::OPimState( int state ) { |
17 | data = new Data; | 46 | data = new Data; |
18 | data->state = state; | 47 | data->state = state; |
19 | } | 48 | } |
20 | OPimState::OPimState( const OPimState& st) : | 49 | OPimState::OPimState( const OPimState& st) : |
21 | data( st.data ) { | 50 | data( st.data ) { |
22 | /* ref up */ | 51 | /* ref up */ |
23 | data->ref(); | 52 | data->ref(); |
24 | } | 53 | } |
25 | OPimState::~OPimState() { | 54 | OPimState::~OPimState() { |
26 | if ( data->deref() ) { | 55 | if ( data->deref() ) { |
27 | delete data ; | 56 | delete data ; |
28 | data = 0; | 57 | data = 0; |
@@ -41,24 +70,26 @@ OPimState &OPimState::operator=( const OPimState& st) { | |||
41 | return *this; | 70 | return *this; |
42 | } | 71 | } |
43 | void OPimState::setState( int st) { | 72 | void OPimState::setState( int st) { |
44 | copyInternally(); | 73 | copyInternally(); |
45 | data->state = st; | 74 | data->state = st; |
46 | } | 75 | } |
47 | int OPimState::state()const { | 76 | int OPimState::state()const { |
48 | return data->state; | 77 | return data->state; |
49 | } | 78 | } |
50 | void OPimState::deref() { | 79 | void OPimState::deref() { |
51 | if ( data->deref() ) { | 80 | if ( data->deref() ) { |
52 | delete data; | 81 | delete data; |
53 | data = 0l; | 82 | data = 0l; |
54 | } | 83 | } |
55 | } | 84 | } |
56 | void OPimState::copyInternally() { | 85 | void OPimState::copyInternally() { |
57 | /* we need to change it */ | 86 | /* we need to change it */ |
58 | if ( data->count != 1 ) { | 87 | if ( data->count != 1 ) { |
59 | data->deref(); | 88 | data->deref(); |
60 | Data* d2 = new Data; | 89 | Data* d2 = new Data; |
61 | d2->state = data->state; | 90 | d2->state = data->state; |
62 | data = d2; | 91 | data = d2; |
63 | } | 92 | } |
64 | } | 93 | } |
94 | |||
95 | } | ||
diff --git a/libopie2/opiepim/core/opimstate.h b/libopie2/opiepim/core/opimstate.h index cf6af46..78e8cd0 100644 --- a/libopie2/opiepim/core/opimstate.h +++ b/libopie2/opiepim/core/opimstate.h | |||
@@ -1,46 +1,75 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #ifndef OPIE_PIM_STATE_H | 29 | #ifndef OPIE_PIM_STATE_H |
2 | #define OPIE_PIM_STATE_H | 30 | #define OPIE_PIM_STATE_H |
3 | 31 | ||
4 | #include <qstring.h> | 32 | #include <qstring.h> |
5 | 33 | ||
34 | namespace Opie { | ||
6 | /** | 35 | /** |
7 | * The State of a Task | 36 | * The State of a Task |
8 | * This class encapsules the state of a todo | 37 | * This class encapsules the state of a todo |
9 | * and it's shared too | 38 | * and it's shared too |
10 | */ | 39 | */ |
11 | /* | 40 | /* |
12 | * in c a simple struct would be enough ;) | 41 | * in c a simple struct would be enough ;) |
13 | * g_new_state(); | 42 | * g_new_state(); |
14 | * g_do_some_thing( state_t* ); | 43 | * g_do_some_thing( state_t* ); |
15 | * ;) | 44 | * ;) |
16 | */ | 45 | */ |
17 | class OPimState { | 46 | class OPimState { |
18 | public: | 47 | public: |
19 | enum State { | 48 | enum State { |
20 | Started = 0, | 49 | Started = 0, |
21 | Postponed, | 50 | Postponed, |
22 | Finished, | 51 | Finished, |
23 | NotStarted, | 52 | NotStarted, |
24 | Undefined | 53 | Undefined |
25 | }; | 54 | }; |
26 | OPimState( int state = Undefined ); | 55 | OPimState( int state = Undefined ); |
27 | OPimState( const OPimState& ); | 56 | OPimState( const OPimState& ); |
28 | ~OPimState(); | 57 | ~OPimState(); |
29 | 58 | ||
30 | bool operator==( const OPimState& ); | 59 | bool operator==( const OPimState& ); |
31 | OPimState &operator=( const OPimState& ); | 60 | OPimState &operator=( const OPimState& ); |
32 | void setState( int state); | 61 | void setState( int state); |
33 | int state()const; | 62 | int state()const; |
34 | private: | 63 | private: |
35 | void deref(); | 64 | void deref(); |
36 | inline void copyInternally(); | 65 | inline void copyInternally(); |
37 | 66 | ||
38 | struct Data; | 67 | struct Data; |
39 | Data* data; | 68 | Data* data; |
40 | 69 | ||
41 | class Private; | 70 | class Private; |
42 | Private *d; | 71 | Private *d; |
43 | }; | 72 | }; |
44 | 73 | ||
45 | 74 | } | |
46 | #endif | 75 | #endif |
diff --git a/libopie2/opiepim/core/opimxref.cpp b/libopie2/opiepim/core/opimxref.cpp index 8eefbd8..85d3345 100644 --- a/libopie2/opiepim/core/opimxref.cpp +++ b/libopie2/opiepim/core/opimxref.cpp | |||
@@ -1,47 +1,79 @@ | |||
1 | #include "opimxref.h" | 1 | /* |
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | #include <opie2/opimxref.h> | ||
30 | |||
31 | namespace Opie { | ||
2 | 32 | ||
3 | OPimXRef::OPimXRef( const OPimXRefPartner& one, const OPimXRefPartner& two ) | 33 | OPimXRef::OPimXRef( const OPimXRefPartner& one, const OPimXRefPartner& two ) |
4 | : m_partners(2) | 34 | : m_partners(2) |
5 | { | 35 | { |
6 | m_partners[0] = one; | 36 | m_partners[0] = one; |
7 | m_partners[1] = two; | 37 | m_partners[1] = two; |
8 | } | 38 | } |
9 | OPimXRef::OPimXRef() | 39 | OPimXRef::OPimXRef() |
10 | : m_partners(2) | 40 | : m_partners(2) |
11 | { | 41 | { |
12 | 42 | ||
13 | } | 43 | } |
14 | OPimXRef::OPimXRef( const OPimXRef& ref) { | 44 | OPimXRef::OPimXRef( const OPimXRef& ref) { |
15 | *this = ref; | 45 | *this = ref; |
16 | } | 46 | } |
17 | OPimXRef::~OPimXRef() { | 47 | OPimXRef::~OPimXRef() { |
18 | } | 48 | } |
19 | OPimXRef &OPimXRef::operator=( const OPimXRef& ref) { | 49 | OPimXRef &OPimXRef::operator=( const OPimXRef& ref) { |
20 | m_partners = ref.m_partners; | 50 | m_partners = ref.m_partners; |
21 | m_partners.detach(); | 51 | m_partners.detach(); |
22 | 52 | ||
23 | return* this; | 53 | return* this; |
24 | } | 54 | } |
25 | bool OPimXRef::operator==( const OPimXRef& oper ) { | 55 | bool OPimXRef::operator==( const OPimXRef& oper ) { |
26 | if ( m_partners == oper.m_partners ) return true; | 56 | if ( m_partners == oper.m_partners ) return true; |
27 | 57 | ||
28 | return false; | 58 | return false; |
29 | } | 59 | } |
30 | OPimXRefPartner OPimXRef::partner( enum Partners par) const{ | 60 | OPimXRefPartner OPimXRef::partner( enum Partners par) const{ |
31 | return m_partners[par]; | 61 | return m_partners[par]; |
32 | } | 62 | } |
33 | void OPimXRef::setPartner( enum Partners par, const OPimXRefPartner& part) { | 63 | void OPimXRef::setPartner( enum Partners par, const OPimXRefPartner& part) { |
34 | m_partners[par] = part; | 64 | m_partners[par] = part; |
35 | } | 65 | } |
36 | bool OPimXRef::containsString( const QString& string ) const{ | 66 | bool OPimXRef::containsString( const QString& string ) const{ |
37 | if ( m_partners[One].service() == string || | 67 | if ( m_partners[One].service() == string || |
38 | m_partners[Two].service() == string ) return true; | 68 | m_partners[Two].service() == string ) return true; |
39 | 69 | ||
40 | return false; | 70 | return false; |
41 | } | 71 | } |
42 | bool OPimXRef::containsUid( int uid ) const{ | 72 | bool OPimXRef::containsUid( int uid ) const{ |
43 | if ( m_partners[One].uid() == uid || | 73 | if ( m_partners[One].uid() == uid || |
44 | m_partners[Two].uid() == uid ) return true; | 74 | m_partners[Two].uid() == uid ) return true; |
45 | 75 | ||
46 | return false; | 76 | return false; |
47 | } | 77 | } |
78 | |||
79 | } | ||
diff --git a/libopie2/opiepim/core/opimxref.h b/libopie2/opiepim/core/opimxref.h index 6852651..820c9c4 100644 --- a/libopie2/opiepim/core/opimxref.h +++ b/libopie2/opiepim/core/opimxref.h | |||
@@ -1,39 +1,71 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | |||
1 | #ifndef OPIM_XREF_H | 30 | #ifndef OPIM_XREF_H |
2 | #define OPIM_XREF_H | 31 | #define OPIM_XREF_H |
3 | 32 | ||
4 | #include <qarray.h> | 33 | #include <qarray.h> |
5 | #include <qvaluelist.h> | 34 | #include <qvaluelist.h> |
6 | 35 | ||
7 | #include <opie/opimxrefpartner.h> | 36 | #include <opie2/opimxrefpartner.h> |
8 | 37 | ||
38 | namespace Opie { | ||
9 | /** | 39 | /** |
10 | * this is a Cross Referecne between | 40 | * this is a Cross Referecne between |
11 | * two Cross Reference Partners | 41 | * two Cross Reference Partners |
12 | */ | 42 | */ |
13 | class OPimXRef { | 43 | class OPimXRef { |
14 | public: | 44 | public: |
15 | typedef QValueList<OPimXRef> ValueList; | 45 | typedef QValueList<OPimXRef> ValueList; |
16 | enum Partners { One, Two }; | 46 | enum Partners { One, Two }; |
17 | OPimXRef( const OPimXRefPartner& ONE, const OPimXRefPartner& ); | 47 | OPimXRef( const OPimXRefPartner& ONE, const OPimXRefPartner& ); |
18 | OPimXRef(); | 48 | OPimXRef(); |
19 | OPimXRef( const OPimXRef& ); | 49 | OPimXRef( const OPimXRef& ); |
20 | ~OPimXRef(); | 50 | ~OPimXRef(); |
21 | 51 | ||
22 | OPimXRef &operator=( const OPimXRef& ); | 52 | OPimXRef &operator=( const OPimXRef& ); |
23 | bool operator==( const OPimXRef& ); | 53 | bool operator==( const OPimXRef& ); |
24 | 54 | ||
25 | OPimXRefPartner partner( enum Partners )const; | 55 | OPimXRefPartner partner( enum Partners )const; |
26 | 56 | ||
27 | void setPartner( enum Partners, const OPimXRefPartner& ); | 57 | void setPartner( enum Partners, const OPimXRefPartner& ); |
28 | 58 | ||
29 | bool containsString( const QString& service)const; | 59 | bool containsString( const QString& service)const; |
30 | bool containsUid( int uid )const; | 60 | bool containsUid( int uid )const; |
31 | 61 | ||
32 | private: | 62 | private: |
33 | QArray<OPimXRefPartner> m_partners; | 63 | QArray<OPimXRefPartner> m_partners; |
34 | 64 | ||
35 | class Private; | 65 | class Private; |
36 | Private *d; | 66 | Private *d; |
37 | }; | 67 | }; |
38 | 68 | ||
69 | } | ||
70 | |||
39 | #endif | 71 | #endif |
diff --git a/libopie2/opiepim/core/opimxrefmanager.cpp b/libopie2/opiepim/core/opimxrefmanager.cpp index 58bfd24..bf6fed6 100644 --- a/libopie2/opiepim/core/opimxrefmanager.cpp +++ b/libopie2/opiepim/core/opimxrefmanager.cpp | |||
@@ -1,26 +1,55 @@ | |||
1 | #include "opimxrefmanager.h" | 1 | /* |
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | #include <opie2/opimxrefmanager.h> | ||
2 | 30 | ||
31 | namespace Opie { | ||
3 | 32 | ||
4 | OPimXRefManager::OPimXRefManager() { | 33 | OPimXRefManager::OPimXRefManager() { |
5 | } | 34 | } |
6 | OPimXRefManager::OPimXRefManager( const OPimXRefManager& ref) { | 35 | OPimXRefManager::OPimXRefManager( const OPimXRefManager& ref) { |
7 | m_list = ref.m_list; | 36 | m_list = ref.m_list; |
8 | } | 37 | } |
9 | OPimXRefManager::~OPimXRefManager() { | 38 | OPimXRefManager::~OPimXRefManager() { |
10 | } | 39 | } |
11 | OPimXRefManager &OPimXRefManager::operator=( const OPimXRefManager& ref) { | 40 | OPimXRefManager &OPimXRefManager::operator=( const OPimXRefManager& ref) { |
12 | m_list = ref.m_list; | 41 | m_list = ref.m_list; |
13 | return *this; | 42 | return *this; |
14 | } | 43 | } |
15 | bool OPimXRefManager::operator==( const OPimXRefManager& /*ref*/) { | 44 | bool OPimXRefManager::operator==( const OPimXRefManager& /*ref*/) { |
16 | // if ( m_list == ref.m_list ) return true; | 45 | // if ( m_list == ref.m_list ) return true; |
17 | 46 | ||
18 | return false; | 47 | return false; |
19 | } | 48 | } |
20 | void OPimXRefManager::add( const OPimXRef& ref) { | 49 | void OPimXRefManager::add( const OPimXRef& ref) { |
21 | m_list.append( ref ); | 50 | m_list.append( ref ); |
22 | } | 51 | } |
23 | void OPimXRefManager::remove( const OPimXRef& ref) { | 52 | void OPimXRefManager::remove( const OPimXRef& ref) { |
24 | m_list.remove( ref ); | 53 | m_list.remove( ref ); |
25 | } | 54 | } |
26 | void OPimXRefManager::replace( const OPimXRef& ref) { | 55 | void OPimXRefManager::replace( const OPimXRef& ref) { |
@@ -48,24 +77,26 @@ OPimXRef::ValueList OPimXRefManager::list()const { | |||
48 | return m_list; | 77 | return m_list; |
49 | } | 78 | } |
50 | OPimXRef::ValueList OPimXRefManager::list( const QString& appName )const{ | 79 | OPimXRef::ValueList OPimXRefManager::list( const QString& appName )const{ |
51 | OPimXRef::ValueList list; | 80 | OPimXRef::ValueList list; |
52 | OPimXRef::ValueList::ConstIterator it; | 81 | OPimXRef::ValueList::ConstIterator it; |
53 | 82 | ||
54 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | 83 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { |
55 | if ( (*it).containsString( appName ) ) | 84 | if ( (*it).containsString( appName ) ) |
56 | list.append( (*it) ); | 85 | list.append( (*it) ); |
57 | } | 86 | } |
58 | 87 | ||
59 | return list; | 88 | return list; |
60 | } | 89 | } |
61 | OPimXRef::ValueList OPimXRefManager::list( int uid )const { | 90 | OPimXRef::ValueList OPimXRefManager::list( int uid )const { |
62 | OPimXRef::ValueList list; | 91 | OPimXRef::ValueList list; |
63 | OPimXRef::ValueList::ConstIterator it; | 92 | OPimXRef::ValueList::ConstIterator it; |
64 | 93 | ||
65 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | 94 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { |
66 | if ( (*it).containsUid( uid ) ) | 95 | if ( (*it).containsUid( uid ) ) |
67 | list.append( (*it) ); | 96 | list.append( (*it) ); |
68 | } | 97 | } |
69 | 98 | ||
70 | return list; | 99 | return list; |
71 | } | 100 | } |
101 | |||
102 | } | ||
diff --git a/libopie2/opiepim/core/opimxrefmanager.h b/libopie2/opiepim/core/opimxrefmanager.h index c485e98..fa2d7f4 100644 --- a/libopie2/opiepim/core/opimxrefmanager.h +++ b/libopie2/opiepim/core/opimxrefmanager.h | |||
@@ -1,43 +1,74 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #ifndef OPIM_XREF_MANAGER_H | 29 | #ifndef OPIM_XREF_MANAGER_H |
2 | #define OPIM_XREF_MANAGER_H | 30 | #define OPIM_XREF_MANAGER_H |
3 | 31 | ||
4 | #include <qstringlist.h> | 32 | #include <qstringlist.h> |
5 | 33 | ||
6 | #include <opie/opimxref.h> | 34 | #include <opie2/opimxref.h> |
7 | 35 | ||
36 | namespace Opie { | ||
8 | /** | 37 | /** |
9 | * This is a simple manager for | 38 | * This is a simple manager for |
10 | * OPimXRefs. | 39 | * OPimXRefs. |
11 | * It allows addition, removing, replacing | 40 | * It allows addition, removing, replacing |
12 | * clearing and 'querying' the XRef... | 41 | * clearing and 'querying' the XRef... |
13 | */ | 42 | */ |
14 | class OPimXRefManager { | 43 | class OPimXRefManager { |
15 | public: | 44 | public: |
16 | OPimXRefManager(); | 45 | OPimXRefManager(); |
17 | OPimXRefManager( const OPimXRefManager& ); | 46 | OPimXRefManager( const OPimXRefManager& ); |
18 | ~OPimXRefManager(); | 47 | ~OPimXRefManager(); |
19 | 48 | ||
20 | OPimXRefManager& operator=( const OPimXRefManager& ); | 49 | OPimXRefManager& operator=( const OPimXRefManager& ); |
21 | bool operator==( const OPimXRefManager& ); | 50 | bool operator==( const OPimXRefManager& ); |
22 | 51 | ||
23 | void add( const OPimXRef& ); | 52 | void add( const OPimXRef& ); |
24 | void remove( const OPimXRef& ); | 53 | void remove( const OPimXRef& ); |
25 | void replace( const OPimXRef& ); | 54 | void replace( const OPimXRef& ); |
26 | 55 | ||
27 | void clear(); | 56 | void clear(); |
28 | 57 | ||
29 | /** | 58 | /** |
30 | * apps participating | 59 | * apps participating |
31 | */ | 60 | */ |
32 | QStringList apps()const; | 61 | QStringList apps()const; |
33 | OPimXRef::ValueList list()const; | 62 | OPimXRef::ValueList list()const; |
34 | OPimXRef::ValueList list( const QString& service )const; | 63 | OPimXRef::ValueList list( const QString& service )const; |
35 | OPimXRef::ValueList list( int uid )const; | 64 | OPimXRef::ValueList list( int uid )const; |
36 | 65 | ||
37 | private: | 66 | private: |
38 | OPimXRef::ValueList m_list; | 67 | OPimXRef::ValueList m_list; |
39 | class Private; | 68 | class Private; |
40 | Private *d; | 69 | Private *d; |
41 | }; | 70 | }; |
42 | 71 | ||
72 | } | ||
73 | |||
43 | #endif | 74 | #endif |
diff --git a/libopie2/opiepim/core/opimxrefpartner.cpp b/libopie2/opiepim/core/opimxrefpartner.cpp index 6ef3efb..f6ccc7f 100644 --- a/libopie2/opiepim/core/opimxrefpartner.cpp +++ b/libopie2/opiepim/core/opimxrefpartner.cpp | |||
@@ -1,43 +1,75 @@ | |||
1 | #include "opimxrefpartner.h" | 1 | /* |
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | #include <opie2/opimxrefpartner.h> | ||
30 | |||
31 | namespace Opie { | ||
2 | 32 | ||
3 | OPimXRefPartner::OPimXRefPartner( const QString& appName, | 33 | OPimXRefPartner::OPimXRefPartner( const QString& appName, |
4 | int uid, int field ) | 34 | int uid, int field ) |
5 | : m_app(appName), m_uid(uid), m_field( field ) { | 35 | : m_app(appName), m_uid(uid), m_field( field ) { |
6 | } | 36 | } |
7 | OPimXRefPartner::OPimXRefPartner( const OPimXRefPartner& ref ) { | 37 | OPimXRefPartner::OPimXRefPartner( const OPimXRefPartner& ref ) { |
8 | *this = ref; | 38 | *this = ref; |
9 | } | 39 | } |
10 | OPimXRefPartner::~OPimXRefPartner() { | 40 | OPimXRefPartner::~OPimXRefPartner() { |
11 | } | 41 | } |
12 | OPimXRefPartner &OPimXRefPartner::operator=( const OPimXRefPartner& par ) { | 42 | OPimXRefPartner &OPimXRefPartner::operator=( const OPimXRefPartner& par ) { |
13 | m_app = par.m_app; | 43 | m_app = par.m_app; |
14 | m_uid = par.m_uid; | 44 | m_uid = par.m_uid; |
15 | m_field = par.m_field; | 45 | m_field = par.m_field; |
16 | 46 | ||
17 | return *this; | 47 | return *this; |
18 | } | 48 | } |
19 | bool OPimXRefPartner::operator==( const OPimXRefPartner& par ) { | 49 | bool OPimXRefPartner::operator==( const OPimXRefPartner& par ) { |
20 | if ( m_app != par.m_app ) return false; | 50 | if ( m_app != par.m_app ) return false; |
21 | if ( m_uid != par.m_uid ) return false; | 51 | if ( m_uid != par.m_uid ) return false; |
22 | if ( m_field != par.m_field ) return false; | 52 | if ( m_field != par.m_field ) return false; |
23 | 53 | ||
24 | return true; | 54 | return true; |
25 | } | 55 | } |
26 | QString OPimXRefPartner::service()const { | 56 | QString OPimXRefPartner::service()const { |
27 | return m_app; | 57 | return m_app; |
28 | } | 58 | } |
29 | int OPimXRefPartner::uid()const { | 59 | int OPimXRefPartner::uid()const { |
30 | return m_uid; | 60 | return m_uid; |
31 | } | 61 | } |
32 | int OPimXRefPartner::field()const { | 62 | int OPimXRefPartner::field()const { |
33 | return m_field; | 63 | return m_field; |
34 | } | 64 | } |
35 | void OPimXRefPartner::setService( const QString& appName ) { | 65 | void OPimXRefPartner::setService( const QString& appName ) { |
36 | m_app = appName; | 66 | m_app = appName; |
37 | } | 67 | } |
38 | void OPimXRefPartner::setUid( int uid ) { | 68 | void OPimXRefPartner::setUid( int uid ) { |
39 | m_uid = uid; | 69 | m_uid = uid; |
40 | } | 70 | } |
41 | void OPimXRefPartner::setField( int field ) { | 71 | void OPimXRefPartner::setField( int field ) { |
42 | m_field = field; | 72 | m_field = field; |
43 | } | 73 | } |
74 | |||
75 | } | ||
diff --git a/libopie2/opiepim/core/opimxrefpartner.h b/libopie2/opiepim/core/opimxrefpartner.h index d76e384..6853d5b 100644 --- a/libopie2/opiepim/core/opimxrefpartner.h +++ b/libopie2/opiepim/core/opimxrefpartner.h | |||
@@ -1,40 +1,70 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #ifndef OPIM_XREF_PARTNER_H | 29 | #ifndef OPIM_XREF_PARTNER_H |
2 | #define OPIM_XREF_PARTNER_H | 30 | #define OPIM_XREF_PARTNER_H |
3 | 31 | ||
4 | #include <qstring.h> | 32 | #include <qstring.h> |
5 | 33 | ||
34 | namespace Opie { | ||
6 | /** | 35 | /** |
7 | * This class represents one partner | 36 | * This class represents one partner |
8 | * of a Cross Reference. | 37 | * of a Cross Reference. |
9 | * In Opie one application | 38 | * In Opie one application |
10 | * can link one uid | 39 | * can link one uid |
11 | * with one tableId( fieldId ) to another. | 40 | * with one tableId( fieldId ) to another. |
12 | */ | 41 | */ |
13 | class OPimXRefPartner { | 42 | class OPimXRefPartner { |
14 | public: | 43 | public: |
15 | OPimXRefPartner( const QString& service = QString::null, | 44 | OPimXRefPartner( const QString& service = QString::null, |
16 | int uid = 0, int field = -1 ); | 45 | int uid = 0, int field = -1 ); |
17 | OPimXRefPartner( const OPimXRefPartner& ); | 46 | OPimXRefPartner( const OPimXRefPartner& ); |
18 | OPimXRefPartner& operator=( const OPimXRefPartner& ); | 47 | OPimXRefPartner& operator=( const OPimXRefPartner& ); |
19 | ~OPimXRefPartner(); | 48 | ~OPimXRefPartner(); |
20 | 49 | ||
21 | bool operator==(const OPimXRefPartner& ); | 50 | bool operator==(const OPimXRefPartner& ); |
22 | 51 | ||
23 | QString service()const; | 52 | QString service()const; |
24 | int uid()const; | 53 | int uid()const; |
25 | int field()const; | 54 | int field()const; |
26 | 55 | ||
27 | void setService( const QString& service ); | 56 | void setService( const QString& service ); |
28 | void setUid( int uid ); | 57 | void setUid( int uid ); |
29 | void setField( int field ); | 58 | void setField( int field ); |
30 | private: | 59 | private: |
31 | QString m_app; | 60 | QString m_app; |
32 | int m_uid; | 61 | int m_uid; |
33 | int m_field; | 62 | int m_field; |
34 | 63 | ||
35 | class Private; | 64 | class Private; |
36 | Private* d; | 65 | Private* d; |
37 | }; | 66 | }; |
38 | 67 | ||
68 | } | ||
39 | 69 | ||
40 | #endif | 70 | #endif |
diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/orecur.cpp index f46f22e..033f264 100644 --- a/libopie2/opiepim/core/orecur.cpp +++ b/libopie2/opiepim/core/orecur.cpp | |||
@@ -1,33 +1,63 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | |||
1 | #include <time.h> | 30 | #include <time.h> |
2 | 31 | ||
3 | #include <qshared.h> | 32 | #include <qshared.h> |
4 | 33 | ||
5 | #include <qtopia/timeconversion.h> | 34 | #include <qtopia/timeconversion.h> |
6 | 35 | ||
7 | #include "otimezone.h" | 36 | #include <opie2/otimezone.h> |
8 | #include "orecur.h" | 37 | #include <opie2/orecur.h> |
9 | 38 | ||
39 | namespace Opie { | ||
10 | struct ORecur::Data : public QShared { | 40 | struct ORecur::Data : public QShared { |
11 | Data() : QShared() { | 41 | Data() : QShared() { |
12 | type = ORecur::NoRepeat; | 42 | type = ORecur::NoRepeat; |
13 | freq = -1; | 43 | freq = -1; |
14 | days = 0; | 44 | days = 0; |
15 | pos = 0; | 45 | pos = 0; |
16 | create = QDateTime::currentDateTime(); | 46 | create = QDateTime::currentDateTime(); |
17 | hasEnd = FALSE; | 47 | hasEnd = FALSE; |
18 | end = QDate::currentDate(); | 48 | end = QDate::currentDate(); |
19 | } | 49 | } |
20 | char days; // Q_UINT8 for 8 seven days;) | 50 | char days; // Q_UINT8 for 8 seven days;) |
21 | ORecur::RepeatType type; | 51 | ORecur::RepeatType type; |
22 | int freq; | 52 | int freq; |
23 | int pos; | 53 | int pos; |
24 | bool hasEnd : 1; | 54 | bool hasEnd : 1; |
25 | QDate end; | 55 | QDate end; |
26 | QDateTime create; | 56 | QDateTime create; |
27 | int rep; | 57 | int rep; |
28 | QString app; | 58 | QString app; |
29 | ExceptionList list; | 59 | ExceptionList list; |
30 | QDate start; | 60 | QDate start; |
31 | }; | 61 | }; |
32 | 62 | ||
33 | 63 | ||
@@ -570,24 +600,26 @@ void ORecur::fromMap( const QMap<int, QString>& map ) | |||
570 | QMap<QString, RepeatType> repTypeMap = rTypeValueConvertMap(); | 600 | QMap<QString, RepeatType> repTypeMap = rTypeValueConvertMap(); |
571 | 601 | ||
572 | data -> type = repTypeMap[ map [ORecur::RType] ]; | 602 | data -> type = repTypeMap[ map [ORecur::RType] ]; |
573 | data -> days = (char) map[ ORecur::RWeekdays ].toInt(); | 603 | data -> days = (char) map[ ORecur::RWeekdays ].toInt(); |
574 | data -> pos = map[ ORecur::RPosition ].toInt(); | 604 | data -> pos = map[ ORecur::RPosition ].toInt(); |
575 | data -> freq = map[ ORecur::RFreq ].toInt(); | 605 | data -> freq = map[ ORecur::RFreq ].toInt(); |
576 | data -> hasEnd= map[ ORecur::RHasEndDate ].toInt() ? true : false; | 606 | data -> hasEnd= map[ ORecur::RHasEndDate ].toInt() ? true : false; |
577 | OTimeZone utc = OTimeZone::utc(); | 607 | OTimeZone utc = OTimeZone::utc(); |
578 | if ( data -> hasEnd ){ | 608 | if ( data -> hasEnd ){ |
579 | data -> end = utc.fromUTCDateTime( (time_t) map[ ORecur::EndDate ].toLong() ).date(); | 609 | data -> end = utc.fromUTCDateTime( (time_t) map[ ORecur::EndDate ].toLong() ).date(); |
580 | } | 610 | } |
581 | data -> create = utc.fromUTCDateTime( (time_t) map[ ORecur::Created ].toLong() ).date(); | 611 | data -> create = utc.fromUTCDateTime( (time_t) map[ ORecur::Created ].toLong() ).date(); |
582 | 612 | ||
583 | #if 0 | 613 | #if 0 |
584 | // FIXME: Exceptions currently not supported... | 614 | // FIXME: Exceptions currently not supported... |
585 | // Convert the list of exceptions from QString into ExceptionList | 615 | // Convert the list of exceptions from QString into ExceptionList |
586 | data -> list.clear(); | 616 | data -> list.clear(); |
587 | QString exceptStr = map[ ORecur::Exceptions ]; | 617 | QString exceptStr = map[ ORecur::Exceptions ]; |
588 | QStringList exceptList = QStringList::split( " ", exceptStr ); | 618 | QStringList exceptList = QStringList::split( " ", exceptStr ); |
589 | ... | 619 | ... |
590 | #endif | 620 | #endif |
591 | 621 | ||
592 | 622 | ||
593 | } | 623 | } |
624 | |||
625 | } \ No newline at end of file | ||
diff --git a/libopie2/opiepim/core/orecur.h b/libopie2/opiepim/core/orecur.h index d7ecd90..60508f5 100644 --- a/libopie2/opiepim/core/orecur.h +++ b/libopie2/opiepim/core/orecur.h | |||
@@ -1,38 +1,64 @@ | |||
1 | /* | 1 | /* |
2 | * GPL from TT | 2 | This file is part of the Opie Project |
3 | */ | 3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
4 | 29 | ||
5 | #ifndef OPIE_RECUR_H | 30 | #ifndef OPIE_RECUR_H |
6 | #define OPIE_RECUR_H | 31 | #define OPIE_RECUR_H |
7 | 32 | ||
8 | #include <sys/types.h> | 33 | #include <sys/types.h> |
9 | 34 | ||
10 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
11 | #include <qvaluelist.h> | 36 | #include <qvaluelist.h> |
12 | #include <qmap.h> | 37 | #include <qmap.h> |
13 | 38 | ||
14 | 39 | ||
40 | namespace Opie { | ||
15 | /** | 41 | /** |
16 | * Class to handle Recurrencies.. | 42 | * Class to handle Recurrencies.. |
17 | */ | 43 | */ |
18 | 44 | ||
19 | class ORecur { | 45 | class ORecur { |
20 | public: | 46 | public: |
21 | typedef QValueList<QDate> ExceptionList; | 47 | typedef QValueList<QDate> ExceptionList; |
22 | enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay, | 48 | enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay, |
23 | MonthlyDate, Yearly }; | 49 | MonthlyDate, Yearly }; |
24 | enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08, | 50 | enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08, |
25 | FRI = 0x10, SAT = 0x20, SUN = 0x40 }; | 51 | FRI = 0x10, SAT = 0x20, SUN = 0x40 }; |
26 | enum Fields{ RType = 0, RWeekdays, RPosition, RFreq, RHasEndDate, | 52 | enum Fields{ RType = 0, RWeekdays, RPosition, RFreq, RHasEndDate, |
27 | EndDate, Created, Exceptions }; | 53 | EndDate, Created, Exceptions }; |
28 | 54 | ||
29 | ORecur(); | 55 | ORecur(); |
30 | ORecur( const QMap<int, QString>& map ); | 56 | ORecur( const QMap<int, QString>& map ); |
31 | ORecur( const ORecur& ); | 57 | ORecur( const ORecur& ); |
32 | ~ORecur(); | 58 | ~ORecur(); |
33 | 59 | ||
34 | ORecur &operator=( const ORecur& ); | 60 | ORecur &operator=( const ORecur& ); |
35 | bool operator==(const ORecur& )const; | 61 | bool operator==(const ORecur& )const; |
36 | 62 | ||
37 | bool doesRecur()const; | 63 | bool doesRecur()const; |
38 | /* if it recurrs on that day */ | 64 | /* if it recurrs on that day */ |
@@ -83,25 +109,26 @@ public: | |||
83 | 109 | ||
84 | void setService( const QString& ser ); | 110 | void setService( const QString& ser ); |
85 | 111 | ||
86 | QMap<int, QString> toMap() const; | 112 | QMap<int, QString> toMap() const; |
87 | void fromMap( const QMap<int, QString>& map ); | 113 | void fromMap( const QMap<int, QString>& map ); |
88 | 114 | ||
89 | /* almost internal */ | 115 | /* almost internal */ |
90 | QString toString()const; | 116 | QString toString()const; |
91 | private: | 117 | private: |
92 | bool p_nextOccurrence( const QDate& from, QDate& next ); | 118 | bool p_nextOccurrence( const QDate& from, QDate& next ); |
93 | void deref(); | 119 | void deref(); |
94 | inline void checkOrModify(); | 120 | inline void checkOrModify(); |
95 | 121 | ||
96 | /* Converts rType to String */ | 122 | /* Converts rType to String */ |
97 | QString rTypeString() const; | 123 | QString rTypeString() const; |
98 | /* Returns a map to convert Stringname for RType to RepeatType */ | 124 | /* Returns a map to convert Stringname for RType to RepeatType */ |
99 | QMap<QString, RepeatType> rTypeValueConvertMap() const; | 125 | QMap<QString, RepeatType> rTypeValueConvertMap() const; |
100 | 126 | ||
101 | class Data; | 127 | class Data; |
102 | Data* data; | 128 | Data* data; |
103 | class ORecurPrivate; | 129 | class ORecurPrivate; |
104 | ORecurPrivate *d; | 130 | ORecurPrivate *d; |
105 | }; | 131 | }; |
106 | 132 | ||
133 | } | ||
107 | #endif | 134 | #endif |
diff --git a/libopie2/opiepim/core/otemplatebase.h b/libopie2/opiepim/core/otemplatebase.h index cadac74..17d9961 100644 --- a/libopie2/opiepim/core/otemplatebase.h +++ b/libopie2/opiepim/core/otemplatebase.h | |||
@@ -1,32 +1,61 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #ifndef OPIE_TEMPLATE_BASE_H | 29 | #ifndef OPIE_TEMPLATE_BASE_H |
2 | #define OPIE_TEMPLATE_BASE_H | 30 | #define OPIE_TEMPLATE_BASE_H |
3 | 31 | ||
4 | #include <qarray.h> | 32 | #include <qarray.h> |
5 | 33 | ||
6 | #include <opie/opimrecord.h> | 34 | #include <opie2/opimrecord.h> |
7 | 35 | ||
8 | 36 | ||
37 | namespace Opie { | ||
9 | /** | 38 | /** |
10 | * Templates do not have a base class, This is why | 39 | * Templates do not have a base class, This is why |
11 | * we've this class | 40 | * we've this class |
12 | * this is here to give us the possibility | 41 | * this is here to give us the possibility |
13 | * to have a common base class | 42 | * to have a common base class |
14 | * You may not want to use that interface internaly | 43 | * You may not want to use that interface internaly |
15 | * POOR mans interface | 44 | * POOR mans interface |
16 | */ | 45 | */ |
17 | class OPimBasePrivate; | 46 | class OPimBasePrivate; |
18 | struct OPimBase { | 47 | struct OPimBase { |
19 | /** | 48 | /** |
20 | * return the rtti | 49 | * return the rtti |
21 | */ | 50 | */ |
22 | virtual int rtti()= 0; | 51 | virtual int rtti()= 0; |
23 | virtual OPimRecord* record()const = 0; | 52 | virtual OPimRecord* record()const = 0; |
24 | virtual OPimRecord* record(int uid)const = 0; | 53 | virtual OPimRecord* record(int uid)const = 0; |
25 | virtual bool add( const OPimRecord& ) = 0; | 54 | virtual bool add( const OPimRecord& ) = 0; |
26 | virtual bool remove( int uid ) = 0; | 55 | virtual bool remove( int uid ) = 0; |
27 | virtual bool remove( const OPimRecord& ) = 0; | 56 | virtual bool remove( const OPimRecord& ) = 0; |
28 | virtual void clear() = 0; | 57 | virtual void clear() = 0; |
29 | virtual bool load() = 0; | 58 | virtual bool load() = 0; |
30 | virtual bool save() = 0; | 59 | virtual bool save() = 0; |
31 | virtual QArray<int> records()const = 0; | 60 | virtual QArray<int> records()const = 0; |
32 | /* | 61 | /* |
@@ -74,25 +103,27 @@ private: | |||
74 | * implementation | 103 | * implementation |
75 | */ | 104 | */ |
76 | template <class T> | 105 | template <class T> |
77 | int | 106 | int |
78 | OTemplateBase<T>::rtti() { | 107 | OTemplateBase<T>::rtti() { |
79 | return T::rtti(); | 108 | return T::rtti(); |
80 | } | 109 | } |
81 | template <class T> | 110 | template <class T> |
82 | OPimRecord* OTemplateBase<T>::record()const { | 111 | OPimRecord* OTemplateBase<T>::record()const { |
83 | T* t = new T; | 112 | T* t = new T; |
84 | return t; | 113 | return t; |
85 | } | 114 | } |
86 | template <class T> | 115 | template <class T> |
87 | OPimRecord* OTemplateBase<T>::record(int uid )const { | 116 | OPimRecord* OTemplateBase<T>::record(int uid )const { |
88 | T t2 = find(uid ); | 117 | T t2 = find(uid ); |
89 | T* t1 = new T(t2); | 118 | T* t1 = new T(t2); |
90 | 119 | ||
91 | return t1; | 120 | return t1; |
92 | }; | 121 | }; |
93 | template <class T> | 122 | template <class T> |
94 | T* OTemplateBase<T>::rec() { | 123 | T* OTemplateBase<T>::rec() { |
95 | return new T; | 124 | return new T; |
96 | } | 125 | } |
97 | 126 | ||
127 | } | ||
128 | |||
98 | #endif | 129 | #endif |
diff --git a/libopie2/opiepim/core/otimezone.cpp b/libopie2/opiepim/core/otimezone.cpp index 34659c3..dab68af 100644 --- a/libopie2/opiepim/core/otimezone.cpp +++ b/libopie2/opiepim/core/otimezone.cpp | |||
@@ -1,32 +1,61 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | |||
1 | #include <stdio.h> | 30 | #include <stdio.h> |
2 | #include <stdlib.h> | 31 | #include <stdlib.h> |
3 | 32 | ||
4 | #include <sys/types.h> | 33 | #include <sys/types.h> |
5 | 34 | ||
6 | #include "otimezone.h" | 35 | #include <opie2/otimezone.h> |
7 | 36 | ||
8 | namespace { | 37 | namespace Opie { |
9 | 38 | ||
10 | QDateTime utcTime( time_t t) { | 39 | QDateTime utcTime( time_t t) { |
11 | tm* broken = ::gmtime( &t ); | 40 | tm* broken = ::gmtime( &t ); |
12 | QDateTime ret; | 41 | QDateTime ret; |
13 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon +1, broken->tm_mday ) ); | 42 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon +1, broken->tm_mday ) ); |
14 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); | 43 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); |
15 | return ret; | 44 | return ret; |
16 | } | 45 | } |
17 | QDateTime utcTime( time_t t, const QString& zone) { | 46 | QDateTime utcTime( time_t t, const QString& zone) { |
18 | QCString org = ::getenv( "TZ" ); | 47 | QCString org = ::getenv( "TZ" ); |
19 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac | 48 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac |
20 | ::setenv( "TZ", zone.latin1(), true ); | 49 | ::setenv( "TZ", zone.latin1(), true ); |
21 | ::tzset(); | 50 | ::tzset(); |
22 | 51 | ||
23 | tm* broken = ::localtime( &t ); | 52 | tm* broken = ::localtime( &t ); |
24 | ::setenv( "TZ", org, true ); | 53 | ::setenv( "TZ", org, true ); |
25 | #else | 54 | #else |
26 | #warning "Need a replacement for MacOSX!!" | 55 | #warning "Need a replacement for MacOSX!!" |
27 | tm* broken = ::localtime( &t ); | 56 | tm* broken = ::localtime( &t ); |
28 | #endif | 57 | #endif |
29 | 58 | ||
30 | QDateTime ret; | 59 | QDateTime ret; |
31 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon +1, broken->tm_mday ) ); | 60 | ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon +1, broken->tm_mday ) ); |
32 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); | 61 | ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); |
@@ -38,48 +67,50 @@ namespace { | |||
38 | QTime t = utc.time(); | 67 | QTime t = utc.time(); |
39 | 68 | ||
40 | tm broken; | 69 | tm broken; |
41 | broken.tm_year = d.year() - 1900; | 70 | broken.tm_year = d.year() - 1900; |
42 | broken.tm_mon = d.month() - 1; | 71 | broken.tm_mon = d.month() - 1; |
43 | broken.tm_mday = d.day(); | 72 | broken.tm_mday = d.day(); |
44 | broken.tm_hour = t.hour(); | 73 | broken.tm_hour = t.hour(); |
45 | broken.tm_min = t.minute(); | 74 | broken.tm_min = t.minute(); |
46 | broken.tm_sec = t.second(); | 75 | broken.tm_sec = t.second(); |
47 | 76 | ||
48 | QCString org = ::getenv( "TZ" ); | 77 | QCString org = ::getenv( "TZ" ); |
49 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac | 78 | #ifndef Q_OS_MACX // Following line causes bus errors on Mac |
50 | ::setenv( "TZ", str.latin1(), true ); | 79 | ::setenv( "TZ", str.latin1(), true ); |
51 | ::tzset(); | 80 | ::tzset(); |
52 | 81 | ||
53 | time_t ti = ::mktime( &broken ); | 82 | time_t ti = ::mktime( &broken ); |
54 | ::setenv( "TZ", org, true ); | 83 | ::setenv( "TZ", org, true ); |
55 | #else | 84 | #else |
56 | #warning "Need a replacement for MacOSX!!" | 85 | #warning "Need a replacement for MacOSX!!" |
57 | time_t ti = ::mktime( &broken ); | 86 | time_t ti = ::mktime( &broken ); |
58 | #endif | 87 | #endif |
59 | return ti; | 88 | return ti; |
60 | } | 89 | } |
61 | } | 90 | } |
91 | |||
92 | namespace Opie { | ||
62 | OTimeZone::OTimeZone( const ZoneName& zone ) | 93 | OTimeZone::OTimeZone( const ZoneName& zone ) |
63 | : m_name(zone) { | 94 | : m_name(zone) { |
64 | } | 95 | } |
65 | OTimeZone::~OTimeZone() { | 96 | OTimeZone::~OTimeZone() { |
66 | } | 97 | } |
67 | 98 | ||
68 | bool OTimeZone::isValid()const { | 99 | bool OTimeZone::isValid()const { |
69 | return !m_name.isEmpty(); | 100 | return !m_name.isEmpty(); |
70 | } | 101 | } |
71 | 102 | ||
72 | /* | 103 | /* |
73 | * we will get the current timezone | 104 | * we will get the current timezone |
74 | * and ask it to convert to the timezone date | 105 | * and ask it to convert to the timezone date |
75 | */ | 106 | */ |
76 | QDateTime OTimeZone::toLocalDateTime( const QDateTime& dt) { | 107 | QDateTime OTimeZone::toLocalDateTime( const QDateTime& dt) { |
77 | return OTimeZone::current().toDateTime( dt, *this ); | 108 | return OTimeZone::current().toDateTime( dt, *this ); |
78 | } | 109 | } |
79 | QDateTime OTimeZone::toUTCDateTime( const QDateTime& dt ) { | 110 | QDateTime OTimeZone::toUTCDateTime( const QDateTime& dt ) { |
80 | return OTimeZone::utc().toDateTime( dt, *this ); | 111 | return OTimeZone::utc().toDateTime( dt, *this ); |
81 | } | 112 | } |
82 | QDateTime OTimeZone::fromUTCDateTime( time_t t) { | 113 | QDateTime OTimeZone::fromUTCDateTime( time_t t) { |
83 | return utcTime( t ); | 114 | return utcTime( t ); |
84 | } | 115 | } |
85 | QDateTime OTimeZone::toDateTime( time_t t) { | 116 | QDateTime OTimeZone::toDateTime( time_t t) { |
@@ -90,24 +121,26 @@ QDateTime OTimeZone::toDateTime( time_t t) { | |||
90 | * convert utc -> timeZoneDT using this->m_name | 121 | * convert utc -> timeZoneDT using this->m_name |
91 | */ | 122 | */ |
92 | QDateTime OTimeZone::toDateTime( const QDateTime& dt, const OTimeZone& zone ) { | 123 | QDateTime OTimeZone::toDateTime( const QDateTime& dt, const OTimeZone& zone ) { |
93 | time_t utc = to_Time_t( dt, zone.m_name ); | 124 | time_t utc = to_Time_t( dt, zone.m_name ); |
94 | qWarning("%d %s", utc, zone.m_name.latin1() ); | 125 | qWarning("%d %s", utc, zone.m_name.latin1() ); |
95 | return utcTime( utc, m_name ); | 126 | return utcTime( utc, m_name ); |
96 | } | 127 | } |
97 | time_t OTimeZone::fromDateTime( const QDateTime& time ) { | 128 | time_t OTimeZone::fromDateTime( const QDateTime& time ) { |
98 | return to_Time_t( time, m_name ); | 129 | return to_Time_t( time, m_name ); |
99 | } | 130 | } |
100 | time_t OTimeZone::fromUTCDateTime( const QDateTime& time ) { | 131 | time_t OTimeZone::fromUTCDateTime( const QDateTime& time ) { |
101 | return to_Time_t( time, "UTC" ); | 132 | return to_Time_t( time, "UTC" ); |
102 | } | 133 | } |
103 | OTimeZone OTimeZone::current() { | 134 | OTimeZone OTimeZone::current() { |
104 | QCString str = ::getenv("TZ"); | 135 | QCString str = ::getenv("TZ"); |
105 | OTimeZone zone( str ); | 136 | OTimeZone zone( str ); |
106 | return zone; | 137 | return zone; |
107 | } | 138 | } |
108 | OTimeZone OTimeZone::utc() { | 139 | OTimeZone OTimeZone::utc() { |
109 | return OTimeZone("UTC"); | 140 | return OTimeZone("UTC"); |
110 | } | 141 | } |
111 | QString OTimeZone::timeZone()const { | 142 | QString OTimeZone::timeZone()const { |
112 | return m_name; | 143 | return m_name; |
113 | } | 144 | } |
145 | |||
146 | } | ||
diff --git a/libopie2/opiepim/core/otimezone.h b/libopie2/opiepim/core/otimezone.h index bb08349..28ae6cb 100644 --- a/libopie2/opiepim/core/otimezone.h +++ b/libopie2/opiepim/core/otimezone.h | |||
@@ -1,30 +1,61 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | |||
1 | #ifndef OPIE_TIME_ZONE_H | 30 | #ifndef OPIE_TIME_ZONE_H |
2 | #define OPIE_TIME_ZONE_H | 31 | #define OPIE_TIME_ZONE_H |
3 | 32 | ||
4 | #include <time.h> | 33 | #include <time.h> |
5 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
6 | 35 | ||
36 | namespace Opie | ||
37 | { | ||
7 | /** | 38 | /** |
8 | * A very primitive class to convert time | 39 | * A very primitive class to convert time |
9 | * from one timezone to another | 40 | * from one timezone to another |
10 | * and to localtime | 41 | * and to localtime |
11 | * and time_t | 42 | * and time_t |
12 | */ | 43 | */ |
13 | class OTimeZone { | 44 | class OTimeZone { |
14 | public: | 45 | public: |
15 | typedef QString ZoneName; | 46 | typedef QString ZoneName; |
16 | OTimeZone( const ZoneName& = ZoneName::null ); | 47 | OTimeZone( const ZoneName& = ZoneName::null ); |
17 | virtual ~OTimeZone(); // just in case. | 48 | virtual ~OTimeZone(); // just in case. |
18 | 49 | ||
19 | bool isValid()const; | 50 | bool isValid()const; |
20 | 51 | ||
21 | /** | 52 | /** |
22 | * converts the QDateTime to a DateTime | 53 | * converts the QDateTime to a DateTime |
23 | * in the local timezone | 54 | * in the local timezone |
24 | * if QDateTime is 25th Jan and takes place in Europe/Berlin at 12h | 55 | * if QDateTime is 25th Jan and takes place in Europe/Berlin at 12h |
25 | * and the current timezone is Europe/London the returned | 56 | * and the current timezone is Europe/London the returned |
26 | * time will be 11h. | 57 | * time will be 11h. |
27 | */ | 58 | */ |
28 | QDateTime toLocalDateTime( const QDateTime& dt ); | 59 | QDateTime toLocalDateTime( const QDateTime& dt ); |
29 | 60 | ||
30 | /** | 61 | /** |
@@ -45,27 +76,27 @@ class OTimeZone { | |||
45 | /** | 76 | /** |
46 | * converts the QDateTime from one timezone to this timeZone | 77 | * converts the QDateTime from one timezone to this timeZone |
47 | */ | 78 | */ |
48 | QDateTime toDateTime( const QDateTime&, const OTimeZone& timeZone ); | 79 | QDateTime toDateTime( const QDateTime&, const OTimeZone& timeZone ); |
49 | 80 | ||
50 | /** | 81 | /** |
51 | * converts the date time into a time_t. It takes the timezone into account | 82 | * converts the date time into a time_t. It takes the timezone into account |
52 | */ | 83 | */ |
53 | time_t fromDateTime( const QDateTime& ); | 84 | time_t fromDateTime( const QDateTime& ); |
54 | 85 | ||
55 | /** | 86 | /** |
56 | * converts the datetime with timezone UTC | 87 | * converts the datetime with timezone UTC |
57 | */ | 88 | */ |
58 | time_t fromUTCDateTime( const QDateTime& ); | 89 | time_t fromUTCDateTime( const QDateTime& ); |
59 | 90 | ||
60 | static OTimeZone current(); | 91 | static OTimeZone current(); |
61 | static OTimeZone utc(); | 92 | static OTimeZone utc(); |
62 | 93 | ||
63 | QString timeZone()const; | 94 | QString timeZone()const; |
64 | private: | 95 | private: |
65 | ZoneName m_name; | 96 | ZoneName m_name; |
66 | class Private; | 97 | class Private; |
67 | Private* d; | 98 | Private* d; |
68 | }; | 99 | }; |
69 | 100 | }; | |
70 | 101 | ||
71 | #endif | 102 | #endif |
diff --git a/libopie2/opiepim/core/otodoaccess.cpp b/libopie2/opiepim/core/otodoaccess.cpp index 37f6fbc..2a3695d 100644 --- a/libopie2/opiepim/core/otodoaccess.cpp +++ b/libopie2/opiepim/core/otodoaccess.cpp | |||
@@ -1,62 +1,93 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #include <qdatetime.h> | 29 | #include <qdatetime.h> |
2 | 30 | ||
3 | #include <qpe/alarmserver.h> | 31 | #include <qpe/alarmserver.h> |
4 | 32 | ||
5 | // #include "otodoaccesssql.h" | 33 | // #include "otodoaccesssql.h" |
6 | #include "otodoaccess.h" | 34 | #include <opie2/otodoaccess.h> |
7 | #include "obackendfactory.h" | 35 | #include <opie2/obackendfactory.h> |
8 | 36 | ||
37 | namespace Opie { | ||
9 | OTodoAccess::OTodoAccess( OTodoAccessBackend* end, enum Access ) | 38 | OTodoAccess::OTodoAccess( OTodoAccessBackend* end, enum Access ) |
10 | : QObject(), OPimAccessTemplate<OTodo>( end ), m_todoBackEnd( end ) | 39 | : QObject(), OPimAccessTemplate<OTodo>( end ), m_todoBackEnd( end ) |
11 | { | 40 | { |
12 | // if (end == 0l ) | 41 | // if (end == 0l ) |
13 | // m_todoBackEnd = new OTodoAccessBackendSQL( QString::null); | 42 | // m_todoBackEnd = new OTodoAccessBackendSQL( QString::null); |
14 | 43 | ||
15 | // Zecke: Du musst hier noch für das XML-Backend einen Appnamen übergeben ! | 44 | // Zecke: Du musst hier noch fr das XML-Backend einen Appnamen bergeben ! |
16 | if (end == 0l ) | 45 | if (end == 0l ) |
17 | m_todoBackEnd = OBackendFactory<OTodoAccessBackend>::Default ("todo", QString::null); | 46 | m_todoBackEnd = OBackendFactory<OTodoAccessBackend>::Default ("todo", QString::null); |
18 | 47 | ||
19 | setBackEnd( m_todoBackEnd ); | 48 | setBackEnd( m_todoBackEnd ); |
20 | } | 49 | } |
21 | OTodoAccess::~OTodoAccess() { | 50 | OTodoAccess::~OTodoAccess() { |
22 | // qWarning("~OTodoAccess"); | 51 | // qWarning("~OTodoAccess"); |
23 | } | 52 | } |
24 | void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) { | 53 | void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) { |
25 | QValueList<OTodo>::ConstIterator it; | 54 | QValueList<OTodo>::ConstIterator it; |
26 | for ( it = list.begin(); it != list.end(); ++it ) { | 55 | for ( it = list.begin(); it != list.end(); ++it ) { |
27 | replace( (*it) ); | 56 | replace( (*it) ); |
28 | } | 57 | } |
29 | } | 58 | } |
30 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, | 59 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, |
31 | const QDate& end, | 60 | const QDate& end, |
32 | bool includeNoDates ) { | 61 | bool includeNoDates ) { |
33 | QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); | 62 | QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); |
34 | 63 | ||
35 | List lis( ints, this ); | 64 | List lis( ints, this ); |
36 | return lis; | 65 | return lis; |
37 | } | 66 | } |
38 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, | 67 | OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, |
39 | bool includeNoDates ) { | 68 | bool includeNoDates ) { |
40 | return effectiveToDos( start, QDate::currentDate(), | 69 | return effectiveToDos( start, QDate::currentDate(), |
41 | includeNoDates ); | 70 | includeNoDates ); |
42 | } | 71 | } |
43 | OTodoAccess::List OTodoAccess::overDue() { | 72 | OTodoAccess::List OTodoAccess::overDue() { |
44 | List lis( m_todoBackEnd->overDue(), this ); | 73 | List lis( m_todoBackEnd->overDue(), this ); |
45 | return lis; | 74 | return lis; |
46 | } | 75 | } |
47 | /* sort order */ | 76 | /* sort order */ |
48 | OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { | 77 | OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { |
49 | QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, | 78 | QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, |
50 | filter, cat ); | 79 | filter, cat ); |
51 | OTodoAccess::List list( ints, this ); | 80 | OTodoAccess::List list( ints, this ); |
52 | return list; | 81 | return list; |
53 | } | 82 | } |
54 | void OTodoAccess::removeAllCompleted() { | 83 | void OTodoAccess::removeAllCompleted() { |
55 | m_todoBackEnd->removeAllCompleted(); | 84 | m_todoBackEnd->removeAllCompleted(); |
56 | } | 85 | } |
57 | QBitArray OTodoAccess::backendSupport( const QString& ) const{ | 86 | QBitArray OTodoAccess::backendSupport( const QString& ) const{ |
58 | return m_todoBackEnd->supports(); | 87 | return m_todoBackEnd->supports(); |
59 | } | 88 | } |
60 | bool OTodoAccess::backendSupports( int attr, const QString& ar) const{ | 89 | bool OTodoAccess::backendSupports( int attr, const QString& ar) const{ |
61 | return backendSupport(ar).testBit( attr ); | 90 | return backendSupport(ar).testBit( attr ); |
62 | } | 91 | } |
92 | |||
93 | } | ||
diff --git a/libopie2/opiepim/core/otodoaccess.h b/libopie2/opiepim/core/otodoaccess.h index 916923f..e13d277 100644 --- a/libopie2/opiepim/core/otodoaccess.h +++ b/libopie2/opiepim/core/otodoaccess.h | |||
@@ -1,34 +1,63 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.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 | */ | ||
1 | #ifndef OPIE_TODO_ACCESS_H | 29 | #ifndef OPIE_TODO_ACCESS_H |
2 | #define OPIE_TODO_ACCESS_H | 30 | #define OPIE_TODO_ACCESS_H |
3 | 31 | ||
4 | #include <qobject.h> | 32 | #include <qobject.h> |
5 | #include <qvaluelist.h> | 33 | #include <qvaluelist.h> |
6 | 34 | ||
7 | #include "otodo.h" | 35 | #include <opie2/otodo.h> |
8 | #include "otodoaccessbackend.h" | 36 | #include <opie2/otodoaccessbackend.h> |
9 | #include "opimaccesstemplate.h" | 37 | #include <opie2/opimaccesstemplate.h> |
10 | 38 | ||
39 | namespace Opie { | ||
11 | 40 | ||
12 | /** | 41 | /** |
13 | * OTodoAccess | 42 | * OTodoAccess |
14 | * the class to get access to | 43 | * the class to get access to |
15 | * the todolist | 44 | * the todolist |
16 | */ | 45 | */ |
17 | class OTodoAccess : public QObject, public OPimAccessTemplate<OTodo> { | 46 | class OTodoAccess : public QObject, public OPimAccessTemplate<OTodo> { |
18 | Q_OBJECT | 47 | Q_OBJECT |
19 | public: | 48 | public: |
20 | enum SortOrder { Completed = 0, | 49 | enum SortOrder { Completed = 0, |
21 | Priority, | 50 | Priority, |
22 | Description, | 51 | Description, |
23 | Deadline }; | 52 | Deadline }; |
24 | enum SortFilter{ Category =1, | 53 | enum SortFilter{ Category =1, |
25 | OnlyOverDue= 2, | 54 | OnlyOverDue= 2, |
26 | DoNotShowCompleted =4 }; | 55 | DoNotShowCompleted =4 }; |
27 | /** | 56 | /** |
28 | * if you use 0l | 57 | * if you use 0l |
29 | * the default resource will be | 58 | * the default resource will be |
30 | * picked up | 59 | * picked up |
31 | */ | 60 | */ |
32 | OTodoAccess( OTodoAccessBackend* = 0l, enum Access acc = Random ); | 61 | OTodoAccess( OTodoAccessBackend* = 0l, enum Access acc = Random ); |
33 | ~OTodoAccess(); | 62 | ~OTodoAccess(); |
34 | 63 | ||
@@ -81,25 +110,27 @@ public: | |||
81 | */ | 110 | */ |
82 | QBitArray backendSupport( const QString& backend = QString::null )const; | 111 | QBitArray backendSupport( const QString& backend = QString::null )const; |
83 | 112 | ||
84 | /** | 113 | /** |
85 | * see above but for a specefic attribute. This method was added for convience | 114 | * see above but for a specefic attribute. This method was added for convience |
86 | * @param attr The attribute to be queried for | 115 | * @param attr The attribute to be queried for |
87 | * @param backend Will be used in the future when we support multiple backends | 116 | * @param backend Will be used in the future when we support multiple backends |
88 | */ | 117 | */ |
89 | bool backendSupports( int attr, const QString& backend = QString::null )const; | 118 | bool backendSupports( int attr, const QString& backend = QString::null )const; |
90 | signals: | 119 | signals: |
91 | /** | 120 | /** |
92 | * if the OTodoAccess was changed | 121 | * if the OTodoAccess was changed |
93 | */ | 122 | */ |
94 | void changed( const OTodoAccess* ); | 123 | void changed( const OTodoAccess* ); |
95 | void changed( const OTodoAccess*, int uid ); | 124 | void changed( const OTodoAccess*, int uid ); |
96 | void added( const OTodoAccess*, int uid ); | 125 | void added( const OTodoAccess*, int uid ); |
97 | void removed( const OTodoAccess*, int uid ); | 126 | void removed( const OTodoAccess*, int uid ); |
98 | private: | 127 | private: |
99 | int m_cat; | 128 | int m_cat; |
100 | OTodoAccessBackend* m_todoBackEnd; | 129 | OTodoAccessBackend* m_todoBackEnd; |
101 | class OTodoAccessPrivate; | 130 | class OTodoAccessPrivate; |
102 | OTodoAccessPrivate* d; | 131 | OTodoAccessPrivate* d; |
103 | }; | 132 | }; |
104 | 133 | ||
134 | } | ||
135 | |||
105 | #endif | 136 | #endif |