author | eilers <eilers> | 2003-08-01 12:30:16 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-08-01 12:30:16 (UTC) |
commit | 6c715b67a8f0e32a4edca5be91332622834c8d91 (patch) (unidiff) | |
tree | ae2d660e1fd9c990c2d725c075ce6c42480b0af8 | |
parent | cb45aa10043fdd6fddcab42ef0e07ddafc3d506d (diff) | |
download | opie-6c715b67a8f0e32a4edca5be91332622834c8d91.zip opie-6c715b67a8f0e32a4edca5be91332622834c8d91.tar.gz opie-6c715b67a8f0e32a4edca5be91332622834c8d91.tar.bz2 |
Merging changes from BRANCH_1_0 to HEAD
48 files changed, 678 insertions, 263 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 34bf7f1..6819085 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -1,217 +1,216 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2003 Stefan Eilers (eilers.stefan@epost.de) | ||
3 | ** | 4 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 5 | ** This file is part of the Open Palmtop Environment (see www.opie.info). |
5 | ** | 6 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 10 | ** packaging of this file. |
10 | ** | 11 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 14 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 16 | ** |
16 | ** OContact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | 17 | ** |
19 | **********************************************************************/ | 18 | **********************************************************************/ |
20 | 19 | ||
21 | #define QTOPIA_INTERNAL_FD | 20 | #define QTOPIA_INTERNAL_FD |
22 | 21 | ||
23 | #include "contacteditor.h" | 22 | #include "contacteditor.h" |
24 | #include "ablabel.h" | 23 | #include "ablabel.h" |
25 | #include "abview.h" | 24 | #include "abview.h" |
26 | #include "abtable.h" | 25 | #include "abtable.h" |
27 | // #include "addresssettings.h" | 26 | // #include "addresssettings.h" |
28 | #include "addressbook.h" | 27 | #include "addressbook.h" |
29 | 28 | ||
30 | 29 | ||
31 | #include <opie/ofileselector.h> | 30 | #include <opie/ofileselector.h> |
32 | #include <opie/ofiledialog.h> | 31 | #include <opie/ofiledialog.h> |
33 | #include <opie/ocontact.h> | 32 | #include <opie/ocontact.h> |
34 | #include <opie/ocontactaccessbackend_vcard.h> | 33 | #include <opie/ocontactaccessbackend_vcard.h> |
35 | 34 | ||
36 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
37 | #include <qpe/ir.h> | 36 | #include <qpe/ir.h> |
38 | #include <qpe/qpemessagebox.h> | 37 | #include <qpe/qpemessagebox.h> |
39 | #include <qpe/qcopenvelope_qws.h> | 38 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/qpetoolbar.h> | 39 | #include <qpe/qpetoolbar.h> |
41 | #include <qpe/qpemenubar.h> | 40 | #include <qpe/qpemenubar.h> |
42 | // #include <qtoolbar.h> | 41 | // #include <qtoolbar.h> |
43 | // #include <qmenubar.h> | 42 | // #include <qmenubar.h> |
44 | #include <qpe/qpeapplication.h> | 43 | #include <qpe/qpeapplication.h> |
45 | #include <qpe/config.h> | 44 | #include <qpe/config.h> |
46 | 45 | ||
47 | #include <qaction.h> | 46 | #include <qaction.h> |
48 | #include <qdialog.h> | 47 | #include <qdialog.h> |
49 | #include <qdir.h> | 48 | #include <qdir.h> |
50 | #include <qfile.h> | 49 | #include <qfile.h> |
51 | #include <qimage.h> | 50 | #include <qimage.h> |
52 | #include <qlayout.h> | 51 | #include <qlayout.h> |
53 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
54 | #include <qpixmap.h> | 53 | #include <qpixmap.h> |
55 | #include <qpopupmenu.h> | 54 | #include <qpopupmenu.h> |
56 | #include <qstringlist.h> | 55 | #include <qstringlist.h> |
57 | #include <qtoolbutton.h> | 56 | #include <qtoolbutton.h> |
58 | #include <qwhatsthis.h> | 57 | #include <qwhatsthis.h> |
59 | #include <qdatetime.h> | 58 | #include <qdatetime.h> |
60 | 59 | ||
61 | #include <stdlib.h> | 60 | #include <stdlib.h> |
62 | #include <sys/stat.h> | 61 | #include <sys/stat.h> |
63 | #include <sys/types.h> | 62 | #include <sys/types.h> |
64 | #include <fcntl.h> | 63 | #include <fcntl.h> |
65 | #include <unistd.h> | 64 | #include <unistd.h> |
66 | 65 | ||
67 | 66 | ||
68 | #include "picker.h" | 67 | #include "picker.h" |
69 | #include "configdlg.h" | 68 | #include "configdlg.h" |
70 | 69 | ||
71 | extern QString addressbookPersonalVCardName(); | 70 | extern QString addressbookPersonalVCardName(); |
72 | 71 | ||
73 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 72 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, |
74 | WFlags f ) | 73 | WFlags f ) |
75 | : QMainWindow( parent, name, f ), | 74 | : QMainWindow( parent, name, f ), |
76 | catMenu (0l), | 75 | catMenu (0l), |
77 | abEditor(0l), | 76 | abEditor(0l), |
78 | syncing(FALSE), | 77 | syncing(FALSE), |
79 | m_tableViewButton(0l), | 78 | m_tableViewButton(0l), |
80 | m_cardViewButton(0l) | 79 | m_cardViewButton(0l) |
81 | { | 80 | { |
82 | isLoading = true; | 81 | isLoading = true; |
83 | 82 | ||
84 | m_config.load(); | 83 | m_config.load(); |
85 | 84 | ||
86 | setCaption( tr("Contacts") ); | 85 | setCaption( tr("Contacts") ); |
87 | setIcon( Resource::loadPixmap( "AddressBook" ) ); | 86 | setIcon( Resource::loadPixmap( "AddressBook" ) ); |
88 | 87 | ||
89 | // Settings for Main Menu | 88 | // Settings for Main Menu |
90 | // setToolBarsMovable( false ); | 89 | // setToolBarsMovable( false ); |
91 | setToolBarsMovable( !m_config.fixedBars() ); | 90 | setToolBarsMovable( !m_config.fixedBars() ); |
92 | setRightJustification( true ); | 91 | setRightJustification( true ); |
93 | 92 | ||
94 | QPEToolBar *bar = new QPEToolBar( this ); | 93 | QPEToolBar *bar = new QPEToolBar( this ); |
95 | bar->setHorizontalStretchable( TRUE ); | 94 | bar->setHorizontalStretchable( TRUE ); |
96 | 95 | ||
97 | QPEMenuBar *mbList = new QPEMenuBar( bar ); | 96 | QPEMenuBar *mbList = new QPEMenuBar( bar ); |
98 | mbList->setMargin( 0 ); | 97 | mbList->setMargin( 0 ); |
99 | 98 | ||
100 | QPopupMenu *edit = new QPopupMenu( mbList ); | 99 | QPopupMenu *edit = new QPopupMenu( mbList ); |
101 | mbList->insertItem( tr( "Contact" ), edit ); | 100 | mbList->insertItem( tr( "Contact" ), edit ); |
102 | 101 | ||
103 | // Category Menu | 102 | // Category Menu |
104 | catMenu = new QPopupMenu( this ); | 103 | catMenu = new QPopupMenu( this ); |
105 | catMenu->setCheckable( TRUE ); | 104 | catMenu->setCheckable( TRUE ); |
106 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); | 105 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); |
107 | mbList->insertItem( tr("View"), catMenu ); | 106 | mbList->insertItem( tr("View"), catMenu ); |
108 | 107 | ||
109 | // Create Toolbar | 108 | // Create Toolbar |
110 | listTools = new QPEToolBar( this, "list operations" ); | 109 | listTools = new QPEToolBar( this, "list operations" ); |
111 | listTools->setHorizontalStretchable( true ); | 110 | listTools->setHorizontalStretchable( true ); |
112 | addToolBar( listTools ); | 111 | addToolBar( listTools ); |
113 | moveToolBar( listTools, m_config.getToolBarPos() ); | 112 | moveToolBar( listTools, m_config.getToolBarPos() ); |
114 | 113 | ||
115 | // View Icons | 114 | // View Icons |
116 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/weeklst" ), | 115 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "addressbook/listview" ), |
117 | QString::null, 0, this, 0 ); | 116 | QString::null, 0, this, 0 ); |
118 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); | 117 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); |
119 | m_tableViewButton->setToggleAction( true ); | 118 | m_tableViewButton->setToggleAction( true ); |
120 | m_tableViewButton->addTo( listTools ); | 119 | m_tableViewButton->addTo( listTools ); |
121 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "day" ), QString::null, 0, this, 0 ); | 120 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "addressbook/cardview" ), QString::null, 0, this, 0 ); |
122 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); | 121 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); |
123 | m_cardViewButton->setToggleAction( true ); | 122 | m_cardViewButton->setToggleAction( true ); |
124 | m_cardViewButton->addTo( listTools ); | 123 | m_cardViewButton->addTo( listTools ); |
125 | 124 | ||
126 | listTools->addSeparator(); | 125 | listTools->addSeparator(); |
127 | 126 | ||
128 | // Other Buttons | 127 | // Other Buttons |
129 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, | 128 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, |
130 | 0, this, 0 ); | 129 | 0, this, 0 ); |
131 | actionNew = a; | 130 | actionNew = a; |
132 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); | 131 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); |
133 | a->addTo( edit ); | 132 | a->addTo( edit ); |
134 | a->addTo( listTools ); | 133 | a->addTo( listTools ); |
135 | 134 | ||
136 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 135 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
137 | 0, this, 0 ); | 136 | 0, this, 0 ); |
138 | actionEdit = a; | 137 | actionEdit = a; |
139 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); | 138 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); |
140 | a->addTo( edit ); | 139 | a->addTo( edit ); |
141 | a->addTo( listTools ); | 140 | a->addTo( listTools ); |
142 | 141 | ||
143 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 142 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
144 | 0, this, 0 ); | 143 | 0, this, 0 ); |
145 | actionTrash = a; | 144 | actionTrash = a; |
146 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); | 145 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); |
147 | a->addTo( edit ); | 146 | a->addTo( edit ); |
148 | a->addTo( listTools ); | 147 | a->addTo( listTools ); |
149 | 148 | ||
150 | 149 | ||
151 | // make it possible to go directly to businesscard via qcop call | 150 | // make it possible to go directly to businesscard via qcop call |
152 | //#if defined(Q_WS_QWS) // Why this ? (se) | 151 | //#if defined(Q_WS_QWS) // Why this ? (se) |
153 | #if !defined(QT_NO_COP) | 152 | #if !defined(QT_NO_COP) |
154 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); | 153 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); |
155 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 154 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
156 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); | 155 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); |
157 | #endif | 156 | #endif |
158 | // #endif | 157 | // #endif |
159 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), | 158 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), |
160 | QString::null, 0, this, 0 ); | 159 | QString::null, 0, this, 0 ); |
161 | actionFind = a; | 160 | actionFind = a; |
162 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); | 161 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); |
163 | a->addTo( edit ); | 162 | a->addTo( edit ); |
164 | a->addTo( listTools ); | 163 | a->addTo( listTools ); |
165 | 164 | ||
166 | // Much better search widget, taken from QTReader.. (se) | 165 | // Much better search widget, taken from QTReader.. (se) |
167 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 166 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
168 | searchBar->setHorizontalStretchable( TRUE ); | 167 | searchBar->setHorizontalStretchable( TRUE ); |
169 | searchBar->hide(); | 168 | searchBar->hide(); |
170 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 169 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
171 | 170 | ||
172 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 171 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
173 | // searchEdit->setFont( f ); | 172 | // searchEdit->setFont( f ); |
174 | 173 | ||
175 | searchBar->setStretchableWidget( searchEdit ); | 174 | searchBar->setStretchableWidget( searchEdit ); |
176 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 175 | connect( searchEdit, SIGNAL( returnPressed( ) ), |
177 | this, SLOT( slotFind( ) ) ); | 176 | this, SLOT( slotFind( ) ) ); |
178 | 177 | ||
179 | a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); | 178 | a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); |
180 | connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 179 | connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
181 | a->addTo( searchBar ); | 180 | a->addTo( searchBar ); |
182 | 181 | ||
183 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 182 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
184 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); | 183 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); |
185 | a->addTo( searchBar ); | 184 | a->addTo( searchBar ); |
186 | 185 | ||
187 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), | 186 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "addressbook/sendmail" ), |
188 | QString::null, 0, this, 0 ); | 187 | QString::null, 0, this, 0 ); |
189 | //a->setEnabled( FALSE ); we got support for it now :) zecke | 188 | //a->setEnabled( FALSE ); we got support for it now :) zecke |
190 | actionMail = a; | 189 | actionMail = a; |
191 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); | 190 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); |
192 | a->addTo( edit ); | 191 | a->addTo( edit ); |
193 | a->addTo( listTools ); | 192 | a->addTo( listTools ); |
194 | 193 | ||
195 | if ( Ir::supported() ) { | 194 | if ( Ir::supported() ) { |
196 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, | 195 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, |
197 | 0, this, 0 ); | 196 | 0, this, 0 ); |
198 | actionBeam = a; | 197 | actionBeam = a; |
199 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 198 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
200 | a->addTo( edit ); | 199 | a->addTo( edit ); |
201 | a->addTo( listTools ); | 200 | a->addTo( listTools ); |
202 | } | 201 | } |
203 | 202 | ||
204 | edit->insertSeparator(); | 203 | edit->insertSeparator(); |
205 | 204 | ||
206 | a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, | 205 | a = new QAction( tr("Import vCard"), Resource::loadPixmap( "addressbook/fileimport"), QString::null, |
207 | 0, this, 0); | 206 | 0, this, 0); |
208 | actionPersonal = a; | 207 | actionPersonal = a; |
209 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); | 208 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); |
210 | a->addTo( edit ); | 209 | a->addTo( edit ); |
211 | 210 | ||
212 | a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, | 211 | a = new QAction( tr("Export vCard"), Resource::loadPixmap( "addressbook/fileexport"), QString::null, |
213 | 0, this, 0); | 212 | 0, this, 0); |
214 | actionPersonal = a; | 213 | actionPersonal = a; |
215 | connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); | 214 | connect( a, SIGNAL( activated() ), this, SLOT( exportvCard() ) ); |
216 | a->addTo( edit ); | 215 | a->addTo( edit ); |
217 | 216 | ||
@@ -559,491 +558,497 @@ void AddressbookWindow::writeMail() | |||
559 | e << name << email; | 558 | e << name << email; |
560 | return; | 559 | return; |
561 | } else | 560 | } else |
562 | m_config.setUseOpieMail( true ); | 561 | m_config.setUseOpieMail( true ); |
563 | } | 562 | } |
564 | if ( m_config.useOpieMail() ){ | 563 | if ( m_config.useOpieMail() ){ |
565 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); | 564 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); |
566 | if ( QFile::exists( basepath + "/bin/mail" ) ){ | 565 | if ( QFile::exists( basepath + "/bin/mail" ) ){ |
567 | qWarning ("QCop"); | 566 | qWarning ("QCop"); |
568 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); | 567 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); |
569 | e << name << email; | 568 | e << name << email; |
570 | return; | 569 | return; |
571 | } else | 570 | } else |
572 | m_config.setUseQtMail( true ); | 571 | m_config.setUseQtMail( true ); |
573 | } | 572 | } |
574 | 573 | ||
575 | } | 574 | } |
576 | 575 | ||
577 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 576 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
578 | 577 | ||
579 | void AddressbookWindow::slotBeam() | 578 | void AddressbookWindow::slotBeam() |
580 | { | 579 | { |
581 | QString beamFilename; | 580 | QString beamFilename; |
582 | OContact c; | 581 | OContact c; |
583 | if ( actionPersonal->isOn() ) { | 582 | if ( actionPersonal->isOn() ) { |
584 | beamFilename = addressbookPersonalVCardName(); | 583 | beamFilename = addressbookPersonalVCardName(); |
585 | if ( !QFile::exists( beamFilename ) ) | 584 | if ( !QFile::exists( beamFilename ) ) |
586 | return; // can't beam a non-existent file | 585 | return; // can't beam a non-existent file |
587 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 586 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
588 | beamFilename ); | 587 | beamFilename ); |
589 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 588 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
590 | OContactAccess::List allList = access->allRecords(); | 589 | OContactAccess::List allList = access->allRecords(); |
591 | OContactAccess::List::Iterator it = allList.begin(); // Just take first | 590 | OContactAccess::List::Iterator it = allList.begin(); // Just take first |
592 | c = *it; | 591 | c = *it; |
593 | 592 | ||
594 | delete access; | 593 | delete access; |
595 | } else { | 594 | } else { |
596 | unlink( beamfile ); // delete if exists | 595 | unlink( beamfile ); // delete if exists |
597 | mkdir("/tmp/obex/", 0755); | 596 | mkdir("/tmp/obex/", 0755); |
598 | c = m_abView -> currentEntry(); | 597 | c = m_abView -> currentEntry(); |
599 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 598 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
600 | beamfile ); | 599 | beamfile ); |
601 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 600 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
602 | access->add( c ); | 601 | access->add( c ); |
603 | access->save(); | 602 | access->save(); |
604 | delete access; | 603 | delete access; |
605 | 604 | ||
606 | beamFilename = beamfile; | 605 | beamFilename = beamfile; |
607 | } | 606 | } |
608 | 607 | ||
609 | qWarning("Beaming: %s", beamFilename.latin1() ); | 608 | qWarning("Beaming: %s", beamFilename.latin1() ); |
610 | 609 | ||
611 | Ir *ir = new Ir( this ); | 610 | Ir *ir = new Ir( this ); |
612 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 611 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
613 | QString description = c.fullName(); | 612 | QString description = c.fullName(); |
614 | ir->send( beamFilename, description, "text/x-vCard" ); | 613 | ir->send( beamFilename, description, "text/x-vCard" ); |
615 | } | 614 | } |
616 | 615 | ||
617 | void AddressbookWindow::beamDone( Ir *ir ) | 616 | void AddressbookWindow::beamDone( Ir *ir ) |
618 | { | 617 | { |
619 | 618 | ||
620 | delete ir; | 619 | delete ir; |
621 | unlink( beamfile ); | 620 | unlink( beamfile ); |
622 | } | 621 | } |
623 | 622 | ||
624 | 623 | ||
625 | static void parseName( const QString& name, QString *first, QString *middle, | 624 | static void parseName( const QString& name, QString *first, QString *middle, |
626 | QString * last ) | 625 | QString * last ) |
627 | { | 626 | { |
628 | 627 | ||
629 | int comma = name.find ( "," ); | 628 | int comma = name.find ( "," ); |
630 | QString rest; | 629 | QString rest; |
631 | if ( comma > 0 ) { | 630 | if ( comma > 0 ) { |
632 | *last = name.left( comma ); | 631 | *last = name.left( comma ); |
633 | comma++; | 632 | comma++; |
634 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 633 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
635 | comma++; | 634 | comma++; |
636 | rest = name.mid( comma ); | 635 | rest = name.mid( comma ); |
637 | } else { | 636 | } else { |
638 | int space = name.findRev( ' ' ); | 637 | int space = name.findRev( ' ' ); |
639 | *last = name.mid( space+1 ); | 638 | *last = name.mid( space+1 ); |
640 | rest = name.left( space ); | 639 | rest = name.left( space ); |
641 | } | 640 | } |
642 | int space = rest.find( ' ' ); | 641 | int space = rest.find( ' ' ); |
643 | if ( space <= 0 ) { | 642 | if ( space <= 0 ) { |
644 | *first = rest; | 643 | *first = rest; |
645 | } else { | 644 | } else { |
646 | *first = rest.left( space ); | 645 | *first = rest.left( space ); |
647 | *middle = rest.mid( space+1 ); | 646 | *middle = rest.mid( space+1 ); |
648 | } | 647 | } |
649 | 648 | ||
650 | } | 649 | } |
651 | 650 | ||
652 | 651 | ||
653 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 652 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
654 | { | 653 | { |
655 | qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); | 654 | bool needShow = FALSE; |
655 | qWarning("Receiving QCop-Call with message %s", QString( msg ).latin1() ); | ||
656 | |||
656 | 657 | ||
657 | if (msg == "editPersonal()") { | 658 | if (msg == "editPersonal()") { |
658 | editPersonal(); | 659 | editPersonal(); |
659 | } else if (msg == "editPersonalAndClose()") { | 660 | } else if (msg == "editPersonalAndClose()") { |
660 | editPersonal(); | 661 | editPersonal(); |
661 | close(); | 662 | close(); |
662 | } else if ( msg == "addContact(QString,QString)" ) { | 663 | } else if ( msg == "addContact(QString,QString)" ) { |
663 | QDataStream stream(data,IO_ReadOnly); | 664 | QDataStream stream(data,IO_ReadOnly); |
664 | QString name, email; | 665 | QString name, email; |
665 | stream >> name >> email; | 666 | stream >> name >> email; |
666 | 667 | ||
667 | OContact cnt; | 668 | OContact cnt; |
668 | QString fn, mn, ln; | 669 | QString fn, mn, ln; |
669 | parseName( name, &fn, &mn, &ln ); | 670 | parseName( name, &fn, &mn, &ln ); |
670 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); | 671 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); |
671 | cnt.setFirstName( fn ); | 672 | cnt.setFirstName( fn ); |
672 | cnt.setMiddleName( mn ); | 673 | cnt.setMiddleName( mn ); |
673 | cnt.setLastName( ln ); | 674 | cnt.setLastName( ln ); |
674 | cnt.insertEmails( email ); | 675 | cnt.insertEmails( email ); |
675 | cnt.setDefaultEmail( email ); | 676 | cnt.setDefaultEmail( email ); |
676 | cnt.setFileAs(); | 677 | cnt.setFileAs(); |
677 | 678 | ||
678 | m_abView -> addEntry( cnt ); | 679 | m_abView -> addEntry( cnt ); |
679 | 680 | ||
680 | // :SXm_abView()->init( cnt ); | 681 | // :SXm_abView()->init( cnt ); |
681 | editEntry( EditEntry ); | 682 | editEntry( EditEntry ); |
682 | } else if ( msg == "beamBusinessCard()" ) { | 683 | } else if ( msg == "beamBusinessCard()" ) { |
683 | QString beamFilename = addressbookPersonalVCardName(); | 684 | QString beamFilename = addressbookPersonalVCardName(); |
684 | if ( !QFile::exists( beamFilename ) ) | 685 | if ( !QFile::exists( beamFilename ) ) |
685 | return; // can't beam a non-existent file | 686 | return; // can't beam a non-existent file |
686 | 687 | ||
687 | Ir *ir = new Ir( this ); | 688 | Ir *ir = new Ir( this ); |
688 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 689 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
689 | QString description = "mycard.vcf"; | 690 | QString description = "mycard.vcf"; |
690 | ir->send( beamFilename, description, "text/x-vCard" ); | 691 | ir->send( beamFilename, description, "text/x-vCard" ); |
691 | } else if ( msg == "show(int)" ) { | 692 | } else if ( msg == "show(int)" ) { |
693 | raise(); | ||
692 | QDataStream stream(data,IO_ReadOnly); | 694 | QDataStream stream(data,IO_ReadOnly); |
693 | int uid; | 695 | int uid; |
694 | stream >> uid; | 696 | stream >> uid; |
695 | 697 | ||
696 | qWarning( "Showing uid: %d" , uid ); | 698 | qWarning( "Showing uid: %d" , uid ); |
697 | 699 | ||
698 | // Deactivate Personal View.. | 700 | // Deactivate Personal View.. |
699 | if ( actionPersonal->isOn() ){ | 701 | if ( actionPersonal->isOn() ){ |
700 | actionPersonal->setOn( false ); | 702 | actionPersonal->setOn( false ); |
701 | slotPersonalView(); | 703 | slotPersonalView(); |
702 | } | 704 | } |
703 | 705 | ||
704 | // Reset category and show as card.. | 706 | // Reset category and show as card.. |
705 | m_abView -> setShowByCategory( QString::null ); | 707 | m_abView -> setShowByCategory( QString::null ); |
706 | m_abView -> setCurrentUid( uid ); | 708 | m_abView -> setCurrentUid( uid ); |
707 | slotViewSwitched ( AbView::CardView ); | 709 | slotViewSwitched ( AbView::CardView ); |
708 | 710 | ||
709 | showMaximized(); | 711 | needShow = true; |
710 | qApp->exec(); | 712 | |
711 | 713 | ||
712 | } else if ( msg == "edit(int)" ) { | 714 | } else if ( msg == "edit(int)" ) { |
713 | QDataStream stream(data,IO_ReadOnly); | 715 | QDataStream stream(data,IO_ReadOnly); |
714 | int uid; | 716 | int uid; |
715 | stream >> uid; | 717 | stream >> uid; |
716 | 718 | ||
717 | // Deactivate Personal View.. | 719 | // Deactivate Personal View.. |
718 | if ( actionPersonal->isOn() ){ | 720 | if ( actionPersonal->isOn() ){ |
719 | actionPersonal->setOn( false ); | 721 | actionPersonal->setOn( false ); |
720 | slotPersonalView(); | 722 | slotPersonalView(); |
721 | } | 723 | } |
722 | 724 | ||
723 | // Reset category and edit.. | 725 | // Reset category and edit.. |
724 | m_abView -> setShowByCategory( QString::null ); | 726 | m_abView -> setShowByCategory( QString::null ); |
725 | m_abView -> setCurrentUid( uid ); | 727 | m_abView -> setCurrentUid( uid ); |
726 | slotViewEdit(); | 728 | slotViewEdit(); |
727 | } | 729 | } |
730 | |||
731 | if (needShow) | ||
732 | QPEApplication::setKeepRunning(); | ||
728 | 733 | ||
729 | } | 734 | } |
730 | 735 | ||
731 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 736 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
732 | { | 737 | { |
733 | OContact entry; | 738 | OContact entry; |
734 | if ( !abEditor ) { | 739 | if ( !abEditor ) { |
735 | abEditor = new ContactEditor( entry, this, "editor" ); | 740 | abEditor = new ContactEditor( entry, this, "editor" ); |
736 | } | 741 | } |
737 | if ( entryMode == EditEntry ) | 742 | if ( entryMode == EditEntry ) |
738 | abEditor->setEntry( m_abView -> currentEntry() ); | 743 | abEditor->setEntry( m_abView -> currentEntry() ); |
739 | else if ( entryMode == NewEntry ) | 744 | else if ( entryMode == NewEntry ) |
740 | abEditor->setEntry( entry ); | 745 | abEditor->setEntry( entry ); |
741 | // other things may change the caption. | 746 | // other things may change the caption. |
742 | abEditor->setCaption( tr("Edit Address") ); | 747 | abEditor->setCaption( tr("Edit Address") ); |
743 | 748 | ||
744 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 749 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
745 | abEditor->showMaximized(); | 750 | abEditor->showMaximized(); |
746 | #endif | 751 | #endif |
747 | // fix the foxus... | 752 | // fix the foxus... |
748 | abEditor->setNameFocus(); | 753 | abEditor->setNameFocus(); |
749 | if ( abEditor->exec() ) { | 754 | if ( abEditor->exec() ) { |
750 | setFocus(); | 755 | setFocus(); |
751 | if ( entryMode == NewEntry ) { | 756 | if ( entryMode == NewEntry ) { |
752 | OContact insertEntry = abEditor->entry(); | 757 | OContact insertEntry = abEditor->entry(); |
753 | insertEntry.assignUid(); | 758 | insertEntry.assignUid(); |
754 | m_abView -> addEntry( insertEntry ); | 759 | m_abView -> addEntry( insertEntry ); |
755 | m_abView -> setCurrentUid( insertEntry.uid() ); | 760 | m_abView -> setCurrentUid( insertEntry.uid() ); |
756 | } else { | 761 | } else { |
757 | OContact replEntry = abEditor->entry(); | 762 | OContact replEntry = abEditor->entry(); |
758 | 763 | ||
759 | if ( !replEntry.isValidUid() ) | 764 | if ( !replEntry.isValidUid() ) |
760 | replEntry.assignUid(); | 765 | replEntry.assignUid(); |
761 | 766 | ||
762 | m_abView -> replaceEntry( replEntry ); | 767 | m_abView -> replaceEntry( replEntry ); |
763 | } | 768 | } |
764 | } | 769 | } |
765 | // populateCategories(); | 770 | // populateCategories(); |
766 | 771 | ||
767 | } | 772 | } |
768 | 773 | ||
769 | void AddressbookWindow::editPersonal() | 774 | void AddressbookWindow::editPersonal() |
770 | { | 775 | { |
771 | OContact entry; | 776 | OContact entry; |
772 | 777 | ||
773 | // Switch to personal view if not selected | 778 | // Switch to personal view if not selected |
774 | // but take care of the menu, too | 779 | // but take care of the menu, too |
775 | if ( ! actionPersonal->isOn() ){ | 780 | if ( ! actionPersonal->isOn() ){ |
776 | qWarning("*** ++++"); | 781 | qWarning("*** ++++"); |
777 | actionPersonal->setOn( true ); | 782 | actionPersonal->setOn( true ); |
778 | slotPersonalView(); | 783 | slotPersonalView(); |
779 | } | 784 | } |
780 | 785 | ||
781 | if ( !abEditor ) { | 786 | if ( !abEditor ) { |
782 | abEditor = new ContactEditor( entry, this, "editor" ); | 787 | abEditor = new ContactEditor( entry, this, "editor" ); |
783 | } | 788 | } |
784 | 789 | ||
785 | abEditor->setCaption(tr("Edit My Personal Details")); | 790 | abEditor->setCaption(tr("Edit My Personal Details")); |
786 | abEditor->setPersonalView( true ); | 791 | abEditor->setPersonalView( true ); |
787 | editEntry( EditEntry ); | 792 | editEntry( EditEntry ); |
788 | abEditor->setPersonalView( false ); | 793 | abEditor->setPersonalView( false ); |
789 | 794 | ||
790 | } | 795 | } |
791 | 796 | ||
792 | 797 | ||
793 | void AddressbookWindow::slotPersonalView() | 798 | void AddressbookWindow::slotPersonalView() |
794 | { | 799 | { |
795 | qWarning("slotPersonalView()"); | 800 | qWarning("slotPersonalView()"); |
796 | if (!actionPersonal->isOn()) { | 801 | if (!actionPersonal->isOn()) { |
797 | // we just turned it off | 802 | // we just turned it off |
798 | qWarning("slotPersonalView()-> OFF"); | 803 | qWarning("slotPersonalView()-> OFF"); |
799 | setCaption( tr("Contacts") ); | 804 | setCaption( tr("Contacts") ); |
800 | actionNew->setEnabled(TRUE); | 805 | actionNew->setEnabled(TRUE); |
801 | actionTrash->setEnabled(TRUE); | 806 | actionTrash->setEnabled(TRUE); |
802 | actionFind->setEnabled(TRUE); | 807 | actionFind->setEnabled(TRUE); |
803 | actionMail->setEnabled(TRUE); | 808 | actionMail->setEnabled(TRUE); |
804 | // slotUpdateToolbar(); | 809 | // slotUpdateToolbar(); |
805 | 810 | ||
806 | m_abView->showPersonal( false ); | 811 | m_abView->showPersonal( false ); |
807 | 812 | ||
808 | return; | 813 | return; |
809 | } | 814 | } |
810 | 815 | ||
811 | qWarning("slotPersonalView()-> ON"); | 816 | qWarning("slotPersonalView()-> ON"); |
812 | // XXX need to disable some QActions. | 817 | // XXX need to disable some QActions. |
813 | actionNew->setEnabled(FALSE); | 818 | actionNew->setEnabled(FALSE); |
814 | actionTrash->setEnabled(FALSE); | 819 | actionTrash->setEnabled(FALSE); |
815 | actionFind->setEnabled(FALSE); | 820 | actionFind->setEnabled(FALSE); |
816 | actionMail->setEnabled(FALSE); | 821 | actionMail->setEnabled(FALSE); |
817 | 822 | ||
818 | setCaption( tr("Contacts - My Personal Details") ); | 823 | setCaption( tr("Contacts - My Personal Details") ); |
819 | 824 | ||
820 | m_abView->showPersonal( true ); | 825 | m_abView->showPersonal( true ); |
821 | 826 | ||
822 | } | 827 | } |
823 | 828 | ||
824 | 829 | ||
825 | void AddressbookWindow::listIsEmpty( bool empty ) | 830 | void AddressbookWindow::listIsEmpty( bool empty ) |
826 | { | 831 | { |
827 | if ( !empty ) { | 832 | if ( !empty ) { |
828 | deleteButton->setEnabled( TRUE ); | 833 | deleteButton->setEnabled( TRUE ); |
829 | } | 834 | } |
830 | } | 835 | } |
831 | 836 | ||
832 | void AddressbookWindow::reload() | 837 | void AddressbookWindow::reload() |
833 | { | 838 | { |
834 | syncing = FALSE; | 839 | syncing = FALSE; |
835 | m_abView->clear(); | 840 | m_abView->clear(); |
836 | m_abView->reload(); | 841 | m_abView->reload(); |
837 | } | 842 | } |
838 | 843 | ||
839 | void AddressbookWindow::flush() | 844 | void AddressbookWindow::flush() |
840 | { | 845 | { |
841 | syncing = TRUE; | 846 | syncing = TRUE; |
842 | m_abView->save(); | 847 | m_abView->save(); |
843 | } | 848 | } |
844 | 849 | ||
845 | 850 | ||
846 | void AddressbookWindow::closeEvent( QCloseEvent *e ) | 851 | void AddressbookWindow::closeEvent( QCloseEvent *e ) |
847 | { | 852 | { |
848 | if(active_view == AbView::CardView){ | 853 | if(active_view == AbView::CardView){ |
849 | slotViewSwitched( AbView::TableView ); | 854 | slotViewSwitched( AbView::TableView ); |
850 | e->ignore(); | 855 | e->ignore(); |
851 | return; | 856 | return; |
852 | } | 857 | } |
853 | if(syncing) { | 858 | if(syncing) { |
854 | /* shouldn't we save, I hear you say? well its already been set | 859 | /* shouldn't we save, I hear you say? well its already been set |
855 | so that an edit can not occur during a sync, and we flushed | 860 | so that an edit can not occur during a sync, and we flushed |
856 | at the start of the sync, so there is no need to save | 861 | at the start of the sync, so there is no need to save |
857 | Saving however itself would cause problems. */ | 862 | Saving however itself would cause problems. */ |
858 | e->accept(); | 863 | e->accept(); |
859 | return; | 864 | return; |
860 | } | 865 | } |
861 | //################## shouldn't always save | 866 | //################## shouldn't always save |
862 | // True, but the database handles this automatically ! (se) | 867 | // True, but the database handles this automatically ! (se) |
863 | if ( save() ) | 868 | if ( save() ) |
864 | e->accept(); | 869 | e->accept(); |
865 | else | 870 | else |
866 | e->ignore(); | 871 | e->ignore(); |
867 | } | 872 | } |
868 | 873 | ||
869 | /* | 874 | /* |
870 | Returns TRUE if it is OK to exit | 875 | Returns TRUE if it is OK to exit |
871 | */ | 876 | */ |
872 | 877 | ||
873 | bool AddressbookWindow::save() | 878 | bool AddressbookWindow::save() |
874 | { | 879 | { |
875 | if ( !m_abView->save() ) { | 880 | if ( !m_abView->save() ) { |
876 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 881 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
877 | tr("Unable to save information.\n" | 882 | tr("Unable to save information.\n" |
878 | "Free up some space\n" | 883 | "Free up some space\n" |
879 | "and try again.\n" | 884 | "and try again.\n" |
880 | "\nQuit anyway?"), | 885 | "\nQuit anyway?"), |
881 | QMessageBox::Yes|QMessageBox::Escape, | 886 | QMessageBox::Yes|QMessageBox::Escape, |
882 | QMessageBox::No|QMessageBox::Default ) | 887 | QMessageBox::No|QMessageBox::Default ) |
883 | != QMessageBox::No ) | 888 | != QMessageBox::No ) |
884 | return TRUE; | 889 | return TRUE; |
885 | else | 890 | else |
886 | return FALSE; | 891 | return FALSE; |
887 | } | 892 | } |
888 | return TRUE; | 893 | return TRUE; |
889 | } | 894 | } |
890 | 895 | ||
891 | #ifdef __DEBUG_RELEASE | 896 | #ifdef __DEBUG_RELEASE |
892 | void AddressbookWindow::slotSave() | 897 | void AddressbookWindow::slotSave() |
893 | { | 898 | { |
894 | save(); | 899 | save(); |
895 | } | 900 | } |
896 | #endif | 901 | #endif |
897 | 902 | ||
898 | 903 | ||
899 | void AddressbookWindow::slotNotFound() | 904 | void AddressbookWindow::slotNotFound() |
900 | { | 905 | { |
901 | qWarning("Got notfound signal!"); | 906 | qWarning("Got notfound signal!"); |
902 | QMessageBox::information( this, tr( "Not Found" ), | 907 | QMessageBox::information( this, tr( "Not Found" ), |
903 | tr( "Unable to find a contact for this \n search pattern!" ) ); | 908 | "<qt>" + tr( "Unable to find a contact for this search pattern!" ) + "</qt>" ); |
904 | 909 | ||
905 | 910 | ||
906 | } | 911 | } |
907 | void AddressbookWindow::slotWrapAround() | 912 | void AddressbookWindow::slotWrapAround() |
908 | { | 913 | { |
909 | qWarning("Got wrap signal!"); | 914 | qWarning("Got wrap signal!"); |
910 | // if ( doNotifyWrapAround ) | 915 | // if ( doNotifyWrapAround ) |
911 | // QMessageBox::information( this, tr( "End of list" ), | 916 | // QMessageBox::information( this, tr( "End of list" ), |
912 | // tr( "End of list. Wrap around now...!" ) + "\n" ); | 917 | // tr( "End of list. Wrap around now...!" ) + "\n" ); |
913 | 918 | ||
914 | } | 919 | } |
915 | 920 | ||
916 | void AddressbookWindow::slotSetCategory( int c ) | 921 | void AddressbookWindow::slotSetCategory( int c ) |
917 | { | 922 | { |
918 | qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); | 923 | qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); |
919 | 924 | ||
920 | QString cat, book; | 925 | QString cat, book; |
921 | AbView::Views view = AbView::TableView; | 926 | AbView::Views view = AbView::TableView; |
922 | 927 | ||
923 | if ( c <= 0 ) | 928 | if ( c <= 0 ) |
924 | return; | 929 | return; |
925 | 930 | ||
926 | // Switch view | 931 | // Switch view |
927 | if ( c < 3 ) | 932 | if ( c < 3 ) |
928 | for ( unsigned int i = 1; i < 3; i++ ){ | 933 | for ( unsigned int i = 1; i < 3; i++ ){ |
929 | if ( catMenu ) | 934 | if ( catMenu ) |
930 | catMenu->setItemChecked( i, c == (int)i ); | 935 | catMenu->setItemChecked( i, c == (int)i ); |
931 | } | 936 | } |
932 | else | 937 | else |
933 | // Checkmark Category Menu Item Selected | 938 | // Checkmark Category Menu Item Selected |
934 | for ( unsigned int i = 3; i < catMenu->count(); i++ ) | 939 | for ( unsigned int i = 3; i < catMenu->count(); i++ ) |
935 | catMenu->setItemChecked( i, c == (int)i ); | 940 | catMenu->setItemChecked( i, c == (int)i ); |
936 | 941 | ||
937 | // Now switch to the selected category | 942 | // Now switch to the selected category |
938 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { | 943 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { |
939 | if (catMenu->isItemChecked( i )) { | 944 | if (catMenu->isItemChecked( i )) { |
940 | if ( i == 1 ){ // default List view | 945 | if ( i == 1 ){ // default List view |
941 | book = QString::null; | 946 | book = QString::null; |
942 | view = AbView::TableView; | 947 | view = AbView::TableView; |
943 | }else if ( i == 2 ){ | 948 | }else if ( i == 2 ){ |
944 | book = tr( "Cards" ); | 949 | book = tr( "Cards" ); |
945 | view = AbView::CardView; | 950 | view = AbView::CardView; |
946 | // }else if ( i == 3 ){ | 951 | // }else if ( i == 3 ){ |
947 | // book = tr( "Personal" ); | 952 | // book = tr( "Personal" ); |
948 | // view = AbView:: PersonalView; | 953 | // view = AbView:: PersonalView; |
949 | }else if ( i == 3 ){ // default All Categories | 954 | }else if ( i == 3 ){ // default All Categories |
950 | cat = QString::null; | 955 | cat = QString::null; |
951 | }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled | 956 | }else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled |
952 | cat = "Unfiled"; | 957 | cat = "Unfiled"; |
953 | qWarning ("Unfiled selected!!!"); | 958 | qWarning ("Unfiled selected!"); |
954 | }else{ | 959 | }else{ |
955 | cat = m_abView->categories()[i - 4]; | 960 | cat = m_abView->categories()[i - 4]; |
956 | } | 961 | } |
957 | } | 962 | } |
958 | } | 963 | } |
959 | 964 | ||
960 | // Switch to the selected View | 965 | // Switch to the selected View |
961 | slotViewSwitched( view ); | 966 | slotViewSwitched( view ); |
962 | 967 | ||
963 | // Tell the view about the selected category | 968 | // Tell the view about the selected category |
964 | m_abView -> setShowByCategory( cat ); | 969 | m_abView -> setShowByCategory( cat ); |
965 | 970 | ||
966 | if ( book.isEmpty() ) | 971 | if ( book.isEmpty() ) |
967 | book = "List"; | 972 | book = "List"; |
968 | if ( cat.isEmpty() ) | 973 | if ( cat.isEmpty() ) |
969 | cat = "All"; | 974 | cat = "All"; |
970 | 975 | ||
971 | setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); | 976 | setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) ); |
972 | } | 977 | } |
973 | 978 | ||
974 | void AddressbookWindow::slotViewSwitched( int view ) | 979 | void AddressbookWindow::slotViewSwitched( int view ) |
975 | { | 980 | { |
976 | qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); | 981 | qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); |
977 | int menu = 0; | 982 | int menu = 0; |
978 | 983 | ||
979 | // Switch to selected view | 984 | // Switch to selected view |
980 | switch ( view ){ | 985 | switch ( view ){ |
981 | case AbView::TableView: | 986 | case AbView::TableView: |
982 | menu = 1; | 987 | menu = 1; |
983 | m_tableViewButton->setOn(true); | 988 | m_tableViewButton->setOn(true); |
984 | m_cardViewButton->setOn(false); | 989 | m_cardViewButton->setOn(false); |
985 | break; | 990 | break; |
986 | case AbView::CardView: | 991 | case AbView::CardView: |
987 | menu = 2; | 992 | menu = 2; |
988 | m_tableViewButton->setOn(false); | 993 | m_tableViewButton->setOn(false); |
989 | m_cardViewButton->setOn(true); | 994 | m_cardViewButton->setOn(true); |
990 | break; | 995 | break; |
991 | } | 996 | } |
992 | for ( unsigned int i = 1; i < 3; i++ ){ | 997 | for ( unsigned int i = 1; i < 3; i++ ){ |
993 | if ( catMenu ) | 998 | if ( catMenu ) |
994 | catMenu->setItemChecked( i, menu == (int)i ); | 999 | catMenu->setItemChecked( i, menu == (int)i ); |
995 | } | 1000 | } |
996 | 1001 | ||
997 | // Tell the view about the selected view | 1002 | // Tell the view about the selected view |
998 | m_abView -> setShowToView ( (AbView::Views) view ); | 1003 | m_abView -> setShowToView ( (AbView::Views) view ); |
999 | active_view = view; | 1004 | active_view = view; |
1000 | } | 1005 | } |
1001 | 1006 | ||
1002 | 1007 | ||
1003 | void AddressbookWindow::slotListView() | 1008 | void AddressbookWindow::slotListView() |
1004 | { | 1009 | { |
1005 | slotViewSwitched( AbView::TableView ); | 1010 | slotViewSwitched( AbView::TableView ); |
1006 | } | 1011 | } |
1007 | 1012 | ||
1008 | void AddressbookWindow::slotCardView() | 1013 | void AddressbookWindow::slotCardView() |
1009 | { | 1014 | { |
1010 | slotViewSwitched( AbView::CardView ); | 1015 | slotViewSwitched( AbView::CardView ); |
1011 | } | 1016 | } |
1012 | 1017 | ||
1013 | void AddressbookWindow::slotSetLetter( char c ) { | 1018 | void AddressbookWindow::slotSetLetter( char c ) { |
1014 | 1019 | ||
1015 | m_abView->setShowByLetter( c, m_config.letterPickerSearch() ); | 1020 | m_abView->setShowByLetter( c, m_config.letterPickerSearch() ); |
1016 | 1021 | ||
1017 | } | 1022 | } |
1018 | 1023 | ||
1019 | 1024 | ||
1020 | void AddressbookWindow::populateCategories() | 1025 | void AddressbookWindow::populateCategories() |
1021 | { | 1026 | { |
1022 | catMenu->clear(); | 1027 | catMenu->clear(); |
1023 | 1028 | ||
1024 | int id, rememberId; | 1029 | int id, rememberId; |
1025 | id = 1; | 1030 | id = 1; |
1026 | rememberId = 0; | 1031 | rememberId = 0; |
1027 | 1032 | ||
1028 | catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ ); | 1033 | catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ ); |
1029 | catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ ); | 1034 | catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ ); |
1030 | // catMenu->insertItem( tr( "Personal" ), id++ ); | 1035 | // catMenu->insertItem( tr( "Personal" ), id++ ); |
1031 | catMenu->insertSeparator(); | 1036 | catMenu->insertSeparator(); |
1032 | 1037 | ||
1033 | catMenu->insertItem( tr( "All" ), id++ ); | 1038 | catMenu->insertItem( tr( "All" ), id++ ); |
1034 | QStringList categories = m_abView->categories(); | 1039 | QStringList categories = m_abView->categories(); |
1035 | categories.append( tr( "Unfiled" ) ); | 1040 | categories.append( tr( "Unfiled" ) ); |
1036 | for ( QStringList::Iterator it = categories.begin(); | 1041 | for ( QStringList::Iterator it = categories.begin(); |
1037 | it != categories.end(); ++it ) { | 1042 | it != categories.end(); ++it ) { |
1038 | catMenu->insertItem( *it, id ); | 1043 | catMenu->insertItem( *it, id ); |
1039 | if ( *it == m_abView -> showCategory() ) | 1044 | if ( *it == m_abView -> showCategory() ) |
1040 | rememberId = id; | 1045 | rememberId = id; |
1041 | ++id; | 1046 | ++id; |
1042 | } | 1047 | } |
1043 | 1048 | ||
1044 | 1049 | ||
1045 | if ( m_abView -> showCategory().isEmpty() ) { | 1050 | if ( m_abView -> showCategory().isEmpty() ) { |
1046 | slotSetCategory( 3 ); | 1051 | slotSetCategory( 3 ); |
1047 | } | 1052 | } |
1048 | else { | 1053 | else { |
1049 | slotSetCategory( rememberId ); | 1054 | slotSetCategory( rememberId ); |
diff --git a/core/pim/addressbook/contacteditor.cpp b/core/pim/addressbook/contacteditor.cpp index ce14f98..9d1a1c7 100644 --- a/core/pim/addressbook/contacteditor.cpp +++ b/core/pim/addressbook/contacteditor.cpp | |||
@@ -504,193 +504,193 @@ void ContactEditor::init() { | |||
504 | m_widgetStack4 -> addWidget( txtChooserField4, TextField ); | 504 | m_widgetStack4 -> addWidget( txtChooserField4, TextField ); |
505 | gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 ); | 505 | gl->addMultiCellWidget( m_widgetStack4, 6, 6, 1, 2 ); |
506 | m_widgetStack4 -> raiseWidget( TextField ); | 506 | m_widgetStack4 -> raiseWidget( TextField ); |
507 | 507 | ||
508 | QSpacerItem *space = new QSpacerItem(1,1, | 508 | QSpacerItem *space = new QSpacerItem(1,1, |
509 | QSizePolicy::Maximum, | 509 | QSizePolicy::Maximum, |
510 | QSizePolicy::MinimumExpanding ); | 510 | QSizePolicy::MinimumExpanding ); |
511 | gl->addItem( space, 7, 0 ); | 511 | gl->addItem( space, 7, 0 ); |
512 | 512 | ||
513 | tabMain->insertTab( tabViewport, tr( "Address" ) ); | 513 | tabMain->insertTab( tabViewport, tr( "Address" ) ); |
514 | 514 | ||
515 | tabViewport = new QWidget ( tabMain ); | 515 | tabViewport = new QWidget ( tabMain ); |
516 | 516 | ||
517 | vb = new QVBoxLayout( tabViewport ); | 517 | vb = new QVBoxLayout( tabViewport ); |
518 | 518 | ||
519 | svDetails = new QScrollView( tabViewport ); | 519 | svDetails = new QScrollView( tabViewport ); |
520 | vb->addWidget( svDetails, 0, 0 ); | 520 | vb->addWidget( svDetails, 0, 0 ); |
521 | svDetails->setResizePolicy( QScrollView::AutoOneFit ); | 521 | svDetails->setResizePolicy( QScrollView::AutoOneFit ); |
522 | svDetails->setFrameStyle( QFrame::NoFrame ); | 522 | svDetails->setFrameStyle( QFrame::NoFrame ); |
523 | 523 | ||
524 | container = new QWidget( svDetails->viewport() ); | 524 | container = new QWidget( svDetails->viewport() ); |
525 | svDetails->addChild( container ); | 525 | svDetails->addChild( container ); |
526 | 526 | ||
527 | gl = new QGridLayout( container, 1, 2, 2, 4 ); | 527 | gl = new QGridLayout( container, 1, 2, 2, 4 ); |
528 | 528 | ||
529 | int counter = 0; | 529 | int counter = 0; |
530 | 530 | ||
531 | // Birthday | 531 | // Birthday |
532 | QHBox* hBox = new QHBox( container ); | 532 | QHBox* hBox = new QHBox( container ); |
533 | l = new QLabel( tr("Birthday"), container ); | 533 | l = new QLabel( tr("Birthday"), container ); |
534 | gl->addWidget( l, counter, 0 ); | 534 | gl->addWidget( l, counter, 0 ); |
535 | 535 | ||
536 | QPopupMenu* m1 = new QPopupMenu( container ); | 536 | QPopupMenu* m1 = new QPopupMenu( container ); |
537 | birthdayPicker = new DateBookMonth( m1, 0, TRUE ); | 537 | birthdayPicker = new DateBookMonth( m1, 0, TRUE ); |
538 | m1->insertItem( birthdayPicker ); | 538 | m1->insertItem( birthdayPicker ); |
539 | 539 | ||
540 | birthdayButton= new QToolButton( hBox, "buttonStart" ); | 540 | birthdayButton= new QToolButton( hBox, "buttonStart" ); |
541 | birthdayButton->setPopup( m1 ); | 541 | birthdayButton->setPopup( m1 ); |
542 | birthdayButton->setPopupDelay(0); | 542 | birthdayButton->setPopupDelay(0); |
543 | 543 | ||
544 | QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), | 544 | QPushButton* deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), |
545 | tr( "Delete" ), | 545 | tr( "Delete" ), |
546 | hBox, 0 ); | 546 | hBox, 0 ); |
547 | 547 | ||
548 | gl->addWidget( hBox, counter , 1 ); | 548 | gl->addWidget( hBox, counter , 1 ); |
549 | 549 | ||
550 | connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ), | 550 | connect( birthdayPicker, SIGNAL( dateClicked( int, int, int ) ), |
551 | this, SLOT( slotBirthdayDateChanged( int, int, int ) ) ); | 551 | this, SLOT( slotBirthdayDateChanged( int, int, int ) ) ); |
552 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) ); | 552 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveBirthday() ) ); |
553 | 553 | ||
554 | ++counter; | 554 | ++counter; |
555 | 555 | ||
556 | // Anniversary | 556 | // Anniversary |
557 | hBox = new QHBox( container ); | 557 | hBox = new QHBox( container ); |
558 | l = new QLabel( tr("Anniversary"), container ); | 558 | l = new QLabel( tr("Anniversary"), container ); |
559 | gl->addWidget( l, counter, 0 ); | 559 | gl->addWidget( l, counter, 0 ); |
560 | 560 | ||
561 | m1 = new QPopupMenu( container ); | 561 | m1 = new QPopupMenu( container ); |
562 | anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); | 562 | anniversaryPicker = new DateBookMonth( m1, 0, TRUE ); |
563 | m1->insertItem( anniversaryPicker ); | 563 | m1->insertItem( anniversaryPicker ); |
564 | 564 | ||
565 | anniversaryButton= new QToolButton( hBox, "buttonStart" ); | 565 | anniversaryButton= new QToolButton( hBox, "buttonStart" ); |
566 | anniversaryButton->setPopup( m1 ); | 566 | anniversaryButton->setPopup( m1 ); |
567 | anniversaryButton->setPopupDelay(0); | 567 | anniversaryButton->setPopupDelay(0); |
568 | 568 | ||
569 | deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), | 569 | deleteButton = new QPushButton( QIconSet( Resource::loadPixmap( "trash" ) ), |
570 | tr( "Delete" ), | 570 | tr( "Delete" ), |
571 | hBox, 0 ); | 571 | hBox, 0 ); |
572 | gl->addWidget( hBox, counter , 1 ); | 572 | gl->addWidget( hBox, counter , 1 ); |
573 | 573 | ||
574 | connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ), | 574 | connect( anniversaryPicker, SIGNAL( dateClicked( int, int, int ) ), |
575 | this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) ); | 575 | this, SLOT( slotAnniversaryDateChanged( int, int, int ) ) ); |
576 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); | 576 | connect( deleteButton, SIGNAL( clicked() ), this, SLOT( slotRemoveAnniversary() ) ); |
577 | 577 | ||
578 | ++counter; | 578 | ++counter; |
579 | 579 | ||
580 | // Gender | 580 | // Gender |
581 | l = new QLabel( tr("Gender"), container ); | 581 | l = new QLabel( tr("Gender"), container ); |
582 | gl->addWidget( l, counter, 0 ); | 582 | gl->addWidget( l, counter, 0 ); |
583 | cmbGender = new QComboBox( container ); | 583 | cmbGender = new QComboBox( container ); |
584 | cmbGender->insertItem( "", 0 ); | 584 | cmbGender->insertItem( "", 0 ); |
585 | cmbGender->insertItem( tr("Male"), 1); | 585 | cmbGender->insertItem( tr("Male"), 1); |
586 | cmbGender->insertItem( tr("Female"), 2); | 586 | cmbGender->insertItem( tr("Female"), 2); |
587 | gl->addWidget( cmbGender, counter, 1 ); | 587 | gl->addWidget( cmbGender, counter, 1 ); |
588 | 588 | ||
589 | ++counter; | 589 | ++counter; |
590 | 590 | ||
591 | // Create Labels and lineedit fields for every dynamic entry | 591 | // Create Labels and lineedit fields for every dynamic entry |
592 | QStringList::ConstIterator it = slDynamicEntries.begin(); | 592 | QStringList::ConstIterator it = slDynamicEntries.begin(); |
593 | QMap<QString, int> mapStrToID = OContactFields::untrFieldsToId(); | 593 | QMap<QString, int> mapStrToID = OContactFields::untrFieldsToId(); |
594 | QMap<int, QString> mapIdToStr = OContactFields::idToTrFields(); | 594 | QMap<int, QString> mapIdToStr = OContactFields::idToTrFields(); |
595 | for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { | 595 | for (i = counter; it != slDynamicEntries.end(); i++, ++it ) { |
596 | 596 | ||
597 | if (((*it) == "Anniversary") || | 597 | if (((*it) == "Anniversary") || |
598 | ((*it) == "Birthday")|| ((*it) == "Gender")) continue; | 598 | ((*it) == "Birthday")|| ((*it) == "Gender")) continue; |
599 | 599 | ||
600 | l = new QLabel( mapIdToStr[mapStrToID[*it]].utf8() , container ); | 600 | l = new QLabel( mapIdToStr[mapStrToID[*it]], container ); |
601 | listName.append( l ); | 601 | listName.append( l ); |
602 | gl->addWidget( l, i, 0 ); | 602 | gl->addWidget( l, i, 0 ); |
603 | QLineEdit *e = new QLineEdit( container ); | 603 | QLineEdit *e = new QLineEdit( container ); |
604 | listValue.append( e ); | 604 | listValue.append( e ); |
605 | gl->addWidget( e, i, 1); | 605 | gl->addWidget( e, i, 1); |
606 | } | 606 | } |
607 | // Fill labels with names.. | 607 | // Fill labels with names.. |
608 | //loadFields(); | 608 | //loadFields(); |
609 | 609 | ||
610 | 610 | ||
611 | tabMain->insertTab( tabViewport, tr( "Details" ) ); | 611 | tabMain->insertTab( tabViewport, tr( "Details" ) ); |
612 | 612 | ||
613 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); | 613 | dlgNote = new QDialog( this, "Note Dialog", TRUE ); |
614 | dlgNote->setCaption( tr("Enter Note") ); | 614 | dlgNote->setCaption( tr("Enter Note") ); |
615 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); | 615 | QVBoxLayout *vbNote = new QVBoxLayout( dlgNote ); |
616 | txtNote = new QMultiLineEdit( dlgNote ); | 616 | txtNote = new QMultiLineEdit( dlgNote ); |
617 | vbNote->addWidget( txtNote ); | 617 | vbNote->addWidget( txtNote ); |
618 | connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); | 618 | connect( btnNote, SIGNAL(clicked()), this, SLOT(slotNote()) ); |
619 | 619 | ||
620 | dlgName = new QDialog( this, "Name Dialog", TRUE ); | 620 | dlgName = new QDialog( this, "Name Dialog", TRUE ); |
621 | dlgName->setCaption( tr("Edit Name") ); | 621 | dlgName->setCaption( tr("Edit Name") ); |
622 | gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); | 622 | gl = new QGridLayout( dlgName, 5, 2, 2, 3 ); |
623 | 623 | ||
624 | l = new QLabel( tr("First Name"), dlgName ); | 624 | l = new QLabel( tr("First Name"), dlgName ); |
625 | gl->addWidget( l, 0, 0 ); | 625 | gl->addWidget( l, 0, 0 ); |
626 | txtFirstName = new QLineEdit( dlgName ); | 626 | txtFirstName = new QLineEdit( dlgName ); |
627 | gl->addWidget( txtFirstName, 0, 1 ); | 627 | gl->addWidget( txtFirstName, 0, 1 ); |
628 | 628 | ||
629 | l = new QLabel( tr("Middle Name"), dlgName ); | 629 | l = new QLabel( tr("Middle Name"), dlgName ); |
630 | gl->addWidget( l, 1, 0 ); | 630 | gl->addWidget( l, 1, 0 ); |
631 | txtMiddleName = new QLineEdit( dlgName ); | 631 | txtMiddleName = new QLineEdit( dlgName ); |
632 | gl->addWidget( txtMiddleName, 1, 1 ); | 632 | gl->addWidget( txtMiddleName, 1, 1 ); |
633 | 633 | ||
634 | l = new QLabel( tr("Last Name"), dlgName ); | 634 | l = new QLabel( tr("Last Name"), dlgName ); |
635 | gl->addWidget( l, 2, 0 ); | 635 | gl->addWidget( l, 2, 0 ); |
636 | txtLastName = new QLineEdit( dlgName ); | 636 | txtLastName = new QLineEdit( dlgName ); |
637 | gl->addWidget( txtLastName, 2, 1 ); | 637 | gl->addWidget( txtLastName, 2, 1 ); |
638 | 638 | ||
639 | // l = new QLabel( tr("Suffix"), dlgName ); | 639 | // l = new QLabel( tr("Suffix"), dlgName ); |
640 | // gl->addWidget( l, 3, 0 ); | 640 | // gl->addWidget( l, 3, 0 ); |
641 | // txtSuffix = new QLineEdit( dlgName ); | 641 | // txtSuffix = new QLineEdit( dlgName ); |
642 | // gl->addWidget( txtSuffix, 3, 1 ); | 642 | // gl->addWidget( txtSuffix, 3, 1 ); |
643 | space = new QSpacerItem(1,1, | 643 | space = new QSpacerItem(1,1, |
644 | QSizePolicy::Maximum, | 644 | QSizePolicy::Maximum, |
645 | QSizePolicy::MinimumExpanding ); | 645 | QSizePolicy::MinimumExpanding ); |
646 | gl->addItem( space, 4, 0 ); | 646 | gl->addItem( space, 4, 0 ); |
647 | 647 | ||
648 | cmbChooserField1->insertStringList( trlChooserNames ); | 648 | cmbChooserField1->insertStringList( trlChooserNames ); |
649 | cmbChooserField2->insertStringList( trlChooserNames ); | 649 | cmbChooserField2->insertStringList( trlChooserNames ); |
650 | cmbChooserField3->insertStringList( trlChooserNames ); | 650 | cmbChooserField3->insertStringList( trlChooserNames ); |
651 | cmbChooserField4->insertStringList( trlChooserNames ); | 651 | cmbChooserField4->insertStringList( trlChooserNames ); |
652 | 652 | ||
653 | cmbChooserField1->setCurrentItem( 0 ); | 653 | cmbChooserField1->setCurrentItem( 0 ); |
654 | cmbChooserField2->setCurrentItem( 1 ); | 654 | cmbChooserField2->setCurrentItem( 1 ); |
655 | cmbChooserField3->setCurrentItem( 2 ); | 655 | cmbChooserField3->setCurrentItem( 2 ); |
656 | 656 | ||
657 | connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); | 657 | connect( btnFullName, SIGNAL(clicked()), this, SLOT(slotName()) ); |
658 | 658 | ||
659 | connect( txtFullName, SIGNAL(textChanged(const QString &)), | 659 | connect( txtFullName, SIGNAL(textChanged(const QString &)), |
660 | this, SLOT(slotFullNameChange(const QString &)) ); | 660 | this, SLOT(slotFullNameChange(const QString &)) ); |
661 | connect( txtSuffix, SIGNAL(textChanged(const QString &)), | 661 | connect( txtSuffix, SIGNAL(textChanged(const QString &)), |
662 | this, SLOT(slotSuffixChange(const QString &)) ); | 662 | this, SLOT(slotSuffixChange(const QString &)) ); |
663 | connect( txtOrganization, SIGNAL(textChanged(const QString &)), | 663 | connect( txtOrganization, SIGNAL(textChanged(const QString &)), |
664 | this, SLOT(slotOrganizationChange(const QString &)) ); | 664 | this, SLOT(slotOrganizationChange(const QString &)) ); |
665 | connect( txtChooserField1, SIGNAL(textChanged(const QString &)), | 665 | connect( txtChooserField1, SIGNAL(textChanged(const QString &)), |
666 | this, SLOT(slotChooser1Change(const QString &)) ); | 666 | this, SLOT(slotChooser1Change(const QString &)) ); |
667 | connect( txtChooserField2, SIGNAL(textChanged(const QString &)), | 667 | connect( txtChooserField2, SIGNAL(textChanged(const QString &)), |
668 | this, SLOT(slotChooser2Change(const QString &)) ); | 668 | this, SLOT(slotChooser2Change(const QString &)) ); |
669 | connect( txtChooserField3, SIGNAL(textChanged(const QString &)), | 669 | connect( txtChooserField3, SIGNAL(textChanged(const QString &)), |
670 | this, SLOT(slotChooser3Change(const QString &)) ); | 670 | this, SLOT(slotChooser3Change(const QString &)) ); |
671 | connect( txtChooserField4, SIGNAL(textChanged(const QString &)), | 671 | connect( txtChooserField4, SIGNAL(textChanged(const QString &)), |
672 | this, SLOT(slotChooser4Change(const QString &)) ); | 672 | this, SLOT(slotChooser4Change(const QString &)) ); |
673 | connect( txtAddress, SIGNAL(textChanged(const QString &)), | 673 | connect( txtAddress, SIGNAL(textChanged(const QString &)), |
674 | this, SLOT(slotAddressChange(const QString &)) ); | 674 | this, SLOT(slotAddressChange(const QString &)) ); |
675 | connect( txtCity, SIGNAL(textChanged(const QString &)), | 675 | connect( txtCity, SIGNAL(textChanged(const QString &)), |
676 | this, SLOT(slotCityChange(const QString &)) ); | 676 | this, SLOT(slotCityChange(const QString &)) ); |
677 | connect( txtState, SIGNAL(textChanged(const QString &)), | 677 | connect( txtState, SIGNAL(textChanged(const QString &)), |
678 | this, SLOT(slotStateChange(const QString &)) ); | 678 | this, SLOT(slotStateChange(const QString &)) ); |
679 | connect( txtZip, SIGNAL(textChanged(const QString &)), | 679 | connect( txtZip, SIGNAL(textChanged(const QString &)), |
680 | this, SLOT(slotZipChange(const QString &)) ); | 680 | this, SLOT(slotZipChange(const QString &)) ); |
681 | connect( cmbCountry, SIGNAL(textChanged(const QString &)), | 681 | connect( cmbCountry, SIGNAL(textChanged(const QString &)), |
682 | this, SLOT(slotCountryChange(const QString &)) ); | 682 | this, SLOT(slotCountryChange(const QString &)) ); |
683 | connect( cmbCountry, SIGNAL(activated(const QString &)), | 683 | connect( cmbCountry, SIGNAL(activated(const QString &)), |
684 | this, SLOT(slotCountryChange(const QString &)) ); | 684 | this, SLOT(slotCountryChange(const QString &)) ); |
685 | connect( cmbChooserField1, SIGNAL(activated(int)), | 685 | connect( cmbChooserField1, SIGNAL(activated(int)), |
686 | this, SLOT(slotCmbChooser1Change(int)) ); | 686 | this, SLOT(slotCmbChooser1Change(int)) ); |
687 | connect( cmbChooserField2, SIGNAL(activated(int)), | 687 | connect( cmbChooserField2, SIGNAL(activated(int)), |
688 | this, SLOT(slotCmbChooser2Change(int)) ); | 688 | this, SLOT(slotCmbChooser2Change(int)) ); |
689 | connect( cmbChooserField3, SIGNAL(activated(int)), | 689 | connect( cmbChooserField3, SIGNAL(activated(int)), |
690 | this, SLOT(slotCmbChooser3Change(int)) ); | 690 | this, SLOT(slotCmbChooser3Change(int)) ); |
691 | connect( cmbChooserField4, SIGNAL(activated(int)), | 691 | connect( cmbChooserField4, SIGNAL(activated(int)), |
692 | this, SLOT(slotCmbChooser4Change(int)) ); | 692 | this, SLOT(slotCmbChooser4Change(int)) ); |
693 | connect( cmbAddress, SIGNAL(activated(int)), | 693 | connect( cmbAddress, SIGNAL(activated(int)), |
694 | this, SLOT(slotAddressTypeChange(int)) ); | 694 | this, SLOT(slotAddressTypeChange(int)) ); |
695 | 695 | ||
696 | new QPEDialogListener(this); | 696 | new QPEDialogListener(this); |
diff --git a/core/pim/addressbook/opie-addressbook.control b/core/pim/addressbook/opie-addressbook.control index f06fa91..d949bd4 100644 --- a/core/pim/addressbook/opie-addressbook.control +++ b/core/pim/addressbook/opie-addressbook.control | |||
@@ -1,11 +1,11 @@ | |||
1 | Package: opie-addressbook | 1 | Package: opie-addressbook |
2 | Files: bin/addressbook apps/1Pim/addressbook.desktop pics/addressbook/*.png | 2 | Files: bin/addressbook apps/1Pim/addressbook.desktop |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Conflicts: qpe-tkcaddressbook | 5 | Conflicts: qpe-tkcaddressbook |
6 | Maintainer: Stefan Eilers <eilers.stefan@epost.de> | 6 | Maintainer: Stefan Eilers <eilers.stefan@epost.de> |
7 | Architecture: arm | 7 | Architecture: arm |
8 | Version: $QPE_VERSION-$SUB_VERSION | 8 | Depends: task-opie-minimal, libopie1, opie-pics |
9 | Depends: task-opie-minimal, libopie1 | ||
10 | Description: Contacts | 9 | Description: Contacts |
11 | A simple addressbook for the Opie environment. | 10 | A simple addressbook for the Opie environment. |
11 | Version: $QPE_VERSION$EXTRAVERSION | ||
diff --git a/core/pim/addressbook/version.h b/core/pim/addressbook/version.h index 4c93584..9621826 100644 --- a/core/pim/addressbook/version.h +++ b/core/pim/addressbook/version.h | |||
@@ -1,10 +1,10 @@ | |||
1 | #ifndef _VERSION_H_ | 1 | #ifndef _VERSION_H_ |
2 | #define _VERSION_H_ | 2 | #define _VERSION_H_ |
3 | 3 | ||
4 | #define MAINVERSION "0" | 4 | #define MAINVERSION "1" |
5 | #define SUBVERSION "9" | 5 | #define SUBVERSION "0" |
6 | #define PATCHVERSION "5" | 6 | #define PATCHVERSION "0" |
7 | 7 | ||
8 | #define APPNAME "OPIE_ADDRESSBOOK" | 8 | #define APPNAME "OPIE_ADDRESSBOOK" |
9 | 9 | ||
10 | #endif | 10 | #endif |
diff --git a/libopie/pim/obackendfactory.h b/libopie/pim/obackendfactory.h index ad6cf5a..f3c339d 100644 --- a/libopie/pim/obackendfactory.h +++ b/libopie/pim/obackendfactory.h | |||
@@ -1,154 +1,166 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage Backends. | 2 | * Class to manage Backends. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 5 | * |
6 | * ===================================================================== | 6 | * ===================================================================== |
7 | *This program is free software; you can redistribute it and/or | 7 | *This program is free software; you can redistribute it and/or |
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; | 9 | * License as published by the Free Software Foundation; |
10 | * either version 2 of the License, or (at your option) any later | 10 | * either version 2 of the License, or (at your option) any later |
11 | * version. | 11 | * version. |
12 | * ===================================================================== | 12 | * ===================================================================== |
13 | * ToDo: Use plugins | 13 | * ToDo: Use plugins |
14 | * ===================================================================== | 14 | * ===================================================================== |
15 | * Version: $Id$ | 15 | * Version: $Id$ |
16 | * ===================================================================== | 16 | * ===================================================================== |
17 | * History: | 17 | * History: |
18 | * $Log$ | 18 | * $Log$ |
19 | * Revision 1.7 2003/08/01 12:30:16 eilers | ||
20 | * Merging changes from BRANCH_1_0 to HEAD | ||
21 | * | ||
22 | * Revision 1.6.4.1 2003/06/30 14:34:19 eilers | ||
23 | * Patches from Zecke: | ||
24 | * Fixing and cleaning up extraMap handling | ||
25 | * Adding d_ptr for binary compatibility in the future | ||
26 | * | ||
19 | * Revision 1.6 2003/04/13 18:07:10 zecke | 27 | * Revision 1.6 2003/04/13 18:07:10 zecke |
20 | * More API doc | 28 | * More API doc |
21 | * QString -> const QString& | 29 | * QString -> const QString& |
22 | * QString = 0l -> QString::null | 30 | * QString = 0l -> QString::null |
23 | * | 31 | * |
24 | * Revision 1.5 2003/02/21 23:31:52 zecke | 32 | * Revision 1.5 2003/02/21 23:31:52 zecke |
25 | * Add XML datebookresource | 33 | * Add XML datebookresource |
26 | * -clean up todoaccessxml header | 34 | * -clean up todoaccessxml header |
27 | * -implement some more stuff in the oeven tester | 35 | * -implement some more stuff in the oeven tester |
28 | * -extend DefaultFactory to not crash and to use datebook | 36 | * -extend DefaultFactory to not crash and to use datebook |
29 | * | 37 | * |
30 | * -reading of OEvents is working nicely.. saving will be added | 38 | * -reading of OEvents is working nicely.. saving will be added |
31 | * tomorrow | 39 | * tomorrow |
32 | * -fix spelling in ODateBookAcces | 40 | * -fix spelling in ODateBookAcces |
33 | * | 41 | * |
34 | * Revision 1.4 2002/10/14 15:55:18 eilers | 42 | * Revision 1.4 2002/10/14 15:55:18 eilers |
35 | * Redeactivate SQL.. ;) | 43 | * Redeactivate SQL.. ;) |
36 | * | 44 | * |
37 | * Revision 1.3 2002/10/10 17:08:58 zecke | 45 | * Revision 1.3 2002/10/10 17:08:58 zecke |
38 | * The Cache is finally in place | 46 | * The Cache is finally in place |
39 | * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;) | 47 | * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;) |
40 | * The read ahead functionality does not make sense for XMLs backends because most of the stuff is already in memory. While using readahead on SQL makes things a lot faster.... | 48 | * The read ahead functionality does not make sense for XMLs backends because most of the stuff is already in memory. While using readahead on SQL makes things a lot faster.... |
41 | * I still have to fully implement read ahead | 49 | * I still have to fully implement read ahead |
42 | * This change is bic but sc | 50 | * This change is bic but sc |
43 | * | 51 | * |
44 | * Revision 1.2 2002/10/08 09:27:36 eilers | 52 | * Revision 1.2 2002/10/08 09:27:36 eilers |
45 | * Fixed libopie.pro to include the new pim-API. | 53 | * Fixed libopie.pro to include the new pim-API. |
46 | * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to | 54 | * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to |
47 | * compile itself would need to install libsqlite, libopiesql... | 55 | * compile itself would need to install libsqlite, libopiesql... |
48 | * Therefore, the backend currently uses XML only.. | 56 | * Therefore, the backend currently uses XML only.. |
49 | * | 57 | * |
50 | * Revision 1.1 2002/10/07 17:35:01 eilers | 58 | * Revision 1.1 2002/10/07 17:35:01 eilers |
51 | * added OBackendFactory for advanced backend access | 59 | * added OBackendFactory for advanced backend access |
52 | * | 60 | * |
53 | * | 61 | * |
54 | * ===================================================================== | 62 | * ===================================================================== |
55 | */ | 63 | */ |
56 | #ifndef OPIE_BACKENDFACTORY_H_ | 64 | #ifndef OPIE_BACKENDFACTORY_H_ |
57 | #define OPIE_BACKENDFACTORY_H_ | 65 | #define OPIE_BACKENDFACTORY_H_ |
58 | 66 | ||
59 | #include <qstring.h> | 67 | #include <qstring.h> |
60 | #include <qasciidict.h> | 68 | #include <qasciidict.h> |
61 | #include <qpe/config.h> | 69 | #include <qpe/config.h> |
62 | 70 | ||
63 | #include "otodoaccessxml.h" | 71 | #include "otodoaccessxml.h" |
64 | #include "ocontactaccessbackend_xml.h" | 72 | #include "ocontactaccessbackend_xml.h" |
65 | #include "odatebookaccessbackend_xml.h" | 73 | #include "odatebookaccessbackend_xml.h" |
66 | 74 | ||
67 | #ifdef __USE_SQL | 75 | #ifdef __USE_SQL |
68 | #include "otodoaccesssql.h" | 76 | #include "otodoaccesssql.h" |
69 | #endif | 77 | #endif |
70 | 78 | ||
79 | class OBackendPrivate; | ||
80 | |||
71 | /** | 81 | /** |
72 | * This class is our factory. It will give us the default implementations | 82 | * This class is our factory. It will give us the default implementations |
73 | * of at least Todolist, Contacts and Datebook. In the future this class will | 83 | * of at least Todolist, Contacts and Datebook. In the future this class will |
74 | * allow users to switch the backend with ( XML->SQLite ) without the need | 84 | * allow users to switch the backend with ( XML->SQLite ) without the need |
75 | * to recompile.# | 85 | * to recompile.# |
76 | * This class as the whole PIM Api is making use of templates | 86 | * This class as the whole PIM Api is making use of templates |
77 | * | 87 | * |
78 | * <pre> | 88 | * <pre> |
79 | * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null ); | 89 | * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null ); |
80 | * backend->load(); | 90 | * backend->load(); |
81 | * </pre> | 91 | * </pre> |
82 | * | 92 | * |
83 | * @author Stefan Eilers | 93 | * @author Stefan Eilers |
84 | * @version 0.1 | 94 | * @version 0.1 |
85 | */ | 95 | */ |
86 | template<class T> | 96 | template<class T> |
87 | class OBackendFactory | 97 | class OBackendFactory |
88 | { | 98 | { |
89 | public: | 99 | public: |
90 | OBackendFactory() {}; | 100 | OBackendFactory() {}; |
91 | 101 | ||
92 | enum BACKENDS { | 102 | enum BACKENDS { |
93 | TODO, | 103 | TODO, |
94 | CONTACT, | 104 | CONTACT, |
95 | DATE | 105 | DATE |
96 | }; | 106 | }; |
97 | 107 | ||
98 | /** | 108 | /** |
99 | * Returns a backend implementation for backendName | 109 | * Returns a backend implementation for backendName |
100 | * @param backendName the type of the backend | 110 | * @param backendName the type of the backend |
101 | * @param appName will be passed on to the backend | 111 | * @param appName will be passed on to the backend |
102 | */ | 112 | */ |
103 | static T* Default( const QString backendName, const QString& appName ){ | 113 | static T* Default( const QString backendName, const QString& appName ){ |
104 | 114 | ||
105 | // __asm__("int3"); | 115 | // __asm__("int3"); |
106 | 116 | ||
107 | Config config( "pimaccess" ); | 117 | Config config( "pimaccess" ); |
108 | config.setGroup ( backendName ); | 118 | config.setGroup ( backendName ); |
109 | QString backend = config.readEntry( "usebackend" ); | 119 | QString backend = config.readEntry( "usebackend" ); |
110 | 120 | ||
111 | QAsciiDict<int> dict ( 3 ); | 121 | QAsciiDict<int> dict ( 3 ); |
112 | dict.setAutoDelete ( TRUE ); | 122 | dict.setAutoDelete ( TRUE ); |
113 | 123 | ||
114 | dict.insert( "todo", new int (TODO) ); | 124 | dict.insert( "todo", new int (TODO) ); |
115 | dict.insert( "contact", new int (CONTACT) ); | 125 | dict.insert( "contact", new int (CONTACT) ); |
116 | dict.insert( "datebook", new int(DATE) ); | 126 | dict.insert( "datebook", new int(DATE) ); |
117 | 127 | ||
118 | qWarning ("TODO is: %d", TODO); | 128 | qWarning ("TODO is: %d", TODO); |
119 | qWarning ("CONTACT is: %d", CONTACT); | 129 | qWarning ("CONTACT is: %d", CONTACT); |
120 | 130 | ||
121 | int *find = dict[ backendName ]; | 131 | int *find = dict[ backendName ]; |
122 | if (!find ) return 0; | 132 | if (!find ) return 0; |
123 | 133 | ||
124 | switch ( *find ){ | 134 | switch ( *find ){ |
125 | case TODO: | 135 | case TODO: |
126 | #ifdef __USE_SQL | 136 | #ifdef __USE_SQL |
127 | if ( backend == "sql" ) | 137 | if ( backend == "sql" ) |
128 | return (T*) new OTodoAccessBackendSQL(""); | 138 | return (T*) new OTodoAccessBackendSQL(""); |
129 | #else | 139 | #else |
130 | if ( backend == "sql" ) | 140 | if ( backend == "sql" ) |
131 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 141 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
132 | #endif | 142 | #endif |
133 | 143 | ||
134 | return (T*) new OTodoAccessXML( appName ); | 144 | return (T*) new OTodoAccessXML( appName ); |
135 | case CONTACT: | 145 | case CONTACT: |
136 | if ( backend == "sql" ) | 146 | if ( backend == "sql" ) |
137 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 147 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
138 | 148 | ||
139 | return (T*) new OContactAccessBackend_XML( appName ); | 149 | return (T*) new OContactAccessBackend_XML( appName ); |
140 | case DATE: | 150 | case DATE: |
141 | if ( backend == "sql" ) | 151 | if ( backend == "sql" ) |
142 | qWarning("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 152 | qWarning("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
143 | 153 | ||
144 | return (T*) new ODateBookAccessBackend_XML( appName ); | 154 | return (T*) new ODateBookAccessBackend_XML( appName ); |
145 | default: | 155 | default: |
146 | return NULL; | 156 | return NULL; |
147 | } | 157 | } |
148 | 158 | ||
149 | 159 | ||
150 | } | 160 | } |
161 | private: | ||
162 | OBackendPrivate* d; | ||
151 | }; | 163 | }; |
152 | 164 | ||
153 | 165 | ||
154 | #endif | 166 | #endif |
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp index be4ce0a..3473baa 100644 --- a/libopie/pim/ocontact.cpp +++ b/libopie/pim/ocontact.cpp | |||
@@ -1,123 +1,124 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 13 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
14 | ** | 14 | ** |
15 | ** Contact info@trolltech.com if any conditions of this licensing are | 15 | ** Contact info@trolltech.com if any conditions of this licensing are |
16 | ** not clear to you. | 16 | ** not clear to you. |
17 | ** | 17 | ** |
18 | **********************************************************************/ | 18 | **********************************************************************/ |
19 | 19 | ||
20 | #define QTOPIA_INTERNAL_CONTACT_MRE | 20 | #define QTOPIA_INTERNAL_CONTACT_MRE |
21 | 21 | ||
22 | #include "ocontact.h" | 22 | #include "ocontact.h" |
23 | #include "opimresolver.h" | 23 | #include "opimresolver.h" |
24 | #include "oconversion.h" | ||
24 | 25 | ||
25 | #include <qpe/stringutil.h> | 26 | #include <qpe/stringutil.h> |
26 | #include "oconversion.h" | ||
27 | #include <qpe/timestring.h> | 27 | #include <qpe/timestring.h> |
28 | #include <qpe/config.h> | ||
28 | 29 | ||
29 | #include <qobject.h> | 30 | #include <qobject.h> |
30 | #include <qregexp.h> | 31 | #include <qregexp.h> |
31 | #include <qstylesheet.h> | 32 | #include <qstylesheet.h> |
32 | #include <qfileinfo.h> | 33 | #include <qfileinfo.h> |
33 | #include <qmap.h> | 34 | #include <qmap.h> |
34 | 35 | ||
35 | #include <stdio.h> | 36 | #include <stdio.h> |
36 | 37 | ||
37 | /*! | 38 | /*! |
38 | \class Contact contact.h | 39 | \class Contact contact.h |
39 | \brief The Contact class holds the data of an address book entry. | 40 | \brief The Contact class holds the data of an address book entry. |
40 | 41 | ||
41 | This data includes information the name of the person, contact | 42 | This data includes information the name of the person, contact |
42 | information, and business information such as deparment and job title. | 43 | information, and business information such as deparment and job title. |
43 | 44 | ||
44 | \ingroup qtopiaemb | 45 | \ingroup qtopiaemb |
45 | \ingroup qtopiadesktop | 46 | \ingroup qtopiadesktop |
46 | */ | 47 | */ |
47 | 48 | ||
48 | 49 | ||
49 | /*! | 50 | /*! |
50 | Creates a new, empty contact. | 51 | Creates a new, empty contact. |
51 | */ | 52 | */ |
52 | OContact::OContact() | 53 | OContact::OContact() |
53 | : OPimRecord(), mMap(), d( 0 ) | 54 | : OPimRecord(), mMap(), d( 0 ) |
54 | { | 55 | { |
55 | } | 56 | } |
56 | 57 | ||
57 | /*! | 58 | /*! |
58 | \internal | 59 | \internal |
59 | Creates a new contact. The properties of the contact are | 60 | Creates a new contact. The properties of the contact are |
60 | set from \a fromMap. | 61 | set from \a fromMap. |
61 | */ | 62 | */ |
62 | OContact::OContact( const QMap<int, QString> &fromMap ) : | 63 | OContact::OContact( const QMap<int, QString> &fromMap ) : |
63 | OPimRecord(), mMap( fromMap ), d( 0 ) | 64 | OPimRecord(), mMap( fromMap ), d( 0 ) |
64 | { | 65 | { |
65 | QString cats = mMap[ Qtopia::AddressCategory ]; | 66 | QString cats = mMap[ Qtopia::AddressCategory ]; |
66 | if ( !cats.isEmpty() ) | 67 | if ( !cats.isEmpty() ) |
67 | setCategories( idsFromString( cats ) ); | 68 | setCategories( idsFromString( cats ) ); |
68 | 69 | ||
69 | QString uidStr = find( Qtopia::AddressUid ); | 70 | QString uidStr = find( Qtopia::AddressUid ); |
70 | 71 | ||
71 | if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ | 72 | if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ |
72 | qWarning( "Invalid UID found. Generate new one.." ); | 73 | qWarning( "Invalid UID found. Generate new one.." ); |
73 | setUid( uidGen().generate() ); | 74 | setUid( uidGen().generate() ); |
74 | }else | 75 | }else |
75 | setUid( uidStr.toInt() ); | 76 | setUid( uidStr.toInt() ); |
76 | 77 | ||
77 | // if ( !uidStr.isEmpty() ) | 78 | // if ( !uidStr.isEmpty() ) |
78 | // setUid( uidStr.toInt() ); | 79 | // setUid( uidStr.toInt() ); |
79 | } | 80 | } |
80 | 81 | ||
81 | /*! | 82 | /*! |
82 | Destroys a contact. | 83 | Destroys a contact. |
83 | */ | 84 | */ |
84 | OContact::~OContact() | 85 | OContact::~OContact() |
85 | { | 86 | { |
86 | } | 87 | } |
87 | 88 | ||
88 | /*! \fn void OContact::setTitle( const QString &str ) | 89 | /*! \fn void OContact::setTitle( const QString &str ) |
89 | Sets the title of the contact to \a str. | 90 | Sets the title of the contact to \a str. |
90 | */ | 91 | */ |
91 | 92 | ||
92 | /*! \fn void OContact::setFirstName( const QString &str ) | 93 | /*! \fn void OContact::setFirstName( const QString &str ) |
93 | Sets the first name of the contact to \a str. | 94 | Sets the first name of the contact to \a str. |
94 | */ | 95 | */ |
95 | 96 | ||
96 | /*! \fn void OContact::setMiddleName( const QString &str ) | 97 | /*! \fn void OContact::setMiddleName( const QString &str ) |
97 | Sets the middle name of the contact to \a str. | 98 | Sets the middle name of the contact to \a str. |
98 | */ | 99 | */ |
99 | 100 | ||
100 | /*! \fn void OContact::setLastName( const QString &str ) | 101 | /*! \fn void OContact::setLastName( const QString &str ) |
101 | Sets the last name of the contact to \a str. | 102 | Sets the last name of the contact to \a str. |
102 | */ | 103 | */ |
103 | 104 | ||
104 | /*! \fn void OContact::setSuffix( const QString &str ) | 105 | /*! \fn void OContact::setSuffix( const QString &str ) |
105 | Sets the suffix of the contact to \a str. | 106 | Sets the suffix of the contact to \a str. |
106 | */ | 107 | */ |
107 | 108 | ||
108 | /*! \fn void OContact::setFileAs( const QString &str ) | 109 | /*! \fn void OContact::setFileAs( const QString &str ) |
109 | Sets the contact to filed as \a str. | 110 | Sets the contact to filed as \a str. |
110 | */ | 111 | */ |
111 | 112 | ||
112 | /*! \fn void OContact::setDefaultEmail( const QString &str ) | 113 | /*! \fn void OContact::setDefaultEmail( const QString &str ) |
113 | Sets the default email of the contact to \a str. | 114 | Sets the default email of the contact to \a str. |
114 | */ | 115 | */ |
115 | 116 | ||
116 | /*! \fn void OContact::setHomeStreet( const QString &str ) | 117 | /*! \fn void OContact::setHomeStreet( const QString &str ) |
117 | Sets the home street address of the contact to \a str. | 118 | Sets the home street address of the contact to \a str. |
118 | */ | 119 | */ |
119 | 120 | ||
120 | /*! \fn void OContact::setHomeCity( const QString &str ) | 121 | /*! \fn void OContact::setHomeCity( const QString &str ) |
121 | Sets the home city of the contact to \a str. | 122 | Sets the home city of the contact to \a str. |
122 | */ | 123 | */ |
123 | 124 | ||
@@ -345,388 +346,460 @@ OContact::~OContact() | |||
345 | /*! \fn QString OContact::businessZip() const | 346 | /*! \fn QString OContact::businessZip() const |
346 | Returns the business zip of the contact. | 347 | Returns the business zip of the contact. |
347 | */ | 348 | */ |
348 | 349 | ||
349 | /*! \fn QString OContact::businessCountry() const | 350 | /*! \fn QString OContact::businessCountry() const |
350 | Returns the business country of the contact. | 351 | Returns the business country of the contact. |
351 | */ | 352 | */ |
352 | 353 | ||
353 | /*! \fn QString OContact::businessPhone() const | 354 | /*! \fn QString OContact::businessPhone() const |
354 | Returns the business phone number of the contact. | 355 | Returns the business phone number of the contact. |
355 | */ | 356 | */ |
356 | 357 | ||
357 | /*! \fn QString OContact::businessFax() const | 358 | /*! \fn QString OContact::businessFax() const |
358 | Returns the business fax number of the contact. | 359 | Returns the business fax number of the contact. |
359 | */ | 360 | */ |
360 | 361 | ||
361 | /*! \fn QString OContact::businessMobile() const | 362 | /*! \fn QString OContact::businessMobile() const |
362 | Returns the business mobile number of the contact. | 363 | Returns the business mobile number of the contact. |
363 | */ | 364 | */ |
364 | 365 | ||
365 | /*! \fn QString OContact::businessPager() const | 366 | /*! \fn QString OContact::businessPager() const |
366 | Returns the business pager number of the contact. | 367 | Returns the business pager number of the contact. |
367 | */ | 368 | */ |
368 | 369 | ||
369 | /*! \fn QString OContact::businessWebpage() const | 370 | /*! \fn QString OContact::businessWebpage() const |
370 | Returns the business webpage of the contact. | 371 | Returns the business webpage of the contact. |
371 | */ | 372 | */ |
372 | 373 | ||
373 | /*! \fn QString OContact::spouse() const | 374 | /*! \fn QString OContact::spouse() const |
374 | Returns the spouse of the contact. | 375 | Returns the spouse of the contact. |
375 | */ | 376 | */ |
376 | 377 | ||
377 | /*! \fn QString OContact::gender() const | 378 | /*! \fn QString OContact::gender() const |
378 | Returns the gender of the contact. | 379 | Returns the gender of the contact. |
379 | */ | 380 | */ |
380 | 381 | ||
381 | /*! \fn QString OContact::nickname() const | 382 | /*! \fn QString OContact::nickname() const |
382 | Returns the nickname of the contact. | 383 | Returns the nickname of the contact. |
383 | */ | 384 | */ |
384 | 385 | ||
385 | /*! \fn QString OContact::children() const | 386 | /*! \fn QString OContact::children() const |
386 | Returns the children of the contact. | 387 | Returns the children of the contact. |
387 | */ | 388 | */ |
388 | 389 | ||
389 | /*! \fn QString OContact::notes() const | 390 | /*! \fn QString OContact::notes() const |
390 | Returns the notes relating to the the contact. | 391 | Returns the notes relating to the the contact. |
391 | */ | 392 | */ |
392 | 393 | ||
393 | /*! \fn QString OContact::groups() const | 394 | /*! \fn QString OContact::groups() const |
394 | \internal | 395 | \internal |
395 | Returns the groups for the contact. | 396 | Returns the groups for the contact. |
396 | */ | 397 | */ |
397 | 398 | ||
398 | /*! \fn QStringList OContact::groupList() const | 399 | /*! \fn QStringList OContact::groupList() const |
399 | \internal | 400 | \internal |
400 | */ | 401 | */ |
401 | 402 | ||
402 | /*! \fn QString OContact::field(int) const | 403 | /*! \fn QString OContact::field(int) const |
403 | \internal | 404 | \internal |
404 | */ | 405 | */ |
405 | 406 | ||
406 | /*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) | 407 | /*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) |
407 | \internal | 408 | \internal |
408 | */ | 409 | */ |
409 | 410 | ||
410 | /*! \fn void OContact::setUid( int id ) | 411 | /*! \fn void OContact::setUid( int id ) |
411 | \internal | 412 | \internal |
412 | Sets the uid for this record to \a id. | 413 | Sets the uid for this record to \a id. |
413 | */ | 414 | */ |
414 | 415 | ||
415 | /*! \enum OContact::journal_action | 416 | /*! \enum OContact::journal_action |
416 | \internal | 417 | \internal |
417 | */ | 418 | */ |
418 | 419 | ||
419 | /*! | 420 | /*! |
420 | \internal | 421 | \internal |
421 | */ | 422 | */ |
422 | QMap<int, QString> OContact::toMap() const | 423 | QMap<int, QString> OContact::toMap() const |
423 | { | 424 | { |
424 | QMap<int, QString> map = mMap; | 425 | QMap<int, QString> map = mMap; |
425 | QString cats = idsToString( categories() ); | 426 | QString cats = idsToString( categories() ); |
426 | if ( !cats.isEmpty() ) | 427 | if ( !cats.isEmpty() ) |
427 | map.insert( Qtopia::AddressCategory, cats ); | 428 | map.insert( Qtopia::AddressCategory, cats ); |
428 | return map; | 429 | return map; |
429 | } | 430 | } |
430 | 431 | ||
431 | /*! | 432 | /*! |
432 | Returns a rich text formatted QString representing the contents the contact. | 433 | Returns a rich text formatted QString representing the contents the contact. |
433 | */ | 434 | */ |
434 | QString OContact::toRichText() const | 435 | QString OContact::toRichText() const |
435 | { | 436 | { |
436 | QString text; | 437 | QString text; |
437 | QString value, comp, state; | 438 | QString value, comp, state; |
438 | QString str; | 439 | QString str; |
439 | bool marker = false; | 440 | bool marker = false; |
440 | 441 | ||
442 | Config cfg("qpe"); | ||
443 | cfg.setGroup("Appearance"); | ||
444 | int addressformat = cfg.readNumEntry( "AddressFormat", Zip_City_State ); | ||
445 | |||
441 | // name, jobtitle and company | 446 | // name, jobtitle and company |
442 | if ( !(value = fullName()).isEmpty() ) | 447 | if ( !(value = fullName()).isEmpty() ) |
443 | text += "<b><h3><img src=\"addressbook/AddressBook\">" + Qtopia::escapeString(value) + "</h3></b>"; | 448 | text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString(value) + "</h3></b>"; |
444 | 449 | ||
445 | if ( !(value = jobTitle()).isEmpty() ) | 450 | if ( !(value = jobTitle()).isEmpty() ) |
446 | text += Qtopia::escapeString(value) + "<br>"; | 451 | text += Qtopia::escapeString(value); |
447 | 452 | ||
448 | comp = company(); | 453 | comp = company(); |
449 | if ( !(value = department()).isEmpty() ) { | 454 | if ( !(value = department()).isEmpty() ) { |
450 | text += Qtopia::escapeString(value); | 455 | text += Qtopia::escapeString(value); |
451 | if ( comp ) | 456 | if ( comp ) |
452 | text += ", "; | 457 | text += ", "; |
453 | else | 458 | else |
454 | text += "<br>"; | 459 | text += "<br>"; |
455 | } | 460 | } |
456 | if ( !comp.isEmpty() ) | 461 | if ( !comp.isEmpty() ) |
457 | text += Qtopia::escapeString(comp) + "<br>"; | 462 | text += Qtopia::escapeString(comp); |
458 | 463 | ||
459 | text += "<hr><br>"; | 464 | text += "<br><hr>"; |
460 | 465 | ||
461 | // defailt email | 466 | // defailt email |
462 | QString defEmail = defaultEmail(); | 467 | QString defEmail = defaultEmail(); |
463 | if ( !defEmail.isEmpty() ) | 468 | if ( !defEmail.isEmpty() ){ |
464 | text += "<b><img src=\"addressbook/email\">" + QObject::tr("Default Email: ") + "</b>" | 469 | text += "<b><img src=\"addressbook/email\"> " + QObject::tr("Default Email: ") + "</b>" |
465 | + Qtopia::escapeString(defEmail) + "<br>"; | 470 | + Qtopia::escapeString(defEmail); |
466 | 471 | marker = true; | |
467 | text += "<br>"; | 472 | } |
468 | 473 | ||
469 | // business address | 474 | // business address |
470 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || | 475 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || |
471 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { | 476 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { |
472 | text += QObject::tr( "<b>Work Address:</b>" ); | 477 | text += QObject::tr( "<br><br><b>Work Address:</b>" ); |
473 | text += "<br>"; | ||
474 | marker = true; | 478 | marker = true; |
475 | } | 479 | } |
476 | 480 | ||
477 | if ( !(value = businessStreet()).isEmpty() ) | 481 | if ( !(value = businessStreet()).isEmpty() ){ |
478 | text += Qtopia::escapeString(value) + "<br>"; | 482 | text += "<br>" + Qtopia::escapeString(value); |
479 | state = businessState(); | 483 | marker = true; |
480 | if ( !(value = businessZip()).isEmpty() ) | 484 | } |
481 | text += Qtopia::escapeString(value) + " "; | 485 | |
482 | if ( !(value = businessCity()).isEmpty() ) { | 486 | switch( addressformat ){ |
483 | text += Qtopia::escapeString(value); | 487 | case Zip_City_State:{ // Zip_Code City, State |
484 | if ( state ) | 488 | state = businessState(); |
485 | text += ", " + Qtopia::escapeString(state); | 489 | if ( !(value = businessZip()).isEmpty() ){ |
486 | text += "<br>"; | 490 | text += "<br>" + Qtopia::escapeString(value) + " "; |
487 | } else if ( !state.isEmpty() ) | 491 | marker = true; |
488 | text += Qtopia::escapeString(state) + "<br>"; | 492 | |
493 | } else | ||
494 | text += "<br>"; | ||
495 | |||
496 | if ( !(value = businessCity()).isEmpty() ) { | ||
497 | marker = true; | ||
498 | text += Qtopia::escapeString(value); | ||
499 | if ( state ) | ||
500 | text += ", " + Qtopia::escapeString(state); | ||
501 | } else if ( !state.isEmpty() ){ | ||
502 | text += "<br>" + Qtopia::escapeString(state); | ||
503 | marker = true; | ||
504 | } | ||
505 | break; | ||
506 | } | ||
507 | case City_State_Zip:{ // City, State Zip_Code | ||
508 | state = businessState(); | ||
509 | if ( !(value = businessCity()).isEmpty() ) { | ||
510 | marker = true; | ||
511 | text += "<br>" + Qtopia::escapeString(value); | ||
512 | if ( state ) | ||
513 | text += ", " + Qtopia::escapeString(state); | ||
514 | } else if ( !state.isEmpty() ){ | ||
515 | text += "<br>" + Qtopia::escapeString(state); | ||
516 | marker = true; | ||
517 | } | ||
518 | if ( !(value = businessZip()).isEmpty() ){ | ||
519 | text += " " + Qtopia::escapeString(value); | ||
520 | marker = true; | ||
521 | } | ||
522 | break; | ||
523 | } | ||
524 | } | ||
489 | 525 | ||
490 | if ( !(value = businessCountry()).isEmpty() ) | 526 | if ( !(value = businessCountry()).isEmpty() ){ |
491 | text += Qtopia::escapeString(value) + "<br>"; | 527 | text += "<br>" + Qtopia::escapeString(value); |
528 | marker = true; | ||
529 | } | ||
492 | 530 | ||
493 | // rest of Business data | 531 | // rest of Business data |
494 | str = office(); | 532 | str = office(); |
495 | if ( !str.isEmpty() ){ | 533 | if ( !str.isEmpty() ){ |
496 | text += "<b>" + QObject::tr("Office: ") + "</b>" | 534 | text += "<br><b>" + QObject::tr("Office: ") + "</b>" |
497 | + Qtopia::escapeString(str) + "<br>"; | 535 | + Qtopia::escapeString(str); |
498 | marker = true; | 536 | marker = true; |
499 | } | 537 | } |
500 | str = businessWebpage(); | 538 | str = businessWebpage(); |
501 | if ( !str.isEmpty() ){ | 539 | if ( !str.isEmpty() ){ |
502 | text += "<b><img src=\"addressbook/webpagework\">" + QObject::tr("Business Web Page: ") + "</b>" | 540 | text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr("Business Web Page: ") + "</b>" |
503 | + Qtopia::escapeString(str) + "<br>"; | 541 | + Qtopia::escapeString(str); |
504 | marker = true; | 542 | marker = true; |
505 | } | 543 | } |
506 | str = businessPhone(); | 544 | str = businessPhone(); |
507 | if ( !str.isEmpty() ){ | 545 | if ( !str.isEmpty() ){ |
508 | text += "<b><img src=\"addressbook/phonework\">" + QObject::tr("Business Phone: ") + "</b>" | 546 | text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr("Business Phone: ") + "</b>" |
509 | + Qtopia::escapeString(str) + "<br>"; | 547 | + Qtopia::escapeString(str); |
510 | marker = true; | 548 | marker = true; |
511 | } | 549 | } |
512 | str = businessFax(); | 550 | str = businessFax(); |
513 | if ( !str.isEmpty() ){ | 551 | if ( !str.isEmpty() ){ |
514 | text += "<b><img src=\"addressbook/faxwork\">" + QObject::tr("Business Fax: ") + "</b>" | 552 | text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr("Business Fax: ") + "</b>" |
515 | + Qtopia::escapeString(str) + "<br>"; | 553 | + Qtopia::escapeString(str); |
516 | marker = true; | 554 | marker = true; |
517 | } | 555 | } |
518 | str = businessMobile(); | 556 | str = businessMobile(); |
519 | if ( !str.isEmpty() ){ | 557 | if ( !str.isEmpty() ){ |
520 | text += "<b><img src=\"addressbook/mobilework\">" + QObject::tr("Business Mobile: ") + "</b>" | 558 | text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr("Business Mobile: ") + "</b>" |
521 | + Qtopia::escapeString(str) + "<br>"; | 559 | + Qtopia::escapeString(str); |
522 | marker = true; | 560 | marker = true; |
523 | } | 561 | } |
524 | str = businessPager(); | 562 | str = businessPager(); |
525 | if ( !str.isEmpty() ){ | 563 | if ( !str.isEmpty() ){ |
526 | text += "<b>" + QObject::tr("Business Pager: ") + "</b>" | 564 | text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>" |
527 | + Qtopia::escapeString(str) + "<br>"; | 565 | + Qtopia::escapeString(str); |
528 | marker = true; | 566 | marker = true; |
529 | } | 567 | } |
530 | 568 | ||
531 | text += "<br>"; | 569 | text += "<br>"; |
532 | 570 | ||
533 | // home address | 571 | // home address |
534 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || | 572 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || |
535 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { | 573 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { |
536 | text += QObject::tr( "<b>Home Address:</b>" ); | 574 | text += QObject::tr( "<br><br><b>Home Address:</b>" ); |
537 | text += "<br>"; | 575 | marker = true; |
538 | } | 576 | } |
539 | 577 | ||
540 | if ( !(value = homeStreet()).isEmpty() ) | 578 | if ( !(value = homeStreet()).isEmpty() ){ |
541 | text += Qtopia::escapeString(value) + "<br>"; | 579 | text += "<br>" + Qtopia::escapeString(value); |
542 | state = homeState(); | 580 | marker = true; |
543 | if ( !(value = homeZip()).isEmpty() ) | 581 | } |
544 | text += Qtopia::escapeString(value) + " "; | 582 | |
545 | if ( !(value = homeCity()).isEmpty() ) { | 583 | switch( addressformat ){ |
546 | text += Qtopia::escapeString(value); | 584 | case Zip_City_State:{ // Zip_Code City, State |
547 | if ( !state.isEmpty() ) | 585 | state = homeState(); |
548 | text += ", " + Qtopia::escapeString(state); | 586 | if ( !(value = homeZip()).isEmpty() ){ |
549 | text += "<br>"; | 587 | text += "<br>" + Qtopia::escapeString(value) + " "; |
550 | } else if (!state.isEmpty()) | 588 | marker = true; |
551 | text += Qtopia::escapeString(state) + "<br>"; | 589 | } else |
552 | if ( !(value = homeCountry()).isEmpty() ) | 590 | text += "<br>"; |
553 | text += Qtopia::escapeString(value) + "<br>"; | 591 | |
592 | if ( !(value = homeCity()).isEmpty() ) { | ||
593 | marker = true; | ||
594 | text += Qtopia::escapeString(value); | ||
595 | if ( !state.isEmpty() ) | ||
596 | text += ", " + Qtopia::escapeString(state); | ||
597 | } else if (!state.isEmpty()) { | ||
598 | text += "<br>" + Qtopia::escapeString(state); | ||
599 | marker = true; | ||
600 | } | ||
601 | break; | ||
602 | } | ||
603 | case City_State_Zip:{ // City, State Zip_Code | ||
604 | state = homeState(); | ||
605 | if ( !(value = homeCity()).isEmpty() ) { | ||
606 | marker = true; | ||
607 | text += "<br>" + Qtopia::escapeString(value); | ||
608 | if ( state ) | ||
609 | text += ", " + Qtopia::escapeString(state); | ||
610 | } else if ( !state.isEmpty() ){ | ||
611 | text += "<br>" + Qtopia::escapeString(state); | ||
612 | marker = true; | ||
613 | } | ||
614 | if ( !(value = homeZip()).isEmpty() ){ | ||
615 | text += " " + Qtopia::escapeString(value); | ||
616 | marker = true; | ||
617 | } | ||
618 | break; | ||
619 | } | ||
620 | } | ||
621 | |||
622 | if ( !(value = homeCountry()).isEmpty() ){ | ||
623 | text += "<br>" + Qtopia::escapeString(value); | ||
624 | marker = true; | ||
625 | } | ||
554 | 626 | ||
555 | // rest of Home data | 627 | // rest of Home data |
556 | str = homeWebpage(); | 628 | str = homeWebpage(); |
557 | if ( !str.isEmpty() ){ | 629 | if ( !str.isEmpty() ){ |
558 | text += "<b><img src=\"addressbook/webpagehome\">" + QObject::tr("Home Web Page: ") + "</b>" | 630 | text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr("Home Web Page: ") + "</b>" |
559 | + Qtopia::escapeString(str) + "<br>"; | 631 | + Qtopia::escapeString(str); |
560 | marker = true; | 632 | marker = true; |
561 | } | 633 | } |
562 | str = homePhone(); | 634 | str = homePhone(); |
563 | if ( !str.isEmpty() ){ | 635 | if ( !str.isEmpty() ){ |
564 | text += "<b><img src=\"addressbook/phonehome\">" + QObject::tr("Home Phone: ") + "</b>" | 636 | text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr("Home Phone: ") + "</b>" |
565 | + Qtopia::escapeString(str) + "<br>"; | 637 | + Qtopia::escapeString(str); |
566 | marker = true; | 638 | marker = true; |
567 | } | 639 | } |
568 | str = homeFax(); | 640 | str = homeFax(); |
569 | if ( !str.isEmpty() ){ | 641 | if ( !str.isEmpty() ){ |
570 | text += "<b><img src=\"addressbook/faxhome\">" + QObject::tr("Home Fax: ") + "</b>" | 642 | text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr("Home Fax: ") + "</b>" |
571 | + Qtopia::escapeString(str) + "<br>"; | 643 | + Qtopia::escapeString(str); |
572 | marker = true; | 644 | marker = true; |
573 | } | 645 | } |
574 | str = homeMobile(); | 646 | str = homeMobile(); |
575 | if ( !str.isEmpty() ){ | 647 | if ( !str.isEmpty() ){ |
576 | text += "<b><img src=\"addressbook/mobilehome\">" + QObject::tr("Home Mobile: ") + "</b>" | 648 | text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>" |
577 | + Qtopia::escapeString(str) + "<br>"; | 649 | + Qtopia::escapeString(str); |
578 | marker = true; | 650 | marker = true; |
579 | } | 651 | } |
580 | 652 | ||
581 | if ( marker ) | 653 | if ( marker ) |
582 | text += "<br><hr><br>"; | 654 | text += "<br><hr>"; |
583 | // the others... | 655 | |
656 | // the rest... | ||
584 | str = emails(); | 657 | str = emails(); |
585 | if ( !str.isEmpty() && ( str != defEmail ) ) | 658 | if ( !str.isEmpty() && ( str != defEmail ) ) |
586 | text += "<b>" + QObject::tr("All Emails: ") + "</b>" | 659 | text += "<br><b>" + QObject::tr("All Emails: ") + "</b>" |
587 | + Qtopia::escapeString(str) + "<br>"; | 660 | + Qtopia::escapeString(str); |
588 | str = profession(); | 661 | str = profession(); |
589 | if ( !str.isEmpty() ) | 662 | if ( !str.isEmpty() ) |
590 | text += "<b>" + QObject::tr("Profession: ") + "</b>" | 663 | text += "<br><b>" + QObject::tr("Profession: ") + "</b>" |
591 | + Qtopia::escapeString(str) + "<br>"; | 664 | + Qtopia::escapeString(str); |
592 | str = assistant(); | 665 | str = assistant(); |
593 | if ( !str.isEmpty() ) | 666 | if ( !str.isEmpty() ) |
594 | text += "<b>" + QObject::tr("Assistant: ") + "</b>" | 667 | text += "<br><b>" + QObject::tr("Assistant: ") + "</b>" |
595 | + Qtopia::escapeString(str) + "<br>"; | 668 | + Qtopia::escapeString(str); |
596 | str = manager(); | 669 | str = manager(); |
597 | if ( !str.isEmpty() ) | 670 | if ( !str.isEmpty() ) |
598 | text += "<b>" + QObject::tr("Manager: ") + "</b>" | 671 | text += "<br><b>" + QObject::tr("Manager: ") + "</b>" |
599 | + Qtopia::escapeString(str) + "<br>"; | 672 | + Qtopia::escapeString(str); |
600 | str = gender(); | 673 | str = gender(); |
601 | if ( !str.isEmpty() && str.toInt() != 0 ) { | 674 | if ( !str.isEmpty() && str.toInt() != 0 ) { |
602 | if ( str.toInt() == 1 ) | 675 | text += "<br>"; |
603 | str = QObject::tr( "Male" ); | 676 | if ( str.toInt() == 1 ) |
604 | else if ( str.toInt() == 2 ) | 677 | str = QObject::tr( "Male" ); |
605 | str = QObject::tr( "Female" ); | 678 | else if ( str.toInt() == 2 ) |
606 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; | 679 | str = QObject::tr( "Female" ); |
680 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str; | ||
607 | } | 681 | } |
608 | str = spouse(); | 682 | str = spouse(); |
609 | if ( !str.isEmpty() ) | 683 | if ( !str.isEmpty() ) |
610 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" | 684 | text += "<br><b>" + QObject::tr("Spouse: ") + "</b>" |
611 | + Qtopia::escapeString(str) + "<br>"; | 685 | + Qtopia::escapeString(str); |
612 | if ( birthday().isValid() ){ | 686 | if ( birthday().isValid() ){ |
613 | str = TimeString::numberDateString( birthday() ); | 687 | str = TimeString::numberDateString( birthday() ); |
614 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" | 688 | text += "<br><b>" + QObject::tr("Birthday: ") + "</b>" |
615 | + Qtopia::escapeString(str) + "<br>"; | 689 | + Qtopia::escapeString(str); |
616 | } | 690 | } |
617 | if ( anniversary().isValid() ){ | 691 | if ( anniversary().isValid() ){ |
618 | str = TimeString::numberDateString( anniversary() ); | 692 | str = TimeString::numberDateString( anniversary() ); |
619 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" | 693 | text += "<br><b>" + QObject::tr("Anniversary: ") + "</b>" |
620 | + Qtopia::escapeString(str) + "<br>"; | 694 | + Qtopia::escapeString(str); |
621 | } | 695 | } |
622 | str = children(); | 696 | str = children(); |
623 | if ( !str.isEmpty() ) | 697 | if ( !str.isEmpty() ) |
624 | text += "<b>" + QObject::tr("Children: ") + "</b>" | 698 | text += "<br><b>" + QObject::tr("Children: ") + "</b>" |
625 | + Qtopia::escapeString(str) + "<br>"; | 699 | + Qtopia::escapeString(str); |
626 | 700 | ||
627 | str = nickname(); | 701 | str = nickname(); |
628 | if ( !str.isEmpty() ) | 702 | if ( !str.isEmpty() ) |
629 | text += "<b>" + QObject::tr("Nickname: ") + "</b>" | 703 | text += "<br><b>" + QObject::tr("Nickname: ") + "</b>" |
630 | + Qtopia::escapeString(str) + "<br>"; | 704 | + Qtopia::escapeString(str); |
631 | 705 | ||
632 | // categories | 706 | // categories |
633 | if ( categoryNames("Contacts").count() ){ | 707 | if ( categoryNames("Contacts").count() ){ |
634 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 708 | text += "<br><b>" + QObject::tr( "Category:") + "</b> "; |
635 | text += categoryNames("Contacts").join(", "); | 709 | text += categoryNames("Contacts").join(", "); |
636 | text += "<br>"; | ||
637 | } | 710 | } |
638 | 711 | ||
639 | // notes last | 712 | // notes last |
640 | if ( !(value = notes()).isEmpty() ) { | 713 | if ( !(value = notes()).isEmpty() ) { |
641 | text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; | 714 | text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; |
642 | QRegExp reg("\n"); | 715 | QRegExp reg("\n"); |
643 | 716 | ||
644 | //QString tmp = Qtopia::escapeString(value); | 717 | //QString tmp = Qtopia::escapeString(value); |
645 | QString tmp = QStyleSheet::convertFromPlainText(value); | 718 | QString tmp = QStyleSheet::convertFromPlainText(value); |
646 | //tmp.replace( reg, "<br>" ); | 719 | //tmp.replace( reg, "<br>" ); |
647 | text += "<br>" + tmp + "<br>"; | 720 | text += "<br>" + tmp + "<br>"; |
648 | } | 721 | } |
649 | return text; | 722 | return text; |
650 | } | 723 | } |
651 | 724 | ||
652 | /*! | 725 | /*! |
653 | \internal | 726 | \internal |
654 | */ | 727 | */ |
655 | void OContact::insert( int key, const QString &v ) | 728 | void OContact::insert( int key, const QString &v ) |
656 | { | 729 | { |
657 | QString value = v.stripWhiteSpace(); | 730 | QString value = v.stripWhiteSpace(); |
658 | if ( value.isEmpty() ) | 731 | if ( value.isEmpty() ) |
659 | mMap.remove( key ); | 732 | mMap.remove( key ); |
660 | else | 733 | else |
661 | mMap.insert( key, value ); | 734 | mMap.insert( key, value ); |
662 | } | 735 | } |
663 | 736 | ||
664 | /*! | 737 | /*! |
665 | \internal | 738 | \internal |
666 | */ | 739 | */ |
667 | void OContact::replace( int key, const QString & v ) | 740 | void OContact::replace( int key, const QString & v ) |
668 | { | 741 | { |
669 | QString value = v.stripWhiteSpace(); | 742 | QString value = v.stripWhiteSpace(); |
670 | if ( value.isEmpty() ) | 743 | if ( value.isEmpty() ) |
671 | mMap.remove( key ); | 744 | mMap.remove( key ); |
672 | else | 745 | else |
673 | mMap.replace( key, value ); | 746 | mMap.replace( key, value ); |
674 | } | 747 | } |
675 | 748 | ||
676 | /*! | 749 | /*! |
677 | \internal | 750 | \internal |
678 | */ | 751 | */ |
679 | QString OContact::find( int key ) const | 752 | QString OContact::find( int key ) const |
680 | { | 753 | { |
681 | return mMap[key]; | 754 | return mMap[key]; |
682 | } | 755 | } |
683 | 756 | ||
684 | /*! | 757 | /*! |
685 | \internal | 758 | \internal |
686 | */ | 759 | */ |
687 | QString OContact::displayAddress( const QString &street, | 760 | QString OContact::displayAddress( const QString &street, |
688 | const QString &city, | 761 | const QString &city, |
689 | const QString &state, | 762 | const QString &state, |
690 | const QString &zip, | 763 | const QString &zip, |
691 | const QString &country ) const | 764 | const QString &country ) const |
692 | { | 765 | { |
693 | QString s = street; | 766 | QString s = street; |
694 | if ( !street.isEmpty() ) | 767 | if ( !street.isEmpty() ) |
695 | s+= "\n"; | 768 | s+= "\n"; |
696 | s += city; | 769 | s += city; |
697 | if ( !city.isEmpty() && !state.isEmpty() ) | 770 | if ( !city.isEmpty() && !state.isEmpty() ) |
698 | s += ", "; | 771 | s += ", "; |
699 | s += state; | 772 | s += state; |
700 | if ( !state.isEmpty() && !zip.isEmpty() ) | 773 | if ( !state.isEmpty() && !zip.isEmpty() ) |
701 | s += " "; | 774 | s += " "; |
702 | s += zip; | 775 | s += zip; |
703 | if ( !country.isEmpty() && !s.isEmpty() ) | 776 | if ( !country.isEmpty() && !s.isEmpty() ) |
704 | s += "\n"; | 777 | s += "\n"; |
705 | s += country; | 778 | s += country; |
706 | return s; | 779 | return s; |
707 | } | 780 | } |
708 | 781 | ||
709 | /*! | 782 | /*! |
710 | \internal | 783 | \internal |
711 | */ | 784 | */ |
712 | QString OContact::displayBusinessAddress() const | 785 | QString OContact::displayBusinessAddress() const |
713 | { | 786 | { |
714 | return displayAddress( businessStreet(), businessCity(), | 787 | return displayAddress( businessStreet(), businessCity(), |
715 | businessState(), businessZip(), | 788 | businessState(), businessZip(), |
716 | businessCountry() ); | 789 | businessCountry() ); |
717 | } | 790 | } |
718 | 791 | ||
719 | /*! | 792 | /*! |
720 | \internal | 793 | \internal |
721 | */ | 794 | */ |
722 | QString OContact::displayHomeAddress() const | 795 | QString OContact::displayHomeAddress() const |
723 | { | 796 | { |
724 | return displayAddress( homeStreet(), homeCity(), | 797 | return displayAddress( homeStreet(), homeCity(), |
725 | homeState(), homeZip(), | 798 | homeState(), homeZip(), |
726 | homeCountry() ); | 799 | homeCountry() ); |
727 | } | 800 | } |
728 | 801 | ||
729 | /*! | 802 | /*! |
730 | Returns the full name of the contact | 803 | Returns the full name of the contact |
731 | */ | 804 | */ |
732 | QString OContact::fullName() const | 805 | QString OContact::fullName() const |
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h index dd2de17..9a1a8dc 100644 --- a/libopie/pim/ocontact.h +++ b/libopie/pim/ocontact.h | |||
@@ -1,240 +1,245 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 13 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
14 | ** | 14 | ** |
15 | ** Contact info@trolltech.com if any conditions of this licensing are | 15 | ** Contact info@trolltech.com if any conditions of this licensing are |
16 | ** not clear to you. | 16 | ** not clear to you. |
17 | ** | 17 | ** |
18 | **********************************************************************/ | 18 | **********************************************************************/ |
19 | 19 | ||
20 | #ifndef __OCONTACT_H__ | 20 | #ifndef __OCONTACT_H__ |
21 | #define __OCONTACT_H__ | 21 | #define __OCONTACT_H__ |
22 | 22 | ||
23 | #include <opie/opimrecord.h> | 23 | #include <opie/opimrecord.h> |
24 | #include <qpe/recordfields.h> | 24 | #include <qpe/recordfields.h> |
25 | 25 | ||
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | 28 | ||
29 | #if defined(QPC_TEMPLATEDLL) | 29 | #if defined(QPC_TEMPLATEDLL) |
30 | // MOC_SKIP_BEGIN | 30 | // MOC_SKIP_BEGIN |
31 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; | 31 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; |
32 | // MOC_SKIP_END | 32 | // MOC_SKIP_END |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | class ContactPrivate; | 35 | class OContactPrivate; |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * OContact class represents a specialised PIM Record for contacts. | 38 | * OContact class represents a specialised PIM Record for contacts. |
39 | * It does store all kind of persopn related information. | 39 | * It does store all kind of persopn related information. |
40 | * | 40 | * |
41 | * @short Contact Container | 41 | * @short Contact Container |
42 | * @author TT, Stefan Eiler, Holger Freyther | 42 | * @author TT, Stefan Eiler, Holger Freyther |
43 | */ | 43 | */ |
44 | class QPC_EXPORT OContact : public OPimRecord | 44 | class QPC_EXPORT OContact : public OPimRecord |
45 | { | 45 | { |
46 | friend class DataSet; | 46 | friend class DataSet; |
47 | public: | 47 | public: |
48 | OContact(); | 48 | OContact(); |
49 | OContact( const QMap<int, QString> &fromMap ); | 49 | OContact( const QMap<int, QString> &fromMap ); |
50 | virtual ~OContact(); | 50 | virtual ~OContact(); |
51 | 51 | ||
52 | enum DateFormat{ | ||
53 | Zip_City_State = 0, | ||
54 | City_State_Zip | ||
55 | }; | ||
56 | |||
52 | /* | 57 | /* |
53 | * do we need to inline them | 58 | * do we need to inline them |
54 | * if yes do we need to inline them this way? | 59 | * if yes do we need to inline them this way? |
55 | * -zecke | 60 | * -zecke |
56 | */ | 61 | */ |
57 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } | 62 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } |
58 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } | 63 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } |
59 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } | 64 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } |
60 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } | 65 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } |
61 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } | 66 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } |
62 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } | 67 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } |
63 | void setFileAs(); | 68 | void setFileAs(); |
64 | 69 | ||
65 | // default email address | 70 | // default email address |
66 | void setDefaultEmail( const QString &v ); | 71 | void setDefaultEmail( const QString &v ); |
67 | // inserts email to list and ensure's doesn't already exist | 72 | // inserts email to list and ensure's doesn't already exist |
68 | void insertEmail( const QString &v ); | 73 | void insertEmail( const QString &v ); |
69 | void removeEmail( const QString &v ); | 74 | void removeEmail( const QString &v ); |
70 | void clearEmails(); | 75 | void clearEmails(); |
71 | void insertEmails( const QStringList &v ); | 76 | void insertEmails( const QStringList &v ); |
72 | 77 | ||
73 | // home | 78 | // home |
74 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } | 79 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } |
75 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } | 80 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } |
76 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } | 81 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } |
77 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } | 82 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } |
78 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } | 83 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } |
79 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } | 84 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } |
80 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } | 85 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } |
81 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } | 86 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } |
82 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } | 87 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } |
83 | 88 | ||
84 | // business | 89 | // business |
85 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } | 90 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } |
86 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } | 91 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } |
87 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } | 92 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } |
88 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } | 93 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } |
89 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 94 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
90 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 95 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
91 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 96 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
92 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 97 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
93 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 98 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
94 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 99 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
95 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 100 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
96 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 101 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
97 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 102 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
98 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 103 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
99 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 104 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
100 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 105 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
101 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 106 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
102 | 107 | ||
103 | // personal | 108 | // personal |
104 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 109 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
105 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 110 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
106 | void setBirthday( const QDate &v ); | 111 | void setBirthday( const QDate &v ); |
107 | void setAnniversary( const QDate &v ); | 112 | void setAnniversary( const QDate &v ); |
108 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 113 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
109 | void setChildren( const QString &v ); | 114 | void setChildren( const QString &v ); |
110 | 115 | ||
111 | // other | 116 | // other |
112 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 117 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } |
113 | 118 | ||
114 | virtual bool match( const QRegExp ®exp ) const; | 119 | virtual bool match( const QRegExp ®exp ) const; |
115 | 120 | ||
116 | // // custom | 121 | // // custom |
117 | // void setCustomField( const QString &key, const QString &v ) | 122 | // void setCustomField( const QString &key, const QString &v ) |
118 | // { replace(Custom- + key, v ); } | 123 | // { replace(Custom- + key, v ); } |
119 | 124 | ||
120 | // name | 125 | // name |
121 | QString fullName() const; | 126 | QString fullName() const; |
122 | QString title() const { return find( Qtopia::Title ); } | 127 | QString title() const { return find( Qtopia::Title ); } |
123 | QString firstName() const { return find( Qtopia::FirstName ); } | 128 | QString firstName() const { return find( Qtopia::FirstName ); } |
124 | QString middleName() const { return find( Qtopia::MiddleName ); } | 129 | QString middleName() const { return find( Qtopia::MiddleName ); } |
125 | QString lastName() const { return find( Qtopia::LastName ); } | 130 | QString lastName() const { return find( Qtopia::LastName ); } |
126 | QString suffix() const { return find( Qtopia::Suffix ); } | 131 | QString suffix() const { return find( Qtopia::Suffix ); } |
127 | QString fileAs() const { return find( Qtopia::FileAs ); } | 132 | QString fileAs() const { return find( Qtopia::FileAs ); } |
128 | 133 | ||
129 | 134 | ||
130 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 135 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
131 | QStringList emailList() const; | 136 | QStringList emailList() const; |
132 | 137 | ||
133 | // home | 138 | // home |
134 | /* | 139 | /* |
135 | * OPimAddress address(enum Location)const; | 140 | * OPimAddress address(enum Location)const; |
136 | * would be some how nicer... | 141 | * would be some how nicer... |
137 | * -zecke | 142 | * -zecke |
138 | */ | 143 | */ |
139 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 144 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
140 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 145 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
141 | QString homeState() const { return find( Qtopia::HomeState ); } | 146 | QString homeState() const { return find( Qtopia::HomeState ); } |
142 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 147 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
143 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 148 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
144 | QString homePhone() const { return find( Qtopia::HomePhone ); } | 149 | QString homePhone() const { return find( Qtopia::HomePhone ); } |
145 | QString homeFax() const { return find( Qtopia::HomeFax ); } | 150 | QString homeFax() const { return find( Qtopia::HomeFax ); } |
146 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } | 151 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } |
147 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } | 152 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } |
148 | /** Multi line string containing all non-empty address info in the form | 153 | /** Multi line string containing all non-empty address info in the form |
149 | * Street | 154 | * Street |
150 | * City, State Zip | 155 | * City, State Zip |
151 | * Country | 156 | * Country |
152 | */ | 157 | */ |
153 | QString displayHomeAddress() const; | 158 | QString displayHomeAddress() const; |
154 | 159 | ||
155 | // business | 160 | // business |
156 | QString company() const { return find( Qtopia::Company ); } | 161 | QString company() const { return find( Qtopia::Company ); } |
157 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } | 162 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } |
158 | QString businessCity() const { return find( Qtopia::BusinessCity ); } | 163 | QString businessCity() const { return find( Qtopia::BusinessCity ); } |
159 | QString businessState() const { return find( Qtopia::BusinessState ); } | 164 | QString businessState() const { return find( Qtopia::BusinessState ); } |
160 | QString businessZip() const { return find( Qtopia::BusinessZip ); } | 165 | QString businessZip() const { return find( Qtopia::BusinessZip ); } |
161 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } | 166 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } |
162 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | 167 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } |
163 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 168 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
164 | QString department() const { return find( Qtopia::Department ); } | 169 | QString department() const { return find( Qtopia::Department ); } |
165 | QString office() const { return find( Qtopia::Office ); } | 170 | QString office() const { return find( Qtopia::Office ); } |
166 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 171 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
167 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 172 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
168 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 173 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
169 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 174 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
170 | QString profession() const { return find( Qtopia::Profession ); } | 175 | QString profession() const { return find( Qtopia::Profession ); } |
171 | QString assistant() const { return find( Qtopia::Assistant ); } | 176 | QString assistant() const { return find( Qtopia::Assistant ); } |
172 | QString manager() const { return find( Qtopia::Manager ); } | 177 | QString manager() const { return find( Qtopia::Manager ); } |
173 | /** Multi line string containing all non-empty address info in the form | 178 | /** Multi line string containing all non-empty address info in the form |
174 | * Street | 179 | * Street |
175 | * City, State Zip | 180 | * City, State Zip |
176 | * Country | 181 | * Country |
177 | */ | 182 | */ |
178 | QString displayBusinessAddress() const; | 183 | QString displayBusinessAddress() const; |
179 | 184 | ||
180 | //personal | 185 | //personal |
181 | QString spouse() const { return find( Qtopia::Spouse ); } | 186 | QString spouse() const { return find( Qtopia::Spouse ); } |
182 | QString gender() const { return find( Qtopia::Gender ); } | 187 | QString gender() const { return find( Qtopia::Gender ); } |
183 | QDate birthday() const; | 188 | QDate birthday() const; |
184 | QDate anniversary() const; | 189 | QDate anniversary() const; |
185 | QString nickname() const { return find( Qtopia::Nickname ); } | 190 | QString nickname() const { return find( Qtopia::Nickname ); } |
186 | QString children() const { return find( Qtopia::Children ); } | 191 | QString children() const { return find( Qtopia::Children ); } |
187 | QStringList childrenList() const; | 192 | QStringList childrenList() const; |
188 | 193 | ||
189 | // other | 194 | // other |
190 | QString notes() const { return find( Qtopia::Notes ); } | 195 | QString notes() const { return find( Qtopia::Notes ); } |
191 | QString groups() const { return find( Qtopia::Groups ); } | 196 | QString groups() const { return find( Qtopia::Groups ); } |
192 | QStringList groupList() const; | 197 | QStringList groupList() const; |
193 | 198 | ||
194 | // // custom | 199 | // // custom |
195 | // const QString &customField( const QString &key ) | 200 | // const QString &customField( const QString &key ) |
196 | // { return find( Custom- + key ); } | 201 | // { return find( Custom- + key ); } |
197 | 202 | ||
198 | 203 | ||
199 | QString toRichText() const; | 204 | QString toRichText() const; |
200 | QMap<int, QString> toMap() const; | 205 | QMap<int, QString> toMap() const; |
201 | QString field( int key ) const { return find( key ); } | 206 | QString field( int key ) const { return find( key ); } |
202 | 207 | ||
203 | 208 | ||
204 | void setUid( int i ); | 209 | void setUid( int i ); |
205 | 210 | ||
206 | QString toShortText()const; | 211 | QString toShortText()const; |
207 | QString OContact::type()const; | 212 | QString OContact::type()const; |
208 | QMap<QString,QString> OContact::toExtraMap() const; | 213 | QMap<QString,QString> OContact::toExtraMap() const; |
209 | class QString OContact::recordField(int) const; | 214 | class QString OContact::recordField(int) const; |
210 | 215 | ||
211 | // Why private ? (eilers,se) | 216 | // Why private ? (eilers,se) |
212 | QString emailSeparator() const { return " "; } | 217 | QString emailSeparator() const { return " "; } |
213 | // the emails should be seperated by a comma | 218 | // the emails should be seperated by a comma |
214 | void setEmails( const QString &v ); | 219 | void setEmails( const QString &v ); |
215 | QString emails() const { return find( Qtopia::Emails ); } | 220 | QString emails() const { return find( Qtopia::Emails ); } |
216 | static int rtti(); | 221 | static int rtti(); |
217 | 222 | ||
218 | private: | 223 | private: |
219 | // The XML-Backend needs some access to the private functions | 224 | // The XML-Backend needs some access to the private functions |
220 | friend class OContactAccessBackend_XML; | 225 | friend class OContactAccessBackend_XML; |
221 | 226 | ||
222 | void insert( int key, const QString &value ); | 227 | void insert( int key, const QString &value ); |
223 | void replace( int key, const QString &value ); | 228 | void replace( int key, const QString &value ); |
224 | QString find( int key ) const; | 229 | QString find( int key ) const; |
225 | static QStringList fields(); | 230 | static QStringList fields(); |
226 | 231 | ||
227 | void save( QString &buf ) const; | 232 | void save( QString &buf ) const; |
228 | 233 | ||
229 | QString displayAddress( const QString &street, | 234 | QString displayAddress( const QString &street, |
230 | const QString &city, | 235 | const QString &city, |
231 | const QString &state, | 236 | const QString &state, |
232 | const QString &zip, | 237 | const QString &zip, |
233 | const QString &country ) const; | 238 | const QString &country ) const; |
234 | 239 | ||
235 | QMap<int, QString> mMap; | 240 | QMap<int, QString> mMap; |
236 | ContactPrivate *d; | 241 | OContactPrivate *d; |
237 | }; | 242 | }; |
238 | 243 | ||
239 | 244 | ||
240 | #endif | 245 | #endif |
diff --git a/libopie/pim/ocontactaccess.h b/libopie/pim/ocontactaccess.h index e90db32..9b0a719 100644 --- a/libopie/pim/ocontactaccess.h +++ b/libopie/pim/ocontactaccess.h | |||
@@ -1,170 +1,181 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage the Contacts. | 2 | * Class to manage the Contacts. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) | 5 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) |
6 | * | 6 | * |
7 | * ===================================================================== | 7 | * ===================================================================== |
8 | *This program is free software; you can redistribute it and/or | 8 | *This program is free software; you can redistribute it and/or |
9 | *modify it under the terms of the GNU Library General Public | 9 | *modify it under the terms of the GNU Library General Public |
10 | * License as published by the Free Software Foundation; | 10 | * License as published by the Free Software Foundation; |
11 | * either version 2 of the License, or (at your option) any later | 11 | * either version 2 of the License, or (at your option) any later |
12 | * version. | 12 | * version. |
13 | * ===================================================================== | 13 | * ===================================================================== |
14 | * ToDo: Define enum for query settings | 14 | * ToDo: Define enum for query settings |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * Version: $Id$ | 16 | * Version: $Id$ |
17 | * ===================================================================== | 17 | * ===================================================================== |
18 | * History: | 18 | * History: |
19 | * $Log$ | 19 | * $Log$ |
20 | * Revision 1.9 2003/08/01 12:30:16 eilers | ||
21 | * Merging changes from BRANCH_1_0 to HEAD | ||
22 | * | ||
23 | * Revision 1.8.2.1 2003/06/30 14:34:19 eilers | ||
24 | * Patches from Zecke: | ||
25 | * Fixing and cleaning up extraMap handling | ||
26 | * Adding d_ptr for binary compatibility in the future | ||
27 | * | ||
20 | * Revision 1.8 2003/05/08 13:55:09 tille | 28 | * Revision 1.8 2003/05/08 13:55:09 tille |
21 | * search stuff | 29 | * search stuff |
22 | * and match, toRichText & toShortText in oevent | 30 | * and match, toRichText & toShortText in oevent |
23 | * | 31 | * |
24 | * Revision 1.7 2003/04/13 18:07:10 zecke | 32 | * Revision 1.7 2003/04/13 18:07:10 zecke |
25 | * More API doc | 33 | * More API doc |
26 | * QString -> const QString& | 34 | * QString -> const QString& |
27 | * QString = 0l -> QString::null | 35 | * QString = 0l -> QString::null |
28 | * | 36 | * |
29 | * Revision 1.6 2003/01/02 14:27:12 eilers | 37 | * Revision 1.6 2003/01/02 14:27:12 eilers |
30 | * Improved query by example: Search by date is possible.. First step | 38 | * Improved query by example: Search by date is possible.. First step |
31 | * for a today plugin for birthdays.. | 39 | * for a today plugin for birthdays.. |
32 | * | 40 | * |
33 | * Revision 1.5 2002/11/13 14:14:51 eilers | 41 | * Revision 1.5 2002/11/13 14:14:51 eilers |
34 | * Added sorted for Contacts.. | 42 | * Added sorted for Contacts.. |
35 | * | 43 | * |
36 | * Revision 1.4 2002/11/01 15:10:42 eilers | 44 | * Revision 1.4 2002/11/01 15:10:42 eilers |
37 | * Added regExp-search in database for all fields in a contact. | 45 | * Added regExp-search in database for all fields in a contact. |
38 | * | 46 | * |
39 | * Revision 1.3 2002/10/16 10:52:40 eilers | 47 | * Revision 1.3 2002/10/16 10:52:40 eilers |
40 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | 48 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) |
41 | * | 49 | * |
42 | * Revision 1.2 2002/10/14 16:21:54 eilers | 50 | * Revision 1.2 2002/10/14 16:21:54 eilers |
43 | * Some minor interface updates | 51 | * Some minor interface updates |
44 | * | 52 | * |
45 | * Revision 1.1 2002/09/27 17:11:44 eilers | 53 | * Revision 1.1 2002/09/27 17:11:44 eilers |
46 | * Added API for accessing the Contact-Database ! It is compiling, but | 54 | * Added API for accessing the Contact-Database ! It is compiling, but |
47 | * please do not expect that anything is working ! | 55 | * please do not expect that anything is working ! |
48 | * I will debug that stuff in the next time .. | 56 | * I will debug that stuff in the next time .. |
49 | * Please read README_COMPILE for compiling ! | 57 | * Please read README_COMPILE for compiling ! |
50 | * | 58 | * |
51 | * ===================================================================== | 59 | * ===================================================================== |
52 | */ | 60 | */ |
53 | #ifndef _OCONTACTACCESS_H | 61 | #ifndef _OCONTACTACCESS_H |
54 | #define _OCONTACTACCESS_H | 62 | #define _OCONTACTACCESS_H |
55 | 63 | ||
56 | #include <qobject.h> | 64 | #include <qobject.h> |
57 | 65 | ||
58 | #include <qpe/qcopenvelope_qws.h> | 66 | #include <qpe/qcopenvelope_qws.h> |
59 | 67 | ||
60 | #include <qvaluelist.h> | 68 | #include <qvaluelist.h> |
61 | #include <qfileinfo.h> | 69 | #include <qfileinfo.h> |
62 | 70 | ||
63 | #include "ocontact.h" | 71 | #include "ocontact.h" |
64 | #include "ocontactaccessbackend.h" | 72 | #include "ocontactaccessbackend.h" |
65 | #include "opimaccesstemplate.h" | 73 | #include "opimaccesstemplate.h" |
66 | 74 | ||
67 | /** | 75 | /** |
68 | * Class to access the contacts database. | 76 | * Class to access the contacts database. |
69 | * This is just a frontend for the real database handling which is | 77 | * This is just a frontend for the real database handling which is |
70 | * done by the backend. | 78 | * done by the backend. |
71 | * This class is used to access the Contacts on a system. This class as any OPIE PIM | 79 | * This class is used to access the Contacts on a system. This class as any OPIE PIM |
72 | * class is backend independent. | 80 | * class is backend independent. |
73 | 81 | ||
74 | * @see OPimAccessTemplate | 82 | * @see OPimAccessTemplate |
75 | */ | 83 | */ |
76 | class OContactAccess: public QObject, public OPimAccessTemplate<OContact> | 84 | class OContactAccess: public QObject, public OPimAccessTemplate<OContact> |
77 | { | 85 | { |
78 | Q_OBJECT | 86 | Q_OBJECT |
79 | 87 | ||
80 | public: | 88 | public: |
81 | /** | 89 | /** |
82 | * Create Database with contacts (addressbook). | 90 | * Create Database with contacts (addressbook). |
83 | * @param appname Name of application which wants access to the database | 91 | * @param appname Name of application which wants access to the database |
84 | * (i.e. "todolist") | 92 | * (i.e. "todolist") |
85 | * @param filename The name of the database file. If not set, the default one | 93 | * @param filename The name of the database file. If not set, the default one |
86 | * is used. | 94 | * is used. |
87 | * @param backend Pointer to an alternative Backend. If not set, we will use | 95 | * @param backend Pointer to an alternative Backend. If not set, we will use |
88 | * the default backend. | 96 | * the default backend. |
89 | * @param handlesync If <b>true</b> the database stores the current state | 97 | * @param handlesync If <b>true</b> the database stores the current state |
90 | * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> | 98 | * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> |
91 | * which are used before and after synchronisation. If the application wants | 99 | * which are used before and after synchronisation. If the application wants |
92 | * to react itself, it should be disabled by setting it to <b>false</b> | 100 | * to react itself, it should be disabled by setting it to <b>false</b> |
93 | * @see OContactAccessBackend | 101 | * @see OContactAccessBackend |
94 | */ | 102 | */ |
95 | OContactAccess (const QString appname, const QString filename = 0l, | 103 | OContactAccess (const QString appname, const QString filename = 0l, |
96 | OContactAccessBackend* backend = 0l, bool handlesync = true); | 104 | OContactAccessBackend* backend = 0l, bool handlesync = true); |
97 | ~OContactAccess (); | 105 | ~OContactAccess (); |
98 | 106 | ||
99 | /** Constants for query. | 107 | /** Constants for query. |
100 | * Use this constants to set the query parameters. | 108 | * Use this constants to set the query parameters. |
101 | * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! | 109 | * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! |
102 | * @see queryByExample() | 110 | * @see queryByExample() |
103 | */ | 111 | */ |
104 | enum QuerySettings { | 112 | enum QuerySettings { |
105 | WildCards = 0x0001, | 113 | WildCards = 0x0001, |
106 | IgnoreCase = 0x0002, | 114 | IgnoreCase = 0x0002, |
107 | RegExp = 0x0004, | 115 | RegExp = 0x0004, |
108 | ExactMatch = 0x0008, | 116 | ExactMatch = 0x0008, |
109 | MatchOne = 0x0010, // Only one Entry must match | 117 | MatchOne = 0x0010, // Only one Entry must match |
110 | DateDiff = 0x0020, // Find all entries from today until given date | 118 | DateDiff = 0x0020, // Find all entries from today until given date |
111 | DateYear = 0x0040, // The year matches | 119 | DateYear = 0x0040, // The year matches |
112 | DateMonth = 0x0080, // The month matches | 120 | DateMonth = 0x0080, // The month matches |
113 | DateDay = 0x0100, // The day matches | 121 | DateDay = 0x0100, // The day matches |
114 | }; | 122 | }; |
115 | 123 | ||
116 | 124 | ||
117 | /** Return all Contacts in a sorted manner. | 125 | /** Return all Contacts in a sorted manner. |
118 | * @param ascending true: Sorted in acending order. | 126 | * @param ascending true: Sorted in acending order. |
119 | * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess | 127 | * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess |
120 | * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess | 128 | * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess |
121 | * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess | 129 | * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess |
122 | */ | 130 | */ |
123 | List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; | 131 | List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; |
124 | 132 | ||
125 | /** Return all possible settings. | 133 | /** Return all possible settings. |
126 | * @return All settings provided by the current backend | 134 | * @return All settings provided by the current backend |
127 | * (i.e.: query_WildCards & query_IgnoreCase) | 135 | * (i.e.: query_WildCards & query_IgnoreCase) |
128 | */ | 136 | */ |
129 | const uint querySettings(); | 137 | const uint querySettings(); |
130 | 138 | ||
131 | /** Check whether settings are correct. | 139 | /** Check whether settings are correct. |
132 | * @return <i>true</i> if the given settings are correct and possible. | 140 | * @return <i>true</i> if the given settings are correct and possible. |
133 | */ | 141 | */ |
134 | bool hasQuerySettings ( int querySettings ) const; | 142 | bool hasQuerySettings ( int querySettings ) const; |
135 | 143 | ||
136 | /** | 144 | /** |
137 | * if the resource was changed externally. | 145 | * if the resource was changed externally. |
138 | * You should use the signal instead of polling possible changes ! | 146 | * You should use the signal instead of polling possible changes ! |
139 | */ | 147 | */ |
140 | bool wasChangedExternally()const; | 148 | bool wasChangedExternally()const; |
141 | 149 | ||
142 | 150 | ||
143 | /** Save contacts database. | 151 | /** Save contacts database. |
144 | * Save is more a "commit". After calling this function, all changes are public available. | 152 | * Save is more a "commit". After calling this function, all changes are public available. |
145 | * @return true if successful | 153 | * @return true if successful |
146 | */ | 154 | */ |
147 | bool save(); | 155 | bool save(); |
148 | 156 | ||
149 | signals: | 157 | signals: |
150 | /* Signal is emitted if the database was changed. Therefore | 158 | /* Signal is emitted if the database was changed. Therefore |
151 | * we may need to reload to stay consistent. | 159 | * we may need to reload to stay consistent. |
152 | * @param which Pointer to the database who created this event. This pointer | 160 | * @param which Pointer to the database who created this event. This pointer |
153 | * is useful if an application has to handle multiple databases at the same time. | 161 | * is useful if an application has to handle multiple databases at the same time. |
154 | * @see reload() | 162 | * @see reload() |
155 | */ | 163 | */ |
156 | void signalChanged ( const OContactAccess *which ); | 164 | void signalChanged ( const OContactAccess *which ); |
157 | 165 | ||
158 | 166 | ||
159 | private: | 167 | private: |
160 | // class OContactAccessPrivate; | 168 | // class OContactAccessPrivate; |
161 | // OContactAccessPrivate* d; | 169 | // OContactAccessPrivate* d; |
162 | OContactAccessBackend *m_backEnd; | 170 | OContactAccessBackend *m_backEnd; |
163 | bool m_loading:1; | 171 | bool m_loading:1; |
164 | 172 | ||
165 | private slots: | 173 | private slots: |
166 | void copMessage( const QCString &msg, const QByteArray &data ); | 174 | void copMessage( const QCString &msg, const QByteArray &data ); |
167 | 175 | ||
176 | private: | ||
177 | class Private; | ||
178 | Private *d; | ||
168 | 179 | ||
169 | }; | 180 | }; |
170 | #endif | 181 | #endif |
diff --git a/libopie/pim/ocontactaccessbackend.h b/libopie/pim/ocontactaccessbackend.h index ebeb42d..280e05c 100644 --- a/libopie/pim/ocontactaccessbackend.h +++ b/libopie/pim/ocontactaccessbackend.h | |||
@@ -1,107 +1,119 @@ | |||
1 | /** | 1 | /** |
2 | * The class responsible for managing a backend. | 2 | * The class responsible for managing a backend. |
3 | * The implementation of this abstract class contains | 3 | * The implementation of this abstract class contains |
4 | * the complete database handling. | 4 | * the complete database handling. |
5 | * | 5 | * |
6 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 6 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
7 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) | 7 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) |
8 | * | 8 | * |
9 | * ===================================================================== | 9 | * ===================================================================== |
10 | *This program is free software; you can redistribute it and/or | 10 | *This program is free software; you can redistribute it and/or |
11 | *modify it under the terms of the GNU Library General Public | 11 | *modify it under the terms of the GNU Library General Public |
12 | * License as published by the Free Software Foundation; | 12 | * License as published by the Free Software Foundation; |
13 | * either version 2 of the License, or (at your option) any later | 13 | * either version 2 of the License, or (at your option) any later |
14 | * version. | 14 | * version. |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * ToDo: Define enum for query settings | 16 | * ToDo: Define enum for query settings |
17 | * ===================================================================== | 17 | * ===================================================================== |
18 | * Version: $Id$ | 18 | * Version: $Id$ |
19 | * ===================================================================== | 19 | * ===================================================================== |
20 | * History: | 20 | * History: |
21 | * $Log$ | 21 | * $Log$ |
22 | * Revision 1.6 2003/08/01 12:30:16 eilers | ||
23 | * Merging changes from BRANCH_1_0 to HEAD | ||
24 | * | ||
25 | * Revision 1.5.4.1 2003/06/30 14:34:19 eilers | ||
26 | * Patches from Zecke: | ||
27 | * Fixing and cleaning up extraMap handling | ||
28 | * Adding d_ptr for binary compatibility in the future | ||
29 | * | ||
22 | * Revision 1.5 2003/04/13 18:07:10 zecke | 30 | * Revision 1.5 2003/04/13 18:07:10 zecke |
23 | * More API doc | 31 | * More API doc |
24 | * QString -> const QString& | 32 | * QString -> const QString& |
25 | * QString = 0l -> QString::null | 33 | * QString = 0l -> QString::null |
26 | * | 34 | * |
27 | * Revision 1.4 2002/11/13 14:14:51 eilers | 35 | * Revision 1.4 2002/11/13 14:14:51 eilers |
28 | * Added sorted for Contacts.. | 36 | * Added sorted for Contacts.. |
29 | * | 37 | * |
30 | * Revision 1.3 2002/11/01 15:10:42 eilers | 38 | * Revision 1.3 2002/11/01 15:10:42 eilers |
31 | * Added regExp-search in database for all fields in a contact. | 39 | * Added regExp-search in database for all fields in a contact. |
32 | * | 40 | * |
33 | * Revision 1.2 2002/10/07 17:34:24 eilers | 41 | * Revision 1.2 2002/10/07 17:34:24 eilers |
34 | * added OBackendFactory for advanced backend access | 42 | * added OBackendFactory for advanced backend access |
35 | * | 43 | * |
36 | * Revision 1.1 2002/09/27 17:11:44 eilers | 44 | * Revision 1.1 2002/09/27 17:11:44 eilers |
37 | * Added API for accessing the Contact-Database ! It is compiling, but | 45 | * Added API for accessing the Contact-Database ! It is compiling, but |
38 | * please do not expect that anything is working ! | 46 | * please do not expect that anything is working ! |
39 | * I will debug that stuff in the next time .. | 47 | * I will debug that stuff in the next time .. |
40 | * Please read README_COMPILE for compiling ! | 48 | * Please read README_COMPILE for compiling ! |
41 | * | 49 | * |
42 | * ===================================================================== | 50 | * ===================================================================== |
43 | * | 51 | * |
44 | */ | 52 | */ |
45 | 53 | ||
46 | #ifndef _OCONTACTACCESSBACKEND_H_ | 54 | #ifndef _OCONTACTACCESSBACKEND_H_ |
47 | #define _OCONTACTACCESSBACKEND_H_ | 55 | #define _OCONTACTACCESSBACKEND_H_ |
48 | 56 | ||
49 | #include "ocontact.h" | 57 | #include "ocontact.h" |
50 | #include "opimaccessbackend.h" | 58 | #include "opimaccessbackend.h" |
51 | 59 | ||
52 | #include <qregexp.h> | 60 | #include <qregexp.h> |
53 | 61 | ||
54 | /** | 62 | /** |
55 | * This class represents the interface of all Contact Backends. | 63 | * This class represents the interface of all Contact Backends. |
56 | * Derivates of this class will be used to access the contacts. | 64 | * Derivates of this class will be used to access the contacts. |
57 | * As implementation currently XML and vCard exist. This class needs to be implemented | 65 | * As implementation currently XML and vCard exist. This class needs to be implemented |
58 | * if you want to provide your own storage. | 66 | * if you want to provide your own storage. |
59 | * In all queries a list of uids is passed on instead of loading the actual record! | 67 | * In all queries a list of uids is passed on instead of loading the actual record! |
60 | * | 68 | * |
61 | * @see OContactAccessBackend_VCard | 69 | * @see OContactAccessBackend_VCard |
62 | * @see OContactAccessBackend_XML | 70 | * @see OContactAccessBackend_XML |
63 | */ | 71 | */ |
64 | class OContactAccessBackend: public OPimAccessBackend<OContact> { | 72 | class OContactAccessBackend: public OPimAccessBackend<OContact> { |
65 | public: | 73 | public: |
66 | OContactAccessBackend() {} | 74 | OContactAccessBackend() {} |
67 | virtual ~OContactAccessBackend() {} | 75 | virtual ~OContactAccessBackend() {} |
68 | 76 | ||
69 | 77 | ||
70 | /** | 78 | /** |
71 | * Return if database was changed externally. | 79 | * Return if database was changed externally. |
72 | * This may just make sense on file based databases like a XML-File. | 80 | * This may just make sense on file based databases like a XML-File. |
73 | * It is used to prevent to overwrite the current database content | 81 | * It is used to prevent to overwrite the current database content |
74 | * if the file was already changed by something else ! | 82 | * if the file was already changed by something else ! |
75 | * If this happens, we have to reload before save our data. | 83 | * If this happens, we have to reload before save our data. |
76 | * If we use real databases, this should be handled by the database | 84 | * If we use real databases, this should be handled by the database |
77 | * management system themselve, therefore this function should always return false in | 85 | * management system themselve, therefore this function should always return false in |
78 | * this case. It is not our problem to handle this conflict ... | 86 | * this case. It is not our problem to handle this conflict ... |
79 | * @return <i>true</i> if the database was changed and if save without reload will | 87 | * @return <i>true</i> if the database was changed and if save without reload will |
80 | * be dangerous. <i>false</i> if the database was not changed or it is save to write | 88 | * be dangerous. <i>false</i> if the database was not changed or it is save to write |
81 | * in this situation. | 89 | * in this situation. |
82 | */ | 90 | */ |
83 | virtual bool wasChangedExternally() = 0; | 91 | virtual bool wasChangedExternally() = 0; |
84 | 92 | ||
85 | virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0; | 93 | virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0; |
86 | 94 | ||
87 | /** | 95 | /** |
88 | * Return all possible settings. | 96 | * Return all possible settings. |
89 | * @return All settings provided by the current backend | 97 | * @return All settings provided by the current backend |
90 | * (i.e.: query_WildCards & query_IgnoreCase) | 98 | * (i.e.: query_WildCards & query_IgnoreCase) |
91 | */ | 99 | */ |
92 | virtual const uint querySettings() = 0; | 100 | virtual const uint querySettings() = 0; |
93 | 101 | ||
94 | /** | 102 | /** |
95 | * Check whether settings are correct. | 103 | * Check whether settings are correct. |
96 | * @return <i>true</i> if the given settings are correct and possible. | 104 | * @return <i>true</i> if the given settings are correct and possible. |
97 | */ | 105 | */ |
98 | virtual bool hasQuerySettings (uint querySettings) const = 0; | 106 | virtual bool hasQuerySettings (uint querySettings) const = 0; |
99 | 107 | ||
100 | /** | 108 | /** |
101 | * FIXME!!! | 109 | * FIXME!!! |
102 | * Returns a sorted list of records either ascendinf or descending for a giving criteria and category | 110 | * Returns a sorted list of records either ascendinf or descending for a giving criteria and category |
103 | */ | 111 | */ |
104 | virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0; | 112 | virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0; |
105 | 113 | ||
114 | |||
115 | private: | ||
116 | class Private; | ||
117 | Private *d; | ||
106 | }; | 118 | }; |
107 | #endif | 119 | #endif |
diff --git a/libopie/pim/ocontactaccessbackend_vcard.cpp b/libopie/pim/ocontactaccessbackend_vcard.cpp index 270bef3..b60c5be 100644 --- a/libopie/pim/ocontactaccessbackend_vcard.cpp +++ b/libopie/pim/ocontactaccessbackend_vcard.cpp | |||
@@ -1,249 +1,265 @@ | |||
1 | /* | 1 | /* |
2 | * VCard Backend for the OPIE-Contact Database. | 2 | * VCard Backend for the OPIE-Contact Database. |
3 | * | 3 | * |
4 | * Copyright (C) 2000 Trolltech AS. All rights reserved. | 4 | * Copyright (C) 2000 Trolltech AS. All rights reserved. |
5 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 5 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
6 | * | 6 | * |
7 | * ===================================================================== | 7 | * ===================================================================== |
8 | *This program is free software; you can redistribute it and/or | 8 | *This program is free software; you can redistribute it and/or |
9 | *modify it under the terms of the GNU Library General Public | 9 | *modify it under the terms of the GNU Library General Public |
10 | * License as published by the Free Software Foundation; either | 10 | * License as published by the Free Software Foundation; either |
11 | * version 2 of the License, or (at your option) any later version. | 11 | * version 2 of the License, or (at your option) any later version. |
12 | * ===================================================================== | 12 | * ===================================================================== |
13 | * ToDo: | 13 | * ToDo: |
14 | * | 14 | * |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * Version: $Id$ | 16 | * Version: $Id$ |
17 | * ===================================================================== | 17 | * ===================================================================== |
18 | * History: | 18 | * History: |
19 | * $Log$ | 19 | * $Log$ |
20 | * Revision 1.11 2003/08/01 12:30:16 eilers | ||
21 | * Merging changes from BRANCH_1_0 to HEAD | ||
22 | * | ||
23 | * Revision 1.10.4.3 2003/07/23 08:54:37 eilers | ||
24 | * Default email was added to the list of all emails, which already contains | ||
25 | * the default email.. | ||
26 | * This closes bug #1045 | ||
27 | * | ||
28 | * Revision 1.10.4.2 2003/07/23 08:44:45 eilers | ||
29 | * Importing of Notes in vcard files wasn't implemented. | ||
30 | * Closes bug #1044 | ||
31 | * | ||
32 | * Revision 1.10.4.1 2003/06/02 13:37:49 eilers | ||
33 | * Fixing memory leak | ||
34 | * | ||
20 | * Revision 1.10 2003/04/13 18:07:10 zecke | 35 | * Revision 1.10 2003/04/13 18:07:10 zecke |
21 | * More API doc | 36 | * More API doc |
22 | * QString -> const QString& | 37 | * QString -> const QString& |
23 | * QString = 0l -> QString::null | 38 | * QString = 0l -> QString::null |
24 | * | 39 | * |
25 | * Revision 1.9 2003/03/21 10:33:09 eilers | 40 | * Revision 1.9 2003/03/21 10:33:09 eilers |
26 | * Merged speed optimized xml backend for contacts to main. | 41 | * Merged speed optimized xml backend for contacts to main. |
27 | * Added QDateTime to querybyexample. For instance, it is now possible to get | 42 | * Added QDateTime to querybyexample. For instance, it is now possible to get |
28 | * all Birthdays/Anniversaries between two dates. This should be used | 43 | * all Birthdays/Anniversaries between two dates. This should be used |
29 | * to show all birthdays in the datebook.. | 44 | * to show all birthdays in the datebook.. |
30 | * This change is sourcecode backward compatible but you have to upgrade | 45 | * This change is sourcecode backward compatible but you have to upgrade |
31 | * the binaries for today-addressbook. | 46 | * the binaries for today-addressbook. |
32 | * | 47 | * |
33 | * Revision 1.8 2003/02/21 16:52:49 zecke | 48 | * Revision 1.8 2003/02/21 16:52:49 zecke |
34 | * -Remove old Todo classes they're deprecated and today I already using the | 49 | * -Remove old Todo classes they're deprecated and today I already using the |
35 | * new API | 50 | * new API |
36 | * -Guard against self assignment in OTodo | 51 | * -Guard against self assignment in OTodo |
37 | * -Add test apps for OPIM | 52 | * -Add test apps for OPIM |
38 | * -Opiefied Event classes | 53 | * -Opiefied Event classes |
39 | * -Added TimeZone handling and pinning of TimeZones to OEvent | 54 | * -Added TimeZone handling and pinning of TimeZones to OEvent |
40 | * -Adjust ORecur and the widget to better timezone behaviour | 55 | * -Adjust ORecur and the widget to better timezone behaviour |
41 | * | 56 | * |
42 | * Revision 1.7 2003/02/16 22:25:46 zecke | 57 | * Revision 1.7 2003/02/16 22:25:46 zecke |
43 | * 0000276 Fix for that bug.. or better temp workaround | 58 | * 0000276 Fix for that bug.. or better temp workaround |
44 | * A Preferred Number is HOME|VOICE | 59 | * A Preferred Number is HOME|VOICE |
45 | * A CellPhone is HOME|VOICE|CELL the type & HOME|VOICE test | 60 | * A CellPhone is HOME|VOICE|CELL the type & HOME|VOICE test |
46 | * triggers both | 61 | * triggers both |
47 | * and the cell phone number overrides the other entries.. | 62 | * and the cell phone number overrides the other entries.. |
48 | * | 63 | * |
49 | * as a temp I check that it's not equal to HOME|VOICE|CELL before setting the | 64 | * as a temp I check that it's not equal to HOME|VOICE|CELL before setting the |
50 | * number | 65 | * number |
51 | * | 66 | * |
52 | * The right and final fix would be to reorder the if statement to make it | 67 | * The right and final fix would be to reorder the if statement to make it |
53 | * if else based and the less common thing put to the bottom | 68 | * if else based and the less common thing put to the bottom |
54 | * | 69 | * |
55 | * OTodoAccessVcal fix the date for beaming | 70 | * OTodoAccessVcal fix the date for beaming |
56 | * | 71 | * |
57 | * Revision 1.6 2003/01/13 15:49:31 eilers | 72 | * Revision 1.6 2003/01/13 15:49:31 eilers |
58 | * Fixing crash when businesscard.vcf is missing.. | 73 | * Fixing crash when businesscard.vcf is missing.. |
59 | * | 74 | * |
60 | * Revision 1.5 2002/12/07 13:26:22 eilers | 75 | * Revision 1.5 2002/12/07 13:26:22 eilers |
61 | * Fixing bug in storing anniversary.. | 76 | * Fixing bug in storing anniversary.. |
62 | * | 77 | * |
63 | * Revision 1.4 2002/11/13 14:14:51 eilers | 78 | * Revision 1.4 2002/11/13 14:14:51 eilers |
64 | * Added sorted for Contacts.. | 79 | * Added sorted for Contacts.. |
65 | * | 80 | * |
66 | * Revision 1.3 2002/11/11 16:41:09 kergoth | 81 | * Revision 1.3 2002/11/11 16:41:09 kergoth |
67 | * no default arguments in implementation | 82 | * no default arguments in implementation |
68 | * | 83 | * |
69 | * Revision 1.2 2002/11/10 15:41:53 eilers | 84 | * Revision 1.2 2002/11/10 15:41:53 eilers |
70 | * Bugfixes.. | 85 | * Bugfixes.. |
71 | * | 86 | * |
72 | * Revision 1.1 2002/11/09 14:34:52 eilers | 87 | * Revision 1.1 2002/11/09 14:34:52 eilers |
73 | * Added VCard Backend. | 88 | * Added VCard Backend. |
74 | * | 89 | * |
75 | */ | 90 | */ |
76 | #include "ocontactaccessbackend_vcard.h" | 91 | #include "ocontactaccessbackend_vcard.h" |
77 | #include "../../library/backend/vobject_p.h" | 92 | #include "../../library/backend/vobject_p.h" |
78 | #include "../../library/backend/qfiledirect_p.h" | 93 | #include "../../library/backend/qfiledirect_p.h" |
79 | 94 | ||
80 | #include <qpe/timeconversion.h> | 95 | #include <qpe/timeconversion.h> |
81 | 96 | ||
82 | #include <qfile.h> | 97 | #include <qfile.h> |
83 | 98 | ||
84 | OContactAccessBackend_VCard::OContactAccessBackend_VCard ( const QString& , const QString& filename ): | 99 | OContactAccessBackend_VCard::OContactAccessBackend_VCard ( const QString& , const QString& filename ): |
85 | m_dirty( false ), | 100 | m_dirty( false ), |
86 | m_file( filename ) | 101 | m_file( filename ) |
87 | { | 102 | { |
88 | load(); | 103 | load(); |
89 | } | 104 | } |
90 | 105 | ||
91 | 106 | ||
92 | bool OContactAccessBackend_VCard::load () | 107 | bool OContactAccessBackend_VCard::load () |
93 | { | 108 | { |
94 | m_map.clear(); | 109 | m_map.clear(); |
95 | m_dirty = false; | 110 | m_dirty = false; |
96 | 111 | ||
97 | VObject* obj = 0l; | 112 | VObject* obj = 0l; |
98 | 113 | ||
99 | if ( QFile::exists(m_file) ){ | 114 | if ( QFile::exists(m_file) ){ |
100 | obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); | 115 | obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); |
101 | if ( !obj ) | 116 | if ( !obj ) |
102 | return false; | 117 | return false; |
103 | }else{ | 118 | }else{ |
104 | qWarning("File \"%s\" not found !", m_file.latin1() ); | 119 | qWarning("File \"%s\" not found !", m_file.latin1() ); |
105 | return false; | 120 | return false; |
106 | } | 121 | } |
107 | 122 | ||
108 | while ( obj ) { | 123 | while ( obj ) { |
109 | OContact con = parseVObject( obj ); | 124 | OContact con = parseVObject( obj ); |
110 | /* | 125 | /* |
111 | * if uid is 0 assign a new one | 126 | * if uid is 0 assign a new one |
112 | * this at least happens on | 127 | * this at least happens on |
113 | * Nokia6210 | 128 | * Nokia6210 |
114 | */ | 129 | */ |
115 | if ( con.uid() == 0 ){ | 130 | if ( con.uid() == 0 ){ |
116 | con.setUid( 1 ); | 131 | con.setUid( 1 ); |
117 | qWarning("assigned new uid %d",con.uid() ); | 132 | qWarning("assigned new uid %d",con.uid() ); |
118 | } | 133 | } |
119 | 134 | ||
120 | m_map.insert( con.uid(), con ); | 135 | m_map.insert( con.uid(), con ); |
121 | 136 | ||
122 | VObject *t = obj; | 137 | VObject *t = obj; |
123 | obj = nextVObjectInList(obj); | 138 | obj = nextVObjectInList(obj); |
124 | cleanVObject( t ); | 139 | cleanVObject( t ); |
125 | } | 140 | } |
126 | 141 | ||
127 | return true; | 142 | return true; |
128 | 143 | ||
129 | } | 144 | } |
130 | bool OContactAccessBackend_VCard::reload() | 145 | bool OContactAccessBackend_VCard::reload() |
131 | { | 146 | { |
132 | return load(); | 147 | return load(); |
133 | } | 148 | } |
134 | bool OContactAccessBackend_VCard::save() | 149 | bool OContactAccessBackend_VCard::save() |
135 | { | 150 | { |
136 | if (!m_dirty ) | 151 | if (!m_dirty ) |
137 | return true; | 152 | return true; |
138 | 153 | ||
139 | QFileDirect file( m_file ); | 154 | QFileDirect file( m_file ); |
140 | if (!file.open(IO_WriteOnly ) ) | 155 | if (!file.open(IO_WriteOnly ) ) |
141 | return false; | 156 | return false; |
142 | 157 | ||
143 | VObject *obj; | 158 | VObject *obj; |
144 | obj = newVObject( VCCalProp ); | 159 | obj = newVObject( VCCalProp ); |
145 | addPropValue( obj, VCVersionProp, "1.0" ); | 160 | addPropValue( obj, VCVersionProp, "1.0" ); |
146 | 161 | ||
147 | VObject *vo; | 162 | VObject *vo; |
148 | for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ | 163 | for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ |
149 | vo = createVObject( *it ); | 164 | vo = createVObject( *it ); |
150 | writeVObject( file.directHandle() , vo ); | 165 | writeVObject( file.directHandle() , vo ); |
151 | cleanVObject( vo ); | 166 | cleanVObject( vo ); |
152 | } | 167 | } |
153 | cleanStrTbl(); | 168 | cleanStrTbl(); |
169 | deleteVObject( obj ); | ||
154 | 170 | ||
155 | m_dirty = false; | 171 | m_dirty = false; |
156 | return true; | 172 | return true; |
157 | 173 | ||
158 | 174 | ||
159 | } | 175 | } |
160 | void OContactAccessBackend_VCard::clear () | 176 | void OContactAccessBackend_VCard::clear () |
161 | { | 177 | { |
162 | m_map.clear(); | 178 | m_map.clear(); |
163 | m_dirty = true; // ??? sure ? (se) | 179 | m_dirty = true; // ??? sure ? (se) |
164 | } | 180 | } |
165 | 181 | ||
166 | bool OContactAccessBackend_VCard::add ( const OContact& newcontact ) | 182 | bool OContactAccessBackend_VCard::add ( const OContact& newcontact ) |
167 | { | 183 | { |
168 | m_map.insert( newcontact.uid(), newcontact ); | 184 | m_map.insert( newcontact.uid(), newcontact ); |
169 | m_dirty = true; | 185 | m_dirty = true; |
170 | return true; | 186 | return true; |
171 | } | 187 | } |
172 | 188 | ||
173 | bool OContactAccessBackend_VCard::remove ( int uid ) | 189 | bool OContactAccessBackend_VCard::remove ( int uid ) |
174 | { | 190 | { |
175 | m_map.remove( uid ); | 191 | m_map.remove( uid ); |
176 | m_dirty = true; | 192 | m_dirty = true; |
177 | return true; | 193 | return true; |
178 | } | 194 | } |
179 | 195 | ||
180 | bool OContactAccessBackend_VCard::replace ( const OContact &contact ) | 196 | bool OContactAccessBackend_VCard::replace ( const OContact &contact ) |
181 | { | 197 | { |
182 | m_map.replace( contact.uid(), contact ); | 198 | m_map.replace( contact.uid(), contact ); |
183 | m_dirty = true; | 199 | m_dirty = true; |
184 | return true; | 200 | return true; |
185 | } | 201 | } |
186 | 202 | ||
187 | OContact OContactAccessBackend_VCard::find ( int uid ) const | 203 | OContact OContactAccessBackend_VCard::find ( int uid ) const |
188 | { | 204 | { |
189 | return m_map[uid]; | 205 | return m_map[uid]; |
190 | } | 206 | } |
191 | 207 | ||
192 | QArray<int> OContactAccessBackend_VCard::allRecords() const | 208 | QArray<int> OContactAccessBackend_VCard::allRecords() const |
193 | { | 209 | { |
194 | QArray<int> ar( m_map.count() ); | 210 | QArray<int> ar( m_map.count() ); |
195 | QMap<int, OContact>::ConstIterator it; | 211 | QMap<int, OContact>::ConstIterator it; |
196 | int i = 0; | 212 | int i = 0; |
197 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | 213 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { |
198 | ar[i] = it.key(); | 214 | ar[i] = it.key(); |
199 | i++; | 215 | i++; |
200 | } | 216 | } |
201 | return ar; | 217 | return ar; |
202 | } | 218 | } |
203 | 219 | ||
204 | // Not implemented | 220 | // Not implemented |
205 | QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int, const QDateTime& ) | 221 | QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int, const QDateTime& ) |
206 | { | 222 | { |
207 | QArray<int> ar(0); | 223 | QArray<int> ar(0); |
208 | return ar; | 224 | return ar; |
209 | } | 225 | } |
210 | 226 | ||
211 | // Not implemented | 227 | // Not implemented |
212 | QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const | 228 | QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const |
213 | { | 229 | { |
214 | QArray<int> ar(0); | 230 | QArray<int> ar(0); |
215 | return ar; | 231 | return ar; |
216 | } | 232 | } |
217 | 233 | ||
218 | const uint OContactAccessBackend_VCard::querySettings() | 234 | const uint OContactAccessBackend_VCard::querySettings() |
219 | { | 235 | { |
220 | return 0; // No search possible | 236 | return 0; // No search possible |
221 | } | 237 | } |
222 | 238 | ||
223 | bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const | 239 | bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const |
224 | { | 240 | { |
225 | return false; // No search possible, therefore all settings invalid ;) | 241 | return false; // No search possible, therefore all settings invalid ;) |
226 | } | 242 | } |
227 | 243 | ||
228 | bool OContactAccessBackend_VCard::wasChangedExternally() | 244 | bool OContactAccessBackend_VCard::wasChangedExternally() |
229 | { | 245 | { |
230 | return false; // Don't expect concurrent access | 246 | return false; // Don't expect concurrent access |
231 | } | 247 | } |
232 | 248 | ||
233 | // Not implemented | 249 | // Not implemented |
234 | QArray<int> OContactAccessBackend_VCard::sorted( bool , int, int, int ) | 250 | QArray<int> OContactAccessBackend_VCard::sorted( bool , int, int, int ) |
235 | { | 251 | { |
236 | QArray<int> ar(0); | 252 | QArray<int> ar(0); |
237 | return ar; | 253 | return ar; |
238 | } | 254 | } |
239 | 255 | ||
240 | // *** Private stuff *** | 256 | // *** Private stuff *** |
241 | 257 | ||
242 | 258 | ||
243 | OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) | 259 | OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) |
244 | { | 260 | { |
245 | OContact c; | 261 | OContact c; |
246 | 262 | ||
247 | VObjectIterator it; | 263 | VObjectIterator it; |
248 | initPropIterator( &it, obj ); | 264 | initPropIterator( &it, obj ); |
249 | while( moreIteration( &it ) ) { | 265 | while( moreIteration( &it ) ) { |
@@ -353,276 +369,278 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) | |||
353 | type |= VOICE; | 369 | type |= VOICE; |
354 | 370 | ||
355 | qWarning("value %s %d", value.data(), type ); | 371 | qWarning("value %s %d", value.data(), type ); |
356 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) ) | 372 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) ) |
357 | c.setHomePhone( value ); | 373 | c.setHomePhone( value ); |
358 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) | 374 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) |
359 | c.setHomeFax( value ); | 375 | c.setHomeFax( value ); |
360 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) | 376 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) |
361 | c.setHomeMobile( value ); | 377 | c.setHomeMobile( value ); |
362 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) ) | 378 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) ) |
363 | c.setBusinessPhone( value ); | 379 | c.setBusinessPhone( value ); |
364 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) | 380 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) |
365 | c.setBusinessFax( value ); | 381 | c.setBusinessFax( value ); |
366 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) | 382 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) |
367 | c.setBusinessMobile( value ); | 383 | c.setBusinessMobile( value ); |
368 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) | 384 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) |
369 | c.setBusinessPager( value ); | 385 | c.setBusinessPager( value ); |
370 | } | 386 | } |
371 | } | 387 | } |
372 | else if ( name == VCEmailAddressProp ) { | 388 | else if ( name == VCEmailAddressProp ) { |
373 | QString email = vObjectStringZValue( o ); | 389 | QString email = vObjectStringZValue( o ); |
374 | bool valid = TRUE; | 390 | bool valid = TRUE; |
375 | VObjectIterator nit; | 391 | VObjectIterator nit; |
376 | initPropIterator( &nit, o ); | 392 | initPropIterator( &nit, o ); |
377 | while( moreIteration( &nit ) ) { | 393 | while( moreIteration( &nit ) ) { |
378 | VObject *o = nextVObject( &nit ); | 394 | VObject *o = nextVObject( &nit ); |
379 | QCString name = vObjectTypeInfo( o ); | 395 | QCString name = vObjectTypeInfo( o ); |
380 | if ( name != VCInternetProp && name != VCHomeProp && | 396 | if ( name != VCInternetProp && name != VCHomeProp && |
381 | name != VCWorkProp && | 397 | name != VCWorkProp && |
382 | name != VCPreferredProp ) | 398 | name != VCPreferredProp ) |
383 | // ### preffered should map to default email | 399 | // ### preffered should map to default email |
384 | valid = FALSE; | 400 | valid = FALSE; |
385 | } | 401 | } |
386 | if ( valid ) { | 402 | if ( valid ) { |
387 | c.insertEmail( email ); | 403 | c.insertEmail( email ); |
388 | } | 404 | } |
389 | } | 405 | } |
390 | else if ( name == VCURLProp ) { | 406 | else if ( name == VCURLProp ) { |
391 | VObjectIterator nit; | 407 | VObjectIterator nit; |
392 | initPropIterator( &nit, o ); | 408 | initPropIterator( &nit, o ); |
393 | while( moreIteration( &nit ) ) { | 409 | while( moreIteration( &nit ) ) { |
394 | VObject *o = nextVObject( &nit ); | 410 | VObject *o = nextVObject( &nit ); |
395 | QCString name = vObjectTypeInfo( o ); | 411 | QCString name = vObjectTypeInfo( o ); |
396 | if ( name == VCHomeProp ) | 412 | if ( name == VCHomeProp ) |
397 | c.setHomeWebpage( value ); | 413 | c.setHomeWebpage( value ); |
398 | else if ( name == VCWorkProp ) | 414 | else if ( name == VCWorkProp ) |
399 | c.setBusinessWebpage( value ); | 415 | c.setBusinessWebpage( value ); |
400 | } | 416 | } |
401 | } | 417 | } |
402 | else if ( name == VCOrgProp ) { | 418 | else if ( name == VCOrgProp ) { |
403 | VObjectIterator nit; | 419 | VObjectIterator nit; |
404 | initPropIterator( &nit, o ); | 420 | initPropIterator( &nit, o ); |
405 | while( moreIteration( &nit ) ) { | 421 | while( moreIteration( &nit ) ) { |
406 | VObject *o = nextVObject( &nit ); | 422 | VObject *o = nextVObject( &nit ); |
407 | QCString name = vObjectName( o ); | 423 | QCString name = vObjectName( o ); |
408 | QString value = vObjectStringZValue( o ); | 424 | QString value = vObjectStringZValue( o ); |
409 | if ( name == VCOrgNameProp ) | 425 | if ( name == VCOrgNameProp ) |
410 | c.setCompany( value ); | 426 | c.setCompany( value ); |
411 | else if ( name == VCOrgUnitProp ) | 427 | else if ( name == VCOrgUnitProp ) |
412 | c.setDepartment( value ); | 428 | c.setDepartment( value ); |
413 | else if ( name == VCOrgUnit2Prop ) | 429 | else if ( name == VCOrgUnit2Prop ) |
414 | c.setOffice( value ); | 430 | c.setOffice( value ); |
415 | } | 431 | } |
416 | } | 432 | } |
417 | else if ( name == VCTitleProp ) { | 433 | else if ( name == VCTitleProp ) { |
418 | c.setJobTitle( value ); | 434 | c.setJobTitle( value ); |
419 | } | 435 | } |
420 | else if ( name == "X-Qtopia-Profession" ) { | 436 | else if ( name == "X-Qtopia-Profession" ) { |
421 | c.setProfession( value ); | 437 | c.setProfession( value ); |
422 | } | 438 | } |
423 | else if ( name == "X-Qtopia-Manager" ) { | 439 | else if ( name == "X-Qtopia-Manager" ) { |
424 | c.setManager( value ); | 440 | c.setManager( value ); |
425 | } | 441 | } |
426 | else if ( name == "X-Qtopia-Assistant" ) { | 442 | else if ( name == "X-Qtopia-Assistant" ) { |
427 | c.setAssistant( value ); | 443 | c.setAssistant( value ); |
428 | } | 444 | } |
429 | else if ( name == "X-Qtopia-Spouse" ) { | 445 | else if ( name == "X-Qtopia-Spouse" ) { |
430 | c.setSpouse( value ); | 446 | c.setSpouse( value ); |
431 | } | 447 | } |
432 | else if ( name == "X-Qtopia-Gender" ) { | 448 | else if ( name == "X-Qtopia-Gender" ) { |
433 | c.setGender( value ); | 449 | c.setGender( value ); |
434 | } | 450 | } |
435 | else if ( name == "X-Qtopia-Anniversary" ) { | 451 | else if ( name == "X-Qtopia-Anniversary" ) { |
436 | c.setAnniversary( convVCardDateToDate( value ) ); | 452 | c.setAnniversary( convVCardDateToDate( value ) ); |
437 | } | 453 | } |
438 | else if ( name == "X-Qtopia-Nickname" ) { | 454 | else if ( name == "X-Qtopia-Nickname" ) { |
439 | c.setNickname( value ); | 455 | c.setNickname( value ); |
440 | } | 456 | } |
441 | else if ( name == "X-Qtopia-Children" ) { | 457 | else if ( name == "X-Qtopia-Children" ) { |
442 | c.setChildren( value ); | 458 | c.setChildren( value ); |
443 | } | 459 | } |
444 | else if ( name == VCBirthDateProp ) { | 460 | else if ( name == VCBirthDateProp ) { |
445 | // Reading Birthdate regarding RFC 2425 (5.8.4) | 461 | // Reading Birthdate regarding RFC 2425 (5.8.4) |
446 | c.setBirthday( convVCardDateToDate( value ) ); | 462 | c.setBirthday( convVCardDateToDate( value ) ); |
447 | 463 | ||
448 | } | 464 | } |
449 | 465 | else if ( name == VCCommentProp ) { | |
466 | c.setNotes( value ); | ||
467 | } | ||
450 | #if 0 | 468 | #if 0 |
451 | else { | 469 | else { |
452 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); | 470 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); |
453 | VObjectIterator nit; | 471 | VObjectIterator nit; |
454 | initPropIterator( &nit, o ); | 472 | initPropIterator( &nit, o ); |
455 | while( moreIteration( &nit ) ) { | 473 | while( moreIteration( &nit ) ) { |
456 | VObject *o = nextVObject( &nit ); | 474 | VObject *o = nextVObject( &nit ); |
457 | QCString name = vObjectName( o ); | 475 | QCString name = vObjectName( o ); |
458 | QString value = vObjectStringZValue( o ); | 476 | QString value = vObjectStringZValue( o ); |
459 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); | 477 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); |
460 | } | 478 | } |
461 | } | 479 | } |
462 | #endif | 480 | #endif |
463 | } | 481 | } |
464 | c.setFileAs(); | 482 | c.setFileAs(); |
465 | return c; | 483 | return c; |
466 | } | 484 | } |
467 | 485 | ||
468 | 486 | ||
469 | VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) | 487 | VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) |
470 | { | 488 | { |
471 | VObject *vcard = newVObject( VCCardProp ); | 489 | VObject *vcard = newVObject( VCCardProp ); |
472 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); | 490 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); |
473 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); | 491 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); |
474 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); | 492 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); |
475 | 493 | ||
476 | // full name | 494 | // full name |
477 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); | 495 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); |
478 | 496 | ||
479 | // name properties | 497 | // name properties |
480 | VObject *name = safeAddProp( vcard, VCNameProp ); | 498 | VObject *name = safeAddProp( vcard, VCNameProp ); |
481 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); | 499 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); |
482 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); | 500 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); |
483 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); | 501 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); |
484 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); | 502 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); |
485 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); | 503 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); |
486 | 504 | ||
487 | // home properties | 505 | // home properties |
488 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); | 506 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); |
489 | safeAddProp( home_adr, VCHomeProp ); | 507 | safeAddProp( home_adr, VCHomeProp ); |
490 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); | 508 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); |
491 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); | 509 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); |
492 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); | 510 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); |
493 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); | 511 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); |
494 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); | 512 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); |
495 | 513 | ||
496 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); | 514 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); |
497 | safeAddProp( home_phone, VCHomeProp ); | 515 | safeAddProp( home_phone, VCHomeProp ); |
498 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); | 516 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); |
499 | safeAddProp( home_phone, VCHomeProp ); | 517 | safeAddProp( home_phone, VCHomeProp ); |
500 | safeAddProp( home_phone, VCCellularProp ); | 518 | safeAddProp( home_phone, VCCellularProp ); |
501 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); | 519 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); |
502 | safeAddProp( home_phone, VCHomeProp ); | 520 | safeAddProp( home_phone, VCHomeProp ); |
503 | safeAddProp( home_phone, VCFaxProp ); | 521 | safeAddProp( home_phone, VCFaxProp ); |
504 | 522 | ||
505 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); | 523 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); |
506 | safeAddProp( url, VCHomeProp ); | 524 | safeAddProp( url, VCHomeProp ); |
507 | 525 | ||
508 | // work properties | 526 | // work properties |
509 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); | 527 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); |
510 | safeAddProp( work_adr, VCWorkProp ); | 528 | safeAddProp( work_adr, VCWorkProp ); |
511 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); | 529 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); |
512 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); | 530 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); |
513 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); | 531 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); |
514 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); | 532 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); |
515 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); | 533 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); |
516 | 534 | ||
517 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); | 535 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); |
518 | safeAddProp( work_phone, VCWorkProp ); | 536 | safeAddProp( work_phone, VCWorkProp ); |
519 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); | 537 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); |
520 | safeAddProp( work_phone, VCWorkProp ); | 538 | safeAddProp( work_phone, VCWorkProp ); |
521 | safeAddProp( work_phone, VCCellularProp ); | 539 | safeAddProp( work_phone, VCCellularProp ); |
522 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); | 540 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); |
523 | safeAddProp( work_phone, VCWorkProp ); | 541 | safeAddProp( work_phone, VCWorkProp ); |
524 | safeAddProp( work_phone, VCFaxProp ); | 542 | safeAddProp( work_phone, VCFaxProp ); |
525 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); | 543 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); |
526 | safeAddProp( work_phone, VCWorkProp ); | 544 | safeAddProp( work_phone, VCWorkProp ); |
527 | safeAddProp( work_phone, VCPagerProp ); | 545 | safeAddProp( work_phone, VCPagerProp ); |
528 | 546 | ||
529 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); | 547 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); |
530 | safeAddProp( url, VCWorkProp ); | 548 | safeAddProp( url, VCWorkProp ); |
531 | 549 | ||
532 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); | 550 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); |
533 | safeAddProp( title, VCWorkProp ); | 551 | safeAddProp( title, VCWorkProp ); |
534 | 552 | ||
535 | 553 | ||
536 | QStringList emails = c.emailList(); | 554 | QStringList emails = c.emailList(); |
537 | emails.prepend( c.defaultEmail() ); | 555 | // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045 |
538 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 556 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
539 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); | 557 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); |
540 | safeAddProp( email, VCInternetProp ); | 558 | safeAddProp( email, VCInternetProp ); |
541 | } | 559 | } |
542 | 560 | ||
543 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); | 561 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); |
544 | 562 | ||
545 | // Exporting Birthday regarding RFC 2425 (5.8.4) | 563 | // Exporting Birthday regarding RFC 2425 (5.8.4) |
546 | if ( c.birthday().isValid() ){ | 564 | if ( c.birthday().isValid() ){ |
547 | qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); | 565 | qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); |
548 | safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); | 566 | safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); |
549 | } | 567 | } |
550 | 568 | ||
551 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { | 569 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { |
552 | VObject *org = safeAddProp( vcard, VCOrgProp ); | 570 | VObject *org = safeAddProp( vcard, VCOrgProp ); |
553 | safeAddPropValue( org, VCOrgNameProp, c.company() ); | 571 | safeAddPropValue( org, VCOrgNameProp, c.company() ); |
554 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); | 572 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); |
555 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); | 573 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); |
556 | } | 574 | } |
557 | 575 | ||
558 | // some values we have to export as custom fields | 576 | // some values we have to export as custom fields |
559 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); | 577 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); |
560 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); | 578 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); |
561 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); | 579 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); |
562 | 580 | ||
563 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); | 581 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); |
564 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); | 582 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); |
565 | if ( c.anniversary().isValid() ){ | 583 | if ( c.anniversary().isValid() ){ |
566 | qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); | 584 | qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); |
567 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); | 585 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); |
568 | } | 586 | } |
569 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); | 587 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); |
570 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); | 588 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); |
571 | 589 | ||
572 | return vcard; | 590 | return vcard; |
573 | } | 591 | } |
574 | 592 | ||
575 | QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const | 593 | QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const |
576 | { | 594 | { |
577 | QString str_rfc2425 = QString("%1-%2-%3") | 595 | QString str_rfc2425 = QString("%1-%2-%3") |
578 | .arg( d.year() ) | 596 | .arg( d.year() ) |
579 | .arg( d.month(), 2 ) | 597 | .arg( d.month(), 2 ) |
580 | .arg( d.day(), 2 ); | 598 | .arg( d.day(), 2 ); |
581 | // Now replace spaces with "0"... | 599 | // Now replace spaces with "0"... |
582 | int pos = 0; | 600 | int pos = 0; |
583 | while ( ( pos = str_rfc2425.find (' ') ) > 0 ) | 601 | while ( ( pos = str_rfc2425.find (' ') ) > 0 ) |
584 | str_rfc2425.replace( pos, 1, "0" ); | 602 | str_rfc2425.replace( pos, 1, "0" ); |
585 | 603 | ||
586 | return str_rfc2425; | 604 | return str_rfc2425; |
587 | } | 605 | } |
588 | 606 | ||
589 | QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) | 607 | QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) |
590 | { | 608 | { |
591 | int monthPos = datestr.find('-'); | 609 | int monthPos = datestr.find('-'); |
592 | int dayPos = datestr.find('-', monthPos+1 ); | 610 | int dayPos = datestr.find('-', monthPos+1 ); |
593 | int sep_ignore = 1; | 611 | int sep_ignore = 1; |
594 | if ( monthPos == -1 || dayPos == -1 ) { | 612 | if ( monthPos == -1 || dayPos == -1 ) { |
595 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | 613 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); |
596 | // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) | 614 | // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) |
597 | if ( datestr.length() == 8 ){ | 615 | if ( datestr.length() == 8 ){ |
598 | monthPos = 4; | 616 | monthPos = 4; |
599 | dayPos = 6; | 617 | dayPos = 6; |
600 | sep_ignore = 0; | 618 | sep_ignore = 0; |
601 | qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | 619 | qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); |
602 | } else { | 620 | } else { |
603 | return QDate(); | 621 | return QDate(); |
604 | } | 622 | } |
605 | } | 623 | } |
606 | int y = datestr.left( monthPos ).toInt(); | 624 | int y = datestr.left( monthPos ).toInt(); |
607 | int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); | 625 | int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); |
608 | int d = datestr.mid( dayPos + sep_ignore ).toInt(); | 626 | int d = datestr.mid( dayPos + sep_ignore ).toInt(); |
609 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); | 627 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); |
610 | QDate date ( y,m,d ); | 628 | QDate date ( y,m,d ); |
611 | return date; | 629 | return date; |
612 | } | 630 | } |
613 | 631 | ||
614 | VObject* OContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 632 | VObject* OContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
615 | { | 633 | { |
616 | VObject *ret = 0; | 634 | VObject *ret = 0; |
617 | if ( o && !value.isEmpty() ) | 635 | if ( o && !value.isEmpty() ) |
618 | ret = addPropValue( o, prop, value.latin1() ); | 636 | ret = addPropValue( o, prop, value.latin1() ); |
619 | return ret; | 637 | return ret; |
620 | } | 638 | } |
621 | 639 | ||
622 | VObject* OContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop) | 640 | VObject* OContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop) |
623 | { | 641 | { |
624 | VObject *ret = 0; | 642 | VObject *ret = 0; |
625 | if ( o ) | 643 | if ( o ) |
626 | ret = addProp( o, prop ); | 644 | ret = addProp( o, prop ); |
627 | return ret; | 645 | return ret; |
628 | } | 646 | } |
diff --git a/libopie/pim/ocontactaccessbackend_xml.cpp b/libopie/pim/ocontactaccessbackend_xml.cpp index 097142b..1c21619 100644 --- a/libopie/pim/ocontactaccessbackend_xml.cpp +++ b/libopie/pim/ocontactaccessbackend_xml.cpp | |||
@@ -1,115 +1,118 @@ | |||
1 | /* | 1 | /* |
2 | * XML Backend for the OPIE-Contact Database. | 2 | * XML Backend for the OPIE-Contact Database. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 5 | * |
6 | * ===================================================================== | 6 | * ===================================================================== |
7 | *This program is free software; you can redistribute it and/or | 7 | *This program is free software; you can redistribute it and/or |
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; either | 9 | * License as published by the Free Software Foundation; either |
10 | * version 2 of the License, or (at your option) any later version. | 10 | * version 2 of the License, or (at your option) any later version. |
11 | * ===================================================================== | 11 | * ===================================================================== |
12 | * ToDo: XML-Backend: Automatic reload if something was changed... | 12 | * ToDo: XML-Backend: Automatic reload if something was changed... |
13 | * | 13 | * |
14 | * | 14 | * |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * Version: $Id$ | 16 | * Version: $Id$ |
17 | * ===================================================================== | 17 | * ===================================================================== |
18 | * History: | 18 | * History: |
19 | * $Log$ | 19 | * $Log$ |
20 | * Revision 1.7 2003/08/01 12:30:16 eilers | ||
21 | * Merging changes from BRANCH_1_0 to HEAD | ||
22 | * | ||
20 | * Revision 1.6 2003/07/07 16:19:47 eilers | 23 | * Revision 1.6 2003/07/07 16:19:47 eilers |
21 | * Fixing serious bug in hasQuerySettings() | 24 | * Fixing serious bug in hasQuerySettings() |
22 | * | 25 | * |
23 | * Revision 1.5 2003/04/13 18:07:10 zecke | 26 | * Revision 1.5 2003/04/13 18:07:10 zecke |
24 | * More API doc | 27 | * More API doc |
25 | * QString -> const QString& | 28 | * QString -> const QString& |
26 | * QString = 0l -> QString::null | 29 | * QString = 0l -> QString::null |
27 | * | 30 | * |
28 | * Revision 1.4 2003/03/21 14:32:54 mickeyl | 31 | * Revision 1.4 2003/03/21 14:32:54 mickeyl |
29 | * g++ compliance fix: default arguments belong into the declaration, but not the definition | 32 | * g++ compliance fix: default arguments belong into the declaration, but not the definition |
30 | * | 33 | * |
31 | * Revision 1.3 2003/03/21 12:26:28 eilers | 34 | * Revision 1.3 2003/03/21 12:26:28 eilers |
32 | * Fixing small bug: If we search a birthday from today to today, it returned | 35 | * Fixing small bug: If we search a birthday from today to today, it returned |
33 | * every contact .. | 36 | * every contact .. |
34 | * | 37 | * |
35 | * Revision 1.2 2003/03/21 10:33:09 eilers | 38 | * Revision 1.2 2003/03/21 10:33:09 eilers |
36 | * Merged speed optimized xml backend for contacts to main. | 39 | * Merged speed optimized xml backend for contacts to main. |
37 | * Added QDateTime to querybyexample. For instance, it is now possible to get | 40 | * Added QDateTime to querybyexample. For instance, it is now possible to get |
38 | * all Birthdays/Anniversaries between two dates. This should be used | 41 | * all Birthdays/Anniversaries between two dates. This should be used |
39 | * to show all birthdays in the datebook.. | 42 | * to show all birthdays in the datebook.. |
40 | * This change is sourcecode backward compatible but you have to upgrade | 43 | * This change is sourcecode backward compatible but you have to upgrade |
41 | * the binaries for today-addressbook. | 44 | * the binaries for today-addressbook. |
42 | * | 45 | * |
43 | * Revision 1.1.2.2 2003/02/11 12:17:28 eilers | 46 | * Revision 1.1.2.2 2003/02/11 12:17:28 eilers |
44 | * Speed optimization. Removed the sequential search loops. | 47 | * Speed optimization. Removed the sequential search loops. |
45 | * | 48 | * |
46 | * Revision 1.1.2.1 2003/02/10 15:31:38 eilers | 49 | * Revision 1.1.2.1 2003/02/10 15:31:38 eilers |
47 | * Writing offsets to debug output.. | 50 | * Writing offsets to debug output.. |
48 | * | 51 | * |
49 | * Revision 1.1 2003/02/09 15:05:01 eilers | 52 | * Revision 1.1 2003/02/09 15:05:01 eilers |
50 | * Nothing happened.. Just some cleanup before I will start.. | 53 | * Nothing happened.. Just some cleanup before I will start.. |
51 | * | 54 | * |
52 | * Revision 1.12 2003/01/03 16:58:03 eilers | 55 | * Revision 1.12 2003/01/03 16:58:03 eilers |
53 | * Reenable debug output | 56 | * Reenable debug output |
54 | * | 57 | * |
55 | * Revision 1.11 2003/01/03 12:31:28 eilers | 58 | * Revision 1.11 2003/01/03 12:31:28 eilers |
56 | * Bugfix for calculating data diffs.. | 59 | * Bugfix for calculating data diffs.. |
57 | * | 60 | * |
58 | * Revision 1.10 2003/01/02 14:27:12 eilers | 61 | * Revision 1.10 2003/01/02 14:27:12 eilers |
59 | * Improved query by example: Search by date is possible.. First step | 62 | * Improved query by example: Search by date is possible.. First step |
60 | * for a today plugin for birthdays.. | 63 | * for a today plugin for birthdays.. |
61 | * | 64 | * |
62 | * Revision 1.9 2002/12/08 12:48:57 eilers | 65 | * Revision 1.9 2002/12/08 12:48:57 eilers |
63 | * Moved journal-enum from ocontact into i the xml-backend.. | 66 | * Moved journal-enum from ocontact into i the xml-backend.. |
64 | * | 67 | * |
65 | * Revision 1.8 2002/11/14 17:04:24 eilers | 68 | * Revision 1.8 2002/11/14 17:04:24 eilers |
66 | * Sorting will now work if fullname is identical on some entries | 69 | * Sorting will now work if fullname is identical on some entries |
67 | * | 70 | * |
68 | * Revision 1.7 2002/11/13 15:02:46 eilers | 71 | * Revision 1.7 2002/11/13 15:02:46 eilers |
69 | * Small Bug in sorted fixed | 72 | * Small Bug in sorted fixed |
70 | * | 73 | * |
71 | * Revision 1.6 2002/11/13 14:14:51 eilers | 74 | * Revision 1.6 2002/11/13 14:14:51 eilers |
72 | * Added sorted for Contacts.. | 75 | * Added sorted for Contacts.. |
73 | * | 76 | * |
74 | * Revision 1.5 2002/11/01 15:10:42 eilers | 77 | * Revision 1.5 2002/11/01 15:10:42 eilers |
75 | * Added regExp-search in database for all fields in a contact. | 78 | * Added regExp-search in database for all fields in a contact. |
76 | * | 79 | * |
77 | * Revision 1.4 2002/10/16 10:52:40 eilers | 80 | * Revision 1.4 2002/10/16 10:52:40 eilers |
78 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | 81 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) |
79 | * | 82 | * |
80 | * Revision 1.3 2002/10/14 16:21:54 eilers | 83 | * Revision 1.3 2002/10/14 16:21:54 eilers |
81 | * Some minor interface updates | 84 | * Some minor interface updates |
82 | * | 85 | * |
83 | * Revision 1.2 2002/10/07 17:34:24 eilers | 86 | * Revision 1.2 2002/10/07 17:34:24 eilers |
84 | * added OBackendFactory for advanced backend access | 87 | * added OBackendFactory for advanced backend access |
85 | * | 88 | * |
86 | * Revision 1.1 2002/09/27 17:11:44 eilers | 89 | * Revision 1.1 2002/09/27 17:11:44 eilers |
87 | * Added API for accessing the Contact-Database ! It is compiling, but | 90 | * Added API for accessing the Contact-Database ! It is compiling, but |
88 | * please do not expect that anything is working ! | 91 | * please do not expect that anything is working ! |
89 | * I will debug that stuff in the next time .. | 92 | * I will debug that stuff in the next time .. |
90 | * Please read README_COMPILE for compiling ! | 93 | * Please read README_COMPILE for compiling ! |
91 | * | 94 | * |
92 | * | 95 | * |
93 | */ | 96 | */ |
94 | 97 | ||
95 | #include "ocontactaccessbackend_xml.h" | 98 | #include "ocontactaccessbackend_xml.h" |
96 | 99 | ||
97 | #include <qasciidict.h> | 100 | #include <qasciidict.h> |
98 | #include <qdatetime.h> | 101 | #include <qdatetime.h> |
99 | #include <qfile.h> | 102 | #include <qfile.h> |
100 | #include <qfileinfo.h> | 103 | #include <qfileinfo.h> |
101 | #include <qregexp.h> | 104 | #include <qregexp.h> |
102 | #include <qarray.h> | 105 | #include <qarray.h> |
103 | #include <qmap.h> | 106 | #include <qmap.h> |
104 | #include <qdatetime.h> | 107 | #include <qdatetime.h> |
105 | 108 | ||
106 | #include <qpe/global.h> | 109 | #include <qpe/global.h> |
107 | 110 | ||
108 | #include <opie/xmltree.h> | 111 | #include <opie/xmltree.h> |
109 | #include "ocontactaccessbackend.h" | 112 | #include "ocontactaccessbackend.h" |
110 | #include "ocontactaccess.h" | 113 | #include "ocontactaccess.h" |
111 | 114 | ||
112 | #include <stdlib.h> | 115 | #include <stdlib.h> |
113 | #include <errno.h> | 116 | #include <errno.h> |
114 | 117 | ||
115 | using namespace Opie; | 118 | using namespace Opie; |
diff --git a/libopie/pim/oconversion.h b/libopie/pim/oconversion.h index 13367e1..4c0a497 100644 --- a/libopie/pim/oconversion.h +++ b/libopie/pim/oconversion.h | |||
@@ -1,43 +1,48 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 13 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
14 | ** | 14 | ** |
15 | ** Contact info@trolltech.com if any conditions of this licensing are | 15 | ** Contact info@trolltech.com if any conditions of this licensing are |
16 | ** not clear to you. | 16 | ** not clear to you. |
17 | **********************************************************************/ | 17 | **********************************************************************/ |
18 | 18 | ||
19 | #ifndef __oconversion_h__ | 19 | #ifndef __oconversion_h__ |
20 | #define __oconversion_h__ | 20 | #define __oconversion_h__ |
21 | 21 | ||
22 | /* #include <time.h> */ | 22 | /* #include <time.h> */ |
23 | /* #include <sys/types.h> */ | 23 | /* #include <sys/types.h> */ |
24 | #include <qdatetime.h> | 24 | #include <qdatetime.h> |
25 | 25 | ||
26 | /* FIXME namespace? -zecke */ | 26 | /* FIXME namespace? -zecke */ |
27 | class OConversion | 27 | class OConversion |
28 | { | 28 | { |
29 | public: | 29 | public: |
30 | static QString dateToString( const QDate &d ); | 30 | static QString dateToString( const QDate &d ); |
31 | static QDate dateFromString( const QString &datestr ); | 31 | static QDate dateFromString( const QString &datestr ); |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * simple function to store DateTime as string and read from string | 34 | * simple function to store DateTime as string and read from string |
35 | * no timezone changing is done | 35 | * no timezone changing is done |
36 | * DDMMYYYYHHMMSS is the simple format | 36 | * DDMMYYYYHHMMSS is the simple format |
37 | */ | 37 | */ |
38 | static QString dateTimeToString( const QDateTime& ); | 38 | static QString dateTimeToString( const QDateTime& ); |
39 | static QDateTime dateTimeFromString( const QString& ); | 39 | static QDateTime dateTimeFromString( const QString& ); |
40 | |||
41 | private: | ||
42 | class Private; | ||
43 | Private* d; | ||
44 | |||
40 | }; | 45 | }; |
41 | 46 | ||
42 | #endif // __oconversion_h__ | 47 | #endif // __oconversion_h__ |
43 | 48 | ||
diff --git a/libopie/pim/odatebookaccessbackend.h b/libopie/pim/odatebookaccessbackend.h index 86ff298..3c02c42 100644 --- a/libopie/pim/odatebookaccessbackend.h +++ b/libopie/pim/odatebookaccessbackend.h | |||
@@ -1,73 +1,77 @@ | |||
1 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_H | 1 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_H |
2 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_H | 2 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_H |
3 | 3 | ||
4 | #include <qarray.h> | 4 | #include <qarray.h> |
5 | 5 | ||
6 | #include "opimaccessbackend.h" | 6 | #include "opimaccessbackend.h" |
7 | #include "oevent.h" | 7 | #include "oevent.h" |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * This class is the interface to the storage of Events. | 10 | * This class is the interface to the storage of Events. |
11 | * @see OPimAccessBackend | 11 | * @see OPimAccessBackend |
12 | * | 12 | * |
13 | */ | 13 | */ |
14 | class ODateBookAccessBackend : public OPimAccessBackend<OEvent> { | 14 | class ODateBookAccessBackend : public OPimAccessBackend<OEvent> { |
15 | public: | 15 | public: |
16 | typedef int UID; | 16 | typedef int UID; |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * c'tor without parameter | 19 | * c'tor without parameter |
20 | */ | 20 | */ |
21 | ODateBookAccessBackend(); | 21 | ODateBookAccessBackend(); |
22 | ~ODateBookAccessBackend(); | 22 | ~ODateBookAccessBackend(); |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * This method should return a list of UIDs containing | 25 | * This method should return a list of UIDs containing |
26 | * all events. No filter should be applied | 26 | * all events. No filter should be applied |
27 | * @return list of events | 27 | * @return list of events |
28 | */ | 28 | */ |
29 | virtual QArray<UID> rawEvents()const = 0; | 29 | virtual QArray<UID> rawEvents()const = 0; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * This method should return a list of UIDs containing | 32 | * This method should return a list of UIDs containing |
33 | * all repeating events. No filter should be applied | 33 | * all repeating events. No filter should be applied |
34 | * @return list of repeating events | 34 | * @return list of repeating events |
35 | */ | 35 | */ |
36 | virtual QArray<UID> rawRepeats()const = 0; | 36 | virtual QArray<UID> rawRepeats()const = 0; |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * This mthod should return a list of UIDs containing all non | 39 | * This mthod should return a list of UIDs containing all non |
40 | * repeating events. No filter should be applied | 40 | * repeating events. No filter should be applied |
41 | * @return list of nonrepeating events | 41 | * @return list of nonrepeating events |
42 | */ | 42 | */ |
43 | virtual QArray<UID> nonRepeats() const = 0; | 43 | virtual QArray<UID> nonRepeats() const = 0; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * If you do not want to implement the effectiveEvents methods below | 46 | * If you do not want to implement the effectiveEvents methods below |
47 | * you need to supply it with directNonRepeats. | 47 | * you need to supply it with directNonRepeats. |
48 | * This method can return empty lists if effectiveEvents is implememted | 48 | * This method can return empty lists if effectiveEvents is implememted |
49 | */ | 49 | */ |
50 | virtual OEvent::ValueList directNonRepeats() = 0; | 50 | virtual OEvent::ValueList directNonRepeats() = 0; |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * Same as above but return raw repeats! | 53 | * Same as above but return raw repeats! |
54 | */ | 54 | */ |
55 | virtual OEvent::ValueList directRawRepeats() = 0; | 55 | virtual OEvent::ValueList directRawRepeats() = 0; |
56 | 56 | ||
57 | /* is implemented by default but you can reimplement it*/ | 57 | /* is implemented by default but you can reimplement it*/ |
58 | /** | 58 | /** |
59 | * Effective Events are special event occuring during a time frame. This method does calcualte | 59 | * Effective Events are special event occuring during a time frame. This method does calcualte |
60 | * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method | 60 | * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method |
61 | * yourself | 61 | * yourself |
62 | */ | 62 | */ |
63 | virtual OEffectiveEvent::ValueList effecticeEvents( const QDate& from, const QDate& to ); | 63 | virtual OEffectiveEvent::ValueList effecticeEvents( const QDate& from, const QDate& to ); |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * this is an overloaded member function | 66 | * this is an overloaded member function |
67 | * @see effecticeEvents | 67 | * @see effecticeEvents |
68 | */ | 68 | */ |
69 | virtual OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start ); | 69 | virtual OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start ); |
70 | 70 | ||
71 | private: | ||
72 | class Private; | ||
73 | Private *d; | ||
74 | |||
71 | }; | 75 | }; |
72 | 76 | ||
73 | #endif | 77 | #endif |
diff --git a/libopie/pim/odatebookaccessbackend_xml.cpp b/libopie/pim/odatebookaccessbackend_xml.cpp index ab2eea4..5ea945c 100644 --- a/libopie/pim/odatebookaccessbackend_xml.cpp +++ b/libopie/pim/odatebookaccessbackend_xml.cpp | |||
@@ -337,216 +337,216 @@ bool ODateBookAccessBackend_XML::loadFile() { | |||
337 | ::close( fd ); | 337 | ::close( fd ); |
338 | return false; | 338 | return false; |
339 | } | 339 | } |
340 | 340 | ||
341 | ::madvise( map_addr, attribute.st_size, MADV_SEQUENTIAL ); | 341 | ::madvise( map_addr, attribute.st_size, MADV_SEQUENTIAL ); |
342 | ::close( fd ); | 342 | ::close( fd ); |
343 | 343 | ||
344 | QAsciiDict<int> dict(FExceptions+1); | 344 | QAsciiDict<int> dict(FExceptions+1); |
345 | dict.setAutoDelete( true ); | 345 | dict.setAutoDelete( true ); |
346 | dict.insert( "description", new int(FDescription) ); | 346 | dict.insert( "description", new int(FDescription) ); |
347 | dict.insert( "location", new int(FLocation) ); | 347 | dict.insert( "location", new int(FLocation) ); |
348 | dict.insert( "categories", new int(FCategories) ); | 348 | dict.insert( "categories", new int(FCategories) ); |
349 | dict.insert( "uid", new int(FUid) ); | 349 | dict.insert( "uid", new int(FUid) ); |
350 | dict.insert( "type", new int(FType) ); | 350 | dict.insert( "type", new int(FType) ); |
351 | dict.insert( "alarm", new int(FAlarm) ); | 351 | dict.insert( "alarm", new int(FAlarm) ); |
352 | dict.insert( "sound", new int(FSound) ); | 352 | dict.insert( "sound", new int(FSound) ); |
353 | dict.insert( "rtype", new int(FRType) ); | 353 | dict.insert( "rtype", new int(FRType) ); |
354 | dict.insert( "rweekdays", new int(FRWeekdays) ); | 354 | dict.insert( "rweekdays", new int(FRWeekdays) ); |
355 | dict.insert( "rposition", new int(FRPosition) ); | 355 | dict.insert( "rposition", new int(FRPosition) ); |
356 | dict.insert( "rfreq", new int(FRFreq) ); | 356 | dict.insert( "rfreq", new int(FRFreq) ); |
357 | dict.insert( "rhasenddate", new int(FRHasEndDate) ); | 357 | dict.insert( "rhasenddate", new int(FRHasEndDate) ); |
358 | dict.insert( "enddt", new int(FREndDate) ); | 358 | dict.insert( "enddt", new int(FREndDate) ); |
359 | dict.insert( "start", new int(FRStart) ); | 359 | dict.insert( "start", new int(FRStart) ); |
360 | dict.insert( "end", new int(FREnd) ); | 360 | dict.insert( "end", new int(FREnd) ); |
361 | dict.insert( "note", new int(FNote) ); | 361 | dict.insert( "note", new int(FNote) ); |
362 | dict.insert( "created", new int(FCreated) ); | 362 | dict.insert( "created", new int(FCreated) ); |
363 | dict.insert( "recparent", new int(FRecParent) ); | 363 | dict.insert( "recparent", new int(FRecParent) ); |
364 | dict.insert( "recchildren", new int(FRecChildren) ); | 364 | dict.insert( "recchildren", new int(FRecChildren) ); |
365 | dict.insert( "exceptions", new int(FExceptions) ); | 365 | dict.insert( "exceptions", new int(FExceptions) ); |
366 | dict.insert( "timezone", new int(FTimeZone) ); | 366 | dict.insert( "timezone", new int(FTimeZone) ); |
367 | 367 | ||
368 | char* dt = (char*)map_addr; | 368 | char* dt = (char*)map_addr; |
369 | int len = attribute.st_size; | 369 | int len = attribute.st_size; |
370 | int i = 0; | 370 | int i = 0; |
371 | char* point; | 371 | char* point; |
372 | const char* collectionString = "<event "; | 372 | const char* collectionString = "<event "; |
373 | int strLen = ::strlen(collectionString); | 373 | int strLen = ::strlen(collectionString); |
374 | int *find; | 374 | int *find; |
375 | while ( ( point = ::strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0 ) { | 375 | while ( ( point = ::strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0 ) { |
376 | i = point -dt; | 376 | i = point -dt; |
377 | i+= strLen; | 377 | i+= strLen; |
378 | 378 | ||
379 | alarmTime = -1; | 379 | alarmTime = -1; |
380 | snd = 0; // silent | 380 | snd = 0; // silent |
381 | 381 | ||
382 | OEvent ev; | 382 | OEvent ev; |
383 | rec = 0; | 383 | rec = 0; |
384 | 384 | ||
385 | while ( TRUE ) { | 385 | while ( TRUE ) { |
386 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) | 386 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) |
387 | ++i; | 387 | ++i; |
388 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) | 388 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) |
389 | break; | 389 | break; |
390 | 390 | ||
391 | 391 | ||
392 | // we have another attribute, read it. | 392 | // we have another attribute, read it. |
393 | int j = i; | 393 | int j = i; |
394 | while ( j < len && dt[j] != '=' ) | 394 | while ( j < len && dt[j] != '=' ) |
395 | ++j; | 395 | ++j; |
396 | QCString attr( dt+i, j-i+1); | 396 | QCString attr( dt+i, j-i+1); |
397 | 397 | ||
398 | i = ++j; // skip = | 398 | i = ++j; // skip = |
399 | 399 | ||
400 | // find the start of quotes | 400 | // find the start of quotes |
401 | while ( i < len && dt[i] != '"' ) | 401 | while ( i < len && dt[i] != '"' ) |
402 | ++i; | 402 | ++i; |
403 | j = ++i; | 403 | j = ++i; |
404 | 404 | ||
405 | bool haveUtf = FALSE; | 405 | bool haveUtf = FALSE; |
406 | bool haveEnt = FALSE; | 406 | bool haveEnt = FALSE; |
407 | while ( j < len && dt[j] != '"' ) { | 407 | while ( j < len && dt[j] != '"' ) { |
408 | if ( ((unsigned char)dt[j]) > 0x7f ) | 408 | if ( ((unsigned char)dt[j]) > 0x7f ) |
409 | haveUtf = TRUE; | 409 | haveUtf = TRUE; |
410 | if ( dt[j] == '&' ) | 410 | if ( dt[j] == '&' ) |
411 | haveEnt = TRUE; | 411 | haveEnt = TRUE; |
412 | ++j; | 412 | ++j; |
413 | } | 413 | } |
414 | if ( i == j ) { | 414 | if ( i == j ) { |
415 | // empty value | 415 | // empty value |
416 | i = j + 1; | 416 | i = j + 1; |
417 | continue; | 417 | continue; |
418 | } | 418 | } |
419 | 419 | ||
420 | QCString value( dt+i, j-i+1 ); | 420 | QCString value( dt+i, j-i+1 ); |
421 | i = j + 1; | 421 | i = j + 1; |
422 | 422 | ||
423 | QString str = (haveUtf ? QString::fromUtf8( value ) | 423 | QString str = (haveUtf ? QString::fromUtf8( value ) |
424 | : QString::fromLatin1( value ) ); | 424 | : QString::fromLatin1( value ) ); |
425 | if ( haveEnt ) | 425 | if ( haveEnt ) |
426 | str = Qtopia::plainString( str ); | 426 | str = Qtopia::plainString( str ); |
427 | 427 | ||
428 | /* | 428 | /* |
429 | * add key + value | 429 | * add key + value |
430 | */ | 430 | */ |
431 | find = dict[attr.data()]; | 431 | find = dict[attr.data()]; |
432 | if (!find) | 432 | if (!find) |
433 | ev.setCustomField( attr, value ); | 433 | ev.setCustomField( attr, str ); |
434 | else { | 434 | else { |
435 | setField( ev, *find, value ); | 435 | setField( ev, *find, str ); |
436 | } | 436 | } |
437 | } | 437 | } |
438 | /* time to finalize */ | 438 | /* time to finalize */ |
439 | finalizeRecord( ev ); | 439 | finalizeRecord( ev ); |
440 | delete rec; | 440 | delete rec; |
441 | } | 441 | } |
442 | ::munmap(map_addr, attribute.st_size ); | 442 | ::munmap(map_addr, attribute.st_size ); |
443 | m_changed = false; // changed during add | 443 | m_changed = false; // changed during add |
444 | 444 | ||
445 | return true; | 445 | return true; |
446 | } | 446 | } |
447 | void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { | 447 | void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { |
448 | /* AllDay is alway in UTC */ | 448 | /* AllDay is alway in UTC */ |
449 | if ( ev.isAllDay() ) { | 449 | if ( ev.isAllDay() ) { |
450 | OTimeZone utc = OTimeZone::utc(); | 450 | OTimeZone utc = OTimeZone::utc(); |
451 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); | 451 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); |
452 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); | 452 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); |
453 | ev.setTimeZone( "UTC"); // make sure it is really utc | 453 | ev.setTimeZone( "UTC"); // make sure it is really utc |
454 | }else { | 454 | }else { |
455 | /* to current date time */ | 455 | /* to current date time */ |
456 | qWarning(" Start is %d", start ); | 456 | // qWarning(" Start is %d", start ); |
457 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); | 457 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); |
458 | QDateTime date = zone.toDateTime( start ); | 458 | QDateTime date = zone.toDateTime( start ); |
459 | qWarning(" Start is %s", date.toString().latin1() ); | 459 | qWarning(" Start is %s", date.toString().latin1() ); |
460 | ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); | 460 | ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); |
461 | 461 | ||
462 | date = zone.toDateTime( end ); | 462 | date = zone.toDateTime( end ); |
463 | ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); | 463 | ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); |
464 | } | 464 | } |
465 | if ( rec && rec->doesRecur() ) { | 465 | if ( rec && rec->doesRecur() ) { |
466 | OTimeZone utc = OTimeZone::utc(); | 466 | OTimeZone utc = OTimeZone::utc(); |
467 | ORecur recu( *rec ); // call copy c'tor; | 467 | ORecur recu( *rec ); // call copy c'tor; |
468 | recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); | 468 | recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); |
469 | recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); | 469 | recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); |
470 | recu.setStart( ev.startDateTime().date() ); | 470 | recu.setStart( ev.startDateTime().date() ); |
471 | ev.setRecurrence( recu ); | 471 | ev.setRecurrence( recu ); |
472 | } | 472 | } |
473 | 473 | ||
474 | if (alarmTime != -1 ) { | 474 | if (alarmTime != -1 ) { |
475 | QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); | 475 | QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); |
476 | OPimAlarm al( snd , dt ); | 476 | OPimAlarm al( snd , dt ); |
477 | ev.notifiers().add( al ); | 477 | ev.notifiers().add( al ); |
478 | } | 478 | } |
479 | if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { | 479 | if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { |
480 | qWarning("already contains assign uid"); | 480 | qWarning("already contains assign uid"); |
481 | ev.setUid( 1 ); | 481 | ev.setUid( 1 ); |
482 | } | 482 | } |
483 | qWarning("addind %d %s", ev.uid(), ev.description().latin1() ); | 483 | qWarning("addind %d %s", ev.uid(), ev.description().latin1() ); |
484 | if ( ev.hasRecurrence() ) | 484 | if ( ev.hasRecurrence() ) |
485 | m_rep.insert( ev.uid(), ev ); | 485 | m_rep.insert( ev.uid(), ev ); |
486 | else | 486 | else |
487 | m_raw.insert( ev.uid(), ev ); | 487 | m_raw.insert( ev.uid(), ev ); |
488 | 488 | ||
489 | } | 489 | } |
490 | void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { | 490 | void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { |
491 | // qWarning(" setting %s", value.latin1() ); | 491 | // qWarning(" setting %s", value.latin1() ); |
492 | switch( id ) { | 492 | switch( id ) { |
493 | case FDescription: | 493 | case FDescription: |
494 | e.setDescription( value ); | 494 | e.setDescription( value ); |
495 | break; | 495 | break; |
496 | case FLocation: | 496 | case FLocation: |
497 | e.setLocation( value ); | 497 | e.setLocation( value ); |
498 | break; | 498 | break; |
499 | case FCategories: | 499 | case FCategories: |
500 | e.setCategories( e.idsFromString( value ) ); | 500 | e.setCategories( e.idsFromString( value ) ); |
501 | break; | 501 | break; |
502 | case FUid: | 502 | case FUid: |
503 | e.setUid( value.toInt() ); | 503 | e.setUid( value.toInt() ); |
504 | break; | 504 | break; |
505 | case FType: | 505 | case FType: |
506 | if ( value == "AllDay" ) { | 506 | if ( value == "AllDay" ) { |
507 | e.setAllDay( true ); | 507 | e.setAllDay( true ); |
508 | e.setTimeZone( "UTC" ); | 508 | e.setTimeZone( "UTC" ); |
509 | } | 509 | } |
510 | break; | 510 | break; |
511 | case FAlarm: | 511 | case FAlarm: |
512 | alarmTime = value.toInt(); | 512 | alarmTime = value.toInt(); |
513 | break; | 513 | break; |
514 | case FSound: | 514 | case FSound: |
515 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; | 515 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; |
516 | break; | 516 | break; |
517 | // recurrence stuff | 517 | // recurrence stuff |
518 | case FRType: | 518 | case FRType: |
519 | if ( value == "Daily" ) | 519 | if ( value == "Daily" ) |
520 | recur()->setType( ORecur::Daily ); | 520 | recur()->setType( ORecur::Daily ); |
521 | else if ( value == "Weekly" ) | 521 | else if ( value == "Weekly" ) |
522 | recur()->setType( ORecur::Weekly); | 522 | recur()->setType( ORecur::Weekly); |
523 | else if ( value == "MonthlyDay" ) | 523 | else if ( value == "MonthlyDay" ) |
524 | recur()->setType( ORecur::MonthlyDay ); | 524 | recur()->setType( ORecur::MonthlyDay ); |
525 | else if ( value == "MonthlyDate" ) | 525 | else if ( value == "MonthlyDate" ) |
526 | recur()->setType( ORecur::MonthlyDate ); | 526 | recur()->setType( ORecur::MonthlyDate ); |
527 | else if ( value == "Yearly" ) | 527 | else if ( value == "Yearly" ) |
528 | recur()->setType( ORecur::Yearly ); | 528 | recur()->setType( ORecur::Yearly ); |
529 | else | 529 | else |
530 | recur()->setType( ORecur::NoRepeat ); | 530 | recur()->setType( ORecur::NoRepeat ); |
531 | break; | 531 | break; |
532 | case FRWeekdays: | 532 | case FRWeekdays: |
533 | recur()->setDays( value.toInt() ); | 533 | recur()->setDays( value.toInt() ); |
534 | break; | 534 | break; |
535 | case FRPosition: | 535 | case FRPosition: |
536 | recur()->setPosition( value.toInt() ); | 536 | recur()->setPosition( value.toInt() ); |
537 | break; | 537 | break; |
538 | case FRFreq: | 538 | case FRFreq: |
539 | recur()->setFrequency( value.toInt() ); | 539 | recur()->setFrequency( value.toInt() ); |
540 | break; | 540 | break; |
541 | case FRHasEndDate: | 541 | case FRHasEndDate: |
542 | recur()->setHasEndDate( value.toInt() ); | 542 | recur()->setHasEndDate( value.toInt() ); |
543 | break; | 543 | break; |
544 | case FREndDate: { | 544 | case FREndDate: { |
545 | rp_end = (time_t) value.toLong(); | 545 | rp_end = (time_t) value.toLong(); |
546 | break; | 546 | break; |
547 | } | 547 | } |
548 | case FRStart: { | 548 | case FRStart: { |
549 | start = (time_t) value.toLong(); | 549 | start = (time_t) value.toLong(); |
550 | break; | 550 | break; |
551 | } | 551 | } |
552 | case FREnd: { | 552 | case FREnd: { |
diff --git a/libopie/pim/opimaccessbackend.h b/libopie/pim/opimaccessbackend.h index f4bbe35..c3d91f7 100644 --- a/libopie/pim/opimaccessbackend.h +++ b/libopie/pim/opimaccessbackend.h | |||
@@ -1,159 +1,159 @@ | |||
1 | #ifndef OPIE_PIM_ACCESS_BACKEND | 1 | #ifndef OPIE_PIM_ACCESS_BACKEND |
2 | #define OPIE_PIM_ACCESS_BACKEND | 2 | #define OPIE_PIM_ACCESS_BACKEND |
3 | 3 | ||
4 | #include <qarray.h> | 4 | #include <qarray.h> |
5 | 5 | ||
6 | #include <opie/otemplatebase.h> | 6 | #include <opie/otemplatebase.h> |
7 | #include <opie/opimrecord.h> | 7 | #include <opie/opimrecord.h> |
8 | 8 | ||
9 | 9 | ||
10 | class OPimAccessBackendPrivate; | ||
10 | /** | 11 | /** |
11 | * OPimAccessBackend is the base class | 12 | * OPimAccessBackend is the base class |
12 | * for all private backends | 13 | * for all private backends |
13 | * it operates on OPimRecord as the base class | 14 | * it operates on OPimRecord as the base class |
14 | * and it's responsible for fast manipulating | 15 | * and it's responsible for fast manipulating |
15 | * the resource the implementation takes care | 16 | * the resource the implementation takes care |
16 | * of | 17 | * of |
17 | */ | 18 | */ |
18 | template <class T = OPimRecord> | 19 | template <class T = OPimRecord> |
19 | class OPimAccessBackend { | 20 | class OPimAccessBackend { |
20 | public: | 21 | public: |
21 | typedef OTemplateBase<T> Frontend; | 22 | typedef OTemplateBase<T> Frontend; |
22 | 23 | ||
23 | /** The access hint from the frontend */ | 24 | /** The access hint from the frontend */ |
24 | OPimAccessBackend(int access = 0); | 25 | OPimAccessBackend(int access = 0); |
25 | virtual ~OPimAccessBackend(); | 26 | virtual ~OPimAccessBackend(); |
26 | 27 | ||
27 | /** | 28 | /** |
28 | * load the resource | 29 | * load the resource |
29 | */ | 30 | */ |
30 | virtual bool load() = 0; | 31 | virtual bool load() = 0; |
31 | 32 | ||
32 | /** | 33 | /** |
33 | * reload the resource | 34 | * reload the resource |
34 | */ | 35 | */ |
35 | virtual bool reload() = 0; | 36 | virtual bool reload() = 0; |
36 | 37 | ||
37 | /** | 38 | /** |
38 | * save the resource and | 39 | * save the resource and |
39 | * all it's changes | 40 | * all it's changes |
40 | */ | 41 | */ |
41 | virtual bool save() = 0; | 42 | virtual bool save() = 0; |
42 | 43 | ||
43 | /** | 44 | /** |
44 | * return an array of | 45 | * return an array of |
45 | * all available uids | 46 | * all available uids |
46 | */ | 47 | */ |
47 | virtual QArray<int> allRecords()const = 0; | 48 | virtual QArray<int> allRecords()const = 0; |
48 | 49 | ||
49 | /** | 50 | /** |
50 | * return a List of records | 51 | * return a List of records |
51 | * that match the regex | 52 | * that match the regex |
52 | */ | 53 | */ |
53 | virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; | 54 | virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; |
54 | 55 | ||
55 | /** | 56 | /** |
56 | * queryByExample for T with the given Settings | 57 | * queryByExample for T with the given Settings |
57 | * | 58 | * |
58 | */ | 59 | */ |
59 | virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; | 60 | virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; |
60 | 61 | ||
61 | /** | 62 | /** |
62 | * find the OPimRecord with uid @param uid | 63 | * find the OPimRecord with uid @param uid |
63 | * returns T and T.isEmpty() if nothing was found | 64 | * returns T and T.isEmpty() if nothing was found |
64 | */ | 65 | */ |
65 | virtual T find(int uid )const = 0; | 66 | virtual T find(int uid )const = 0; |
66 | 67 | ||
67 | virtual T find(int uid, const QArray<int>& items, | 68 | virtual T find(int uid, const QArray<int>& items, |
68 | uint current, typename Frontend::CacheDirection )const ; | 69 | uint current, typename Frontend::CacheDirection )const ; |
69 | /** | 70 | /** |
70 | * clear the back end | 71 | * clear the back end |
71 | */ | 72 | */ |
72 | virtual void clear() = 0; | 73 | virtual void clear() = 0; |
73 | 74 | ||
74 | /** | 75 | /** |
75 | * add T | 76 | * add T |
76 | */ | 77 | */ |
77 | virtual bool add( const T& t ) = 0; | 78 | virtual bool add( const T& t ) = 0; |
78 | 79 | ||
79 | /** | 80 | /** |
80 | * remove | 81 | * remove |
81 | */ | 82 | */ |
82 | virtual bool remove( int uid ) = 0; | 83 | virtual bool remove( int uid ) = 0; |
83 | 84 | ||
84 | /** | 85 | /** |
85 | * replace a record with T.uid() | 86 | * replace a record with T.uid() |
86 | */ | 87 | */ |
87 | virtual bool replace( const T& t ) = 0; | 88 | virtual bool replace( const T& t ) = 0; |
88 | 89 | ||
89 | /* | 90 | /* |
90 | * setTheFrontEnd!!! | 91 | * setTheFrontEnd!!! |
91 | */ | 92 | */ |
92 | void setFrontend( Frontend* front ); | 93 | void setFrontend( Frontend* front ); |
93 | 94 | ||
94 | /** | 95 | /** |
95 | * set the read ahead count | 96 | * set the read ahead count |
96 | */ | 97 | */ |
97 | void setReadAhead( uint count ); | 98 | void setReadAhead( uint count ); |
98 | protected: | 99 | protected: |
99 | int access()const; | 100 | int access()const; |
100 | void cache( const T& t )const; | 101 | void cache( const T& t )const; |
101 | 102 | ||
102 | /** | 103 | /** |
103 | * use a prime number here! | 104 | * use a prime number here! |
104 | */ | 105 | */ |
105 | void setSaneCacheSize( int ); | 106 | void setSaneCacheSize( int ); |
106 | 107 | ||
107 | uint readAhead()const; | 108 | uint readAhead()const; |
108 | 109 | ||
109 | private: | 110 | private: |
110 | class Private; | 111 | OPimAccessBackendPrivate *d; |
111 | Private* d; | ||
112 | Frontend* m_front; | 112 | Frontend* m_front; |
113 | uint m_read; | 113 | uint m_read; |
114 | int m_acc; | 114 | int m_acc; |
115 | 115 | ||
116 | }; | 116 | }; |
117 | 117 | ||
118 | template <class T> | 118 | template <class T> |
119 | OPimAccessBackend<T>::OPimAccessBackend(int acc) | 119 | OPimAccessBackend<T>::OPimAccessBackend(int acc) |
120 | : m_acc( acc ) | 120 | : m_acc( acc ) |
121 | { | 121 | { |
122 | m_front = 0l; | 122 | m_front = 0l; |
123 | } | 123 | } |
124 | template <class T> | 124 | template <class T> |
125 | OPimAccessBackend<T>::~OPimAccessBackend() { | 125 | OPimAccessBackend<T>::~OPimAccessBackend() { |
126 | 126 | ||
127 | } | 127 | } |
128 | template <class T> | 128 | template <class T> |
129 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { | 129 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { |
130 | m_front = fr; | 130 | m_front = fr; |
131 | } | 131 | } |
132 | template <class T> | 132 | template <class T> |
133 | void OPimAccessBackend<T>::cache( const T& t )const { | 133 | void OPimAccessBackend<T>::cache( const T& t )const { |
134 | if (m_front ) | 134 | if (m_front ) |
135 | m_front->cache( t ); | 135 | m_front->cache( t ); |
136 | } | 136 | } |
137 | template <class T> | 137 | template <class T> |
138 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { | 138 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { |
139 | if (m_front ) | 139 | if (m_front ) |
140 | m_front->setSaneCacheSize( size ); | 140 | m_front->setSaneCacheSize( size ); |
141 | } | 141 | } |
142 | template <class T> | 142 | template <class T> |
143 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, | 143 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, |
144 | uint, typename Frontend::CacheDirection )const { | 144 | uint, typename Frontend::CacheDirection )const { |
145 | return find( uid ); | 145 | return find( uid ); |
146 | } | 146 | } |
147 | template <class T> | 147 | template <class T> |
148 | void OPimAccessBackend<T>::setReadAhead( uint count ) { | 148 | void OPimAccessBackend<T>::setReadAhead( uint count ) { |
149 | m_read = count; | 149 | m_read = count; |
150 | } | 150 | } |
151 | template <class T> | 151 | template <class T> |
152 | uint OPimAccessBackend<T>::readAhead()const { | 152 | uint OPimAccessBackend<T>::readAhead()const { |
153 | return m_read; | 153 | return m_read; |
154 | } | 154 | } |
155 | template <class T> | 155 | template <class T> |
156 | int OPimAccessBackend<T>::access()const { | 156 | int OPimAccessBackend<T>::access()const { |
157 | return m_acc; | 157 | return m_acc; |
158 | } | 158 | } |
159 | #endif | 159 | #endif |
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h index 8ff205c..ecbeb68 100644 --- a/libopie/pim/opimaccesstemplate.h +++ b/libopie/pim/opimaccesstemplate.h | |||
@@ -1,250 +1,254 @@ | |||
1 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H | 1 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H |
2 | #define OPIE_PIM_ACCESS_TEMPLATE_H | 2 | #define OPIE_PIM_ACCESS_TEMPLATE_H |
3 | 3 | ||
4 | #include <qarray.h> | 4 | #include <qarray.h> |
5 | 5 | ||
6 | #include <opie/opimrecord.h> | 6 | #include <opie/opimrecord.h> |
7 | #include <opie/opimaccessbackend.h> | 7 | #include <opie/opimaccessbackend.h> |
8 | #include <opie/orecordlist.h> | 8 | #include <opie/orecordlist.h> |
9 | 9 | ||
10 | #include "opimcache.h" | 10 | #include "opimcache.h" |
11 | #include "otemplatebase.h" | 11 | #include "otemplatebase.h" |
12 | 12 | ||
13 | class OPimAccessTemplatePrivate; | ||
13 | /** | 14 | /** |
14 | * Thats the frontend to our OPIE PIM | 15 | * Thats the frontend to our OPIE PIM |
15 | * Library. Either you want to use it's | 16 | * Library. Either you want to use it's |
16 | * interface or you want to implement | 17 | * interface or you want to implement |
17 | * your own Access lib | 18 | * your own Access lib |
18 | * Just create a OPimRecord and inherit from | 19 | * Just create a OPimRecord and inherit from |
19 | * the plugins | 20 | * the plugins |
20 | */ | 21 | */ |
21 | 22 | ||
22 | template <class T = OPimRecord > | 23 | template <class T = OPimRecord > |
23 | class OPimAccessTemplate : public OTemplateBase<T> { | 24 | class OPimAccessTemplate : public OTemplateBase<T> { |
24 | public: | 25 | public: |
25 | enum Access { | 26 | enum Access { |
26 | Random = 0, | 27 | Random = 0, |
27 | SortedAccess | 28 | SortedAccess |
28 | }; | 29 | }; |
29 | typedef ORecordList<T> List; | 30 | typedef ORecordList<T> List; |
30 | typedef OPimAccessBackend<T> BackEnd; | 31 | typedef OPimAccessBackend<T> BackEnd; |
31 | typedef OPimCache<T> Cache; | 32 | typedef OPimCache<T> Cache; |
32 | 33 | ||
33 | /** | 34 | /** |
34 | * c'tor BackEnd | 35 | * c'tor BackEnd |
35 | * enum Access a small hint on how to handle the backend | 36 | * enum Access a small hint on how to handle the backend |
36 | */ | 37 | */ |
37 | OPimAccessTemplate( BackEnd* end); | 38 | OPimAccessTemplate( BackEnd* end); |
38 | 39 | ||
39 | virtual ~OPimAccessTemplate(); | 40 | virtual ~OPimAccessTemplate(); |
40 | 41 | ||
41 | /** | 42 | /** |
42 | * load from the backend | 43 | * load from the backend |
43 | */ | 44 | */ |
44 | bool load(); | 45 | bool load(); |
45 | 46 | ||
46 | /** Reload database. | 47 | /** Reload database. |
47 | * You should execute this function if the external database | 48 | * You should execute this function if the external database |
48 | * was changed. | 49 | * was changed. |
49 | * This function will load the external database and afterwards | 50 | * This function will load the external database and afterwards |
50 | * rejoin the local changes. Therefore the local database will be set consistent. | 51 | * rejoin the local changes. Therefore the local database will be set consistent. |
51 | */ | 52 | */ |
52 | virtual bool reload(); | 53 | virtual bool reload(); |
53 | 54 | ||
54 | /** Save contacts database. | 55 | /** Save contacts database. |
55 | * Save is more a "commit". After calling this function, all changes are public available. | 56 | * Save is more a "commit". After calling this function, all changes are public available. |
56 | * @return true if successful | 57 | * @return true if successful |
57 | */ | 58 | */ |
58 | bool save(); | 59 | bool save(); |
59 | 60 | ||
60 | /** | 61 | /** |
61 | * if the resource was changed externally | 62 | * if the resource was changed externally |
62 | * You should use the signal handling instead of polling possible changes ! | 63 | * You should use the signal handling instead of polling possible changes ! |
63 | * zecke: Do you implement a signal for otodoaccess ? | 64 | * zecke: Do you implement a signal for otodoaccess ? |
64 | */ | 65 | */ |
65 | bool wasChangedExternally()const; | 66 | bool wasChangedExternally()const; |
66 | 67 | ||
67 | /** | 68 | /** |
68 | * return a List of records | 69 | * return a List of records |
69 | * you can iterate over them | 70 | * you can iterate over them |
70 | */ | 71 | */ |
71 | virtual List allRecords()const; | 72 | virtual List allRecords()const; |
72 | 73 | ||
73 | /** | 74 | /** |
74 | * return a List of records | 75 | * return a List of records |
75 | * that match the regex | 76 | * that match the regex |
76 | */ | 77 | */ |
77 | virtual List matchRegexp( const QRegExp &r ) const; | 78 | virtual List matchRegexp( const QRegExp &r ) const; |
78 | 79 | ||
79 | /** | 80 | /** |
80 | * queryByExample. | 81 | * queryByExample. |
81 | * @see otodoaccess, ocontactaccess | 82 | * @see otodoaccess, ocontactaccess |
82 | */ | 83 | */ |
83 | virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); | 84 | virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); |
84 | 85 | ||
85 | /** | 86 | /** |
86 | * find the OPimRecord uid | 87 | * find the OPimRecord uid |
87 | */ | 88 | */ |
88 | virtual T find( int uid )const; | 89 | virtual T find( int uid )const; |
89 | 90 | ||
90 | /** | 91 | /** |
91 | * read ahead cache find method ;) | 92 | * read ahead cache find method ;) |
92 | */ | 93 | */ |
93 | virtual T find( int uid, const QArray<int>&, | 94 | virtual T find( int uid, const QArray<int>&, |
94 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; | 95 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; |
95 | 96 | ||
96 | /* invalidate cache here */ | 97 | /* invalidate cache here */ |
97 | /** | 98 | /** |
98 | * clears the backend and invalidates the backend | 99 | * clears the backend and invalidates the backend |
99 | */ | 100 | */ |
100 | void clear() ; | 101 | void clear() ; |
101 | 102 | ||
102 | /** | 103 | /** |
103 | * add T to the backend | 104 | * add T to the backend |
104 | * @param t The item to add. | 105 | * @param t The item to add. |
105 | * @return <i>true</i> if added successfully. | 106 | * @return <i>true</i> if added successfully. |
106 | */ | 107 | */ |
107 | virtual bool add( const T& t ) ; | 108 | virtual bool add( const T& t ) ; |
108 | bool add( const OPimRecord& ); | 109 | bool add( const OPimRecord& ); |
109 | 110 | ||
110 | /* only the uid matters */ | 111 | /* only the uid matters */ |
111 | /** | 112 | /** |
112 | * remove T from the backend | 113 | * remove T from the backend |
113 | * @param t The item to remove | 114 | * @param t The item to remove |
114 | * @return <i>true</i> if successful. | 115 | * @return <i>true</i> if successful. |
115 | */ | 116 | */ |
116 | virtual bool remove( const T& t ); | 117 | virtual bool remove( const T& t ); |
117 | 118 | ||
118 | /** | 119 | /** |
119 | * remove the OPimRecord with uid | 120 | * remove the OPimRecord with uid |
120 | * @param uid The ID of the item to remove | 121 | * @param uid The ID of the item to remove |
121 | * @return <i>true</i> if successful. | 122 | * @return <i>true</i> if successful. |
122 | */ | 123 | */ |
123 | bool remove( int uid ); | 124 | bool remove( int uid ); |
124 | bool remove( const OPimRecord& ); | 125 | bool remove( const OPimRecord& ); |
125 | 126 | ||
126 | /** | 127 | /** |
127 | * replace T from backend | 128 | * replace T from backend |
128 | * @param t The item to replace | 129 | * @param t The item to replace |
129 | * @return <i>true</i> if successful. | 130 | * @return <i>true</i> if successful. |
130 | */ | 131 | */ |
131 | virtual bool replace( const T& t) ; | 132 | virtual bool replace( const T& t) ; |
132 | 133 | ||
133 | void setReadAhead( uint count ); | 134 | void setReadAhead( uint count ); |
134 | /** | 135 | /** |
135 | * @internal | 136 | * @internal |
136 | */ | 137 | */ |
137 | void cache( const T& )const; | 138 | void cache( const T& )const; |
138 | void setSaneCacheSize( int ); | 139 | void setSaneCacheSize( int ); |
139 | 140 | ||
140 | QArray<int> records()const; | 141 | QArray<int> records()const; |
141 | protected: | 142 | protected: |
142 | /** | 143 | /** |
143 | * invalidate the cache | 144 | * invalidate the cache |
144 | */ | 145 | */ |
145 | void invalidateCache(); | 146 | void invalidateCache(); |
146 | 147 | ||
147 | void setBackEnd( BackEnd* end ); | 148 | void setBackEnd( BackEnd* end ); |
148 | /** | 149 | /** |
149 | * returns the backend | 150 | * returns the backend |
150 | */ | 151 | */ |
151 | BackEnd* backEnd(); | 152 | BackEnd* backEnd(); |
152 | BackEnd* m_backEnd; | 153 | BackEnd* m_backEnd; |
153 | Cache m_cache; | 154 | Cache m_cache; |
154 | 155 | ||
156 | private: | ||
157 | OPimAccessTemplatePrivate *d; | ||
158 | |||
155 | }; | 159 | }; |
156 | 160 | ||
157 | template <class T> | 161 | template <class T> |
158 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) | 162 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) |
159 | : OTemplateBase<T>(), m_backEnd( end ) | 163 | : OTemplateBase<T>(), m_backEnd( end ) |
160 | { | 164 | { |
161 | if (end ) | 165 | if (end ) |
162 | end->setFrontend( this ); | 166 | end->setFrontend( this ); |
163 | } | 167 | } |
164 | template <class T> | 168 | template <class T> |
165 | OPimAccessTemplate<T>::~OPimAccessTemplate() { | 169 | OPimAccessTemplate<T>::~OPimAccessTemplate() { |
166 | qWarning("~OPimAccessTemplate<T>"); | 170 | qWarning("~OPimAccessTemplate<T>"); |
167 | delete m_backEnd; | 171 | delete m_backEnd; |
168 | } | 172 | } |
169 | template <class T> | 173 | template <class T> |
170 | bool OPimAccessTemplate<T>::load() { | 174 | bool OPimAccessTemplate<T>::load() { |
171 | invalidateCache(); | 175 | invalidateCache(); |
172 | return m_backEnd->load(); | 176 | return m_backEnd->load(); |
173 | } | 177 | } |
174 | template <class T> | 178 | template <class T> |
175 | bool OPimAccessTemplate<T>::reload() { | 179 | bool OPimAccessTemplate<T>::reload() { |
176 | invalidateCache(); // zecke: I think this should be added (se) | 180 | invalidateCache(); // zecke: I think this should be added (se) |
177 | return m_backEnd->reload(); | 181 | return m_backEnd->reload(); |
178 | } | 182 | } |
179 | template <class T> | 183 | template <class T> |
180 | bool OPimAccessTemplate<T>::save() { | 184 | bool OPimAccessTemplate<T>::save() { |
181 | return m_backEnd->save(); | 185 | return m_backEnd->save(); |
182 | } | 186 | } |
183 | template <class T> | 187 | template <class T> |
184 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { | 188 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { |
185 | QArray<int> ints = m_backEnd->allRecords(); | 189 | QArray<int> ints = m_backEnd->allRecords(); |
186 | List lis(ints, this ); | 190 | List lis(ints, this ); |
187 | return lis; | 191 | return lis; |
188 | } | 192 | } |
189 | template <class T> | 193 | template <class T> |
190 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const { | 194 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const { |
191 | QArray<int> ints = m_backEnd->matchRegexp( r ); | 195 | QArray<int> ints = m_backEnd->matchRegexp( r ); |
192 | List lis(ints, this ); | 196 | List lis(ints, this ); |
193 | return lis; | 197 | return lis; |
194 | } | 198 | } |
195 | template <class T> | 199 | template <class T> |
196 | QArray<int> OPimAccessTemplate<T>::records()const { | 200 | QArray<int> OPimAccessTemplate<T>::records()const { |
197 | return m_backEnd->allRecords(); | 201 | return m_backEnd->allRecords(); |
198 | } | 202 | } |
199 | template <class T> | 203 | template <class T> |
200 | typename OPimAccessTemplate<T>::List | 204 | typename OPimAccessTemplate<T>::List |
201 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { | 205 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { |
202 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); | 206 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); |
203 | 207 | ||
204 | List lis(ints, this ); | 208 | List lis(ints, this ); |
205 | return lis; | 209 | return lis; |
206 | } | 210 | } |
207 | template <class T> | 211 | template <class T> |
208 | T OPimAccessTemplate<T>::find( int uid ) const{ | 212 | T OPimAccessTemplate<T>::find( int uid ) const{ |
209 | T t = m_backEnd->find( uid ); | 213 | T t = m_backEnd->find( uid ); |
210 | cache( t ); | 214 | cache( t ); |
211 | return t; | 215 | return t; |
212 | } | 216 | } |
213 | template <class T> | 217 | template <class T> |
214 | T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, | 218 | T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, |
215 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { | 219 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { |
216 | /* | 220 | /* |
217 | * better do T.isEmpty() | 221 | * better do T.isEmpty() |
218 | * after a find this way we would | 222 | * after a find this way we would |
219 | * avoid two finds in QCache... | 223 | * avoid two finds in QCache... |
220 | */ | 224 | */ |
221 | // qWarning("find it now %d", uid ); | 225 | // qWarning("find it now %d", uid ); |
222 | if (m_cache.contains( uid ) ) { | 226 | if (m_cache.contains( uid ) ) { |
223 | return m_cache.find( uid ); | 227 | return m_cache.find( uid ); |
224 | } | 228 | } |
225 | 229 | ||
226 | T t = m_backEnd->find( uid, ar, current, dir ); | 230 | T t = m_backEnd->find( uid, ar, current, dir ); |
227 | cache( t ); | 231 | cache( t ); |
228 | return t; | 232 | return t; |
229 | } | 233 | } |
230 | template <class T> | 234 | template <class T> |
231 | void OPimAccessTemplate<T>::clear() { | 235 | void OPimAccessTemplate<T>::clear() { |
232 | invalidateCache(); | 236 | invalidateCache(); |
233 | m_backEnd->clear(); | 237 | m_backEnd->clear(); |
234 | } | 238 | } |
235 | template <class T> | 239 | template <class T> |
236 | bool OPimAccessTemplate<T>::add( const T& t ) { | 240 | bool OPimAccessTemplate<T>::add( const T& t ) { |
237 | cache( t ); | 241 | cache( t ); |
238 | return m_backEnd->add( t ); | 242 | return m_backEnd->add( t ); |
239 | } | 243 | } |
240 | template <class T> | 244 | template <class T> |
241 | bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { | 245 | bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { |
242 | /* same type */ | 246 | /* same type */ |
243 | if ( rec.rtti() == T::rtti() ) { | 247 | if ( rec.rtti() == T::rtti() ) { |
244 | const T &t = static_cast<const T&>(rec); | 248 | const T &t = static_cast<const T&>(rec); |
245 | return add(t); | 249 | return add(t); |
246 | } | 250 | } |
247 | return false; | 251 | return false; |
248 | } | 252 | } |
249 | template <class T> | 253 | template <class T> |
250 | bool OPimAccessTemplate<T>::remove( const T& t ) { | 254 | bool OPimAccessTemplate<T>::remove( const T& t ) { |
diff --git a/libopie/pim/opimcache.h b/libopie/pim/opimcache.h index 73414e5..7f7cff5 100644 --- a/libopie/pim/opimcache.h +++ b/libopie/pim/opimcache.h | |||
@@ -1,125 +1,131 @@ | |||
1 | #ifndef OPIE_PIM_CACHE_H | 1 | #ifndef OPIE_PIM_CACHE_H |
2 | #define OPIE_PIM_CACHE_H | 2 | #define OPIE_PIM_CACHE_H |
3 | 3 | ||
4 | #include <qintcache.h> | 4 | #include <qintcache.h> |
5 | 5 | ||
6 | #include "opimrecord.h" | 6 | #include "opimrecord.h" |
7 | 7 | ||
8 | class OPimCacheItemPrivate; | ||
9 | |||
8 | template <class T = OPimRecord> | 10 | template <class T = OPimRecord> |
9 | class OPimCacheItem { | 11 | class OPimCacheItem { |
10 | public: | 12 | public: |
11 | OPimCacheItem( const T& t = T() ); | 13 | OPimCacheItem( const T& t = T() ); |
12 | OPimCacheItem( const OPimCacheItem& ); | 14 | OPimCacheItem( const OPimCacheItem& ); |
13 | ~OPimCacheItem(); | 15 | ~OPimCacheItem(); |
14 | 16 | ||
15 | OPimCacheItem &operator=( const OPimCacheItem& ); | 17 | OPimCacheItem &operator=( const OPimCacheItem& ); |
16 | 18 | ||
17 | T record()const; | 19 | T record()const; |
18 | void setRecord( const T& ); | 20 | void setRecord( const T& ); |
19 | private: | 21 | private: |
20 | T m_t; | 22 | T m_t; |
23 | OPimCacheItemPrivate *d; | ||
21 | }; | 24 | }; |
22 | 25 | ||
26 | |||
27 | class OPimCachePrivate; | ||
23 | /** | 28 | /** |
24 | * OPimCache for caching the items | 29 | * OPimCache for caching the items |
25 | * We support adding, removing | 30 | * We support adding, removing |
26 | * and finding | 31 | * and finding |
27 | */ | 32 | */ |
28 | template <class T = OPimRecord> | 33 | template <class T = OPimRecord> |
29 | class OPimCache { | 34 | class OPimCache { |
30 | public: | 35 | public: |
31 | typedef OPimCacheItem<T> Item; | 36 | typedef OPimCacheItem<T> Item; |
32 | OPimCache(); | 37 | OPimCache(); |
33 | OPimCache( const OPimCache& ); | 38 | OPimCache( const OPimCache& ); |
34 | ~OPimCache(); | 39 | ~OPimCache(); |
35 | 40 | ||
36 | OPimCache &operator=( const OPimCache& ); | 41 | OPimCache &operator=( const OPimCache& ); |
37 | 42 | ||
38 | bool contains(int uid)const; | 43 | bool contains(int uid)const; |
39 | void invalidate(); | 44 | void invalidate(); |
40 | void setSize( int size ); | 45 | void setSize( int size ); |
41 | 46 | ||
42 | T find(int uid )const; | 47 | T find(int uid )const; |
43 | void add( const T& ); | 48 | void add( const T& ); |
44 | void remove( int uid ); | 49 | void remove( int uid ); |
45 | void replace( const T& ); | 50 | void replace( const T& ); |
46 | 51 | ||
47 | private: | 52 | private: |
48 | QIntCache<Item> m_cache; | 53 | QIntCache<Item> m_cache; |
54 | OPimCachePrivate* d; | ||
49 | }; | 55 | }; |
50 | 56 | ||
51 | // Implementation | 57 | // Implementation |
52 | template <class T> | 58 | template <class T> |
53 | OPimCacheItem<T>::OPimCacheItem( const T& t ) | 59 | OPimCacheItem<T>::OPimCacheItem( const T& t ) |
54 | : m_t(t) { | 60 | : m_t(t) { |
55 | } | 61 | } |
56 | template <class T> | 62 | template <class T> |
57 | OPimCacheItem<T>::~OPimCacheItem() { | 63 | OPimCacheItem<T>::~OPimCacheItem() { |
58 | 64 | ||
59 | } | 65 | } |
60 | template <class T> | 66 | template <class T> |
61 | T OPimCacheItem<T>::record()const { | 67 | T OPimCacheItem<T>::record()const { |
62 | return m_t; | 68 | return m_t; |
63 | } | 69 | } |
64 | template <class T> | 70 | template <class T> |
65 | void OPimCacheItem<T>::setRecord( const T& t ) { | 71 | void OPimCacheItem<T>::setRecord( const T& t ) { |
66 | m_t = t; | 72 | m_t = t; |
67 | } | 73 | } |
68 | // Cache | 74 | // Cache |
69 | template <class T> | 75 | template <class T> |
70 | OPimCache<T>::OPimCache() | 76 | OPimCache<T>::OPimCache() |
71 | : m_cache(100, 53 ) | 77 | : m_cache(100, 53 ) |
72 | { | 78 | { |
73 | m_cache.setAutoDelete( TRUE ); | 79 | m_cache.setAutoDelete( TRUE ); |
74 | } | 80 | } |
75 | template <class T> | 81 | template <class T> |
76 | OPimCache<T>::~OPimCache() { | 82 | OPimCache<T>::~OPimCache() { |
77 | 83 | ||
78 | } | 84 | } |
79 | template <class T> | 85 | template <class T> |
80 | bool OPimCache<T>::contains(int uid )const { | 86 | bool OPimCache<T>::contains(int uid )const { |
81 | Item* it = m_cache.find( uid, FALSE ); | 87 | Item* it = m_cache.find( uid, FALSE ); |
82 | if (!it) | 88 | if (!it) |
83 | return false; | 89 | return false; |
84 | return true; | 90 | return true; |
85 | } | 91 | } |
86 | template <class T> | 92 | template <class T> |
87 | void OPimCache<T>::invalidate() { | 93 | void OPimCache<T>::invalidate() { |
88 | m_cache.clear(); | 94 | m_cache.clear(); |
89 | } | 95 | } |
90 | template <class T> | 96 | template <class T> |
91 | void OPimCache<T>::setSize( int size ) { | 97 | void OPimCache<T>::setSize( int size ) { |
92 | m_cache.setMaxCost( size ); | 98 | m_cache.setMaxCost( size ); |
93 | } | 99 | } |
94 | template <class T> | 100 | template <class T> |
95 | T OPimCache<T>::find(int uid )const { | 101 | T OPimCache<T>::find(int uid )const { |
96 | Item *it = m_cache.find( uid ); | 102 | Item *it = m_cache.find( uid ); |
97 | if (it) | 103 | if (it) |
98 | return it->record(); | 104 | return it->record(); |
99 | return T(); | 105 | return T(); |
100 | } | 106 | } |
101 | template <class T> | 107 | template <class T> |
102 | void OPimCache<T>::add( const T& t ) { | 108 | void OPimCache<T>::add( const T& t ) { |
103 | Item* it = 0l; | 109 | Item* it = 0l; |
104 | it = m_cache.find(t.uid(), FALSE ); | 110 | it = m_cache.find(t.uid(), FALSE ); |
105 | 111 | ||
106 | if (it ) | 112 | if (it ) |
107 | it->setRecord( t ); | 113 | it->setRecord( t ); |
108 | 114 | ||
109 | it = new Item( t ); | 115 | it = new Item( t ); |
110 | if (!m_cache.insert( t.uid(), it ) ) | 116 | if (!m_cache.insert( t.uid(), it ) ) |
111 | delete it; | 117 | delete it; |
112 | } | 118 | } |
113 | template <class T> | 119 | template <class T> |
114 | void OPimCache<T>::remove( int uid ) { | 120 | void OPimCache<T>::remove( int uid ) { |
115 | m_cache.remove( uid ); | 121 | m_cache.remove( uid ); |
116 | } | 122 | } |
117 | template <class T> | 123 | template <class T> |
118 | void OPimCache<T>::replace( const T& t) { | 124 | void OPimCache<T>::replace( const T& t) { |
119 | Item *it = m_cache.find( t.uid() ); | 125 | Item *it = m_cache.find( t.uid() ); |
120 | if ( it ) { | 126 | if ( it ) { |
121 | it->setRecord( t ); | 127 | it->setRecord( t ); |
122 | } | 128 | } |
123 | } | 129 | } |
124 | 130 | ||
125 | #endif | 131 | #endif |
diff --git a/libopie/pim/opimmainwindow.cpp b/libopie/pim/opimmainwindow.cpp index 4044bc1..2739e26 100644 --- a/libopie/pim/opimmainwindow.cpp +++ b/libopie/pim/opimmainwindow.cpp | |||
@@ -1,138 +1,150 @@ | |||
1 | #include <qapplication.h> | 1 | #include <qapplication.h> |
2 | #include <qdatetime.h> | 2 | #include <qdatetime.h> |
3 | #include <qcopchannel_qws.h> | 3 | #include <qcopchannel_qws.h> |
4 | 4 | ||
5 | #include <qpe/sound.h> | 5 | #include <qpe/sound.h> |
6 | #include <qpe/qcopenvelope_qws.h> | 6 | #include <qpe/qcopenvelope_qws.h> |
7 | #include <qpe/qpeapplication.h> | ||
7 | 8 | ||
8 | #include "opimresolver.h" | 9 | #include "opimresolver.h" |
9 | #include "opimmainwindow.h" | 10 | #include "opimmainwindow.h" |
10 | 11 | ||
11 | OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, | 12 | OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, |
12 | const char* name, WFlags flag ) | 13 | const char* name, WFlags flag ) |
13 | : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { | 14 | : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { |
14 | 15 | ||
15 | /* | 16 | /* |
16 | * let's generate our QCopChannel | 17 | * let's generate our QCopChannel |
17 | */ | 18 | */ |
18 | m_str = QString("QPE/"+m_service).local8Bit(); | 19 | m_str = QString("QPE/"+m_service).local8Bit(); |
19 | m_channel= new QCopChannel(m_str, this ); | 20 | m_channel= new QCopChannel(m_str, this ); |
20 | connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), | 21 | connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), |
21 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | 22 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); |
22 | connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), | 23 | connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), |
23 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | 24 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); |
24 | 25 | ||
25 | /* connect flush and reload */ | 26 | /* connect flush and reload */ |
26 | connect(qApp, SIGNAL(flush() ), | 27 | connect(qApp, SIGNAL(flush() ), |
27 | this, SLOT(flush() ) ); | 28 | this, SLOT(flush() ) ); |
28 | connect(qApp, SIGNAL(reload() ), | 29 | connect(qApp, SIGNAL(reload() ), |
29 | this, SLOT(reload() ) ); | 30 | this, SLOT(reload() ) ); |
30 | } | 31 | } |
31 | OPimMainWindow::~OPimMainWindow() { | 32 | OPimMainWindow::~OPimMainWindow() { |
32 | delete m_channel; | 33 | delete m_channel; |
33 | } | 34 | } |
34 | QCopChannel* OPimMainWindow::channel() { | 35 | QCopChannel* OPimMainWindow::channel() { |
35 | return m_channel; | 36 | return m_channel; |
36 | } | 37 | } |
37 | void OPimMainWindow::doSetDocument( const QString& ) { | 38 | void OPimMainWindow::doSetDocument( const QString& ) { |
38 | 39 | ||
39 | } | 40 | } |
40 | void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { | 41 | void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { |
42 | bool needShow = false; | ||
41 | /* | 43 | /* |
42 | * create demands to create | 44 | * create demands to create |
43 | * a new record... | 45 | * a new record... |
44 | */ | 46 | */ |
45 | QDataStream stream(array, IO_ReadOnly); | 47 | QDataStream stream(array, IO_ReadOnly); |
46 | if ( cmd == "create()" ) { | 48 | if ( cmd == "create()" ) { |
49 | raise(); | ||
47 | int uid = create(); | 50 | int uid = create(); |
48 | QCopEnvelope e(m_str, "created(int)" ); | 51 | QCopEnvelope e(m_str, "created(int)" ); |
49 | e << uid; | 52 | e << uid; |
53 | needShow = true; | ||
50 | }else if ( cmd == "remove(int)" ) { | 54 | }else if ( cmd == "remove(int)" ) { |
51 | int uid; | 55 | int uid; |
52 | stream >> uid; | 56 | stream >> uid; |
53 | bool rem = remove( uid ); | 57 | bool rem = remove( uid ); |
54 | QCopEnvelope e(m_str, "removed(bool)" ); | 58 | QCopEnvelope e(m_str, "removed(bool)" ); |
55 | e << rem; | 59 | e << rem; |
60 | needShow = true; | ||
56 | }else if ( cmd == "beam(int)" ) { | 61 | }else if ( cmd == "beam(int)" ) { |
57 | int uid; | 62 | int uid; |
58 | stream >> uid; | 63 | stream >> uid; |
59 | beam( uid); | 64 | beam( uid); |
60 | }else if ( cmd == "show(int)" ) { | 65 | }else if ( cmd == "show(int)" ) { |
66 | raise(); | ||
61 | int uid; | 67 | int uid; |
62 | stream >> uid; | 68 | stream >> uid; |
63 | show( uid ); | 69 | show( uid ); |
70 | needShow = true; | ||
64 | }else if ( cmd == "edit(int)" ) { | 71 | }else if ( cmd == "edit(int)" ) { |
72 | raise(); | ||
65 | int uid; | 73 | int uid; |
66 | stream >> uid; | 74 | stream >> uid; |
67 | edit( uid ); | 75 | edit( uid ); |
68 | }else if ( cmd == "add(int,QByteArray)" ) { | 76 | }else if ( cmd == "add(int,QByteArray)" ) { |
69 | int rtti; | 77 | int rtti; |
70 | QByteArray array; | 78 | QByteArray array; |
71 | stream >> rtti; | 79 | stream >> rtti; |
72 | stream >> array; | 80 | stream >> array; |
73 | m_fallBack = record(rtti, array ); | 81 | m_fallBack = record(rtti, array ); |
74 | if (!m_fallBack) return; | 82 | if (!m_fallBack) return; |
75 | add( *m_fallBack ); | 83 | add( *m_fallBack ); |
76 | delete m_fallBack; | 84 | delete m_fallBack; |
77 | }else if ( cmd == "alarm(QDateTime,int)" ) { | 85 | }else if ( cmd == "alarm(QDateTime,int)" ) { |
86 | raise(); | ||
78 | QDateTime dt; int uid; | 87 | QDateTime dt; int uid; |
79 | stream >> dt; | 88 | stream >> dt; |
80 | stream >> uid; | 89 | stream >> uid; |
81 | qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid ); | 90 | qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid ); |
82 | QDateTime current = QDateTime::currentDateTime(); | 91 | QDateTime current = QDateTime::currentDateTime(); |
83 | if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) | 92 | if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) |
84 | return; | 93 | return; |
85 | doAlarm( dt, uid ); | 94 | doAlarm( dt, uid ); |
86 | 95 | needShow = true; | |
87 | } | 96 | } |
97 | |||
98 | if (needShow ) | ||
99 | QPEApplication::setKeepRunning(); | ||
88 | } | 100 | } |
89 | /* implement the url scripting here */ | 101 | /* implement the url scripting here */ |
90 | void OPimMainWindow::setDocument( const QString& str) { | 102 | void OPimMainWindow::setDocument( const QString& str) { |
91 | doSetDocument( str ); | 103 | doSetDocument( str ); |
92 | } | 104 | } |
93 | /* | 105 | /* |
94 | * we now try to get the array demarshalled | 106 | * we now try to get the array demarshalled |
95 | * check if the rtti matches this one | 107 | * check if the rtti matches this one |
96 | */ | 108 | */ |
97 | OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { | 109 | OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { |
98 | if ( service() != rtti ) | 110 | if ( service() != rtti ) |
99 | return 0l; | 111 | return 0l; |
100 | 112 | ||
101 | OPimRecord* record = OPimResolver::self()->record( rtti ); | 113 | OPimRecord* record = OPimResolver::self()->record( rtti ); |
102 | QDataStream str(array, IO_ReadOnly ); | 114 | QDataStream str(array, IO_ReadOnly ); |
103 | if ( !record || !record->loadFromStream(str) ) { | 115 | if ( !record || !record->loadFromStream(str) ) { |
104 | delete record; | 116 | delete record; |
105 | record = 0l; | 117 | record = 0l; |
106 | } | 118 | } |
107 | 119 | ||
108 | return record; | 120 | return record; |
109 | } | 121 | } |
110 | /* | 122 | /* |
111 | * get the rtti for the service | 123 | * get the rtti for the service |
112 | */ | 124 | */ |
113 | int OPimMainWindow::service() { | 125 | int OPimMainWindow::service() { |
114 | if ( m_rtti == -1 ) | 126 | if ( m_rtti == -1 ) |
115 | m_rtti = OPimResolver::self()->serviceId( m_service ); | 127 | m_rtti = OPimResolver::self()->serviceId( m_service ); |
116 | 128 | ||
117 | return m_rtti; | 129 | return m_rtti; |
118 | } | 130 | } |
119 | void OPimMainWindow::doAlarm( const QDateTime&, int ) { | 131 | void OPimMainWindow::doAlarm( const QDateTime&, int ) { |
120 | 132 | ||
121 | } | 133 | } |
122 | void OPimMainWindow::startAlarm(int count ) { | 134 | void OPimMainWindow::startAlarm(int count ) { |
123 | m_alarmCount = count; | 135 | m_alarmCount = count; |
124 | m_playedCount = 0; | 136 | m_playedCount = 0; |
125 | Sound::soundAlarm(); | 137 | Sound::soundAlarm(); |
126 | m_timerId = startTimer( 5000 ); | 138 | m_timerId = startTimer( 5000 ); |
127 | } | 139 | } |
128 | void OPimMainWindow::killAlarm() { | 140 | void OPimMainWindow::killAlarm() { |
129 | killTimer( m_timerId ); | 141 | killTimer( m_timerId ); |
130 | } | 142 | } |
131 | void OPimMainWindow::timerEvent( QTimerEvent* e) { | 143 | void OPimMainWindow::timerEvent( QTimerEvent* e) { |
132 | if ( m_playedCount <m_alarmCount ) { | 144 | if ( m_playedCount <m_alarmCount ) { |
133 | m_playedCount++; | 145 | m_playedCount++; |
134 | Sound::soundAlarm(); | 146 | Sound::soundAlarm(); |
135 | }else { | 147 | }else { |
136 | killTimer( e->timerId() ); | 148 | killTimer( e->timerId() ); |
137 | } | 149 | } |
138 | } | 150 | } |
diff --git a/libopie/pim/opimxrefmanager.h b/libopie/pim/opimxrefmanager.h index 39e5eef..c485e98 100644 --- a/libopie/pim/opimxrefmanager.h +++ b/libopie/pim/opimxrefmanager.h | |||
@@ -1,41 +1,43 @@ | |||
1 | #ifndef OPIM_XREF_MANAGER_H | 1 | #ifndef OPIM_XREF_MANAGER_H |
2 | #define OPIM_XREF_MANAGER_H | 2 | #define OPIM_XREF_MANAGER_H |
3 | 3 | ||
4 | #include <qstringlist.h> | 4 | #include <qstringlist.h> |
5 | 5 | ||
6 | #include <opie/opimxref.h> | 6 | #include <opie/opimxref.h> |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * This is a simple manager for | 9 | * This is a simple manager for |
10 | * OPimXRefs. | 10 | * OPimXRefs. |
11 | * It allows addition, removing, replacing | 11 | * It allows addition, removing, replacing |
12 | * clearing and 'querying' the XRef... | 12 | * clearing and 'querying' the XRef... |
13 | */ | 13 | */ |
14 | class OPimXRefManager { | 14 | class OPimXRefManager { |
15 | public: | 15 | public: |
16 | OPimXRefManager(); | 16 | OPimXRefManager(); |
17 | OPimXRefManager( const OPimXRefManager& ); | 17 | OPimXRefManager( const OPimXRefManager& ); |
18 | ~OPimXRefManager(); | 18 | ~OPimXRefManager(); |
19 | 19 | ||
20 | OPimXRefManager& operator=( const OPimXRefManager& ); | 20 | OPimXRefManager& operator=( const OPimXRefManager& ); |
21 | bool operator==( const OPimXRefManager& ); | 21 | bool operator==( const OPimXRefManager& ); |
22 | 22 | ||
23 | void add( const OPimXRef& ); | 23 | void add( const OPimXRef& ); |
24 | void remove( const OPimXRef& ); | 24 | void remove( const OPimXRef& ); |
25 | void replace( const OPimXRef& ); | 25 | void replace( const OPimXRef& ); |
26 | 26 | ||
27 | void clear(); | 27 | void clear(); |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * apps participating | 30 | * apps participating |
31 | */ | 31 | */ |
32 | QStringList apps()const; | 32 | QStringList apps()const; |
33 | OPimXRef::ValueList list()const; | 33 | OPimXRef::ValueList list()const; |
34 | OPimXRef::ValueList list( const QString& service )const; | 34 | OPimXRef::ValueList list( const QString& service )const; |
35 | OPimXRef::ValueList list( int uid )const; | 35 | OPimXRef::ValueList list( int uid )const; |
36 | 36 | ||
37 | private: | 37 | private: |
38 | OPimXRef::ValueList m_list; | 38 | OPimXRef::ValueList m_list; |
39 | class Private; | ||
40 | Private *d; | ||
39 | }; | 41 | }; |
40 | 42 | ||
41 | #endif | 43 | #endif |
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h index edcd729..5211f57 100644 --- a/libopie/pim/orecordlist.h +++ b/libopie/pim/orecordlist.h | |||
@@ -1,300 +1,306 @@ | |||
1 | 1 | ||
2 | #ifndef OPIE_RECORD_LIST_H | 2 | #ifndef OPIE_RECORD_LIST_H |
3 | #define OPIE_RECORD_LIST_H | 3 | #define OPIE_RECORD_LIST_H |
4 | 4 | ||
5 | #include <qarray.h> | 5 | #include <qarray.h> |
6 | 6 | ||
7 | #include "otemplatebase.h" | 7 | #include "otemplatebase.h" |
8 | #include "opimrecord.h" | 8 | #include "opimrecord.h" |
9 | 9 | ||
10 | class ORecordListIteratorPrivate; | ||
10 | /** | 11 | /** |
11 | * Our List Iterator | 12 | * Our List Iterator |
12 | * it behaves like STL or Qt | 13 | * it behaves like STL or Qt |
13 | * | 14 | * |
14 | * for(it = list.begin(); it != list.end(); ++it ) | 15 | * for(it = list.begin(); it != list.end(); ++it ) |
15 | * doSomeCoolStuff( (*it) ); | 16 | * doSomeCoolStuff( (*it) ); |
16 | */ | 17 | */ |
17 | template <class T> class ORecordList; | 18 | template <class T> class ORecordList; |
18 | template <class T = OPimRecord> | 19 | template <class T = OPimRecord> |
19 | class ORecordListIterator { | 20 | class ORecordListIterator { |
20 | friend class ORecordList<T>; | 21 | friend class ORecordList<T>; |
21 | public: | 22 | public: |
22 | typedef OTemplateBase<T> Base; | 23 | typedef OTemplateBase<T> Base; |
23 | 24 | ||
24 | /** | 25 | /** |
25 | * The c'tor used internally from | 26 | * The c'tor used internally from |
26 | * ORecordList | 27 | * ORecordList |
27 | */ | 28 | */ |
28 | ORecordListIterator( const QArray<int>, const Base* ); | 29 | ORecordListIterator( const QArray<int>, const Base* ); |
29 | 30 | ||
30 | /** | 31 | /** |
31 | * The standard c'tor | 32 | * The standard c'tor |
32 | */ | 33 | */ |
33 | ORecordListIterator(); | 34 | ORecordListIterator(); |
34 | ~ORecordListIterator(); | 35 | ~ORecordListIterator(); |
35 | 36 | ||
36 | ORecordListIterator( const ORecordListIterator& ); | 37 | ORecordListIterator( const ORecordListIterator& ); |
37 | ORecordListIterator &operator=(const ORecordListIterator& ); | 38 | ORecordListIterator &operator=(const ORecordListIterator& ); |
38 | 39 | ||
39 | /** | 40 | /** |
40 | * a * operator ;) | 41 | * a * operator ;) |
41 | * use it like this T = (*it); | 42 | * use it like this T = (*it); |
42 | */ | 43 | */ |
43 | T operator*(); | 44 | T operator*(); |
44 | ORecordListIterator &operator++(); | 45 | ORecordListIterator &operator++(); |
45 | ORecordListIterator &operator--(); | 46 | ORecordListIterator &operator--(); |
46 | 47 | ||
47 | bool operator==( const ORecordListIterator& it ); | 48 | bool operator==( const ORecordListIterator& it ); |
48 | bool operator!=( const ORecordListIterator& it ); | 49 | bool operator!=( const ORecordListIterator& it ); |
49 | 50 | ||
50 | /** | 51 | /** |
51 | * the current item | 52 | * the current item |
52 | */ | 53 | */ |
53 | uint current()const; | 54 | uint current()const; |
54 | 55 | ||
55 | /** | 56 | /** |
56 | * the number of items | 57 | * the number of items |
57 | */ | 58 | */ |
58 | uint count()const; | 59 | uint count()const; |
59 | 60 | ||
60 | /** | 61 | /** |
61 | * sets the current item | 62 | * sets the current item |
62 | */ | 63 | */ |
63 | void setCurrent( uint cur ); | 64 | void setCurrent( uint cur ); |
64 | 65 | ||
65 | private: | 66 | private: |
66 | QArray<int> m_uids; | 67 | QArray<int> m_uids; |
67 | uint m_current; | 68 | uint m_current; |
68 | const Base* m_temp; | 69 | const Base* m_temp; |
69 | bool m_end : 1; | 70 | bool m_end : 1; |
70 | T m_record; | 71 | T m_record; |
71 | bool m_direction :1; | 72 | bool m_direction :1; |
72 | 73 | ||
73 | /* d pointer for future versions */ | 74 | /* d pointer for future versions */ |
74 | class IteratorPrivate; | 75 | ORecordListIteratorPrivate *d; |
75 | IteratorPrivate *d; | ||
76 | }; | 76 | }; |
77 | |||
78 | class ORecordListPrivate; | ||
77 | /** | 79 | /** |
78 | * The recordlist used as a return type | 80 | * The recordlist used as a return type |
79 | * from OPimAccessTemplate | 81 | * from OPimAccessTemplate |
80 | */ | 82 | */ |
81 | template <class T = OPimRecord > | 83 | template <class T = OPimRecord > |
82 | class ORecordList { | 84 | class ORecordList { |
83 | public: | 85 | public: |
84 | typedef OTemplateBase<T> Base; | 86 | typedef OTemplateBase<T> Base; |
85 | typedef ORecordListIterator<T> Iterator; | 87 | typedef ORecordListIterator<T> Iterator; |
86 | 88 | ||
87 | /** | 89 | /** |
88 | * c'tor | 90 | * c'tor |
89 | */ | 91 | */ |
90 | ORecordList () { | 92 | ORecordList () { |
91 | } | 93 | } |
92 | ORecordList( const QArray<int>& ids, | 94 | ORecordList( const QArray<int>& ids, |
93 | const Base* ); | 95 | const Base* ); |
94 | ~ORecordList(); | 96 | ~ORecordList(); |
95 | 97 | ||
96 | /** | 98 | /** |
97 | * the first iterator | 99 | * the first iterator |
98 | */ | 100 | */ |
99 | Iterator begin(); | 101 | Iterator begin(); |
100 | 102 | ||
101 | /** | 103 | /** |
102 | * the end | 104 | * the end |
103 | */ | 105 | */ |
104 | Iterator end(); | 106 | Iterator end(); |
105 | 107 | ||
106 | /** | 108 | /** |
107 | * the number of items in the list | 109 | * the number of items in the list |
108 | */ | 110 | */ |
109 | uint count()const; | 111 | uint count()const; |
110 | 112 | ||
111 | T operator[]( uint i ); | 113 | T operator[]( uint i ); |
112 | int uidAt(uint i ); | 114 | int uidAt(uint i ); |
113 | 115 | ||
114 | /** | 116 | /** |
115 | * Remove the contact with given uid | 117 | * Remove the contact with given uid |
116 | */ | 118 | */ |
117 | bool remove( int uid ); | 119 | bool remove( int uid ); |
118 | 120 | ||
119 | /* | 121 | /* |
120 | ConstIterator begin()const; | 122 | ConstIterator begin()const; |
121 | ConstIterator end()const; | 123 | ConstIterator end()const; |
122 | */ | 124 | */ |
123 | private: | 125 | private: |
124 | QArray<int> m_ids; | 126 | QArray<int> m_ids; |
125 | const Base* m_acc; | 127 | const Base* m_acc; |
128 | ORecordListPrivate *d; | ||
126 | }; | 129 | }; |
127 | 130 | ||
128 | /* ok now implement it */ | 131 | /* ok now implement it */ |
129 | template <class T> | 132 | template <class T> |
130 | ORecordListIterator<T>::ORecordListIterator() { | 133 | ORecordListIterator<T>::ORecordListIterator() { |
131 | m_current = 0; | 134 | m_current = 0; |
132 | m_temp = 0l; | 135 | m_temp = 0l; |
133 | m_end = true; | 136 | m_end = true; |
134 | m_record = T(); | 137 | m_record = T(); |
135 | /* forward */ | 138 | /* forward */ |
136 | m_direction = TRUE; | 139 | m_direction = TRUE; |
137 | } | 140 | } |
138 | template <class T> | 141 | template <class T> |
139 | ORecordListIterator<T>::~ORecordListIterator() { | 142 | ORecordListIterator<T>::~ORecordListIterator() { |
140 | /* nothing to delete */ | 143 | /* nothing to delete */ |
141 | } | 144 | } |
142 | 145 | ||
143 | template <class T> | 146 | template <class T> |
144 | ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { | 147 | ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { |
145 | // qWarning("ORecordListIterator copy c'tor"); | 148 | // qWarning("ORecordListIterator copy c'tor"); |
146 | m_uids = it.m_uids; | 149 | m_uids = it.m_uids; |
147 | m_current = it.m_current; | 150 | m_current = it.m_current; |
148 | m_temp = it.m_temp; | 151 | m_temp = it.m_temp; |
149 | m_end = it.m_end; | 152 | m_end = it.m_end; |
150 | m_record = it.m_record; | 153 | m_record = it.m_record; |
151 | m_direction = it.m_direction; | 154 | m_direction = it.m_direction; |
152 | } | 155 | } |
153 | 156 | ||
154 | template <class T> | 157 | template <class T> |
155 | ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { | 158 | ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { |
156 | m_uids = it.m_uids; | 159 | m_uids = it.m_uids; |
157 | m_current = it.m_current; | 160 | m_current = it.m_current; |
158 | m_temp = it.m_temp; | 161 | m_temp = it.m_temp; |
159 | m_end = it.m_end; | 162 | m_end = it.m_end; |
160 | m_record = it.m_record; | 163 | m_record = it.m_record; |
161 | 164 | ||
162 | return *this; | 165 | return *this; |
163 | } | 166 | } |
164 | 167 | ||
165 | template <class T> | 168 | template <class T> |
166 | T ORecordListIterator<T>::operator*() { | 169 | T ORecordListIterator<T>::operator*() { |
167 | //qWarning("operator* %d %d", m_current, m_uids[m_current] ); | 170 | //qWarning("operator* %d %d", m_current, m_uids[m_current] ); |
168 | if (!m_end ) | 171 | if (!m_end ) |
169 | m_record = m_temp->find( m_uids[m_current], m_uids, m_current, | 172 | m_record = m_temp->find( m_uids[m_current], m_uids, m_current, |
170 | m_direction ? Base::Forward : | 173 | m_direction ? Base::Forward : |
171 | Base::Reverse ); | 174 | Base::Reverse ); |
172 | else | 175 | else |
173 | m_record = T(); | 176 | m_record = T(); |
174 | 177 | ||
175 | return m_record; | 178 | return m_record; |
176 | } | 179 | } |
177 | 180 | ||
178 | template <class T> | 181 | template <class T> |
179 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { | 182 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { |
180 | m_direction = true; | 183 | m_direction = true; |
181 | if (m_current < m_uids.count() ) { | 184 | if (m_current < m_uids.count() ) { |
182 | m_end = false; | 185 | m_end = false; |
183 | ++m_current; | 186 | ++m_current; |
184 | }else | 187 | }else |
185 | m_end = true; | 188 | m_end = true; |
186 | 189 | ||
187 | return *this; | 190 | return *this; |
188 | } | 191 | } |
189 | template <class T> | 192 | template <class T> |
190 | ORecordListIterator<T> &ORecordListIterator<T>::operator--() { | 193 | ORecordListIterator<T> &ORecordListIterator<T>::operator--() { |
191 | m_direction = false; | 194 | m_direction = false; |
192 | if ( m_current > 0 ) { | 195 | if ( m_current > 0 ) { |
193 | --m_current; | 196 | --m_current; |
194 | m_end = false; | 197 | m_end = false; |
195 | } else | 198 | } else |
196 | m_end = true; | 199 | m_end = true; |
197 | 200 | ||
198 | return *this; | 201 | return *this; |
199 | } | 202 | } |
200 | 203 | ||
201 | template <class T> | 204 | template <class T> |
202 | bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { | 205 | bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { |
203 | 206 | ||
204 | /* if both are at we're the same.... */ | 207 | /* if both are at we're the same.... */ |
205 | if ( m_end == it.m_end ) return true; | 208 | if ( m_end == it.m_end ) return true; |
206 | 209 | ||
207 | if ( m_uids != it.m_uids ) return false; | 210 | if ( m_uids != it.m_uids ) return false; |
208 | if ( m_current != it.m_current ) return false; | 211 | if ( m_current != it.m_current ) return false; |
209 | if ( m_temp != it.m_temp ) return false; | 212 | if ( m_temp != it.m_temp ) return false; |
210 | 213 | ||
211 | return true; | 214 | return true; |
212 | } | 215 | } |
213 | template <class T> | 216 | template <class T> |
214 | bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { | 217 | bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { |
215 | return !(*this == it ); | 218 | return !(*this == it ); |
216 | } | 219 | } |
217 | template <class T> | 220 | template <class T> |
218 | ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, | 221 | ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, |
219 | const Base* t ) | 222 | const Base* t ) |
220 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), | 223 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), |
221 | m_direction( false ) | 224 | m_direction( false ) |
222 | { | 225 | { |
226 | /* if the list is empty we're already at the end of the list */ | ||
227 | if (uids.count() == 0 ) | ||
228 | m_end = true; | ||
223 | } | 229 | } |
224 | template <class T> | 230 | template <class T> |
225 | uint ORecordListIterator<T>::current()const { | 231 | uint ORecordListIterator<T>::current()const { |
226 | return m_current; | 232 | return m_current; |
227 | } | 233 | } |
228 | template <class T> | 234 | template <class T> |
229 | void ORecordListIterator<T>::setCurrent( uint cur ) { | 235 | void ORecordListIterator<T>::setCurrent( uint cur ) { |
230 | if( cur < m_uids.count() ) { | 236 | if( cur < m_uids.count() ) { |
231 | m_end = false; | 237 | m_end = false; |
232 | m_current= cur; | 238 | m_current= cur; |
233 | } | 239 | } |
234 | } | 240 | } |
235 | template <class T> | 241 | template <class T> |
236 | uint ORecordListIterator<T>::count()const { | 242 | uint ORecordListIterator<T>::count()const { |
237 | return m_uids.count(); | 243 | return m_uids.count(); |
238 | } | 244 | } |
239 | template <class T> | 245 | template <class T> |
240 | ORecordList<T>::ORecordList( const QArray<int>& ids, | 246 | ORecordList<T>::ORecordList( const QArray<int>& ids, |
241 | const Base* acc ) | 247 | const Base* acc ) |
242 | : m_ids( ids ), m_acc( acc ) | 248 | : m_ids( ids ), m_acc( acc ) |
243 | { | 249 | { |
244 | } | 250 | } |
245 | template <class T> | 251 | template <class T> |
246 | ORecordList<T>::~ORecordList() { | 252 | ORecordList<T>::~ORecordList() { |
247 | /* nothing to do here */ | 253 | /* nothing to do here */ |
248 | } | 254 | } |
249 | template <class T> | 255 | template <class T> |
250 | typename ORecordList<T>::Iterator ORecordList<T>::begin() { | 256 | typename ORecordList<T>::Iterator ORecordList<T>::begin() { |
251 | Iterator it( m_ids, m_acc ); | 257 | Iterator it( m_ids, m_acc ); |
252 | return it; | 258 | return it; |
253 | } | 259 | } |
254 | template <class T> | 260 | template <class T> |
255 | typename ORecordList<T>::Iterator ORecordList<T>::end() { | 261 | typename ORecordList<T>::Iterator ORecordList<T>::end() { |
256 | Iterator it( m_ids, m_acc ); | 262 | Iterator it( m_ids, m_acc ); |
257 | it.m_end = true; | 263 | it.m_end = true; |
258 | it.m_current = m_ids.count(); | 264 | it.m_current = m_ids.count(); |
259 | 265 | ||
260 | return it; | 266 | return it; |
261 | } | 267 | } |
262 | template <class T> | 268 | template <class T> |
263 | uint ORecordList<T>::count()const { | 269 | uint ORecordList<T>::count()const { |
264 | return m_ids.count(); | 270 | return m_ids.count(); |
265 | } | 271 | } |
266 | template <class T> | 272 | template <class T> |
267 | T ORecordList<T>::operator[]( uint i ) { | 273 | T ORecordList<T>::operator[]( uint i ) { |
268 | if ( i >= m_ids.count() ) | 274 | if ( i >= m_ids.count() ) |
269 | return T(); | 275 | return T(); |
270 | /* forward */ | 276 | /* forward */ |
271 | return m_acc->find( m_ids[i], m_ids, i ); | 277 | return m_acc->find( m_ids[i], m_ids, i ); |
272 | } | 278 | } |
273 | template <class T> | 279 | template <class T> |
274 | int ORecordList<T>::uidAt( uint i ) { | 280 | int ORecordList<T>::uidAt( uint i ) { |
275 | return m_ids[i]; | 281 | return m_ids[i]; |
276 | } | 282 | } |
277 | 283 | ||
278 | template <class T> | 284 | template <class T> |
279 | bool ORecordList<T>::remove( int uid ) { | 285 | bool ORecordList<T>::remove( int uid ) { |
280 | QArray<int> copy( m_ids.count() ); | 286 | QArray<int> copy( m_ids.count() ); |
281 | int counter = 0; | 287 | int counter = 0; |
282 | bool ret_val = false; | 288 | bool ret_val = false; |
283 | 289 | ||
284 | for (uint i = 0; i < m_ids.count(); i++){ | 290 | for (uint i = 0; i < m_ids.count(); i++){ |
285 | if ( m_ids[i] != uid ){ | 291 | if ( m_ids[i] != uid ){ |
286 | copy[counter++] = m_ids[i]; | 292 | copy[counter++] = m_ids[i]; |
287 | 293 | ||
288 | }else | 294 | }else |
289 | ret_val = true; | 295 | ret_val = true; |
290 | } | 296 | } |
291 | 297 | ||
292 | copy.resize( counter ); | 298 | copy.resize( counter ); |
293 | m_ids = copy; | 299 | m_ids = copy; |
294 | 300 | ||
295 | 301 | ||
296 | return ret_val; | 302 | return ret_val; |
297 | } | 303 | } |
298 | 304 | ||
299 | 305 | ||
300 | #endif | 306 | #endif |
diff --git a/libopie/pim/otemplatebase.h b/libopie/pim/otemplatebase.h index 29fb6ec..cadac74 100644 --- a/libopie/pim/otemplatebase.h +++ b/libopie/pim/otemplatebase.h | |||
@@ -1,91 +1,98 @@ | |||
1 | #ifndef OPIE_TEMPLATE_BASE_H | 1 | #ifndef OPIE_TEMPLATE_BASE_H |
2 | #define OPIE_TEMPLATE_BASE_H | 2 | #define OPIE_TEMPLATE_BASE_H |
3 | 3 | ||
4 | #include <qarray.h> | 4 | #include <qarray.h> |
5 | 5 | ||
6 | #include <opie/opimrecord.h> | 6 | #include <opie/opimrecord.h> |
7 | 7 | ||
8 | 8 | ||
9 | /** | 9 | /** |
10 | * Templates do not have a base class, This is why | 10 | * Templates do not have a base class, This is why |
11 | * we've this class | 11 | * we've this class |
12 | * this is here to give us the possibility | 12 | * this is here to give us the possibility |
13 | * to have a common base class | 13 | * to have a common base class |
14 | * You may not want to use that interface internaly | 14 | * You may not want to use that interface internaly |
15 | * POOR mans interface | 15 | * POOR mans interface |
16 | */ | 16 | */ |
17 | class OPimBasePrivate; | ||
17 | struct OPimBase { | 18 | struct OPimBase { |
18 | /** | 19 | /** |
19 | * return the rtti | 20 | * return the rtti |
20 | */ | 21 | */ |
21 | virtual int rtti()= 0; | 22 | virtual int rtti()= 0; |
22 | virtual OPimRecord* record()const = 0; | 23 | virtual OPimRecord* record()const = 0; |
23 | virtual OPimRecord* record(int uid)const = 0; | 24 | virtual OPimRecord* record(int uid)const = 0; |
24 | virtual bool add( const OPimRecord& ) = 0; | 25 | virtual bool add( const OPimRecord& ) = 0; |
25 | virtual bool remove( int uid ) = 0; | 26 | virtual bool remove( int uid ) = 0; |
26 | virtual bool remove( const OPimRecord& ) = 0; | 27 | virtual bool remove( const OPimRecord& ) = 0; |
27 | virtual void clear() = 0; | 28 | virtual void clear() = 0; |
28 | virtual bool load() = 0; | 29 | virtual bool load() = 0; |
29 | virtual bool save() = 0; | 30 | virtual bool save() = 0; |
30 | virtual QArray<int> records()const = 0; | 31 | virtual QArray<int> records()const = 0; |
31 | /* | 32 | /* |
32 | * ADD editing here? | 33 | * ADD editing here? |
33 | * -zecke | 34 | * -zecke |
34 | */ | 35 | */ |
36 | private: | ||
37 | OPimBasePrivate* d; | ||
35 | 38 | ||
36 | }; | 39 | }; |
37 | /** | 40 | /** |
38 | * internal template base | 41 | * internal template base |
39 | * T needs to implement the copy c'tor!!! | 42 | * T needs to implement the copy c'tor!!! |
40 | */ | 43 | */ |
44 | class OTemplateBasePrivate; | ||
41 | template <class T = OPimRecord> | 45 | template <class T = OPimRecord> |
42 | class OTemplateBase : public OPimBase { | 46 | class OTemplateBase : public OPimBase { |
43 | public: | 47 | public: |
44 | enum CacheDirection { Forward=0, Reverse }; | 48 | enum CacheDirection { Forward=0, Reverse }; |
45 | OTemplateBase() { | 49 | OTemplateBase() { |
46 | }; | 50 | }; |
47 | virtual ~OTemplateBase() { | 51 | virtual ~OTemplateBase() { |
48 | } | 52 | } |
49 | virtual T find( int uid )const = 0; | 53 | virtual T find( int uid )const = 0; |
50 | 54 | ||
51 | /** | 55 | /** |
52 | * read ahead find | 56 | * read ahead find |
53 | */ | 57 | */ |
54 | virtual T find( int uid, const QArray<int>& items, | 58 | virtual T find( int uid, const QArray<int>& items, |
55 | uint current, CacheDirection dir = Forward )const = 0; | 59 | uint current, CacheDirection dir = Forward )const = 0; |
56 | virtual void cache( const T& )const = 0; | 60 | virtual void cache( const T& )const = 0; |
57 | virtual void setSaneCacheSize( int ) = 0; | 61 | virtual void setSaneCacheSize( int ) = 0; |
58 | 62 | ||
59 | /* reimplement of OPimBase */ | 63 | /* reimplement of OPimBase */ |
60 | int rtti(); | 64 | int rtti(); |
61 | OPimRecord* record()const; | 65 | OPimRecord* record()const; |
62 | OPimRecord* record(int uid )const; | 66 | OPimRecord* record(int uid )const; |
63 | static T* rec(); | 67 | static T* rec(); |
68 | |||
69 | private: | ||
70 | OTemplateBasePrivate *d; | ||
64 | }; | 71 | }; |
65 | 72 | ||
66 | /* | 73 | /* |
67 | * implementation | 74 | * implementation |
68 | */ | 75 | */ |
69 | template <class T> | 76 | template <class T> |
70 | int | 77 | int |
71 | OTemplateBase<T>::rtti() { | 78 | OTemplateBase<T>::rtti() { |
72 | return T::rtti(); | 79 | return T::rtti(); |
73 | } | 80 | } |
74 | template <class T> | 81 | template <class T> |
75 | OPimRecord* OTemplateBase<T>::record()const { | 82 | OPimRecord* OTemplateBase<T>::record()const { |
76 | T* t = new T; | 83 | T* t = new T; |
77 | return t; | 84 | return t; |
78 | } | 85 | } |
79 | template <class T> | 86 | template <class T> |
80 | OPimRecord* OTemplateBase<T>::record(int uid )const { | 87 | OPimRecord* OTemplateBase<T>::record(int uid )const { |
81 | T t2 = find(uid ); | 88 | T t2 = find(uid ); |
82 | T* t1 = new T(t2); | 89 | T* t1 = new T(t2); |
83 | 90 | ||
84 | return t1; | 91 | return t1; |
85 | }; | 92 | }; |
86 | template <class T> | 93 | template <class T> |
87 | T* OTemplateBase<T>::rec() { | 94 | T* OTemplateBase<T>::rec() { |
88 | return new T; | 95 | return new T; |
89 | } | 96 | } |
90 | 97 | ||
91 | #endif | 98 | #endif |
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp index 38b93f7..5a18c37 100644 --- a/libopie/pim/otodo.cpp +++ b/libopie/pim/otodo.cpp | |||
@@ -1,126 +1,131 @@ | |||
1 | 1 | ||
2 | #include <qobject.h> | 2 | #include <qobject.h> |
3 | #include <qshared.h> | 3 | #include <qshared.h> |
4 | 4 | ||
5 | 5 | ||
6 | 6 | ||
7 | #include <qpe/palmtopuidgen.h> | 7 | #include <qpe/palmtopuidgen.h> |
8 | #include <qpe/stringutil.h> | 8 | #include <qpe/stringutil.h> |
9 | #include <qpe/palmtoprecord.h> | 9 | #include <qpe/palmtoprecord.h> |
10 | #include <qpe/stringutil.h> | 10 | #include <qpe/stringutil.h> |
11 | #include <qpe/categories.h> | 11 | #include <qpe/categories.h> |
12 | #include <qpe/categoryselect.h> | 12 | #include <qpe/categoryselect.h> |
13 | 13 | ||
14 | 14 | ||
15 | #include "opimstate.h" | 15 | #include "opimstate.h" |
16 | #include "orecur.h" | 16 | #include "orecur.h" |
17 | #include "opimmaintainer.h" | 17 | #include "opimmaintainer.h" |
18 | #include "opimnotifymanager.h" | 18 | #include "opimnotifymanager.h" |
19 | #include "opimresolver.h" | 19 | #include "opimresolver.h" |
20 | 20 | ||
21 | #include "otodo.h" | 21 | #include "otodo.h" |
22 | 22 | ||
23 | 23 | ||
24 | struct OTodo::OTodoData : public QShared { | 24 | struct OTodo::OTodoData : public QShared { |
25 | OTodoData() : QShared() { | 25 | OTodoData() : QShared() { |
26 | recur = 0; | 26 | recur = 0; |
27 | state = 0; | 27 | state = 0; |
28 | maintainer = 0; | 28 | maintainer = 0; |
29 | notifiers = 0; | 29 | notifiers = 0; |
30 | }; | 30 | }; |
31 | ~OTodoData() { | ||
32 | delete recur; | ||
33 | delete maintainer; | ||
34 | delete notifiers; | ||
35 | } | ||
31 | 36 | ||
32 | QDate date; | 37 | QDate date; |
33 | bool isCompleted:1; | 38 | bool isCompleted:1; |
34 | bool hasDate:1; | 39 | bool hasDate:1; |
35 | int priority; | 40 | int priority; |
36 | QString desc; | 41 | QString desc; |
37 | QString sum; | 42 | QString sum; |
38 | QMap<QString, QString> extra; | 43 | QMap<QString, QString> extra; |
39 | ushort prog; | 44 | ushort prog; |
40 | OPimState *state; | 45 | OPimState *state; |
41 | ORecur *recur; | 46 | ORecur *recur; |
42 | OPimMaintainer *maintainer; | 47 | OPimMaintainer *maintainer; |
43 | QDate start; | 48 | QDate start; |
44 | QDate completed; | 49 | QDate completed; |
45 | OPimNotifyManager *notifiers; | 50 | OPimNotifyManager *notifiers; |
46 | }; | 51 | }; |
47 | 52 | ||
48 | OTodo::OTodo(const OTodo &event ) | 53 | OTodo::OTodo(const OTodo &event ) |
49 | : OPimRecord( event ), data( event.data ) | 54 | : OPimRecord( event ), data( event.data ) |
50 | { | 55 | { |
51 | data->ref(); | 56 | data->ref(); |
52 | // qWarning("ref up"); | 57 | // qWarning("ref up"); |
53 | } | 58 | } |
54 | OTodo::~OTodo() { | 59 | OTodo::~OTodo() { |
55 | 60 | ||
56 | // qWarning("~OTodo " ); | 61 | // qWarning("~OTodo " ); |
57 | if ( data->deref() ) { | 62 | if ( data->deref() ) { |
58 | // qWarning("OTodo::dereffing"); | 63 | // qWarning("OTodo::dereffing"); |
59 | delete data; | 64 | delete data; |
60 | data = 0l; | 65 | data = 0l; |
61 | } | 66 | } |
62 | } | 67 | } |
63 | OTodo::OTodo(bool completed, int priority, | 68 | OTodo::OTodo(bool completed, int priority, |
64 | const QArray<int> &category, | 69 | const QArray<int> &category, |
65 | const QString& summary, | 70 | const QString& summary, |
66 | const QString &description, | 71 | const QString &description, |
67 | ushort progress, | 72 | ushort progress, |
68 | bool hasDate, QDate date, int uid ) | 73 | bool hasDate, QDate date, int uid ) |
69 | : OPimRecord( uid ) | 74 | : OPimRecord( uid ) |
70 | { | 75 | { |
71 | // qWarning("OTodoData " + summary); | 76 | // qWarning("OTodoData " + summary); |
72 | setCategories( category ); | 77 | setCategories( category ); |
73 | 78 | ||
74 | data = new OTodoData; | 79 | data = new OTodoData; |
75 | 80 | ||
76 | data->date = date; | 81 | data->date = date; |
77 | data->isCompleted = completed; | 82 | data->isCompleted = completed; |
78 | data->hasDate = hasDate; | 83 | data->hasDate = hasDate; |
79 | data->priority = priority; | 84 | data->priority = priority; |
80 | data->sum = summary; | 85 | data->sum = summary; |
81 | data->prog = progress; | 86 | data->prog = progress; |
82 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 87 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
83 | } | 88 | } |
84 | OTodo::OTodo(bool completed, int priority, | 89 | OTodo::OTodo(bool completed, int priority, |
85 | const QStringList &category, | 90 | const QStringList &category, |
86 | const QString& summary, | 91 | const QString& summary, |
87 | const QString &description, | 92 | const QString &description, |
88 | ushort progress, | 93 | ushort progress, |
89 | bool hasDate, QDate date, int uid ) | 94 | bool hasDate, QDate date, int uid ) |
90 | : OPimRecord( uid ) | 95 | : OPimRecord( uid ) |
91 | { | 96 | { |
92 | // qWarning("OTodoData" + summary); | 97 | // qWarning("OTodoData" + summary); |
93 | setCategories( idsFromString( category.join(";") ) ); | 98 | setCategories( idsFromString( category.join(";") ) ); |
94 | 99 | ||
95 | data = new OTodoData; | 100 | data = new OTodoData; |
96 | 101 | ||
97 | data->date = date; | 102 | data->date = date; |
98 | data->isCompleted = completed; | 103 | data->isCompleted = completed; |
99 | data->hasDate = hasDate; | 104 | data->hasDate = hasDate; |
100 | data->priority = priority; | 105 | data->priority = priority; |
101 | data->sum = summary; | 106 | data->sum = summary; |
102 | data->prog = progress; | 107 | data->prog = progress; |
103 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 108 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
104 | } | 109 | } |
105 | bool OTodo::match( const QRegExp ®Exp )const | 110 | bool OTodo::match( const QRegExp ®Exp )const |
106 | { | 111 | { |
107 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 112 | if( QString::number( data->priority ).find( regExp ) != -1 ){ |
108 | setLastHitField( Priority ); | 113 | setLastHitField( Priority ); |
109 | return true; | 114 | return true; |
110 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ | 115 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ |
111 | setLastHitField( HasDate ); | 116 | setLastHitField( HasDate ); |
112 | return true; | 117 | return true; |
113 | }else if(data->desc.find( regExp ) != -1 ){ | 118 | }else if(data->desc.find( regExp ) != -1 ){ |
114 | setLastHitField( Description ); | 119 | setLastHitField( Description ); |
115 | return true; | 120 | return true; |
116 | }else if(data->sum.find( regExp ) != -1 ) { | 121 | }else if(data->sum.find( regExp ) != -1 ) { |
117 | setLastHitField( Summary ); | 122 | setLastHitField( Summary ); |
118 | return true; | 123 | return true; |
119 | } | 124 | } |
120 | return false; | 125 | return false; |
121 | } | 126 | } |
122 | bool OTodo::isCompleted() const | 127 | bool OTodo::isCompleted() const |
123 | { | 128 | { |
124 | return data->isCompleted; | 129 | return data->isCompleted; |
125 | } | 130 | } |
126 | bool OTodo::hasDueDate() const | 131 | bool OTodo::hasDueDate() const |
@@ -181,210 +186,209 @@ ORecur OTodo::recurrence()const { | |||
181 | return (*data->recur); | 186 | return (*data->recur); |
182 | } | 187 | } |
183 | bool OTodo::hasMaintainer()const { | 188 | bool OTodo::hasMaintainer()const { |
184 | if (!data->maintainer) return false; | 189 | if (!data->maintainer) return false; |
185 | 190 | ||
186 | return (data->maintainer->mode() != OPimMaintainer::Undefined ); | 191 | return (data->maintainer->mode() != OPimMaintainer::Undefined ); |
187 | } | 192 | } |
188 | OPimMaintainer OTodo::maintainer()const { | 193 | OPimMaintainer OTodo::maintainer()const { |
189 | if (!data->maintainer) return OPimMaintainer(); | 194 | if (!data->maintainer) return OPimMaintainer(); |
190 | 195 | ||
191 | return (*data->maintainer); | 196 | return (*data->maintainer); |
192 | } | 197 | } |
193 | void OTodo::setCompleted( bool completed ) | 198 | void OTodo::setCompleted( bool completed ) |
194 | { | 199 | { |
195 | changeOrModify(); | 200 | changeOrModify(); |
196 | data->isCompleted = completed; | 201 | data->isCompleted = completed; |
197 | } | 202 | } |
198 | void OTodo::setHasDueDate( bool hasDate ) | 203 | void OTodo::setHasDueDate( bool hasDate ) |
199 | { | 204 | { |
200 | changeOrModify(); | 205 | changeOrModify(); |
201 | data->hasDate = hasDate; | 206 | data->hasDate = hasDate; |
202 | } | 207 | } |
203 | void OTodo::setDescription(const QString &desc ) | 208 | void OTodo::setDescription(const QString &desc ) |
204 | { | 209 | { |
205 | // qWarning( "desc " + desc ); | 210 | // qWarning( "desc " + desc ); |
206 | changeOrModify(); | 211 | changeOrModify(); |
207 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); | 212 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); |
208 | } | 213 | } |
209 | void OTodo::setSummary( const QString& sum ) | 214 | void OTodo::setSummary( const QString& sum ) |
210 | { | 215 | { |
211 | changeOrModify(); | 216 | changeOrModify(); |
212 | data->sum = sum; | 217 | data->sum = sum; |
213 | } | 218 | } |
214 | void OTodo::setPriority(int prio ) | 219 | void OTodo::setPriority(int prio ) |
215 | { | 220 | { |
216 | changeOrModify(); | 221 | changeOrModify(); |
217 | data->priority = prio; | 222 | data->priority = prio; |
218 | } | 223 | } |
219 | void OTodo::setDueDate( const QDate& date ) | 224 | void OTodo::setDueDate( const QDate& date ) |
220 | { | 225 | { |
221 | changeOrModify(); | 226 | changeOrModify(); |
222 | data->date = date; | 227 | data->date = date; |
223 | } | 228 | } |
224 | void OTodo::setStartDate( const QDate& date ) { | 229 | void OTodo::setStartDate( const QDate& date ) { |
225 | changeOrModify(); | 230 | changeOrModify(); |
226 | data->start = date; | 231 | data->start = date; |
227 | } | 232 | } |
228 | void OTodo::setCompletedDate( const QDate& date ) { | 233 | void OTodo::setCompletedDate( const QDate& date ) { |
229 | changeOrModify(); | 234 | changeOrModify(); |
230 | data->completed = date; | 235 | data->completed = date; |
231 | } | 236 | } |
232 | void OTodo::setState( const OPimState& state ) { | 237 | void OTodo::setState( const OPimState& state ) { |
233 | changeOrModify(); | 238 | changeOrModify(); |
234 | if (data->state ) | 239 | if (data->state ) |
235 | (*data->state) = state; | 240 | (*data->state) = state; |
236 | else | 241 | else |
237 | data->state = new OPimState( state ); | 242 | data->state = new OPimState( state ); |
238 | } | 243 | } |
239 | void OTodo::setRecurrence( const ORecur& rec) { | 244 | void OTodo::setRecurrence( const ORecur& rec) { |
240 | changeOrModify(); | 245 | changeOrModify(); |
241 | if (data->recur ) | 246 | if (data->recur ) |
242 | (*data->recur) = rec; | 247 | (*data->recur) = rec; |
243 | else | 248 | else |
244 | data->recur = new ORecur( rec ); | 249 | data->recur = new ORecur( rec ); |
245 | } | 250 | } |
246 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { | 251 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { |
247 | changeOrModify(); | 252 | changeOrModify(); |
248 | 253 | ||
249 | if (data->maintainer ) | 254 | if (data->maintainer ) |
250 | (*data->maintainer) = pim; | 255 | (*data->maintainer) = pim; |
251 | else | 256 | else |
252 | data->maintainer = new OPimMaintainer( pim ); | 257 | data->maintainer = new OPimMaintainer( pim ); |
253 | } | 258 | } |
254 | bool OTodo::isOverdue( ) | 259 | bool OTodo::isOverdue( ) |
255 | { | 260 | { |
256 | if( data->hasDate && !data->isCompleted) | 261 | if( data->hasDate && !data->isCompleted) |
257 | return QDate::currentDate() > data->date; | 262 | return QDate::currentDate() > data->date; |
258 | return false; | 263 | return false; |
259 | } | 264 | } |
260 | void OTodo::setProgress(ushort progress ) | 265 | void OTodo::setProgress(ushort progress ) |
261 | { | 266 | { |
262 | changeOrModify(); | 267 | changeOrModify(); |
263 | data->prog = progress; | 268 | data->prog = progress; |
264 | } | 269 | } |
265 | QString OTodo::toShortText() const { | 270 | QString OTodo::toShortText() const { |
266 | return summary(); | 271 | return summary(); |
267 | } | 272 | } |
268 | /*! | 273 | /*! |
269 | Returns a richt text string | 274 | Returns a richt text string |
270 | */ | 275 | */ |
271 | QString OTodo::toRichText() const | 276 | QString OTodo::toRichText() const |
272 | { | 277 | { |
273 | QString text; | 278 | QString text; |
274 | QStringList catlist; | 279 | QStringList catlist; |
275 | 280 | ||
276 | // summary | 281 | // summary |
277 | text += "<b><h3><img src=\"todo/TodoList\">"; | 282 | text += "<b><h3><img src=\"todo/TodoList\"> "; |
278 | if ( !summary().isEmpty() ) { | 283 | if ( !summary().isEmpty() ) { |
279 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); | 284 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); |
280 | } | 285 | } |
281 | text += "</h3></b><br><hr><br>"; | 286 | text += "</h3></b><br><hr><br>"; |
282 | 287 | ||
283 | // description | 288 | // description |
284 | if( !description().isEmpty() ){ | 289 | if( !description().isEmpty() ){ |
285 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 290 | text += "<b>" + QObject::tr( "Notes:" ) + "</b><br>"; |
286 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; | 291 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
287 | } | 292 | } |
288 | 293 | ||
289 | // priority | 294 | // priority |
290 | int priorityval = priority(); | 295 | int priorityval = priority(); |
291 | text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" + | 296 | text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" + |
292 | QString::number( priorityval ) + "\">"; | 297 | QString::number( priorityval ) + "\"> "; |
293 | // text += "<b>" + QObject::tr( "Priority:") +"</b><img src=\"todo/priority" + | 298 | |
294 | // QString::number( priority() ) + "\"><br>"; | ||
295 | switch ( priorityval ) | 299 | switch ( priorityval ) |
296 | { | 300 | { |
297 | case 1 : text += QObject::tr( "Very high" ); | 301 | case 1 : text += QObject::tr( "Very high" ); |
298 | break; | 302 | break; |
299 | case 2 : text += QObject::tr( "High" ); | 303 | case 2 : text += QObject::tr( "High" ); |
300 | break; | 304 | break; |
301 | case 3 : text += QObject::tr( "Normal" ); | 305 | case 3 : text += QObject::tr( "Normal" ); |
302 | break; | 306 | break; |
303 | case 4 : text += QObject::tr( "Low" ); | 307 | case 4 : text += QObject::tr( "Low" ); |
304 | break; | 308 | break; |
305 | case 5 : text += QObject::tr( "Very low" ); | 309 | case 5 : text += QObject::tr( "Very low" ); |
306 | break; | 310 | break; |
307 | }; | 311 | }; |
308 | text += "<br>"; | 312 | text += "<br>"; |
309 | 313 | ||
310 | // progress | 314 | // progress |
311 | text += "<b>" + QObject::tr( "Progress:") + " </b>" | 315 | text += "<b>" + QObject::tr( "Progress:") + " </b>" |
312 | + QString::number( progress() ) + " %<br>"; | 316 | + QString::number( progress() ) + " %<br>"; |
313 | 317 | ||
314 | // due date | 318 | // due date |
315 | if (hasDueDate() ){ | 319 | if (hasDueDate() ){ |
316 | QDate dd = dueDate(); | 320 | QDate dd = dueDate(); |
317 | int off = QDate::currentDate().daysTo( dd ); | 321 | int off = QDate::currentDate().daysTo( dd ); |
318 | 322 | ||
319 | text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; | 323 | text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; |
320 | if ( off < 0 ) | 324 | if ( off < 0 ) |
321 | text += "#FF0000"; | 325 | text += "#FF0000"; |
322 | else if ( off == 0 ) | 326 | else if ( off == 0 ) |
323 | text += "#FFFF00"; | 327 | text += "#FFFF00"; |
324 | else if ( off > 0 ) | 328 | else if ( off > 0 ) |
325 | text += "#00FF00"; | 329 | text += "#00FF00"; |
326 | 330 | ||
327 | text += "\">" + dd.toString() + "</font><br>"; | 331 | text += "\">" + dd.toString() + "</font><br>"; |
328 | } | 332 | } |
329 | 333 | ||
330 | // categories | 334 | // categories |
331 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 335 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
332 | text += categoryNames( "Todo List" ).join(", "); | 336 | text += categoryNames( "Todo List" ).join(", "); |
333 | text += "<br>"; | 337 | text += "<br>"; |
334 | 338 | ||
335 | return text; | 339 | return text; |
336 | } | 340 | } |
337 | bool OTodo::hasNotifiers()const { | 341 | bool OTodo::hasNotifiers()const { |
338 | if (!data->notifiers) return false; | 342 | if (!data->notifiers) return false; |
339 | return !data->notifiers->isEmpty(); | 343 | return !data->notifiers->isEmpty(); |
340 | } | 344 | } |
341 | OPimNotifyManager& OTodo::notifiers() { | 345 | OPimNotifyManager& OTodo::notifiers() { |
342 | if (!data->notifiers ) | 346 | if (!data->notifiers ) |
343 | data->notifiers = new OPimNotifyManager; | 347 | data->notifiers = new OPimNotifyManager; |
344 | return (*data->notifiers); | 348 | return (*data->notifiers); |
345 | } | 349 | } |
346 | const OPimNotifyManager& OTodo::notifiers()const{ | 350 | const OPimNotifyManager& OTodo::notifiers()const{ |
347 | if (!data->notifiers ) | 351 | if (!data->notifiers ) |
348 | data->notifiers = new OPimNotifyManager; | 352 | data->notifiers = new OPimNotifyManager; |
349 | 353 | ||
350 | return (*data->notifiers); | 354 | return (*data->notifiers); |
351 | } | 355 | } |
352 | 356 | ||
353 | bool OTodo::operator<( const OTodo &toDoEvent )const{ | 357 | bool OTodo::operator<( const OTodo &toDoEvent )const{ |
354 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 358 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
355 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 359 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
356 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 360 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
357 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 361 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
358 | return priority() < toDoEvent.priority(); | 362 | return priority() < toDoEvent.priority(); |
359 | }else{ | 363 | }else{ |
360 | return dueDate() < toDoEvent.dueDate(); | 364 | return dueDate() < toDoEvent.dueDate(); |
361 | } | 365 | } |
362 | } | 366 | } |
363 | return false; | 367 | return false; |
364 | } | 368 | } |
365 | bool OTodo::operator<=(const OTodo &toDoEvent )const | 369 | bool OTodo::operator<=(const OTodo &toDoEvent )const |
366 | { | 370 | { |
367 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 371 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
368 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; | 372 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; |
369 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 373 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
370 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 374 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
371 | return priority() <= toDoEvent.priority(); | 375 | return priority() <= toDoEvent.priority(); |
372 | }else{ | 376 | }else{ |
373 | return dueDate() <= toDoEvent.dueDate(); | 377 | return dueDate() <= toDoEvent.dueDate(); |
374 | } | 378 | } |
375 | } | 379 | } |
376 | return true; | 380 | return true; |
377 | } | 381 | } |
378 | bool OTodo::operator>(const OTodo &toDoEvent )const | 382 | bool OTodo::operator>(const OTodo &toDoEvent )const |
379 | { | 383 | { |
380 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; | 384 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; |
381 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 385 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
382 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 386 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
383 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 387 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
384 | return priority() > toDoEvent.priority(); | 388 | return priority() > toDoEvent.priority(); |
385 | }else{ | 389 | }else{ |
386 | return dueDate() > toDoEvent.dueDate(); | 390 | return dueDate() > toDoEvent.dueDate(); |
387 | } | 391 | } |
388 | } | 392 | } |
389 | return false; | 393 | return false; |
390 | } | 394 | } |
diff --git a/libopie/pim/otodo.h b/libopie/pim/otodo.h index f9a345a..6df98b9 100644 --- a/libopie/pim/otodo.h +++ b/libopie/pim/otodo.h | |||
@@ -5,290 +5,281 @@ | |||
5 | 5 | ||
6 | #include <qarray.h> | 6 | #include <qarray.h> |
7 | #include <qmap.h> | 7 | #include <qmap.h> |
8 | #include <qregexp.h> | 8 | #include <qregexp.h> |
9 | #include <qstringlist.h> | 9 | #include <qstringlist.h> |
10 | #include <qdatetime.h> | 10 | #include <qdatetime.h> |
11 | #include <qvaluelist.h> | 11 | #include <qvaluelist.h> |
12 | 12 | ||
13 | #include <qpe/recordfields.h> | 13 | #include <qpe/recordfields.h> |
14 | #include <qpe/palmtopuidgen.h> | 14 | #include <qpe/palmtopuidgen.h> |
15 | 15 | ||
16 | #include <opie/opimrecord.h> | 16 | #include <opie/opimrecord.h> |
17 | 17 | ||
18 | 18 | ||
19 | class OPimState; | 19 | class OPimState; |
20 | class ORecur; | 20 | class ORecur; |
21 | class OPimMaintainer; | 21 | class OPimMaintainer; |
22 | class OPimNotifyManager; | 22 | class OPimNotifyManager; |
23 | class OTodo : public OPimRecord { | 23 | class OTodo : public OPimRecord { |
24 | public: | 24 | public: |
25 | typedef QValueList<OTodo> ValueList; | 25 | typedef QValueList<OTodo> ValueList; |
26 | enum RecordFields { | 26 | enum RecordFields { |
27 | Uid = Qtopia::UID_ID, | 27 | Uid = Qtopia::UID_ID, |
28 | Category = Qtopia::CATEGORY_ID, | 28 | Category = Qtopia::CATEGORY_ID, |
29 | HasDate, | 29 | HasDate, |
30 | Completed, | 30 | Completed, |
31 | Description, | 31 | Description, |
32 | Summary, | 32 | Summary, |
33 | Priority, | 33 | Priority, |
34 | DateDay, | 34 | DateDay, |
35 | DateMonth, | 35 | DateMonth, |
36 | DateYear, | 36 | DateYear, |
37 | Progress, | 37 | Progress, |
38 | CrossReference, | 38 | CrossReference, |
39 | State, | 39 | State, |
40 | Recurrence, | 40 | Recurrence, |
41 | Alarms, | 41 | Alarms, |
42 | Reminders, | 42 | Reminders, |
43 | Notifiers, | 43 | Notifiers, |
44 | Maintainer, | 44 | Maintainer, |
45 | StartDate, | 45 | StartDate, |
46 | CompletedDate | 46 | CompletedDate |
47 | }; | 47 | }; |
48 | public: | 48 | public: |
49 | // priorities from Very low to very high | 49 | // priorities from Very low to very high |
50 | enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; | 50 | enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; |
51 | 51 | ||
52 | /* Constructs a new ToDoEvent | 52 | /* Constructs a new ToDoEvent |
53 | @param completed Is the TodoEvent completed | 53 | @param completed Is the TodoEvent completed |
54 | @param priority What is the priority of this ToDoEvent | 54 | @param priority What is the priority of this ToDoEvent |
55 | @param category Which category does it belong( uid ) | 55 | @param category Which category does it belong( uid ) |
56 | @param summary A small summary of the todo | 56 | @param summary A small summary of the todo |
57 | @param description What is this ToDoEvent about | 57 | @param description What is this ToDoEvent about |
58 | @param hasDate Does this Event got a deadline | 58 | @param hasDate Does this Event got a deadline |
59 | @param date what is the deadline? | 59 | @param date what is the deadline? |
60 | @param uid what is the UUID of this Event | 60 | @param uid what is the UUID of this Event |
61 | **/ | 61 | **/ |
62 | OTodo( bool completed = false, int priority = Normal, | 62 | OTodo( bool completed = false, int priority = Normal, |
63 | const QStringList &category = QStringList(), | 63 | const QStringList &category = QStringList(), |
64 | const QString &summary = QString::null , | 64 | const QString &summary = QString::null , |
65 | const QString &description = QString::null, | 65 | const QString &description = QString::null, |
66 | ushort progress = 0, | 66 | ushort progress = 0, |
67 | bool hasDate = false, QDate date = QDate::currentDate(), | 67 | bool hasDate = false, QDate date = QDate::currentDate(), |
68 | int uid = 0 /*empty*/ ); | 68 | int uid = 0 /*empty*/ ); |
69 | 69 | ||
70 | OTodo( bool completed, int priority, | 70 | OTodo( bool completed, int priority, |
71 | const QArray<int>& category, | 71 | const QArray<int>& category, |
72 | const QString& summary = QString::null, | 72 | const QString& summary = QString::null, |
73 | const QString& description = QString::null, | 73 | const QString& description = QString::null, |
74 | ushort progress = 0, | 74 | ushort progress = 0, |
75 | bool hasDate = false, QDate date = QDate::currentDate(), | 75 | bool hasDate = false, QDate date = QDate::currentDate(), |
76 | int uid = 0 /* empty */ ); | 76 | int uid = 0 /* empty */ ); |
77 | 77 | ||
78 | /** Copy c'tor | 78 | /** Copy c'tor |
79 | * | 79 | * |
80 | */ | 80 | */ |
81 | OTodo(const OTodo & ); | 81 | OTodo(const OTodo & ); |
82 | 82 | ||
83 | /** | 83 | /** |
84 | *destructor | 84 | *destructor |
85 | */ | 85 | */ |
86 | ~OTodo(); | 86 | ~OTodo(); |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Is this event completed? | 89 | * Is this event completed? |
90 | */ | 90 | */ |
91 | bool isCompleted() const; | 91 | bool isCompleted() const; |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Does this Event have a deadline | 94 | * Does this Event have a deadline |
95 | */ | 95 | */ |
96 | bool hasDueDate() const; | 96 | bool hasDueDate() const; |
97 | bool hasStartDate()const; | 97 | bool hasStartDate()const; |
98 | bool hasCompletedDate()const; | 98 | bool hasCompletedDate()const; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Does this Event has an alarm time ? | ||
102 | */ | ||
103 | bool hasAlarmDateTime() const; | ||
104 | |||
105 | /** | ||
106 | * What is the priority? | 101 | * What is the priority? |
107 | */ | 102 | */ |
108 | int priority()const ; | 103 | int priority()const ; |
109 | 104 | ||
110 | /** | 105 | /** |
111 | * progress as ushort 0, 20, 40, 60, 80 or 100% | 106 | * progress as ushort 0, 20, 40, 60, 80 or 100% |
112 | */ | 107 | */ |
113 | ushort progress() const; | 108 | ushort progress() const; |
114 | 109 | ||
115 | /** | 110 | /** |
116 | * The due Date | 111 | * The due Date |
117 | */ | 112 | */ |
118 | QDate dueDate()const; | 113 | QDate dueDate()const; |
119 | 114 | ||
120 | /** | 115 | /** |
121 | * When did it start? | 116 | * When did it start? |
122 | */ | 117 | */ |
123 | QDate startDate()const; | 118 | QDate startDate()const; |
124 | 119 | ||
125 | /** | 120 | /** |
126 | * When was it completed? | 121 | * When was it completed? |
127 | */ | 122 | */ |
128 | QDate completedDate()const; | 123 | QDate completedDate()const; |
129 | 124 | ||
130 | /** | 125 | /** |
131 | * does it have a state? | 126 | * does it have a state? |
132 | */ | 127 | */ |
133 | bool hasState()const; | 128 | bool hasState()const; |
134 | 129 | ||
135 | /** | 130 | /** |
136 | * What is the state of this OTodo? | 131 | * What is the state of this OTodo? |
137 | */ | 132 | */ |
138 | OPimState state()const; | 133 | OPimState state()const; |
139 | 134 | ||
140 | /** | 135 | /** |
141 | * has recurrence? | 136 | * has recurrence? |
142 | */ | 137 | */ |
143 | bool hasRecurrence()const; | 138 | bool hasRecurrence()const; |
144 | 139 | ||
145 | /** | 140 | /** |
146 | * the recurrance of this | 141 | * the recurrance of this |
147 | */ | 142 | */ |
148 | ORecur recurrence()const; | 143 | ORecur recurrence()const; |
149 | 144 | ||
150 | /** | 145 | /** |
151 | * does this OTodo have a maintainer? | 146 | * does this OTodo have a maintainer? |
152 | */ | 147 | */ |
153 | bool hasMaintainer()const; | 148 | bool hasMaintainer()const; |
154 | 149 | ||
155 | /** | 150 | /** |
156 | * the Maintainer of this OTodo | 151 | * the Maintainer of this OTodo |
157 | */ | 152 | */ |
158 | OPimMaintainer maintainer()const; | 153 | OPimMaintainer maintainer()const; |
159 | 154 | ||
160 | /** | 155 | /** |
161 | * The description of the todo | 156 | * The description of the todo |
162 | */ | 157 | */ |
163 | QString description()const; | 158 | QString description()const; |
164 | 159 | ||
165 | /** | 160 | /** |
166 | * A small summary of the todo | 161 | * A small summary of the todo |
167 | */ | 162 | */ |
168 | QString summary() const; | 163 | QString summary() const; |
169 | 164 | ||
170 | /** | 165 | /** |
171 | * @reimplemented | 166 | * @reimplemented |
172 | * Return this todoevent in a RichText formatted QString | 167 | * Return this todoevent in a RichText formatted QString |
173 | */ | 168 | */ |
174 | QString toRichText() const; | 169 | QString toRichText() const; |
175 | 170 | ||
176 | bool hasNotifiers()const; | 171 | bool hasNotifiers()const; |
177 | /* | 172 | /* |
178 | * FIXME check if the sharing is still fine!! -zecke | 173 | * FIXME check if the sharing is still fine!! -zecke |
179 | * ### CHECK If API is fine | 174 | * ### CHECK If API is fine |
180 | */ | 175 | */ |
181 | /** | 176 | /** |
182 | * return a reference to our notifiers... | 177 | * return a reference to our notifiers... |
183 | */ | 178 | */ |
184 | OPimNotifyManager ¬ifiers(); | 179 | OPimNotifyManager ¬ifiers(); |
185 | 180 | ||
186 | /** | 181 | /** |
187 | * | 182 | * |
188 | */ | 183 | */ |
189 | const OPimNotifyManager ¬ifiers()const; | 184 | const OPimNotifyManager ¬ifiers()const; |
190 | 185 | ||
191 | /** | 186 | /** |
192 | * reimplementations | 187 | * reimplementations |
193 | */ | 188 | */ |
194 | QString type()const; | 189 | QString type()const; |
195 | QString toShortText()const; | 190 | QString toShortText()const; |
196 | QString recordField(int id )const; | 191 | QString recordField(int id )const; |
197 | 192 | ||
198 | /** | 193 | /** |
199 | * toMap puts all data into the map. int relates | 194 | * toMap puts all data into the map. int relates |
200 | * to ToDoEvent RecordFields enum | 195 | * to ToDoEvent RecordFields enum |
201 | */ | 196 | */ |
202 | QMap<int, QString> toMap()const; | 197 | QMap<int, QString> toMap()const; |
203 | 198 | ||
204 | /** | 199 | /** |
205 | * Set if this Todo is completed | 200 | * Set if this Todo is completed |
206 | */ | 201 | */ |
207 | void setCompleted(bool completed ); | 202 | void setCompleted(bool completed ); |
208 | 203 | ||
209 | /** | 204 | /** |
210 | * set if this todo got an end data | 205 | * set if this todo got an end data |
211 | */ | 206 | */ |
212 | void setHasDueDate( bool hasDate ); | 207 | void setHasDueDate( bool hasDate ); |
213 | // FIXME we do not have these for start, completed | 208 | // FIXME we do not have these for start, completed |
214 | // cause we'll use the isNull() of QDate for figuring | 209 | // cause we'll use the isNull() of QDate for figuring |
215 | // out if it's has a date... | 210 | // out if it's has a date... |
216 | // decide what to do here? -zecke | 211 | // decide what to do here? -zecke |
217 | 212 | ||
218 | /** | 213 | /** |
219 | * Set the priority of the Todo | 214 | * Set the priority of the Todo |
220 | */ | 215 | */ |
221 | void setPriority(int priority ); | 216 | void setPriority(int priority ); |
222 | 217 | ||
223 | /** | 218 | /** |
224 | * Set the progress. | 219 | * Set the progress. |
225 | */ | 220 | */ |
226 | void setProgress( ushort progress ); | 221 | void setProgress( ushort progress ); |
227 | 222 | ||
228 | /** | 223 | /** |
229 | * set the end date | 224 | * set the end date |
230 | */ | 225 | */ |
231 | void setDueDate( const QDate& date ); | 226 | void setDueDate( const QDate& date ); |
232 | 227 | ||
233 | /** | 228 | /** |
234 | * set the start date | 229 | * set the start date |
235 | */ | 230 | */ |
236 | void setStartDate( const QDate& date ); | 231 | void setStartDate( const QDate& date ); |
237 | 232 | ||
238 | /** | 233 | /** |
239 | * set the completed date | 234 | * set the completed date |
240 | */ | 235 | */ |
241 | void setCompletedDate( const QDate& date ); | 236 | void setCompletedDate( const QDate& date ); |
242 | 237 | ||
243 | void setRecurrence( const ORecur& ); | 238 | void setRecurrence( const ORecur& ); |
244 | /** | ||
245 | * set the alarm time | ||
246 | */ | ||
247 | void setAlarmDateTime ( const QDateTime& alarm ); | ||
248 | 239 | ||
249 | void setDescription(const QString& ); | 240 | void setDescription(const QString& ); |
250 | void setSummary(const QString& ); | 241 | void setSummary(const QString& ); |
251 | 242 | ||
252 | /** | 243 | /** |
253 | * set the state of a Todo | 244 | * set the state of a Todo |
254 | * @param state State what the todo should take | 245 | * @param state State what the todo should take |
255 | */ | 246 | */ |
256 | void setState( const OPimState& state); | 247 | void setState( const OPimState& state); |
257 | 248 | ||
258 | /** | 249 | /** |
259 | * set the Maintainer Mode | 250 | * set the Maintainer Mode |
260 | */ | 251 | */ |
261 | void setMaintainer( const OPimMaintainer& ); | 252 | void setMaintainer( const OPimMaintainer& ); |
262 | 253 | ||
263 | bool isOverdue(); | 254 | bool isOverdue(); |
264 | 255 | ||
265 | 256 | ||
266 | virtual bool match( const QRegExp &r )const; | 257 | virtual bool match( const QRegExp &r )const; |
267 | 258 | ||
268 | bool operator<(const OTodo &toDoEvent )const; | 259 | bool operator<(const OTodo &toDoEvent )const; |
269 | bool operator<=(const OTodo &toDoEvent )const; | 260 | bool operator<=(const OTodo &toDoEvent )const; |
270 | bool operator!=(const OTodo &toDoEvent )const; | 261 | bool operator!=(const OTodo &toDoEvent )const; |
271 | bool operator>(const OTodo &toDoEvent )const; | 262 | bool operator>(const OTodo &toDoEvent )const; |
272 | bool operator>=(const OTodo &toDoEvent)const; | 263 | bool operator>=(const OTodo &toDoEvent)const; |
273 | bool operator==(const OTodo &toDoEvent )const; | 264 | bool operator==(const OTodo &toDoEvent )const; |
274 | OTodo &operator=(const OTodo &toDoEvent ); | 265 | OTodo &operator=(const OTodo &toDoEvent ); |
275 | 266 | ||
276 | static int rtti(); | 267 | static int rtti(); |
277 | 268 | ||
278 | private: | 269 | private: |
279 | class OTodoPrivate; | 270 | class OTodoPrivate; |
280 | struct OTodoData; | 271 | struct OTodoData; |
281 | 272 | ||
282 | void deref(); | 273 | void deref(); |
283 | inline void changeOrModify(); | 274 | inline void changeOrModify(); |
284 | void copy( OTodoData* src, OTodoData* dest ); | 275 | void copy( OTodoData* src, OTodoData* dest ); |
285 | OTodoPrivate *d; | 276 | OTodoPrivate *d; |
286 | OTodoData *data; | 277 | OTodoData *data; |
287 | 278 | ||
288 | }; | 279 | }; |
289 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { | 280 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { |
290 | return !(*this == toDoEvent); | 281 | return !(*this == toDoEvent); |
291 | } | 282 | } |
292 | 283 | ||
293 | 284 | ||
294 | #endif | 285 | #endif |
diff --git a/libopie/pim/otodoaccessbackend.h b/libopie/pim/otodoaccessbackend.h index 05e8ca9..6be95bc 100644 --- a/libopie/pim/otodoaccessbackend.h +++ b/libopie/pim/otodoaccessbackend.h | |||
@@ -1,24 +1,28 @@ | |||
1 | #ifndef OPIE_TODO_ACCESS_BACKEND_H | 1 | #ifndef OPIE_TODO_ACCESS_BACKEND_H |
2 | #define OPIE_TODO_ACCESS_BACKEND_H | 2 | #define OPIE_TODO_ACCESS_BACKEND_H |
3 | 3 | ||
4 | #include <qbitarray.h> | 4 | #include <qbitarray.h> |
5 | 5 | ||
6 | #include "otodo.h" | 6 | #include "otodo.h" |
7 | #include "opimaccessbackend.h" | 7 | #include "opimaccessbackend.h" |
8 | 8 | ||
9 | class OTodoAccessBackend : public OPimAccessBackend<OTodo> { | 9 | class OTodoAccessBackend : public OPimAccessBackend<OTodo> { |
10 | public: | 10 | public: |
11 | OTodoAccessBackend(); | 11 | OTodoAccessBackend(); |
12 | ~OTodoAccessBackend(); | 12 | ~OTodoAccessBackend(); |
13 | virtual QArray<int> effectiveToDos( const QDate& start, | 13 | virtual QArray<int> effectiveToDos( const QDate& start, |
14 | const QDate& end, | 14 | const QDate& end, |
15 | bool includeNoDates ) = 0; | 15 | bool includeNoDates ) = 0; |
16 | virtual QArray<int> overDue() = 0; | 16 | virtual QArray<int> overDue() = 0; |
17 | virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter, | 17 | virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter, |
18 | int cat ) = 0; | 18 | int cat ) = 0; |
19 | virtual void removeAllCompleted() = 0; | 19 | virtual void removeAllCompleted() = 0; |
20 | virtual QBitArray supports()const = 0; | 20 | virtual QBitArray supports()const = 0; |
21 | |||
22 | private: | ||
23 | class Private; | ||
24 | Private *d; | ||
21 | 25 | ||
22 | }; | 26 | }; |
23 | 27 | ||
24 | #endif | 28 | #endif |
diff --git a/libopie/pim/otodoaccessvcal.cpp b/libopie/pim/otodoaccessvcal.cpp index 3577e14..6415952 100644 --- a/libopie/pim/otodoaccessvcal.cpp +++ b/libopie/pim/otodoaccessvcal.cpp | |||
@@ -1,225 +1,249 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
2 | 2 | ||
3 | #include <qtopia/private/vobject_p.h> | 3 | #include <qtopia/private/vobject_p.h> |
4 | #include <qtopia/timeconversion.h> | 4 | #include <qtopia/timeconversion.h> |
5 | #include <qtopia/private/qfiledirect_p.h> | 5 | #include <qtopia/private/qfiledirect_p.h> |
6 | 6 | ||
7 | #include "otodoaccessvcal.h" | 7 | #include "otodoaccessvcal.h" |
8 | 8 | ||
9 | namespace { | 9 | namespace { |
10 | static OTodo eventByVObj( VObject *obj ){ | 10 | static OTodo eventByVObj( VObject *obj ){ |
11 | OTodo event; | 11 | OTodo event; |
12 | VObject *ob; | 12 | VObject *ob; |
13 | QCString name; | 13 | QCString name; |
14 | // no uid, attendees, ... and no fun | 14 | // no uid, attendees, ... and no fun |
15 | // description | 15 | // description |
16 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ | 16 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ |
17 | name = vObjectStringZValue( ob ); | 17 | name = vObjectStringZValue( ob ); |
18 | #if 0 | ||
18 | event.setDescription( name ); | 19 | event.setDescription( name ); |
20 | #else | ||
21 | event.setSummary( name ); | ||
22 | #endif | ||
19 | } | 23 | } |
20 | // summary | 24 | // summary |
21 | if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { | 25 | if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { |
22 | name = vObjectStringZValue( ob ); | 26 | name = vObjectStringZValue( ob ); |
27 | #if 0 | ||
23 | event.setSummary( name ); | 28 | event.setSummary( name ); |
29 | #else | ||
30 | event.setDescription( name ); | ||
31 | #endif | ||
24 | } | 32 | } |
25 | // completed | 33 | // completed |
26 | if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ | 34 | if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ |
27 | name = vObjectStringZValue( ob ); | 35 | name = vObjectStringZValue( ob ); |
28 | if( name == "COMPLETED" ){ | 36 | if( name == "COMPLETED" ){ |
29 | event.setCompleted( true ); | 37 | event.setCompleted( true ); |
30 | }else{ | 38 | }else{ |
31 | event.setCompleted( false ); | 39 | event.setCompleted( false ); |
32 | } | 40 | } |
33 | }else | 41 | }else |
34 | event.setCompleted( false ); | 42 | event.setCompleted( false ); |
35 | // priority | 43 | // priority |
36 | if ((ob = isAPropertyOf(obj, VCPriorityProp))) { | 44 | if ((ob = isAPropertyOf(obj, VCPriorityProp))) { |
37 | name = vObjectStringZValue( ob ); | 45 | name = vObjectStringZValue( ob ); |
38 | bool ok; | 46 | bool ok; |
39 | event.setPriority(name.toInt(&ok) ); | 47 | event.setPriority(name.toInt(&ok) ); |
40 | } | 48 | } |
41 | //due date | 49 | //due date |
42 | if((ob = isAPropertyOf(obj, VCDueProp)) ){ | 50 | if((ob = isAPropertyOf(obj, VCDueProp)) ){ |
43 | event.setHasDueDate( true ); | 51 | event.setHasDueDate( true ); |
44 | name = vObjectStringZValue( ob ); | 52 | name = vObjectStringZValue( ob ); |
45 | event.setDueDate( TimeConversion::fromISO8601( name).date() ); | 53 | event.setDueDate( TimeConversion::fromISO8601( name).date() ); |
46 | } | 54 | } |
47 | // categories | 55 | // categories |
48 | if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ | 56 | if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ |
49 | name = vObjectStringZValue( ob ); | 57 | name = vObjectStringZValue( ob ); |
50 | qWarning("Categories:%s", name.data() ); | 58 | qWarning("Categories:%s", name.data() ); |
51 | } | 59 | } |
52 | 60 | ||
53 | event.setUid( 1 ); | 61 | event.setUid( 1 ); |
54 | return event; | 62 | return event; |
55 | }; | 63 | }; |
56 | static VObject *vobjByEvent( const OTodo &event ) { | 64 | static VObject *vobjByEvent( const OTodo &event ) { |
57 | VObject *task = newVObject( VCTodoProp ); | 65 | VObject *task = newVObject( VCTodoProp ); |
58 | if( task == 0 ) | 66 | if( task == 0 ) |
59 | return 0l; | 67 | return 0l; |
60 | 68 | ||
61 | if( event.hasDueDate() ) { | 69 | if( event.hasDueDate() ) { |
62 | QTime time(0, 0, 0); | 70 | QTime time(0, 0, 0); |
63 | QDateTime date(event.dueDate(), time ); | 71 | QDateTime date(event.dueDate(), time ); |
64 | addPropValue( task, VCDueProp, | 72 | addPropValue( task, VCDueProp, |
65 | TimeConversion::toISO8601( date ) ); | 73 | TimeConversion::toISO8601( date ) ); |
66 | } | 74 | } |
67 | 75 | ||
68 | if( event.isCompleted() ) | 76 | if( event.isCompleted() ) |
69 | addPropValue( task, VCStatusProp, "COMPLETED"); | 77 | addPropValue( task, VCStatusProp, "COMPLETED"); |
70 | 78 | ||
71 | QString string = QString::number(event.priority() ); | 79 | QString string = QString::number(event.priority() ); |
72 | addPropValue( task, VCPriorityProp, string.local8Bit() ); | 80 | addPropValue( task, VCPriorityProp, string.local8Bit() ); |
73 | 81 | ||
74 | addPropValue( task, VCCategoriesProp, | 82 | addPropValue( task, VCCategoriesProp, |
75 | event.idsToString( event.categories() ).local8Bit() ); | 83 | event.idsToString( event.categories() ).local8Bit() ); |
76 | 84 | ||
85 | #if 0 | ||
86 | |||
87 | // There seems a misrepresentation between summary in otodoevent | ||
88 | // and summary in vcard. | ||
89 | // The same with description.. | ||
90 | // Description is summary and vice versa.. Argh.. (eilers) | ||
91 | |||
92 | |||
77 | addPropValue( task, VCDescriptionProp, | 93 | addPropValue( task, VCDescriptionProp, |
78 | event.description().local8Bit() ); | 94 | event.description().local8Bit() ); |
79 | 95 | ||
80 | addPropValue( task, VCSummaryProp, | 96 | addPropValue( task, VCSummaryProp, |
81 | event.summary().local8Bit() ); | 97 | event.summary().local8Bit() ); |
98 | |||
99 | #else | ||
100 | addPropValue( task, VCDescriptionProp, | ||
101 | event.summary().local8Bit() ); | ||
102 | |||
103 | addPropValue( task, VCSummaryProp, | ||
104 | event.description().local8Bit() ); | ||
105 | #endif | ||
82 | return task; | 106 | return task; |
83 | }; | 107 | }; |
84 | } | 108 | } |
85 | 109 | ||
86 | OTodoAccessVCal::OTodoAccessVCal( const QString& path ) | 110 | OTodoAccessVCal::OTodoAccessVCal( const QString& path ) |
87 | : m_dirty(false), m_file( path ) | 111 | : m_dirty(false), m_file( path ) |
88 | { | 112 | { |
89 | } | 113 | } |
90 | OTodoAccessVCal::~OTodoAccessVCal() { | 114 | OTodoAccessVCal::~OTodoAccessVCal() { |
91 | } | 115 | } |
92 | bool OTodoAccessVCal::load() { | 116 | bool OTodoAccessVCal::load() { |
93 | m_map.clear(); | 117 | m_map.clear(); |
94 | m_dirty = false; | 118 | m_dirty = false; |
95 | 119 | ||
96 | VObject* vcal = 0l; | 120 | VObject* vcal = 0l; |
97 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); | 121 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); |
98 | if (!vcal ) | 122 | if (!vcal ) |
99 | return false; | 123 | return false; |
100 | 124 | ||
101 | // Iterate over the list | 125 | // Iterate over the list |
102 | VObjectIterator it; | 126 | VObjectIterator it; |
103 | VObject* vobj; | 127 | VObject* vobj; |
104 | 128 | ||
105 | initPropIterator(&it, vcal); | 129 | initPropIterator(&it, vcal); |
106 | 130 | ||
107 | while( moreIteration( &it ) ) { | 131 | while( moreIteration( &it ) ) { |
108 | vobj = ::nextVObject( &it ); | 132 | vobj = ::nextVObject( &it ); |
109 | QCString name = ::vObjectName( vobj ); | 133 | QCString name = ::vObjectName( vobj ); |
110 | if( name == VCTodoProp ){ | 134 | if( name == VCTodoProp ){ |
111 | OTodo to = eventByVObj( vobj ); | 135 | OTodo to = eventByVObj( vobj ); |
112 | m_map.insert( to.uid(), to ); | 136 | m_map.insert( to.uid(), to ); |
113 | } | 137 | } |
114 | } | 138 | } |
115 | 139 | ||
116 | // Should I do a delete vcal? | 140 | // Should I do a delete vcal? |
117 | 141 | ||
118 | return true; | 142 | return true; |
119 | } | 143 | } |
120 | bool OTodoAccessVCal::reload() { | 144 | bool OTodoAccessVCal::reload() { |
121 | return load(); | 145 | return load(); |
122 | } | 146 | } |
123 | bool OTodoAccessVCal::save() { | 147 | bool OTodoAccessVCal::save() { |
124 | if (!m_dirty ) | 148 | if (!m_dirty ) |
125 | return true; | 149 | return true; |
126 | 150 | ||
127 | QFileDirect file( m_file ); | 151 | QFileDirect file( m_file ); |
128 | if (!file.open(IO_WriteOnly ) ) | 152 | if (!file.open(IO_WriteOnly ) ) |
129 | return false; | 153 | return false; |
130 | 154 | ||
131 | VObject *obj; | 155 | VObject *obj; |
132 | obj = newVObject( VCCalProp ); | 156 | obj = newVObject( VCCalProp ); |
133 | addPropValue( obj, VCVersionProp, "1.0" ); | 157 | addPropValue( obj, VCVersionProp, "1.0" ); |
134 | VObject *vo; | 158 | VObject *vo; |
135 | for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ | 159 | for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ |
136 | vo = vobjByEvent( it.data() ); | 160 | vo = vobjByEvent( it.data() ); |
137 | addVObjectProp(obj, vo ); | 161 | addVObjectProp(obj, vo ); |
138 | } | 162 | } |
139 | writeVObject( file.directHandle(), obj ); | 163 | writeVObject( file.directHandle(), obj ); |
140 | cleanVObject( obj ); | 164 | cleanVObject( obj ); |
141 | cleanStrTbl(); | 165 | cleanStrTbl(); |
142 | 166 | ||
143 | m_dirty = false; | 167 | m_dirty = false; |
144 | return true; | 168 | return true; |
145 | } | 169 | } |
146 | void OTodoAccessVCal::clear() { | 170 | void OTodoAccessVCal::clear() { |
147 | m_map.clear(); | 171 | m_map.clear(); |
148 | m_dirty = true; | 172 | m_dirty = true; |
149 | } | 173 | } |
150 | bool OTodoAccessVCal::add( const OTodo& to ) { | 174 | bool OTodoAccessVCal::add( const OTodo& to ) { |
151 | m_map.insert( to.uid(), to ); | 175 | m_map.insert( to.uid(), to ); |
152 | m_dirty = true; | 176 | m_dirty = true; |
153 | return true; | 177 | return true; |
154 | } | 178 | } |
155 | bool OTodoAccessVCal::remove( int uid ) { | 179 | bool OTodoAccessVCal::remove( int uid ) { |
156 | m_map.remove( uid ); | 180 | m_map.remove( uid ); |
157 | m_dirty = true; | 181 | m_dirty = true; |
158 | return true; | 182 | return true; |
159 | } | 183 | } |
160 | void OTodoAccessVCal::removeAllCompleted() { | 184 | void OTodoAccessVCal::removeAllCompleted() { |
161 | for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { | 185 | for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { |
162 | if ( (*it).isCompleted() ) | 186 | if ( (*it).isCompleted() ) |
163 | m_map.remove( it ); | 187 | m_map.remove( it ); |
164 | } | 188 | } |
165 | } | 189 | } |
166 | bool OTodoAccessVCal::replace( const OTodo& to ) { | 190 | bool OTodoAccessVCal::replace( const OTodo& to ) { |
167 | m_map.replace( to.uid(), to ); | 191 | m_map.replace( to.uid(), to ); |
168 | m_dirty = true; | 192 | m_dirty = true; |
169 | return true; | 193 | return true; |
170 | } | 194 | } |
171 | OTodo OTodoAccessVCal::find(int uid )const { | 195 | OTodo OTodoAccessVCal::find(int uid )const { |
172 | return m_map[uid]; | 196 | return m_map[uid]; |
173 | } | 197 | } |
174 | QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { | 198 | QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { |
175 | QArray<int> ar(0); | 199 | QArray<int> ar(0); |
176 | return ar; | 200 | return ar; |
177 | } | 201 | } |
178 | QArray<int> OTodoAccessVCal::allRecords()const { | 202 | QArray<int> OTodoAccessVCal::allRecords()const { |
179 | QArray<int> ar( m_map.count() ); | 203 | QArray<int> ar( m_map.count() ); |
180 | QMap<int, OTodo>::ConstIterator it; | 204 | QMap<int, OTodo>::ConstIterator it; |
181 | int i = 0; | 205 | int i = 0; |
182 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | 206 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { |
183 | ar[i] = it.key(); | 207 | ar[i] = it.key(); |
184 | i++; | 208 | i++; |
185 | } | 209 | } |
186 | return ar; | 210 | return ar; |
187 | } | 211 | } |
188 | QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp &r)const { | 212 | QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const { |
189 | QArray<int> ar(0); | 213 | QArray<int> ar(0); |
190 | return ar; | 214 | return ar; |
191 | } | 215 | } |
192 | QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { | 216 | QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { |
193 | QArray<int> ar(0); | 217 | QArray<int> ar(0); |
194 | return ar; | 218 | return ar; |
195 | } | 219 | } |
196 | QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , | 220 | QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , |
197 | const QDate& , | 221 | const QDate& , |
198 | bool ) { | 222 | bool ) { |
199 | QArray<int> ar(0); | 223 | QArray<int> ar(0); |
200 | return ar; | 224 | return ar; |
201 | } | 225 | } |
202 | QArray<int> OTodoAccessVCal::overDue() { | 226 | QArray<int> OTodoAccessVCal::overDue() { |
203 | QArray<int> ar(0); | 227 | QArray<int> ar(0); |
204 | return ar; | 228 | return ar; |
205 | } | 229 | } |
206 | QBitArray OTodoAccessVCal::supports()const { | 230 | QBitArray OTodoAccessVCal::supports()const { |
207 | static QBitArray ar = sup(); | 231 | static QBitArray ar = sup(); |
208 | 232 | ||
209 | return ar; | 233 | return ar; |
210 | } | 234 | } |
211 | QBitArray OTodoAccessVCal::sup() { | 235 | QBitArray OTodoAccessVCal::sup() { |
212 | QBitArray ar ( OTodo::CompletedDate +1 ); | 236 | QBitArray ar ( OTodo::CompletedDate +1 ); |
213 | ar.fill( true ); | 237 | ar.fill( true ); |
214 | 238 | ||
215 | ar[OTodo::CrossReference] = false; | 239 | ar[OTodo::CrossReference] = false; |
216 | ar[OTodo::State ] = false; | 240 | ar[OTodo::State ] = false; |
217 | ar[OTodo::Reminders] = false; | 241 | ar[OTodo::Reminders] = false; |
218 | ar[OTodo::Notifiers] = false; | 242 | ar[OTodo::Notifiers] = false; |
219 | ar[OTodo::Maintainer] = false; | 243 | ar[OTodo::Maintainer] = false; |
220 | ar[OTodo::Progress] = false; | 244 | ar[OTodo::Progress] = false; |
221 | ar[OTodo::Alarms ] = false; | 245 | ar[OTodo::Alarms ] = false; |
222 | ar[OTodo::Recurrence] = false; | 246 | ar[OTodo::Recurrence] = false; |
223 | 247 | ||
224 | return ar; | 248 | return ar; |
225 | } | 249 | } |
diff --git a/libopie/pim/otodoaccessxml.cpp b/libopie/pim/otodoaccessxml.cpp index 3d15354..f688735 100644 --- a/libopie/pim/otodoaccessxml.cpp +++ b/libopie/pim/otodoaccessxml.cpp | |||
@@ -1,186 +1,186 @@ | |||
1 | #include <errno.h> | 1 | #include <errno.h> |
2 | #include <fcntl.h> | 2 | #include <fcntl.h> |
3 | 3 | ||
4 | #include <sys/mman.h> | 4 | #include <sys/mman.h> |
5 | #include <sys/stat.h> | 5 | #include <sys/stat.h> |
6 | #include <sys/types.h> | 6 | #include <sys/types.h> |
7 | 7 | ||
8 | #include <unistd.h> | 8 | #include <unistd.h> |
9 | 9 | ||
10 | 10 | ||
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qvector.h> | 12 | #include <qvector.h> |
13 | 13 | ||
14 | #include <qpe/global.h> | 14 | #include <qpe/global.h> |
15 | #include <qpe/stringutil.h> | 15 | #include <qpe/stringutil.h> |
16 | #include <qpe/timeconversion.h> | 16 | #include <qpe/timeconversion.h> |
17 | 17 | ||
18 | #include "oconversion.h" | 18 | #include "oconversion.h" |
19 | #include "opimstate.h" | 19 | #include "opimstate.h" |
20 | #include "otimezone.h" | 20 | #include "otimezone.h" |
21 | #include "opimnotifymanager.h" | 21 | #include "opimnotifymanager.h" |
22 | #include "orecur.h" | 22 | #include "orecur.h" |
23 | #include "otodoaccessxml.h" | 23 | #include "otodoaccessxml.h" |
24 | 24 | ||
25 | namespace { | 25 | namespace { |
26 | time_t rp_end; | 26 | time_t rp_end; |
27 | ORecur* rec; | 27 | ORecur* rec; |
28 | ORecur *recur() { | 28 | ORecur *recur() { |
29 | if (!rec ) rec = new ORecur; | 29 | if (!rec ) rec = new ORecur; |
30 | return rec; | 30 | return rec; |
31 | } | 31 | } |
32 | int snd; | 32 | int snd; |
33 | enum MoreAttributes { | 33 | enum MoreAttributes { |
34 | FRType = OTodo::CompletedDate + 2, | 34 | FRType = OTodo::CompletedDate + 2, |
35 | FRWeekdays, | 35 | FRWeekdays, |
36 | FRPosition, | 36 | FRPosition, |
37 | FRFreq, | 37 | FRFreq, |
38 | FRHasEndDate, | 38 | FRHasEndDate, |
39 | FREndDate, | 39 | FREndDate, |
40 | FRStart, | 40 | FRStart, |
41 | FREnd | 41 | FREnd |
42 | }; | 42 | }; |
43 | // FROM TT again | 43 | // FROM TT again |
44 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | 44 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) |
45 | { | 45 | { |
46 | char needleChar; | 46 | char needleChar; |
47 | char haystackChar; | 47 | char haystackChar; |
48 | if (!needle || !haystack || !hLen || !nLen) | 48 | if (!needle || !haystack || !hLen || !nLen) |
49 | return 0; | 49 | return 0; |
50 | 50 | ||
51 | const char* hsearch = haystack; | 51 | const char* hsearch = haystack; |
52 | 52 | ||
53 | if ((needleChar = *needle++) != 0) { | 53 | if ((needleChar = *needle++) != 0) { |
54 | nLen--; //(to make up for needle++) | 54 | nLen--; //(to make up for needle++) |
55 | do { | 55 | do { |
56 | do { | 56 | do { |
57 | if ((haystackChar = *hsearch++) == 0) | 57 | if ((haystackChar = *hsearch++) == 0) |
58 | return (0); | 58 | return (0); |
59 | if (hsearch >= haystack + hLen) | 59 | if (hsearch >= haystack + hLen) |
60 | return (0); | 60 | return (0); |
61 | } while (haystackChar != needleChar); | 61 | } while (haystackChar != needleChar); |
62 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); | 62 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); |
63 | hsearch--; | 63 | hsearch--; |
64 | } | 64 | } |
65 | return ((char *)hsearch); | 65 | return ((char *)hsearch); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | 69 | ||
70 | OTodoAccessXML::OTodoAccessXML( const QString& appName, | 70 | OTodoAccessXML::OTodoAccessXML( const QString& appName, |
71 | const QString& fileName ) | 71 | const QString& fileName ) |
72 | : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) | 72 | : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) |
73 | { | 73 | { |
74 | if (!fileName.isEmpty() ) | 74 | if (!fileName.isEmpty() ) |
75 | m_file = fileName; | 75 | m_file = fileName; |
76 | else | 76 | else |
77 | m_file = Global::applicationFileName( "todolist", "todolist.xml" ); | 77 | m_file = Global::applicationFileName( "todolist", "todolist.xml" ); |
78 | } | 78 | } |
79 | OTodoAccessXML::~OTodoAccessXML() { | 79 | OTodoAccessXML::~OTodoAccessXML() { |
80 | 80 | ||
81 | } | 81 | } |
82 | bool OTodoAccessXML::load() { | 82 | bool OTodoAccessXML::load() { |
83 | rec = 0; | 83 | rec = 0; |
84 | m_opened = true; | 84 | m_opened = true; |
85 | m_changed = false; | 85 | m_changed = false; |
86 | /* initialize dict */ | 86 | /* initialize dict */ |
87 | /* | 87 | /* |
88 | * UPDATE dict if you change anything!!! | 88 | * UPDATE dict if you change anything!!! |
89 | */ | 89 | */ |
90 | QAsciiDict<int> dict(21); | 90 | QAsciiDict<int> dict(26); |
91 | dict.setAutoDelete( TRUE ); | 91 | dict.setAutoDelete( TRUE ); |
92 | dict.insert("Categories" , new int(OTodo::Category) ); | 92 | dict.insert("Categories" , new int(OTodo::Category) ); |
93 | dict.insert("Uid" , new int(OTodo::Uid) ); | 93 | dict.insert("Uid" , new int(OTodo::Uid) ); |
94 | dict.insert("HasDate" , new int(OTodo::HasDate) ); | 94 | dict.insert("HasDate" , new int(OTodo::HasDate) ); |
95 | dict.insert("Completed" , new int(OTodo::Completed) ); | 95 | dict.insert("Completed" , new int(OTodo::Completed) ); |
96 | dict.insert("Description" , new int(OTodo::Description) ); | 96 | dict.insert("Description" , new int(OTodo::Description) ); |
97 | dict.insert("Summary" , new int(OTodo::Summary) ); | 97 | dict.insert("Summary" , new int(OTodo::Summary) ); |
98 | dict.insert("Priority" , new int(OTodo::Priority) ); | 98 | dict.insert("Priority" , new int(OTodo::Priority) ); |
99 | dict.insert("DateDay" , new int(OTodo::DateDay) ); | 99 | dict.insert("DateDay" , new int(OTodo::DateDay) ); |
100 | dict.insert("DateMonth" , new int(OTodo::DateMonth) ); | 100 | dict.insert("DateMonth" , new int(OTodo::DateMonth) ); |
101 | dict.insert("DateYear" , new int(OTodo::DateYear) ); | 101 | dict.insert("DateYear" , new int(OTodo::DateYear) ); |
102 | dict.insert("Progress" , new int(OTodo::Progress) ); | 102 | dict.insert("Progress" , new int(OTodo::Progress) ); |
103 | dict.insert("CompletedDate", new int(OTodo::CompletedDate) ); | 103 | dict.insert("CompletedDate", new int(OTodo::CompletedDate) ); |
104 | dict.insert("StartDate", new int(OTodo::StartDate) ); | 104 | dict.insert("StartDate", new int(OTodo::StartDate) ); |
105 | dict.insert("CrossReference", new int(OTodo::CrossReference) ); | 105 | dict.insert("CrossReference", new int(OTodo::CrossReference) ); |
106 | dict.insert("State", new int(OTodo::State) ); | 106 | dict.insert("State", new int(OTodo::State) ); |
107 | dict.insert("Alarms", new int(OTodo::Alarms) ); | 107 | dict.insert("Alarms", new int(OTodo::Alarms) ); |
108 | dict.insert("Reminders", new int(OTodo::Reminders) ); | 108 | dict.insert("Reminders", new int(OTodo::Reminders) ); |
109 | dict.insert("Notifiers", new int(OTodo::Notifiers) ); | 109 | dict.insert("Notifiers", new int(OTodo::Notifiers) ); |
110 | dict.insert("Maintainer", new int(OTodo::Maintainer) ); | 110 | dict.insert("Maintainer", new int(OTodo::Maintainer) ); |
111 | dict.insert("rtype", new int(FRType) ); | 111 | dict.insert("rtype", new int(FRType) ); |
112 | dict.insert("rweekdays", new int(FRWeekdays) ); | 112 | dict.insert("rweekdays", new int(FRWeekdays) ); |
113 | dict.insert("rposition", new int(FRPosition) ); | 113 | dict.insert("rposition", new int(FRPosition) ); |
114 | dict.insert("rfreq", new int(FRFreq) ); | 114 | dict.insert("rfreq", new int(FRFreq) ); |
115 | dict.insert("start", new int(FRStart) ); | 115 | dict.insert("start", new int(FRStart) ); |
116 | dict.insert("rhasenddate", new int(FRHasEndDate) ); | 116 | dict.insert("rhasenddate", new int(FRHasEndDate) ); |
117 | dict.insert("enddt", new int(FREndDate) ); | 117 | dict.insert("enddt", new int(FREndDate) ); |
118 | 118 | ||
119 | // here the custom XML parser from TT it's GPL | 119 | // here the custom XML parser from TT it's GPL |
120 | // but we want to push OpiePIM... to TT..... | 120 | // but we want to push OpiePIM... to TT..... |
121 | // mmap part from zecke :) | 121 | // mmap part from zecke :) |
122 | int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY ); | 122 | int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY ); |
123 | struct stat attribut; | 123 | struct stat attribut; |
124 | if ( fd < 0 ) return false; | 124 | if ( fd < 0 ) return false; |
125 | 125 | ||
126 | if ( fstat(fd, &attribut ) == -1 ) { | 126 | if ( fstat(fd, &attribut ) == -1 ) { |
127 | ::close( fd ); | 127 | ::close( fd ); |
128 | return false; | 128 | return false; |
129 | } | 129 | } |
130 | void* map_addr = ::mmap(NULL, attribut.st_size, PROT_READ, MAP_SHARED, fd, 0 ); | 130 | void* map_addr = ::mmap(NULL, attribut.st_size, PROT_READ, MAP_SHARED, fd, 0 ); |
131 | if ( map_addr == ( (caddr_t)-1) ) { | 131 | if ( map_addr == ( (caddr_t)-1) ) { |
132 | ::close(fd ); | 132 | ::close(fd ); |
133 | return false; | 133 | return false; |
134 | } | 134 | } |
135 | /* advise the kernel who we want to read it */ | 135 | /* advise the kernel who we want to read it */ |
136 | ::madvise( map_addr, attribut.st_size, MADV_SEQUENTIAL ); | 136 | ::madvise( map_addr, attribut.st_size, MADV_SEQUENTIAL ); |
137 | /* we do not the file any more */ | 137 | /* we do not the file any more */ |
138 | ::close( fd ); | 138 | ::close( fd ); |
139 | 139 | ||
140 | char* dt = (char*)map_addr; | 140 | char* dt = (char*)map_addr; |
141 | int len = attribut.st_size; | 141 | int len = attribut.st_size; |
142 | int i = 0; | 142 | int i = 0; |
143 | char *point; | 143 | char *point; |
144 | const char* collectionString = "<Task "; | 144 | const char* collectionString = "<Task "; |
145 | int strLen = strlen(collectionString); | 145 | int strLen = strlen(collectionString); |
146 | while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { | 146 | while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { |
147 | i = point -dt; | 147 | i = point -dt; |
148 | i+= strLen; | 148 | i+= strLen; |
149 | qWarning("Found a start at %d %d", i, (point-dt) ); | 149 | qWarning("Found a start at %d %d", i, (point-dt) ); |
150 | 150 | ||
151 | OTodo ev; | 151 | OTodo ev; |
152 | m_year = m_month = m_day = 0; | 152 | m_year = m_month = m_day = 0; |
153 | 153 | ||
154 | while ( TRUE ) { | 154 | while ( TRUE ) { |
155 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) | 155 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) |
156 | ++i; | 156 | ++i; |
157 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) | 157 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) |
158 | break; | 158 | break; |
159 | 159 | ||
160 | // we have another attribute, read it. | 160 | // we have another attribute, read it. |
161 | int j = i; | 161 | int j = i; |
162 | while ( j < len && dt[j] != '=' ) | 162 | while ( j < len && dt[j] != '=' ) |
163 | ++j; | 163 | ++j; |
164 | QCString attr( dt+i, j-i+1); | 164 | QCString attr( dt+i, j-i+1); |
165 | 165 | ||
166 | i = ++j; // skip = | 166 | i = ++j; // skip = |
167 | 167 | ||
168 | // find the start of quotes | 168 | // find the start of quotes |
169 | while ( i < len && dt[i] != '"' ) | 169 | while ( i < len && dt[i] != '"' ) |
170 | ++i; | 170 | ++i; |
171 | j = ++i; | 171 | j = ++i; |
172 | 172 | ||
173 | bool haveUtf = FALSE; | 173 | bool haveUtf = FALSE; |
174 | bool haveEnt = FALSE; | 174 | bool haveEnt = FALSE; |
175 | while ( j < len && dt[j] != '"' ) { | 175 | while ( j < len && dt[j] != '"' ) { |
176 | if ( ((unsigned char)dt[j]) > 0x7f ) | 176 | if ( ((unsigned char)dt[j]) > 0x7f ) |
177 | haveUtf = TRUE; | 177 | haveUtf = TRUE; |
178 | if ( dt[j] == '&' ) | 178 | if ( dt[j] == '&' ) |
179 | haveEnt = TRUE; | 179 | haveEnt = TRUE; |
180 | ++j; | 180 | ++j; |
181 | } | 181 | } |
182 | if ( i == j ) { | 182 | if ( i == j ) { |
183 | // empty value | 183 | // empty value |
184 | i = j + 1; | 184 | i = j + 1; |
185 | continue; | 185 | continue; |
186 | } | 186 | } |
@@ -743,132 +743,134 @@ public: | |||
743 | if ( ret ) | 743 | if ( ret ) |
744 | return ret; | 744 | return ret; |
745 | 745 | ||
746 | // default did not gave difference let's try it other way around | 746 | // default did not gave difference let's try it other way around |
747 | /* | 747 | /* |
748 | * General try if already checked if not test | 748 | * General try if already checked if not test |
749 | * and return | 749 | * and return |
750 | * 1.Completed | 750 | * 1.Completed |
751 | * 2.Priority | 751 | * 2.Priority |
752 | * 3.Description | 752 | * 3.Description |
753 | * 4.DueDate | 753 | * 4.DueDate |
754 | */ | 754 | */ |
755 | if (!seComp ) { | 755 | if (!seComp ) { |
756 | if ( (ret = completed( con1->todo, con2->todo ) ) ) { | 756 | if ( (ret = completed( con1->todo, con2->todo ) ) ) { |
757 | if (!m_asc ) ret *= -1; | 757 | if (!m_asc ) ret *= -1; |
758 | return ret; | 758 | return ret; |
759 | } | 759 | } |
760 | } | 760 | } |
761 | if (!sePrio ) { | 761 | if (!sePrio ) { |
762 | if ( (ret = priority( con1->todo, con2->todo ) ) ) { | 762 | if ( (ret = priority( con1->todo, con2->todo ) ) ) { |
763 | if (!m_asc ) ret *= -1; | 763 | if (!m_asc ) ret *= -1; |
764 | return ret; | 764 | return ret; |
765 | } | 765 | } |
766 | } | 766 | } |
767 | if (!seDesc ) { | 767 | if (!seDesc ) { |
768 | if ( (ret = description(con1->todo, con2->todo ) ) ) { | 768 | if ( (ret = description(con1->todo, con2->todo ) ) ) { |
769 | if (!m_asc) ret *= -1; | 769 | if (!m_asc) ret *= -1; |
770 | return ret; | 770 | return ret; |
771 | } | 771 | } |
772 | } | 772 | } |
773 | if (!seDeadline) { | 773 | if (!seDeadline) { |
774 | if ( (ret = deadline( con1->todo, con2->todo ) ) ) { | 774 | if ( (ret = deadline( con1->todo, con2->todo ) ) ) { |
775 | if (!m_asc) ret *= -1; | 775 | if (!m_asc) ret *= -1; |
776 | return ret; | 776 | return ret; |
777 | } | 777 | } |
778 | } | 778 | } |
779 | 779 | ||
780 | return 0; | 780 | return 0; |
781 | } | 781 | } |
782 | private: | 782 | private: |
783 | bool m_asc; | 783 | bool m_asc; |
784 | int m_sort; | 784 | int m_sort; |
785 | 785 | ||
786 | }; | 786 | }; |
787 | 787 | ||
788 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, | 788 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, |
789 | int sortFilter, int cat ) { | 789 | int sortFilter, int cat ) { |
790 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); | 790 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); |
791 | QMap<int, OTodo>::Iterator it; | 791 | QMap<int, OTodo>::Iterator it; |
792 | int item = 0; | 792 | int item = 0; |
793 | 793 | ||
794 | bool bCat = sortFilter & 1 ? true : false; | 794 | bool bCat = sortFilter & 1 ? true : false; |
795 | bool bOnly = sortFilter & 2 ? true : false; | 795 | bool bOnly = sortFilter & 2 ? true : false; |
796 | bool comp = sortFilter & 4 ? true : false; | 796 | bool comp = sortFilter & 4 ? true : false; |
797 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 797 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
798 | 798 | ||
799 | /* show category */ | 799 | /* show category */ |
800 | /* -1 == unfiled */ | 800 | /* -1 == unfiled */ |
801 | if ( bCat && cat == -1 ) { | 801 | if ( bCat && cat == -1 ) { |
802 | if(!(*it).categories().isEmpty() ) | 802 | if(!(*it).categories().isEmpty() ) |
803 | continue; | 803 | continue; |
804 | }else if ( bCat && cat != 0) | 804 | }else if ( bCat && cat != 0) |
805 | if (!(*it).categories().contains( cat ) ) { | 805 | if (!(*it).categories().contains( cat ) ) { |
806 | continue; | 806 | continue; |
807 | } | 807 | } |
808 | /* isOverdue but we should not show overdue - why?*/ | 808 | /* isOverdue but we should not show overdue - why?*/ |
809 | /* if ( (*it).isOverdue() && !bOnly ) { | 809 | /* if ( (*it).isOverdue() && !bOnly ) { |
810 | qWarning("item is overdue but !bOnly"); | 810 | qWarning("item is overdue but !bOnly"); |
811 | continue; | 811 | continue; |
812 | } | 812 | } |
813 | */ | 813 | */ |
814 | if ( !(*it).isOverdue() && bOnly ) { | 814 | if ( !(*it).isOverdue() && bOnly ) { |
815 | continue; | 815 | continue; |
816 | } | 816 | } |
817 | 817 | ||
818 | if ((*it).isCompleted() && comp ) { | 818 | if ((*it).isCompleted() && comp ) { |
819 | continue; | 819 | continue; |
820 | } | 820 | } |
821 | 821 | ||
822 | 822 | ||
823 | OTodoXMLContainer* con = new OTodoXMLContainer(); | 823 | OTodoXMLContainer* con = new OTodoXMLContainer(); |
824 | con->todo = (*it); | 824 | con->todo = (*it); |
825 | vector.insert(item, con ); | 825 | vector.insert(item, con ); |
826 | item++; | 826 | item++; |
827 | } | 827 | } |
828 | vector.resize( item ); | 828 | vector.resize( item ); |
829 | /* sort it now */ | 829 | /* sort it now */ |
830 | vector.sort(); | 830 | vector.sort(); |
831 | /* now get the uids */ | 831 | /* now get the uids */ |
832 | QArray<int> array( vector.count() ); | 832 | QArray<int> array( vector.count() ); |
833 | for (uint i= 0; i < vector.count(); i++ ) { | 833 | for (uint i= 0; i < vector.count(); i++ ) { |
834 | array[i] = ( vector.at(i) )->todo.uid(); | 834 | array[i] = ( vector.at(i) )->todo.uid(); |
835 | } | 835 | } |
836 | return array; | 836 | return array; |
837 | }; | 837 | }; |
838 | void OTodoAccessXML::removeAllCompleted() { | 838 | void OTodoAccessXML::removeAllCompleted() { |
839 | QMap<int, OTodo> events = m_events; | ||
839 | for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { | 840 | for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { |
840 | if ( (*it).isCompleted() ) | 841 | if ( (*it).isCompleted() ) |
841 | m_events.remove( it ); | 842 | events.remove( it.key() ); |
842 | } | 843 | } |
844 | m_events = events; | ||
843 | } | 845 | } |
844 | QBitArray OTodoAccessXML::supports()const { | 846 | QBitArray OTodoAccessXML::supports()const { |
845 | static QBitArray ar = sup(); | 847 | static QBitArray ar = sup(); |
846 | return ar; | 848 | return ar; |
847 | } | 849 | } |
848 | QBitArray OTodoAccessXML::sup() { | 850 | QBitArray OTodoAccessXML::sup() { |
849 | QBitArray ar( OTodo::CompletedDate +1 ); | 851 | QBitArray ar( OTodo::CompletedDate +1 ); |
850 | ar.fill( true ); | 852 | ar.fill( true ); |
851 | ar[OTodo::CrossReference] = false; | 853 | ar[OTodo::CrossReference] = false; |
852 | ar[OTodo::State ] = false; | 854 | ar[OTodo::State ] = false; |
853 | ar[OTodo::Reminders] = false; | 855 | ar[OTodo::Reminders] = false; |
854 | ar[OTodo::Notifiers] = false; | 856 | ar[OTodo::Notifiers] = false; |
855 | ar[OTodo::Maintainer] = false; | 857 | ar[OTodo::Maintainer] = false; |
856 | 858 | ||
857 | return ar; | 859 | return ar; |
858 | } | 860 | } |
859 | QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const | 861 | QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const |
860 | { | 862 | { |
861 | QArray<int> m_currentQuery( m_events.count() ); | 863 | QArray<int> m_currentQuery( m_events.count() ); |
862 | uint arraycounter = 0; | 864 | uint arraycounter = 0; |
863 | 865 | ||
864 | QMap<int, OTodo>::ConstIterator it; | 866 | QMap<int, OTodo>::ConstIterator it; |
865 | for (it = m_events.begin(); it != m_events.end(); ++it ) { | 867 | for (it = m_events.begin(); it != m_events.end(); ++it ) { |
866 | if ( it.data().match( r ) ) | 868 | if ( it.data().match( r ) ) |
867 | m_currentQuery[arraycounter++] = it.data().uid(); | 869 | m_currentQuery[arraycounter++] = it.data().uid(); |
868 | 870 | ||
869 | } | 871 | } |
870 | // Shrink to fit.. | 872 | // Shrink to fit.. |
871 | m_currentQuery.resize(arraycounter); | 873 | m_currentQuery.resize(arraycounter); |
872 | 874 | ||
873 | return m_currentQuery; | 875 | return m_currentQuery; |
874 | } | 876 | } |
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h index ad6cf5a..f3c339d 100644 --- a/libopie2/opiepim/backend/obackendfactory.h +++ b/libopie2/opiepim/backend/obackendfactory.h | |||
@@ -1,154 +1,166 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage Backends. | 2 | * Class to manage Backends. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 5 | * |
6 | * ===================================================================== | 6 | * ===================================================================== |
7 | *This program is free software; you can redistribute it and/or | 7 | *This program is free software; you can redistribute it and/or |
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; | 9 | * License as published by the Free Software Foundation; |
10 | * either version 2 of the License, or (at your option) any later | 10 | * either version 2 of the License, or (at your option) any later |
11 | * version. | 11 | * version. |
12 | * ===================================================================== | 12 | * ===================================================================== |
13 | * ToDo: Use plugins | 13 | * ToDo: Use plugins |
14 | * ===================================================================== | 14 | * ===================================================================== |
15 | * Version: $Id$ | 15 | * Version: $Id$ |
16 | * ===================================================================== | 16 | * ===================================================================== |
17 | * History: | 17 | * History: |
18 | * $Log$ | 18 | * $Log$ |
19 | * Revision 1.7 2003/08/01 12:30:16 eilers | ||
20 | * Merging changes from BRANCH_1_0 to HEAD | ||
21 | * | ||
22 | * Revision 1.6.4.1 2003/06/30 14:34:19 eilers | ||
23 | * Patches from Zecke: | ||
24 | * Fixing and cleaning up extraMap handling | ||
25 | * Adding d_ptr for binary compatibility in the future | ||
26 | * | ||
19 | * Revision 1.6 2003/04/13 18:07:10 zecke | 27 | * Revision 1.6 2003/04/13 18:07:10 zecke |
20 | * More API doc | 28 | * More API doc |
21 | * QString -> const QString& | 29 | * QString -> const QString& |
22 | * QString = 0l -> QString::null | 30 | * QString = 0l -> QString::null |
23 | * | 31 | * |
24 | * Revision 1.5 2003/02/21 23:31:52 zecke | 32 | * Revision 1.5 2003/02/21 23:31:52 zecke |
25 | * Add XML datebookresource | 33 | * Add XML datebookresource |
26 | * -clean up todoaccessxml header | 34 | * -clean up todoaccessxml header |
27 | * -implement some more stuff in the oeven tester | 35 | * -implement some more stuff in the oeven tester |
28 | * -extend DefaultFactory to not crash and to use datebook | 36 | * -extend DefaultFactory to not crash and to use datebook |
29 | * | 37 | * |
30 | * -reading of OEvents is working nicely.. saving will be added | 38 | * -reading of OEvents is working nicely.. saving will be added |
31 | * tomorrow | 39 | * tomorrow |
32 | * -fix spelling in ODateBookAcces | 40 | * -fix spelling in ODateBookAcces |
33 | * | 41 | * |
34 | * Revision 1.4 2002/10/14 15:55:18 eilers | 42 | * Revision 1.4 2002/10/14 15:55:18 eilers |
35 | * Redeactivate SQL.. ;) | 43 | * Redeactivate SQL.. ;) |
36 | * | 44 | * |
37 | * Revision 1.3 2002/10/10 17:08:58 zecke | 45 | * Revision 1.3 2002/10/10 17:08:58 zecke |
38 | * The Cache is finally in place | 46 | * The Cache is finally in place |
39 | * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;) | 47 | * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;) |
40 | * The read ahead functionality does not make sense for XMLs backends because most of the stuff is already in memory. While using readahead on SQL makes things a lot faster.... | 48 | * The read ahead functionality does not make sense for XMLs backends because most of the stuff is already in memory. While using readahead on SQL makes things a lot faster.... |
41 | * I still have to fully implement read ahead | 49 | * I still have to fully implement read ahead |
42 | * This change is bic but sc | 50 | * This change is bic but sc |
43 | * | 51 | * |
44 | * Revision 1.2 2002/10/08 09:27:36 eilers | 52 | * Revision 1.2 2002/10/08 09:27:36 eilers |
45 | * Fixed libopie.pro to include the new pim-API. | 53 | * Fixed libopie.pro to include the new pim-API. |
46 | * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to | 54 | * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to |
47 | * compile itself would need to install libsqlite, libopiesql... | 55 | * compile itself would need to install libsqlite, libopiesql... |
48 | * Therefore, the backend currently uses XML only.. | 56 | * Therefore, the backend currently uses XML only.. |
49 | * | 57 | * |
50 | * Revision 1.1 2002/10/07 17:35:01 eilers | 58 | * Revision 1.1 2002/10/07 17:35:01 eilers |
51 | * added OBackendFactory for advanced backend access | 59 | * added OBackendFactory for advanced backend access |
52 | * | 60 | * |
53 | * | 61 | * |
54 | * ===================================================================== | 62 | * ===================================================================== |
55 | */ | 63 | */ |
56 | #ifndef OPIE_BACKENDFACTORY_H_ | 64 | #ifndef OPIE_BACKENDFACTORY_H_ |
57 | #define OPIE_BACKENDFACTORY_H_ | 65 | #define OPIE_BACKENDFACTORY_H_ |
58 | 66 | ||
59 | #include <qstring.h> | 67 | #include <qstring.h> |
60 | #include <qasciidict.h> | 68 | #include <qasciidict.h> |
61 | #include <qpe/config.h> | 69 | #include <qpe/config.h> |
62 | 70 | ||
63 | #include "otodoaccessxml.h" | 71 | #include "otodoaccessxml.h" |
64 | #include "ocontactaccessbackend_xml.h" | 72 | #include "ocontactaccessbackend_xml.h" |
65 | #include "odatebookaccessbackend_xml.h" | 73 | #include "odatebookaccessbackend_xml.h" |
66 | 74 | ||
67 | #ifdef __USE_SQL | 75 | #ifdef __USE_SQL |
68 | #include "otodoaccesssql.h" | 76 | #include "otodoaccesssql.h" |
69 | #endif | 77 | #endif |
70 | 78 | ||
79 | class OBackendPrivate; | ||
80 | |||
71 | /** | 81 | /** |
72 | * This class is our factory. It will give us the default implementations | 82 | * This class is our factory. It will give us the default implementations |
73 | * of at least Todolist, Contacts and Datebook. In the future this class will | 83 | * of at least Todolist, Contacts and Datebook. In the future this class will |
74 | * allow users to switch the backend with ( XML->SQLite ) without the need | 84 | * allow users to switch the backend with ( XML->SQLite ) without the need |
75 | * to recompile.# | 85 | * to recompile.# |
76 | * This class as the whole PIM Api is making use of templates | 86 | * This class as the whole PIM Api is making use of templates |
77 | * | 87 | * |
78 | * <pre> | 88 | * <pre> |
79 | * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null ); | 89 | * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null ); |
80 | * backend->load(); | 90 | * backend->load(); |
81 | * </pre> | 91 | * </pre> |
82 | * | 92 | * |
83 | * @author Stefan Eilers | 93 | * @author Stefan Eilers |
84 | * @version 0.1 | 94 | * @version 0.1 |
85 | */ | 95 | */ |
86 | template<class T> | 96 | template<class T> |
87 | class OBackendFactory | 97 | class OBackendFactory |
88 | { | 98 | { |
89 | public: | 99 | public: |
90 | OBackendFactory() {}; | 100 | OBackendFactory() {}; |
91 | 101 | ||
92 | enum BACKENDS { | 102 | enum BACKENDS { |
93 | TODO, | 103 | TODO, |
94 | CONTACT, | 104 | CONTACT, |
95 | DATE | 105 | DATE |
96 | }; | 106 | }; |
97 | 107 | ||
98 | /** | 108 | /** |
99 | * Returns a backend implementation for backendName | 109 | * Returns a backend implementation for backendName |
100 | * @param backendName the type of the backend | 110 | * @param backendName the type of the backend |
101 | * @param appName will be passed on to the backend | 111 | * @param appName will be passed on to the backend |
102 | */ | 112 | */ |
103 | static T* Default( const QString backendName, const QString& appName ){ | 113 | static T* Default( const QString backendName, const QString& appName ){ |
104 | 114 | ||
105 | // __asm__("int3"); | 115 | // __asm__("int3"); |
106 | 116 | ||
107 | Config config( "pimaccess" ); | 117 | Config config( "pimaccess" ); |
108 | config.setGroup ( backendName ); | 118 | config.setGroup ( backendName ); |
109 | QString backend = config.readEntry( "usebackend" ); | 119 | QString backend = config.readEntry( "usebackend" ); |
110 | 120 | ||
111 | QAsciiDict<int> dict ( 3 ); | 121 | QAsciiDict<int> dict ( 3 ); |
112 | dict.setAutoDelete ( TRUE ); | 122 | dict.setAutoDelete ( TRUE ); |
113 | 123 | ||
114 | dict.insert( "todo", new int (TODO) ); | 124 | dict.insert( "todo", new int (TODO) ); |
115 | dict.insert( "contact", new int (CONTACT) ); | 125 | dict.insert( "contact", new int (CONTACT) ); |
116 | dict.insert( "datebook", new int(DATE) ); | 126 | dict.insert( "datebook", new int(DATE) ); |
117 | 127 | ||
118 | qWarning ("TODO is: %d", TODO); | 128 | qWarning ("TODO is: %d", TODO); |
119 | qWarning ("CONTACT is: %d", CONTACT); | 129 | qWarning ("CONTACT is: %d", CONTACT); |
120 | 130 | ||
121 | int *find = dict[ backendName ]; | 131 | int *find = dict[ backendName ]; |
122 | if (!find ) return 0; | 132 | if (!find ) return 0; |
123 | 133 | ||
124 | switch ( *find ){ | 134 | switch ( *find ){ |
125 | case TODO: | 135 | case TODO: |
126 | #ifdef __USE_SQL | 136 | #ifdef __USE_SQL |
127 | if ( backend == "sql" ) | 137 | if ( backend == "sql" ) |
128 | return (T*) new OTodoAccessBackendSQL(""); | 138 | return (T*) new OTodoAccessBackendSQL(""); |
129 | #else | 139 | #else |
130 | if ( backend == "sql" ) | 140 | if ( backend == "sql" ) |
131 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 141 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
132 | #endif | 142 | #endif |
133 | 143 | ||
134 | return (T*) new OTodoAccessXML( appName ); | 144 | return (T*) new OTodoAccessXML( appName ); |
135 | case CONTACT: | 145 | case CONTACT: |
136 | if ( backend == "sql" ) | 146 | if ( backend == "sql" ) |
137 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 147 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
138 | 148 | ||
139 | return (T*) new OContactAccessBackend_XML( appName ); | 149 | return (T*) new OContactAccessBackend_XML( appName ); |
140 | case DATE: | 150 | case DATE: |
141 | if ( backend == "sql" ) | 151 | if ( backend == "sql" ) |
142 | qWarning("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 152 | qWarning("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
143 | 153 | ||
144 | return (T*) new ODateBookAccessBackend_XML( appName ); | 154 | return (T*) new ODateBookAccessBackend_XML( appName ); |
145 | default: | 155 | default: |
146 | return NULL; | 156 | return NULL; |
147 | } | 157 | } |
148 | 158 | ||
149 | 159 | ||
150 | } | 160 | } |
161 | private: | ||
162 | OBackendPrivate* d; | ||
151 | }; | 163 | }; |
152 | 164 | ||
153 | 165 | ||
154 | #endif | 166 | #endif |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h index ebeb42d..280e05c 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend.h | |||
@@ -1,107 +1,119 @@ | |||
1 | /** | 1 | /** |
2 | * The class responsible for managing a backend. | 2 | * The class responsible for managing a backend. |
3 | * The implementation of this abstract class contains | 3 | * The implementation of this abstract class contains |
4 | * the complete database handling. | 4 | * the complete database handling. |
5 | * | 5 | * |
6 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 6 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
7 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) | 7 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) |
8 | * | 8 | * |
9 | * ===================================================================== | 9 | * ===================================================================== |
10 | *This program is free software; you can redistribute it and/or | 10 | *This program is free software; you can redistribute it and/or |
11 | *modify it under the terms of the GNU Library General Public | 11 | *modify it under the terms of the GNU Library General Public |
12 | * License as published by the Free Software Foundation; | 12 | * License as published by the Free Software Foundation; |
13 | * either version 2 of the License, or (at your option) any later | 13 | * either version 2 of the License, or (at your option) any later |
14 | * version. | 14 | * version. |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * ToDo: Define enum for query settings | 16 | * ToDo: Define enum for query settings |
17 | * ===================================================================== | 17 | * ===================================================================== |
18 | * Version: $Id$ | 18 | * Version: $Id$ |
19 | * ===================================================================== | 19 | * ===================================================================== |
20 | * History: | 20 | * History: |
21 | * $Log$ | 21 | * $Log$ |
22 | * Revision 1.6 2003/08/01 12:30:16 eilers | ||
23 | * Merging changes from BRANCH_1_0 to HEAD | ||
24 | * | ||
25 | * Revision 1.5.4.1 2003/06/30 14:34:19 eilers | ||
26 | * Patches from Zecke: | ||
27 | * Fixing and cleaning up extraMap handling | ||
28 | * Adding d_ptr for binary compatibility in the future | ||
29 | * | ||
22 | * Revision 1.5 2003/04/13 18:07:10 zecke | 30 | * Revision 1.5 2003/04/13 18:07:10 zecke |
23 | * More API doc | 31 | * More API doc |
24 | * QString -> const QString& | 32 | * QString -> const QString& |
25 | * QString = 0l -> QString::null | 33 | * QString = 0l -> QString::null |
26 | * | 34 | * |
27 | * Revision 1.4 2002/11/13 14:14:51 eilers | 35 | * Revision 1.4 2002/11/13 14:14:51 eilers |
28 | * Added sorted for Contacts.. | 36 | * Added sorted for Contacts.. |
29 | * | 37 | * |
30 | * Revision 1.3 2002/11/01 15:10:42 eilers | 38 | * Revision 1.3 2002/11/01 15:10:42 eilers |
31 | * Added regExp-search in database for all fields in a contact. | 39 | * Added regExp-search in database for all fields in a contact. |
32 | * | 40 | * |
33 | * Revision 1.2 2002/10/07 17:34:24 eilers | 41 | * Revision 1.2 2002/10/07 17:34:24 eilers |
34 | * added OBackendFactory for advanced backend access | 42 | * added OBackendFactory for advanced backend access |
35 | * | 43 | * |
36 | * Revision 1.1 2002/09/27 17:11:44 eilers | 44 | * Revision 1.1 2002/09/27 17:11:44 eilers |
37 | * Added API for accessing the Contact-Database ! It is compiling, but | 45 | * Added API for accessing the Contact-Database ! It is compiling, but |
38 | * please do not expect that anything is working ! | 46 | * please do not expect that anything is working ! |
39 | * I will debug that stuff in the next time .. | 47 | * I will debug that stuff in the next time .. |
40 | * Please read README_COMPILE for compiling ! | 48 | * Please read README_COMPILE for compiling ! |
41 | * | 49 | * |
42 | * ===================================================================== | 50 | * ===================================================================== |
43 | * | 51 | * |
44 | */ | 52 | */ |
45 | 53 | ||
46 | #ifndef _OCONTACTACCESSBACKEND_H_ | 54 | #ifndef _OCONTACTACCESSBACKEND_H_ |
47 | #define _OCONTACTACCESSBACKEND_H_ | 55 | #define _OCONTACTACCESSBACKEND_H_ |
48 | 56 | ||
49 | #include "ocontact.h" | 57 | #include "ocontact.h" |
50 | #include "opimaccessbackend.h" | 58 | #include "opimaccessbackend.h" |
51 | 59 | ||
52 | #include <qregexp.h> | 60 | #include <qregexp.h> |
53 | 61 | ||
54 | /** | 62 | /** |
55 | * This class represents the interface of all Contact Backends. | 63 | * This class represents the interface of all Contact Backends. |
56 | * Derivates of this class will be used to access the contacts. | 64 | * Derivates of this class will be used to access the contacts. |
57 | * As implementation currently XML and vCard exist. This class needs to be implemented | 65 | * As implementation currently XML and vCard exist. This class needs to be implemented |
58 | * if you want to provide your own storage. | 66 | * if you want to provide your own storage. |
59 | * In all queries a list of uids is passed on instead of loading the actual record! | 67 | * In all queries a list of uids is passed on instead of loading the actual record! |
60 | * | 68 | * |
61 | * @see OContactAccessBackend_VCard | 69 | * @see OContactAccessBackend_VCard |
62 | * @see OContactAccessBackend_XML | 70 | * @see OContactAccessBackend_XML |
63 | */ | 71 | */ |
64 | class OContactAccessBackend: public OPimAccessBackend<OContact> { | 72 | class OContactAccessBackend: public OPimAccessBackend<OContact> { |
65 | public: | 73 | public: |
66 | OContactAccessBackend() {} | 74 | OContactAccessBackend() {} |
67 | virtual ~OContactAccessBackend() {} | 75 | virtual ~OContactAccessBackend() {} |
68 | 76 | ||
69 | 77 | ||
70 | /** | 78 | /** |
71 | * Return if database was changed externally. | 79 | * Return if database was changed externally. |
72 | * This may just make sense on file based databases like a XML-File. | 80 | * This may just make sense on file based databases like a XML-File. |
73 | * It is used to prevent to overwrite the current database content | 81 | * It is used to prevent to overwrite the current database content |
74 | * if the file was already changed by something else ! | 82 | * if the file was already changed by something else ! |
75 | * If this happens, we have to reload before save our data. | 83 | * If this happens, we have to reload before save our data. |
76 | * If we use real databases, this should be handled by the database | 84 | * If we use real databases, this should be handled by the database |
77 | * management system themselve, therefore this function should always return false in | 85 | * management system themselve, therefore this function should always return false in |
78 | * this case. It is not our problem to handle this conflict ... | 86 | * this case. It is not our problem to handle this conflict ... |
79 | * @return <i>true</i> if the database was changed and if save without reload will | 87 | * @return <i>true</i> if the database was changed and if save without reload will |
80 | * be dangerous. <i>false</i> if the database was not changed or it is save to write | 88 | * be dangerous. <i>false</i> if the database was not changed or it is save to write |
81 | * in this situation. | 89 | * in this situation. |
82 | */ | 90 | */ |
83 | virtual bool wasChangedExternally() = 0; | 91 | virtual bool wasChangedExternally() = 0; |
84 | 92 | ||
85 | virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0; | 93 | virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0; |
86 | 94 | ||
87 | /** | 95 | /** |
88 | * Return all possible settings. | 96 | * Return all possible settings. |
89 | * @return All settings provided by the current backend | 97 | * @return All settings provided by the current backend |
90 | * (i.e.: query_WildCards & query_IgnoreCase) | 98 | * (i.e.: query_WildCards & query_IgnoreCase) |
91 | */ | 99 | */ |
92 | virtual const uint querySettings() = 0; | 100 | virtual const uint querySettings() = 0; |
93 | 101 | ||
94 | /** | 102 | /** |
95 | * Check whether settings are correct. | 103 | * Check whether settings are correct. |
96 | * @return <i>true</i> if the given settings are correct and possible. | 104 | * @return <i>true</i> if the given settings are correct and possible. |
97 | */ | 105 | */ |
98 | virtual bool hasQuerySettings (uint querySettings) const = 0; | 106 | virtual bool hasQuerySettings (uint querySettings) const = 0; |
99 | 107 | ||
100 | /** | 108 | /** |
101 | * FIXME!!! | 109 | * FIXME!!! |
102 | * Returns a sorted list of records either ascendinf or descending for a giving criteria and category | 110 | * Returns a sorted list of records either ascendinf or descending for a giving criteria and category |
103 | */ | 111 | */ |
104 | virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0; | 112 | virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0; |
105 | 113 | ||
114 | |||
115 | private: | ||
116 | class Private; | ||
117 | Private *d; | ||
106 | }; | 118 | }; |
107 | #endif | 119 | #endif |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp index 270bef3..b60c5be 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp | |||
@@ -1,249 +1,265 @@ | |||
1 | /* | 1 | /* |
2 | * VCard Backend for the OPIE-Contact Database. | 2 | * VCard Backend for the OPIE-Contact Database. |
3 | * | 3 | * |
4 | * Copyright (C) 2000 Trolltech AS. All rights reserved. | 4 | * Copyright (C) 2000 Trolltech AS. All rights reserved. |
5 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 5 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
6 | * | 6 | * |
7 | * ===================================================================== | 7 | * ===================================================================== |
8 | *This program is free software; you can redistribute it and/or | 8 | *This program is free software; you can redistribute it and/or |
9 | *modify it under the terms of the GNU Library General Public | 9 | *modify it under the terms of the GNU Library General Public |
10 | * License as published by the Free Software Foundation; either | 10 | * License as published by the Free Software Foundation; either |
11 | * version 2 of the License, or (at your option) any later version. | 11 | * version 2 of the License, or (at your option) any later version. |
12 | * ===================================================================== | 12 | * ===================================================================== |
13 | * ToDo: | 13 | * ToDo: |
14 | * | 14 | * |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * Version: $Id$ | 16 | * Version: $Id$ |
17 | * ===================================================================== | 17 | * ===================================================================== |
18 | * History: | 18 | * History: |
19 | * $Log$ | 19 | * $Log$ |
20 | * Revision 1.11 2003/08/01 12:30:16 eilers | ||
21 | * Merging changes from BRANCH_1_0 to HEAD | ||
22 | * | ||
23 | * Revision 1.10.4.3 2003/07/23 08:54:37 eilers | ||
24 | * Default email was added to the list of all emails, which already contains | ||
25 | * the default email.. | ||
26 | * This closes bug #1045 | ||
27 | * | ||
28 | * Revision 1.10.4.2 2003/07/23 08:44:45 eilers | ||
29 | * Importing of Notes in vcard files wasn't implemented. | ||
30 | * Closes bug #1044 | ||
31 | * | ||
32 | * Revision 1.10.4.1 2003/06/02 13:37:49 eilers | ||
33 | * Fixing memory leak | ||
34 | * | ||
20 | * Revision 1.10 2003/04/13 18:07:10 zecke | 35 | * Revision 1.10 2003/04/13 18:07:10 zecke |
21 | * More API doc | 36 | * More API doc |
22 | * QString -> const QString& | 37 | * QString -> const QString& |
23 | * QString = 0l -> QString::null | 38 | * QString = 0l -> QString::null |
24 | * | 39 | * |
25 | * Revision 1.9 2003/03/21 10:33:09 eilers | 40 | * Revision 1.9 2003/03/21 10:33:09 eilers |
26 | * Merged speed optimized xml backend for contacts to main. | 41 | * Merged speed optimized xml backend for contacts to main. |
27 | * Added QDateTime to querybyexample. For instance, it is now possible to get | 42 | * Added QDateTime to querybyexample. For instance, it is now possible to get |
28 | * all Birthdays/Anniversaries between two dates. This should be used | 43 | * all Birthdays/Anniversaries between two dates. This should be used |
29 | * to show all birthdays in the datebook.. | 44 | * to show all birthdays in the datebook.. |
30 | * This change is sourcecode backward compatible but you have to upgrade | 45 | * This change is sourcecode backward compatible but you have to upgrade |
31 | * the binaries for today-addressbook. | 46 | * the binaries for today-addressbook. |
32 | * | 47 | * |
33 | * Revision 1.8 2003/02/21 16:52:49 zecke | 48 | * Revision 1.8 2003/02/21 16:52:49 zecke |
34 | * -Remove old Todo classes they're deprecated and today I already using the | 49 | * -Remove old Todo classes they're deprecated and today I already using the |
35 | * new API | 50 | * new API |
36 | * -Guard against self assignment in OTodo | 51 | * -Guard against self assignment in OTodo |
37 | * -Add test apps for OPIM | 52 | * -Add test apps for OPIM |
38 | * -Opiefied Event classes | 53 | * -Opiefied Event classes |
39 | * -Added TimeZone handling and pinning of TimeZones to OEvent | 54 | * -Added TimeZone handling and pinning of TimeZones to OEvent |
40 | * -Adjust ORecur and the widget to better timezone behaviour | 55 | * -Adjust ORecur and the widget to better timezone behaviour |
41 | * | 56 | * |
42 | * Revision 1.7 2003/02/16 22:25:46 zecke | 57 | * Revision 1.7 2003/02/16 22:25:46 zecke |
43 | * 0000276 Fix for that bug.. or better temp workaround | 58 | * 0000276 Fix for that bug.. or better temp workaround |
44 | * A Preferred Number is HOME|VOICE | 59 | * A Preferred Number is HOME|VOICE |
45 | * A CellPhone is HOME|VOICE|CELL the type & HOME|VOICE test | 60 | * A CellPhone is HOME|VOICE|CELL the type & HOME|VOICE test |
46 | * triggers both | 61 | * triggers both |
47 | * and the cell phone number overrides the other entries.. | 62 | * and the cell phone number overrides the other entries.. |
48 | * | 63 | * |
49 | * as a temp I check that it's not equal to HOME|VOICE|CELL before setting the | 64 | * as a temp I check that it's not equal to HOME|VOICE|CELL before setting the |
50 | * number | 65 | * number |
51 | * | 66 | * |
52 | * The right and final fix would be to reorder the if statement to make it | 67 | * The right and final fix would be to reorder the if statement to make it |
53 | * if else based and the less common thing put to the bottom | 68 | * if else based and the less common thing put to the bottom |
54 | * | 69 | * |
55 | * OTodoAccessVcal fix the date for beaming | 70 | * OTodoAccessVcal fix the date for beaming |
56 | * | 71 | * |
57 | * Revision 1.6 2003/01/13 15:49:31 eilers | 72 | * Revision 1.6 2003/01/13 15:49:31 eilers |
58 | * Fixing crash when businesscard.vcf is missing.. | 73 | * Fixing crash when businesscard.vcf is missing.. |
59 | * | 74 | * |
60 | * Revision 1.5 2002/12/07 13:26:22 eilers | 75 | * Revision 1.5 2002/12/07 13:26:22 eilers |
61 | * Fixing bug in storing anniversary.. | 76 | * Fixing bug in storing anniversary.. |
62 | * | 77 | * |
63 | * Revision 1.4 2002/11/13 14:14:51 eilers | 78 | * Revision 1.4 2002/11/13 14:14:51 eilers |
64 | * Added sorted for Contacts.. | 79 | * Added sorted for Contacts.. |
65 | * | 80 | * |
66 | * Revision 1.3 2002/11/11 16:41:09 kergoth | 81 | * Revision 1.3 2002/11/11 16:41:09 kergoth |
67 | * no default arguments in implementation | 82 | * no default arguments in implementation |
68 | * | 83 | * |
69 | * Revision 1.2 2002/11/10 15:41:53 eilers | 84 | * Revision 1.2 2002/11/10 15:41:53 eilers |
70 | * Bugfixes.. | 85 | * Bugfixes.. |
71 | * | 86 | * |
72 | * Revision 1.1 2002/11/09 14:34:52 eilers | 87 | * Revision 1.1 2002/11/09 14:34:52 eilers |
73 | * Added VCard Backend. | 88 | * Added VCard Backend. |
74 | * | 89 | * |
75 | */ | 90 | */ |
76 | #include "ocontactaccessbackend_vcard.h" | 91 | #include "ocontactaccessbackend_vcard.h" |
77 | #include "../../library/backend/vobject_p.h" | 92 | #include "../../library/backend/vobject_p.h" |
78 | #include "../../library/backend/qfiledirect_p.h" | 93 | #include "../../library/backend/qfiledirect_p.h" |
79 | 94 | ||
80 | #include <qpe/timeconversion.h> | 95 | #include <qpe/timeconversion.h> |
81 | 96 | ||
82 | #include <qfile.h> | 97 | #include <qfile.h> |
83 | 98 | ||
84 | OContactAccessBackend_VCard::OContactAccessBackend_VCard ( const QString& , const QString& filename ): | 99 | OContactAccessBackend_VCard::OContactAccessBackend_VCard ( const QString& , const QString& filename ): |
85 | m_dirty( false ), | 100 | m_dirty( false ), |
86 | m_file( filename ) | 101 | m_file( filename ) |
87 | { | 102 | { |
88 | load(); | 103 | load(); |
89 | } | 104 | } |
90 | 105 | ||
91 | 106 | ||
92 | bool OContactAccessBackend_VCard::load () | 107 | bool OContactAccessBackend_VCard::load () |
93 | { | 108 | { |
94 | m_map.clear(); | 109 | m_map.clear(); |
95 | m_dirty = false; | 110 | m_dirty = false; |
96 | 111 | ||
97 | VObject* obj = 0l; | 112 | VObject* obj = 0l; |
98 | 113 | ||
99 | if ( QFile::exists(m_file) ){ | 114 | if ( QFile::exists(m_file) ){ |
100 | obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); | 115 | obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); |
101 | if ( !obj ) | 116 | if ( !obj ) |
102 | return false; | 117 | return false; |
103 | }else{ | 118 | }else{ |
104 | qWarning("File \"%s\" not found !", m_file.latin1() ); | 119 | qWarning("File \"%s\" not found !", m_file.latin1() ); |
105 | return false; | 120 | return false; |
106 | } | 121 | } |
107 | 122 | ||
108 | while ( obj ) { | 123 | while ( obj ) { |
109 | OContact con = parseVObject( obj ); | 124 | OContact con = parseVObject( obj ); |
110 | /* | 125 | /* |
111 | * if uid is 0 assign a new one | 126 | * if uid is 0 assign a new one |
112 | * this at least happens on | 127 | * this at least happens on |
113 | * Nokia6210 | 128 | * Nokia6210 |
114 | */ | 129 | */ |
115 | if ( con.uid() == 0 ){ | 130 | if ( con.uid() == 0 ){ |
116 | con.setUid( 1 ); | 131 | con.setUid( 1 ); |
117 | qWarning("assigned new uid %d",con.uid() ); | 132 | qWarning("assigned new uid %d",con.uid() ); |
118 | } | 133 | } |
119 | 134 | ||
120 | m_map.insert( con.uid(), con ); | 135 | m_map.insert( con.uid(), con ); |
121 | 136 | ||
122 | VObject *t = obj; | 137 | VObject *t = obj; |
123 | obj = nextVObjectInList(obj); | 138 | obj = nextVObjectInList(obj); |
124 | cleanVObject( t ); | 139 | cleanVObject( t ); |
125 | } | 140 | } |
126 | 141 | ||
127 | return true; | 142 | return true; |
128 | 143 | ||
129 | } | 144 | } |
130 | bool OContactAccessBackend_VCard::reload() | 145 | bool OContactAccessBackend_VCard::reload() |
131 | { | 146 | { |
132 | return load(); | 147 | return load(); |
133 | } | 148 | } |
134 | bool OContactAccessBackend_VCard::save() | 149 | bool OContactAccessBackend_VCard::save() |
135 | { | 150 | { |
136 | if (!m_dirty ) | 151 | if (!m_dirty ) |
137 | return true; | 152 | return true; |
138 | 153 | ||
139 | QFileDirect file( m_file ); | 154 | QFileDirect file( m_file ); |
140 | if (!file.open(IO_WriteOnly ) ) | 155 | if (!file.open(IO_WriteOnly ) ) |
141 | return false; | 156 | return false; |
142 | 157 | ||
143 | VObject *obj; | 158 | VObject *obj; |
144 | obj = newVObject( VCCalProp ); | 159 | obj = newVObject( VCCalProp ); |
145 | addPropValue( obj, VCVersionProp, "1.0" ); | 160 | addPropValue( obj, VCVersionProp, "1.0" ); |
146 | 161 | ||
147 | VObject *vo; | 162 | VObject *vo; |
148 | for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ | 163 | for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ |
149 | vo = createVObject( *it ); | 164 | vo = createVObject( *it ); |
150 | writeVObject( file.directHandle() , vo ); | 165 | writeVObject( file.directHandle() , vo ); |
151 | cleanVObject( vo ); | 166 | cleanVObject( vo ); |
152 | } | 167 | } |
153 | cleanStrTbl(); | 168 | cleanStrTbl(); |
169 | deleteVObject( obj ); | ||
154 | 170 | ||
155 | m_dirty = false; | 171 | m_dirty = false; |
156 | return true; | 172 | return true; |
157 | 173 | ||
158 | 174 | ||
159 | } | 175 | } |
160 | void OContactAccessBackend_VCard::clear () | 176 | void OContactAccessBackend_VCard::clear () |
161 | { | 177 | { |
162 | m_map.clear(); | 178 | m_map.clear(); |
163 | m_dirty = true; // ??? sure ? (se) | 179 | m_dirty = true; // ??? sure ? (se) |
164 | } | 180 | } |
165 | 181 | ||
166 | bool OContactAccessBackend_VCard::add ( const OContact& newcontact ) | 182 | bool OContactAccessBackend_VCard::add ( const OContact& newcontact ) |
167 | { | 183 | { |
168 | m_map.insert( newcontact.uid(), newcontact ); | 184 | m_map.insert( newcontact.uid(), newcontact ); |
169 | m_dirty = true; | 185 | m_dirty = true; |
170 | return true; | 186 | return true; |
171 | } | 187 | } |
172 | 188 | ||
173 | bool OContactAccessBackend_VCard::remove ( int uid ) | 189 | bool OContactAccessBackend_VCard::remove ( int uid ) |
174 | { | 190 | { |
175 | m_map.remove( uid ); | 191 | m_map.remove( uid ); |
176 | m_dirty = true; | 192 | m_dirty = true; |
177 | return true; | 193 | return true; |
178 | } | 194 | } |
179 | 195 | ||
180 | bool OContactAccessBackend_VCard::replace ( const OContact &contact ) | 196 | bool OContactAccessBackend_VCard::replace ( const OContact &contact ) |
181 | { | 197 | { |
182 | m_map.replace( contact.uid(), contact ); | 198 | m_map.replace( contact.uid(), contact ); |
183 | m_dirty = true; | 199 | m_dirty = true; |
184 | return true; | 200 | return true; |
185 | } | 201 | } |
186 | 202 | ||
187 | OContact OContactAccessBackend_VCard::find ( int uid ) const | 203 | OContact OContactAccessBackend_VCard::find ( int uid ) const |
188 | { | 204 | { |
189 | return m_map[uid]; | 205 | return m_map[uid]; |
190 | } | 206 | } |
191 | 207 | ||
192 | QArray<int> OContactAccessBackend_VCard::allRecords() const | 208 | QArray<int> OContactAccessBackend_VCard::allRecords() const |
193 | { | 209 | { |
194 | QArray<int> ar( m_map.count() ); | 210 | QArray<int> ar( m_map.count() ); |
195 | QMap<int, OContact>::ConstIterator it; | 211 | QMap<int, OContact>::ConstIterator it; |
196 | int i = 0; | 212 | int i = 0; |
197 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | 213 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { |
198 | ar[i] = it.key(); | 214 | ar[i] = it.key(); |
199 | i++; | 215 | i++; |
200 | } | 216 | } |
201 | return ar; | 217 | return ar; |
202 | } | 218 | } |
203 | 219 | ||
204 | // Not implemented | 220 | // Not implemented |
205 | QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int, const QDateTime& ) | 221 | QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int, const QDateTime& ) |
206 | { | 222 | { |
207 | QArray<int> ar(0); | 223 | QArray<int> ar(0); |
208 | return ar; | 224 | return ar; |
209 | } | 225 | } |
210 | 226 | ||
211 | // Not implemented | 227 | // Not implemented |
212 | QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const | 228 | QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const |
213 | { | 229 | { |
214 | QArray<int> ar(0); | 230 | QArray<int> ar(0); |
215 | return ar; | 231 | return ar; |
216 | } | 232 | } |
217 | 233 | ||
218 | const uint OContactAccessBackend_VCard::querySettings() | 234 | const uint OContactAccessBackend_VCard::querySettings() |
219 | { | 235 | { |
220 | return 0; // No search possible | 236 | return 0; // No search possible |
221 | } | 237 | } |
222 | 238 | ||
223 | bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const | 239 | bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const |
224 | { | 240 | { |
225 | return false; // No search possible, therefore all settings invalid ;) | 241 | return false; // No search possible, therefore all settings invalid ;) |
226 | } | 242 | } |
227 | 243 | ||
228 | bool OContactAccessBackend_VCard::wasChangedExternally() | 244 | bool OContactAccessBackend_VCard::wasChangedExternally() |
229 | { | 245 | { |
230 | return false; // Don't expect concurrent access | 246 | return false; // Don't expect concurrent access |
231 | } | 247 | } |
232 | 248 | ||
233 | // Not implemented | 249 | // Not implemented |
234 | QArray<int> OContactAccessBackend_VCard::sorted( bool , int, int, int ) | 250 | QArray<int> OContactAccessBackend_VCard::sorted( bool , int, int, int ) |
235 | { | 251 | { |
236 | QArray<int> ar(0); | 252 | QArray<int> ar(0); |
237 | return ar; | 253 | return ar; |
238 | } | 254 | } |
239 | 255 | ||
240 | // *** Private stuff *** | 256 | // *** Private stuff *** |
241 | 257 | ||
242 | 258 | ||
243 | OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) | 259 | OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) |
244 | { | 260 | { |
245 | OContact c; | 261 | OContact c; |
246 | 262 | ||
247 | VObjectIterator it; | 263 | VObjectIterator it; |
248 | initPropIterator( &it, obj ); | 264 | initPropIterator( &it, obj ); |
249 | while( moreIteration( &it ) ) { | 265 | while( moreIteration( &it ) ) { |
@@ -353,276 +369,278 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) | |||
353 | type |= VOICE; | 369 | type |= VOICE; |
354 | 370 | ||
355 | qWarning("value %s %d", value.data(), type ); | 371 | qWarning("value %s %d", value.data(), type ); |
356 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) ) | 372 | if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) ) |
357 | c.setHomePhone( value ); | 373 | c.setHomePhone( value ); |
358 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) | 374 | if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) |
359 | c.setHomeFax( value ); | 375 | c.setHomeFax( value ); |
360 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) | 376 | if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) |
361 | c.setHomeMobile( value ); | 377 | c.setHomeMobile( value ); |
362 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) ) | 378 | if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) ) |
363 | c.setBusinessPhone( value ); | 379 | c.setBusinessPhone( value ); |
364 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) | 380 | if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) |
365 | c.setBusinessFax( value ); | 381 | c.setBusinessFax( value ); |
366 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) | 382 | if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) |
367 | c.setBusinessMobile( value ); | 383 | c.setBusinessMobile( value ); |
368 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) | 384 | if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) |
369 | c.setBusinessPager( value ); | 385 | c.setBusinessPager( value ); |
370 | } | 386 | } |
371 | } | 387 | } |
372 | else if ( name == VCEmailAddressProp ) { | 388 | else if ( name == VCEmailAddressProp ) { |
373 | QString email = vObjectStringZValue( o ); | 389 | QString email = vObjectStringZValue( o ); |
374 | bool valid = TRUE; | 390 | bool valid = TRUE; |
375 | VObjectIterator nit; | 391 | VObjectIterator nit; |
376 | initPropIterator( &nit, o ); | 392 | initPropIterator( &nit, o ); |
377 | while( moreIteration( &nit ) ) { | 393 | while( moreIteration( &nit ) ) { |
378 | VObject *o = nextVObject( &nit ); | 394 | VObject *o = nextVObject( &nit ); |
379 | QCString name = vObjectTypeInfo( o ); | 395 | QCString name = vObjectTypeInfo( o ); |
380 | if ( name != VCInternetProp && name != VCHomeProp && | 396 | if ( name != VCInternetProp && name != VCHomeProp && |
381 | name != VCWorkProp && | 397 | name != VCWorkProp && |
382 | name != VCPreferredProp ) | 398 | name != VCPreferredProp ) |
383 | // ### preffered should map to default email | 399 | // ### preffered should map to default email |
384 | valid = FALSE; | 400 | valid = FALSE; |
385 | } | 401 | } |
386 | if ( valid ) { | 402 | if ( valid ) { |
387 | c.insertEmail( email ); | 403 | c.insertEmail( email ); |
388 | } | 404 | } |
389 | } | 405 | } |
390 | else if ( name == VCURLProp ) { | 406 | else if ( name == VCURLProp ) { |
391 | VObjectIterator nit; | 407 | VObjectIterator nit; |
392 | initPropIterator( &nit, o ); | 408 | initPropIterator( &nit, o ); |
393 | while( moreIteration( &nit ) ) { | 409 | while( moreIteration( &nit ) ) { |
394 | VObject *o = nextVObject( &nit ); | 410 | VObject *o = nextVObject( &nit ); |
395 | QCString name = vObjectTypeInfo( o ); | 411 | QCString name = vObjectTypeInfo( o ); |
396 | if ( name == VCHomeProp ) | 412 | if ( name == VCHomeProp ) |
397 | c.setHomeWebpage( value ); | 413 | c.setHomeWebpage( value ); |
398 | else if ( name == VCWorkProp ) | 414 | else if ( name == VCWorkProp ) |
399 | c.setBusinessWebpage( value ); | 415 | c.setBusinessWebpage( value ); |
400 | } | 416 | } |
401 | } | 417 | } |
402 | else if ( name == VCOrgProp ) { | 418 | else if ( name == VCOrgProp ) { |
403 | VObjectIterator nit; | 419 | VObjectIterator nit; |
404 | initPropIterator( &nit, o ); | 420 | initPropIterator( &nit, o ); |
405 | while( moreIteration( &nit ) ) { | 421 | while( moreIteration( &nit ) ) { |
406 | VObject *o = nextVObject( &nit ); | 422 | VObject *o = nextVObject( &nit ); |
407 | QCString name = vObjectName( o ); | 423 | QCString name = vObjectName( o ); |
408 | QString value = vObjectStringZValue( o ); | 424 | QString value = vObjectStringZValue( o ); |
409 | if ( name == VCOrgNameProp ) | 425 | if ( name == VCOrgNameProp ) |
410 | c.setCompany( value ); | 426 | c.setCompany( value ); |
411 | else if ( name == VCOrgUnitProp ) | 427 | else if ( name == VCOrgUnitProp ) |
412 | c.setDepartment( value ); | 428 | c.setDepartment( value ); |
413 | else if ( name == VCOrgUnit2Prop ) | 429 | else if ( name == VCOrgUnit2Prop ) |
414 | c.setOffice( value ); | 430 | c.setOffice( value ); |
415 | } | 431 | } |
416 | } | 432 | } |
417 | else if ( name == VCTitleProp ) { | 433 | else if ( name == VCTitleProp ) { |
418 | c.setJobTitle( value ); | 434 | c.setJobTitle( value ); |
419 | } | 435 | } |
420 | else if ( name == "X-Qtopia-Profession" ) { | 436 | else if ( name == "X-Qtopia-Profession" ) { |
421 | c.setProfession( value ); | 437 | c.setProfession( value ); |
422 | } | 438 | } |
423 | else if ( name == "X-Qtopia-Manager" ) { | 439 | else if ( name == "X-Qtopia-Manager" ) { |
424 | c.setManager( value ); | 440 | c.setManager( value ); |
425 | } | 441 | } |
426 | else if ( name == "X-Qtopia-Assistant" ) { | 442 | else if ( name == "X-Qtopia-Assistant" ) { |
427 | c.setAssistant( value ); | 443 | c.setAssistant( value ); |
428 | } | 444 | } |
429 | else if ( name == "X-Qtopia-Spouse" ) { | 445 | else if ( name == "X-Qtopia-Spouse" ) { |
430 | c.setSpouse( value ); | 446 | c.setSpouse( value ); |
431 | } | 447 | } |
432 | else if ( name == "X-Qtopia-Gender" ) { | 448 | else if ( name == "X-Qtopia-Gender" ) { |
433 | c.setGender( value ); | 449 | c.setGender( value ); |
434 | } | 450 | } |
435 | else if ( name == "X-Qtopia-Anniversary" ) { | 451 | else if ( name == "X-Qtopia-Anniversary" ) { |
436 | c.setAnniversary( convVCardDateToDate( value ) ); | 452 | c.setAnniversary( convVCardDateToDate( value ) ); |
437 | } | 453 | } |
438 | else if ( name == "X-Qtopia-Nickname" ) { | 454 | else if ( name == "X-Qtopia-Nickname" ) { |
439 | c.setNickname( value ); | 455 | c.setNickname( value ); |
440 | } | 456 | } |
441 | else if ( name == "X-Qtopia-Children" ) { | 457 | else if ( name == "X-Qtopia-Children" ) { |
442 | c.setChildren( value ); | 458 | c.setChildren( value ); |
443 | } | 459 | } |
444 | else if ( name == VCBirthDateProp ) { | 460 | else if ( name == VCBirthDateProp ) { |
445 | // Reading Birthdate regarding RFC 2425 (5.8.4) | 461 | // Reading Birthdate regarding RFC 2425 (5.8.4) |
446 | c.setBirthday( convVCardDateToDate( value ) ); | 462 | c.setBirthday( convVCardDateToDate( value ) ); |
447 | 463 | ||
448 | } | 464 | } |
449 | 465 | else if ( name == VCCommentProp ) { | |
466 | c.setNotes( value ); | ||
467 | } | ||
450 | #if 0 | 468 | #if 0 |
451 | else { | 469 | else { |
452 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); | 470 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); |
453 | VObjectIterator nit; | 471 | VObjectIterator nit; |
454 | initPropIterator( &nit, o ); | 472 | initPropIterator( &nit, o ); |
455 | while( moreIteration( &nit ) ) { | 473 | while( moreIteration( &nit ) ) { |
456 | VObject *o = nextVObject( &nit ); | 474 | VObject *o = nextVObject( &nit ); |
457 | QCString name = vObjectName( o ); | 475 | QCString name = vObjectName( o ); |
458 | QString value = vObjectStringZValue( o ); | 476 | QString value = vObjectStringZValue( o ); |
459 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); | 477 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); |
460 | } | 478 | } |
461 | } | 479 | } |
462 | #endif | 480 | #endif |
463 | } | 481 | } |
464 | c.setFileAs(); | 482 | c.setFileAs(); |
465 | return c; | 483 | return c; |
466 | } | 484 | } |
467 | 485 | ||
468 | 486 | ||
469 | VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) | 487 | VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) |
470 | { | 488 | { |
471 | VObject *vcard = newVObject( VCCardProp ); | 489 | VObject *vcard = newVObject( VCCardProp ); |
472 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); | 490 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); |
473 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); | 491 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); |
474 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); | 492 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); |
475 | 493 | ||
476 | // full name | 494 | // full name |
477 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); | 495 | safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); |
478 | 496 | ||
479 | // name properties | 497 | // name properties |
480 | VObject *name = safeAddProp( vcard, VCNameProp ); | 498 | VObject *name = safeAddProp( vcard, VCNameProp ); |
481 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); | 499 | safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); |
482 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); | 500 | safeAddPropValue( name, VCGivenNameProp, c.firstName() ); |
483 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); | 501 | safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); |
484 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); | 502 | safeAddPropValue( name, VCNamePrefixesProp, c.title() ); |
485 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); | 503 | safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); |
486 | 504 | ||
487 | // home properties | 505 | // home properties |
488 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); | 506 | VObject *home_adr= safeAddProp( vcard, VCAdrProp ); |
489 | safeAddProp( home_adr, VCHomeProp ); | 507 | safeAddProp( home_adr, VCHomeProp ); |
490 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); | 508 | safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); |
491 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); | 509 | safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); |
492 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); | 510 | safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); |
493 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); | 511 | safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); |
494 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); | 512 | safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); |
495 | 513 | ||
496 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); | 514 | VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); |
497 | safeAddProp( home_phone, VCHomeProp ); | 515 | safeAddProp( home_phone, VCHomeProp ); |
498 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); | 516 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); |
499 | safeAddProp( home_phone, VCHomeProp ); | 517 | safeAddProp( home_phone, VCHomeProp ); |
500 | safeAddProp( home_phone, VCCellularProp ); | 518 | safeAddProp( home_phone, VCCellularProp ); |
501 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); | 519 | home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); |
502 | safeAddProp( home_phone, VCHomeProp ); | 520 | safeAddProp( home_phone, VCHomeProp ); |
503 | safeAddProp( home_phone, VCFaxProp ); | 521 | safeAddProp( home_phone, VCFaxProp ); |
504 | 522 | ||
505 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); | 523 | VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); |
506 | safeAddProp( url, VCHomeProp ); | 524 | safeAddProp( url, VCHomeProp ); |
507 | 525 | ||
508 | // work properties | 526 | // work properties |
509 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); | 527 | VObject *work_adr= safeAddProp( vcard, VCAdrProp ); |
510 | safeAddProp( work_adr, VCWorkProp ); | 528 | safeAddProp( work_adr, VCWorkProp ); |
511 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); | 529 | safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); |
512 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); | 530 | safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); |
513 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); | 531 | safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); |
514 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); | 532 | safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); |
515 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); | 533 | safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); |
516 | 534 | ||
517 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); | 535 | VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); |
518 | safeAddProp( work_phone, VCWorkProp ); | 536 | safeAddProp( work_phone, VCWorkProp ); |
519 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); | 537 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); |
520 | safeAddProp( work_phone, VCWorkProp ); | 538 | safeAddProp( work_phone, VCWorkProp ); |
521 | safeAddProp( work_phone, VCCellularProp ); | 539 | safeAddProp( work_phone, VCCellularProp ); |
522 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); | 540 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); |
523 | safeAddProp( work_phone, VCWorkProp ); | 541 | safeAddProp( work_phone, VCWorkProp ); |
524 | safeAddProp( work_phone, VCFaxProp ); | 542 | safeAddProp( work_phone, VCFaxProp ); |
525 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); | 543 | work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); |
526 | safeAddProp( work_phone, VCWorkProp ); | 544 | safeAddProp( work_phone, VCWorkProp ); |
527 | safeAddProp( work_phone, VCPagerProp ); | 545 | safeAddProp( work_phone, VCPagerProp ); |
528 | 546 | ||
529 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); | 547 | url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); |
530 | safeAddProp( url, VCWorkProp ); | 548 | safeAddProp( url, VCWorkProp ); |
531 | 549 | ||
532 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); | 550 | VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); |
533 | safeAddProp( title, VCWorkProp ); | 551 | safeAddProp( title, VCWorkProp ); |
534 | 552 | ||
535 | 553 | ||
536 | QStringList emails = c.emailList(); | 554 | QStringList emails = c.emailList(); |
537 | emails.prepend( c.defaultEmail() ); | 555 | // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045 |
538 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 556 | for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
539 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); | 557 | VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); |
540 | safeAddProp( email, VCInternetProp ); | 558 | safeAddProp( email, VCInternetProp ); |
541 | } | 559 | } |
542 | 560 | ||
543 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); | 561 | safeAddPropValue( vcard, VCNoteProp, c.notes() ); |
544 | 562 | ||
545 | // Exporting Birthday regarding RFC 2425 (5.8.4) | 563 | // Exporting Birthday regarding RFC 2425 (5.8.4) |
546 | if ( c.birthday().isValid() ){ | 564 | if ( c.birthday().isValid() ){ |
547 | qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); | 565 | qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); |
548 | safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); | 566 | safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); |
549 | } | 567 | } |
550 | 568 | ||
551 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { | 569 | if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { |
552 | VObject *org = safeAddProp( vcard, VCOrgProp ); | 570 | VObject *org = safeAddProp( vcard, VCOrgProp ); |
553 | safeAddPropValue( org, VCOrgNameProp, c.company() ); | 571 | safeAddPropValue( org, VCOrgNameProp, c.company() ); |
554 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); | 572 | safeAddPropValue( org, VCOrgUnitProp, c.department() ); |
555 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); | 573 | safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); |
556 | } | 574 | } |
557 | 575 | ||
558 | // some values we have to export as custom fields | 576 | // some values we have to export as custom fields |
559 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); | 577 | safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); |
560 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); | 578 | safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); |
561 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); | 579 | safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); |
562 | 580 | ||
563 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); | 581 | safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); |
564 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); | 582 | safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); |
565 | if ( c.anniversary().isValid() ){ | 583 | if ( c.anniversary().isValid() ){ |
566 | qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); | 584 | qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); |
567 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); | 585 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); |
568 | } | 586 | } |
569 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); | 587 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); |
570 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); | 588 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); |
571 | 589 | ||
572 | return vcard; | 590 | return vcard; |
573 | } | 591 | } |
574 | 592 | ||
575 | QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const | 593 | QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const |
576 | { | 594 | { |
577 | QString str_rfc2425 = QString("%1-%2-%3") | 595 | QString str_rfc2425 = QString("%1-%2-%3") |
578 | .arg( d.year() ) | 596 | .arg( d.year() ) |
579 | .arg( d.month(), 2 ) | 597 | .arg( d.month(), 2 ) |
580 | .arg( d.day(), 2 ); | 598 | .arg( d.day(), 2 ); |
581 | // Now replace spaces with "0"... | 599 | // Now replace spaces with "0"... |
582 | int pos = 0; | 600 | int pos = 0; |
583 | while ( ( pos = str_rfc2425.find (' ') ) > 0 ) | 601 | while ( ( pos = str_rfc2425.find (' ') ) > 0 ) |
584 | str_rfc2425.replace( pos, 1, "0" ); | 602 | str_rfc2425.replace( pos, 1, "0" ); |
585 | 603 | ||
586 | return str_rfc2425; | 604 | return str_rfc2425; |
587 | } | 605 | } |
588 | 606 | ||
589 | QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) | 607 | QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) |
590 | { | 608 | { |
591 | int monthPos = datestr.find('-'); | 609 | int monthPos = datestr.find('-'); |
592 | int dayPos = datestr.find('-', monthPos+1 ); | 610 | int dayPos = datestr.find('-', monthPos+1 ); |
593 | int sep_ignore = 1; | 611 | int sep_ignore = 1; |
594 | if ( monthPos == -1 || dayPos == -1 ) { | 612 | if ( monthPos == -1 || dayPos == -1 ) { |
595 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | 613 | qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); |
596 | // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) | 614 | // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) |
597 | if ( datestr.length() == 8 ){ | 615 | if ( datestr.length() == 8 ){ |
598 | monthPos = 4; | 616 | monthPos = 4; |
599 | dayPos = 6; | 617 | dayPos = 6; |
600 | sep_ignore = 0; | 618 | sep_ignore = 0; |
601 | qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); | 619 | qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); |
602 | } else { | 620 | } else { |
603 | return QDate(); | 621 | return QDate(); |
604 | } | 622 | } |
605 | } | 623 | } |
606 | int y = datestr.left( monthPos ).toInt(); | 624 | int y = datestr.left( monthPos ).toInt(); |
607 | int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); | 625 | int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); |
608 | int d = datestr.mid( dayPos + sep_ignore ).toInt(); | 626 | int d = datestr.mid( dayPos + sep_ignore ).toInt(); |
609 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); | 627 | qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); |
610 | QDate date ( y,m,d ); | 628 | QDate date ( y,m,d ); |
611 | return date; | 629 | return date; |
612 | } | 630 | } |
613 | 631 | ||
614 | VObject* OContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 632 | VObject* OContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
615 | { | 633 | { |
616 | VObject *ret = 0; | 634 | VObject *ret = 0; |
617 | if ( o && !value.isEmpty() ) | 635 | if ( o && !value.isEmpty() ) |
618 | ret = addPropValue( o, prop, value.latin1() ); | 636 | ret = addPropValue( o, prop, value.latin1() ); |
619 | return ret; | 637 | return ret; |
620 | } | 638 | } |
621 | 639 | ||
622 | VObject* OContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop) | 640 | VObject* OContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop) |
623 | { | 641 | { |
624 | VObject *ret = 0; | 642 | VObject *ret = 0; |
625 | if ( o ) | 643 | if ( o ) |
626 | ret = addProp( o, prop ); | 644 | ret = addProp( o, prop ); |
627 | return ret; | 645 | return ret; |
628 | } | 646 | } |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp index 097142b..1c21619 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp | |||
@@ -1,115 +1,118 @@ | |||
1 | /* | 1 | /* |
2 | * XML Backend for the OPIE-Contact Database. | 2 | * XML Backend for the OPIE-Contact Database. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 5 | * |
6 | * ===================================================================== | 6 | * ===================================================================== |
7 | *This program is free software; you can redistribute it and/or | 7 | *This program is free software; you can redistribute it and/or |
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; either | 9 | * License as published by the Free Software Foundation; either |
10 | * version 2 of the License, or (at your option) any later version. | 10 | * version 2 of the License, or (at your option) any later version. |
11 | * ===================================================================== | 11 | * ===================================================================== |
12 | * ToDo: XML-Backend: Automatic reload if something was changed... | 12 | * ToDo: XML-Backend: Automatic reload if something was changed... |
13 | * | 13 | * |
14 | * | 14 | * |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * Version: $Id$ | 16 | * Version: $Id$ |
17 | * ===================================================================== | 17 | * ===================================================================== |
18 | * History: | 18 | * History: |
19 | * $Log$ | 19 | * $Log$ |
20 | * Revision 1.7 2003/08/01 12:30:16 eilers | ||
21 | * Merging changes from BRANCH_1_0 to HEAD | ||
22 | * | ||
20 | * Revision 1.6 2003/07/07 16:19:47 eilers | 23 | * Revision 1.6 2003/07/07 16:19:47 eilers |
21 | * Fixing serious bug in hasQuerySettings() | 24 | * Fixing serious bug in hasQuerySettings() |
22 | * | 25 | * |
23 | * Revision 1.5 2003/04/13 18:07:10 zecke | 26 | * Revision 1.5 2003/04/13 18:07:10 zecke |
24 | * More API doc | 27 | * More API doc |
25 | * QString -> const QString& | 28 | * QString -> const QString& |
26 | * QString = 0l -> QString::null | 29 | * QString = 0l -> QString::null |
27 | * | 30 | * |
28 | * Revision 1.4 2003/03/21 14:32:54 mickeyl | 31 | * Revision 1.4 2003/03/21 14:32:54 mickeyl |
29 | * g++ compliance fix: default arguments belong into the declaration, but not the definition | 32 | * g++ compliance fix: default arguments belong into the declaration, but not the definition |
30 | * | 33 | * |
31 | * Revision 1.3 2003/03/21 12:26:28 eilers | 34 | * Revision 1.3 2003/03/21 12:26:28 eilers |
32 | * Fixing small bug: If we search a birthday from today to today, it returned | 35 | * Fixing small bug: If we search a birthday from today to today, it returned |
33 | * every contact .. | 36 | * every contact .. |
34 | * | 37 | * |
35 | * Revision 1.2 2003/03/21 10:33:09 eilers | 38 | * Revision 1.2 2003/03/21 10:33:09 eilers |
36 | * Merged speed optimized xml backend for contacts to main. | 39 | * Merged speed optimized xml backend for contacts to main. |
37 | * Added QDateTime to querybyexample. For instance, it is now possible to get | 40 | * Added QDateTime to querybyexample. For instance, it is now possible to get |
38 | * all Birthdays/Anniversaries between two dates. This should be used | 41 | * all Birthdays/Anniversaries between two dates. This should be used |
39 | * to show all birthdays in the datebook.. | 42 | * to show all birthdays in the datebook.. |
40 | * This change is sourcecode backward compatible but you have to upgrade | 43 | * This change is sourcecode backward compatible but you have to upgrade |
41 | * the binaries for today-addressbook. | 44 | * the binaries for today-addressbook. |
42 | * | 45 | * |
43 | * Revision 1.1.2.2 2003/02/11 12:17:28 eilers | 46 | * Revision 1.1.2.2 2003/02/11 12:17:28 eilers |
44 | * Speed optimization. Removed the sequential search loops. | 47 | * Speed optimization. Removed the sequential search loops. |
45 | * | 48 | * |
46 | * Revision 1.1.2.1 2003/02/10 15:31:38 eilers | 49 | * Revision 1.1.2.1 2003/02/10 15:31:38 eilers |
47 | * Writing offsets to debug output.. | 50 | * Writing offsets to debug output.. |
48 | * | 51 | * |
49 | * Revision 1.1 2003/02/09 15:05:01 eilers | 52 | * Revision 1.1 2003/02/09 15:05:01 eilers |
50 | * Nothing happened.. Just some cleanup before I will start.. | 53 | * Nothing happened.. Just some cleanup before I will start.. |
51 | * | 54 | * |
52 | * Revision 1.12 2003/01/03 16:58:03 eilers | 55 | * Revision 1.12 2003/01/03 16:58:03 eilers |
53 | * Reenable debug output | 56 | * Reenable debug output |
54 | * | 57 | * |
55 | * Revision 1.11 2003/01/03 12:31:28 eilers | 58 | * Revision 1.11 2003/01/03 12:31:28 eilers |
56 | * Bugfix for calculating data diffs.. | 59 | * Bugfix for calculating data diffs.. |
57 | * | 60 | * |
58 | * Revision 1.10 2003/01/02 14:27:12 eilers | 61 | * Revision 1.10 2003/01/02 14:27:12 eilers |
59 | * Improved query by example: Search by date is possible.. First step | 62 | * Improved query by example: Search by date is possible.. First step |
60 | * for a today plugin for birthdays.. | 63 | * for a today plugin for birthdays.. |
61 | * | 64 | * |
62 | * Revision 1.9 2002/12/08 12:48:57 eilers | 65 | * Revision 1.9 2002/12/08 12:48:57 eilers |
63 | * Moved journal-enum from ocontact into i the xml-backend.. | 66 | * Moved journal-enum from ocontact into i the xml-backend.. |
64 | * | 67 | * |
65 | * Revision 1.8 2002/11/14 17:04:24 eilers | 68 | * Revision 1.8 2002/11/14 17:04:24 eilers |
66 | * Sorting will now work if fullname is identical on some entries | 69 | * Sorting will now work if fullname is identical on some entries |
67 | * | 70 | * |
68 | * Revision 1.7 2002/11/13 15:02:46 eilers | 71 | * Revision 1.7 2002/11/13 15:02:46 eilers |
69 | * Small Bug in sorted fixed | 72 | * Small Bug in sorted fixed |
70 | * | 73 | * |
71 | * Revision 1.6 2002/11/13 14:14:51 eilers | 74 | * Revision 1.6 2002/11/13 14:14:51 eilers |
72 | * Added sorted for Contacts.. | 75 | * Added sorted for Contacts.. |
73 | * | 76 | * |
74 | * Revision 1.5 2002/11/01 15:10:42 eilers | 77 | * Revision 1.5 2002/11/01 15:10:42 eilers |
75 | * Added regExp-search in database for all fields in a contact. | 78 | * Added regExp-search in database for all fields in a contact. |
76 | * | 79 | * |
77 | * Revision 1.4 2002/10/16 10:52:40 eilers | 80 | * Revision 1.4 2002/10/16 10:52:40 eilers |
78 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | 81 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) |
79 | * | 82 | * |
80 | * Revision 1.3 2002/10/14 16:21:54 eilers | 83 | * Revision 1.3 2002/10/14 16:21:54 eilers |
81 | * Some minor interface updates | 84 | * Some minor interface updates |
82 | * | 85 | * |
83 | * Revision 1.2 2002/10/07 17:34:24 eilers | 86 | * Revision 1.2 2002/10/07 17:34:24 eilers |
84 | * added OBackendFactory for advanced backend access | 87 | * added OBackendFactory for advanced backend access |
85 | * | 88 | * |
86 | * Revision 1.1 2002/09/27 17:11:44 eilers | 89 | * Revision 1.1 2002/09/27 17:11:44 eilers |
87 | * Added API for accessing the Contact-Database ! It is compiling, but | 90 | * Added API for accessing the Contact-Database ! It is compiling, but |
88 | * please do not expect that anything is working ! | 91 | * please do not expect that anything is working ! |
89 | * I will debug that stuff in the next time .. | 92 | * I will debug that stuff in the next time .. |
90 | * Please read README_COMPILE for compiling ! | 93 | * Please read README_COMPILE for compiling ! |
91 | * | 94 | * |
92 | * | 95 | * |
93 | */ | 96 | */ |
94 | 97 | ||
95 | #include "ocontactaccessbackend_xml.h" | 98 | #include "ocontactaccessbackend_xml.h" |
96 | 99 | ||
97 | #include <qasciidict.h> | 100 | #include <qasciidict.h> |
98 | #include <qdatetime.h> | 101 | #include <qdatetime.h> |
99 | #include <qfile.h> | 102 | #include <qfile.h> |
100 | #include <qfileinfo.h> | 103 | #include <qfileinfo.h> |
101 | #include <qregexp.h> | 104 | #include <qregexp.h> |
102 | #include <qarray.h> | 105 | #include <qarray.h> |
103 | #include <qmap.h> | 106 | #include <qmap.h> |
104 | #include <qdatetime.h> | 107 | #include <qdatetime.h> |
105 | 108 | ||
106 | #include <qpe/global.h> | 109 | #include <qpe/global.h> |
107 | 110 | ||
108 | #include <opie/xmltree.h> | 111 | #include <opie/xmltree.h> |
109 | #include "ocontactaccessbackend.h" | 112 | #include "ocontactaccessbackend.h" |
110 | #include "ocontactaccess.h" | 113 | #include "ocontactaccess.h" |
111 | 114 | ||
112 | #include <stdlib.h> | 115 | #include <stdlib.h> |
113 | #include <errno.h> | 116 | #include <errno.h> |
114 | 117 | ||
115 | using namespace Opie; | 118 | using namespace Opie; |
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.h b/libopie2/opiepim/backend/odatebookaccessbackend.h index 86ff298..3c02c42 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend.h +++ b/libopie2/opiepim/backend/odatebookaccessbackend.h | |||
@@ -1,73 +1,77 @@ | |||
1 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_H | 1 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_H |
2 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_H | 2 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_H |
3 | 3 | ||
4 | #include <qarray.h> | 4 | #include <qarray.h> |
5 | 5 | ||
6 | #include "opimaccessbackend.h" | 6 | #include "opimaccessbackend.h" |
7 | #include "oevent.h" | 7 | #include "oevent.h" |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * This class is the interface to the storage of Events. | 10 | * This class is the interface to the storage of Events. |
11 | * @see OPimAccessBackend | 11 | * @see OPimAccessBackend |
12 | * | 12 | * |
13 | */ | 13 | */ |
14 | class ODateBookAccessBackend : public OPimAccessBackend<OEvent> { | 14 | class ODateBookAccessBackend : public OPimAccessBackend<OEvent> { |
15 | public: | 15 | public: |
16 | typedef int UID; | 16 | typedef int UID; |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * c'tor without parameter | 19 | * c'tor without parameter |
20 | */ | 20 | */ |
21 | ODateBookAccessBackend(); | 21 | ODateBookAccessBackend(); |
22 | ~ODateBookAccessBackend(); | 22 | ~ODateBookAccessBackend(); |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * This method should return a list of UIDs containing | 25 | * This method should return a list of UIDs containing |
26 | * all events. No filter should be applied | 26 | * all events. No filter should be applied |
27 | * @return list of events | 27 | * @return list of events |
28 | */ | 28 | */ |
29 | virtual QArray<UID> rawEvents()const = 0; | 29 | virtual QArray<UID> rawEvents()const = 0; |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * This method should return a list of UIDs containing | 32 | * This method should return a list of UIDs containing |
33 | * all repeating events. No filter should be applied | 33 | * all repeating events. No filter should be applied |
34 | * @return list of repeating events | 34 | * @return list of repeating events |
35 | */ | 35 | */ |
36 | virtual QArray<UID> rawRepeats()const = 0; | 36 | virtual QArray<UID> rawRepeats()const = 0; |
37 | 37 | ||
38 | /** | 38 | /** |
39 | * This mthod should return a list of UIDs containing all non | 39 | * This mthod should return a list of UIDs containing all non |
40 | * repeating events. No filter should be applied | 40 | * repeating events. No filter should be applied |
41 | * @return list of nonrepeating events | 41 | * @return list of nonrepeating events |
42 | */ | 42 | */ |
43 | virtual QArray<UID> nonRepeats() const = 0; | 43 | virtual QArray<UID> nonRepeats() const = 0; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * If you do not want to implement the effectiveEvents methods below | 46 | * If you do not want to implement the effectiveEvents methods below |
47 | * you need to supply it with directNonRepeats. | 47 | * you need to supply it with directNonRepeats. |
48 | * This method can return empty lists if effectiveEvents is implememted | 48 | * This method can return empty lists if effectiveEvents is implememted |
49 | */ | 49 | */ |
50 | virtual OEvent::ValueList directNonRepeats() = 0; | 50 | virtual OEvent::ValueList directNonRepeats() = 0; |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * Same as above but return raw repeats! | 53 | * Same as above but return raw repeats! |
54 | */ | 54 | */ |
55 | virtual OEvent::ValueList directRawRepeats() = 0; | 55 | virtual OEvent::ValueList directRawRepeats() = 0; |
56 | 56 | ||
57 | /* is implemented by default but you can reimplement it*/ | 57 | /* is implemented by default but you can reimplement it*/ |
58 | /** | 58 | /** |
59 | * Effective Events are special event occuring during a time frame. This method does calcualte | 59 | * Effective Events are special event occuring during a time frame. This method does calcualte |
60 | * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method | 60 | * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method |
61 | * yourself | 61 | * yourself |
62 | */ | 62 | */ |
63 | virtual OEffectiveEvent::ValueList effecticeEvents( const QDate& from, const QDate& to ); | 63 | virtual OEffectiveEvent::ValueList effecticeEvents( const QDate& from, const QDate& to ); |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * this is an overloaded member function | 66 | * this is an overloaded member function |
67 | * @see effecticeEvents | 67 | * @see effecticeEvents |
68 | */ | 68 | */ |
69 | virtual OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start ); | 69 | virtual OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start ); |
70 | 70 | ||
71 | private: | ||
72 | class Private; | ||
73 | Private *d; | ||
74 | |||
71 | }; | 75 | }; |
72 | 76 | ||
73 | #endif | 77 | #endif |
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp index ab2eea4..5ea945c 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp | |||
@@ -337,216 +337,216 @@ bool ODateBookAccessBackend_XML::loadFile() { | |||
337 | ::close( fd ); | 337 | ::close( fd ); |
338 | return false; | 338 | return false; |
339 | } | 339 | } |
340 | 340 | ||
341 | ::madvise( map_addr, attribute.st_size, MADV_SEQUENTIAL ); | 341 | ::madvise( map_addr, attribute.st_size, MADV_SEQUENTIAL ); |
342 | ::close( fd ); | 342 | ::close( fd ); |
343 | 343 | ||
344 | QAsciiDict<int> dict(FExceptions+1); | 344 | QAsciiDict<int> dict(FExceptions+1); |
345 | dict.setAutoDelete( true ); | 345 | dict.setAutoDelete( true ); |
346 | dict.insert( "description", new int(FDescription) ); | 346 | dict.insert( "description", new int(FDescription) ); |
347 | dict.insert( "location", new int(FLocation) ); | 347 | dict.insert( "location", new int(FLocation) ); |
348 | dict.insert( "categories", new int(FCategories) ); | 348 | dict.insert( "categories", new int(FCategories) ); |
349 | dict.insert( "uid", new int(FUid) ); | 349 | dict.insert( "uid", new int(FUid) ); |
350 | dict.insert( "type", new int(FType) ); | 350 | dict.insert( "type", new int(FType) ); |
351 | dict.insert( "alarm", new int(FAlarm) ); | 351 | dict.insert( "alarm", new int(FAlarm) ); |
352 | dict.insert( "sound", new int(FSound) ); | 352 | dict.insert( "sound", new int(FSound) ); |
353 | dict.insert( "rtype", new int(FRType) ); | 353 | dict.insert( "rtype", new int(FRType) ); |
354 | dict.insert( "rweekdays", new int(FRWeekdays) ); | 354 | dict.insert( "rweekdays", new int(FRWeekdays) ); |
355 | dict.insert( "rposition", new int(FRPosition) ); | 355 | dict.insert( "rposition", new int(FRPosition) ); |
356 | dict.insert( "rfreq", new int(FRFreq) ); | 356 | dict.insert( "rfreq", new int(FRFreq) ); |
357 | dict.insert( "rhasenddate", new int(FRHasEndDate) ); | 357 | dict.insert( "rhasenddate", new int(FRHasEndDate) ); |
358 | dict.insert( "enddt", new int(FREndDate) ); | 358 | dict.insert( "enddt", new int(FREndDate) ); |
359 | dict.insert( "start", new int(FRStart) ); | 359 | dict.insert( "start", new int(FRStart) ); |
360 | dict.insert( "end", new int(FREnd) ); | 360 | dict.insert( "end", new int(FREnd) ); |
361 | dict.insert( "note", new int(FNote) ); | 361 | dict.insert( "note", new int(FNote) ); |
362 | dict.insert( "created", new int(FCreated) ); | 362 | dict.insert( "created", new int(FCreated) ); |
363 | dict.insert( "recparent", new int(FRecParent) ); | 363 | dict.insert( "recparent", new int(FRecParent) ); |
364 | dict.insert( "recchildren", new int(FRecChildren) ); | 364 | dict.insert( "recchildren", new int(FRecChildren) ); |
365 | dict.insert( "exceptions", new int(FExceptions) ); | 365 | dict.insert( "exceptions", new int(FExceptions) ); |
366 | dict.insert( "timezone", new int(FTimeZone) ); | 366 | dict.insert( "timezone", new int(FTimeZone) ); |
367 | 367 | ||
368 | char* dt = (char*)map_addr; | 368 | char* dt = (char*)map_addr; |
369 | int len = attribute.st_size; | 369 | int len = attribute.st_size; |
370 | int i = 0; | 370 | int i = 0; |
371 | char* point; | 371 | char* point; |
372 | const char* collectionString = "<event "; | 372 | const char* collectionString = "<event "; |
373 | int strLen = ::strlen(collectionString); | 373 | int strLen = ::strlen(collectionString); |
374 | int *find; | 374 | int *find; |
375 | while ( ( point = ::strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0 ) { | 375 | while ( ( point = ::strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0 ) { |
376 | i = point -dt; | 376 | i = point -dt; |
377 | i+= strLen; | 377 | i+= strLen; |
378 | 378 | ||
379 | alarmTime = -1; | 379 | alarmTime = -1; |
380 | snd = 0; // silent | 380 | snd = 0; // silent |
381 | 381 | ||
382 | OEvent ev; | 382 | OEvent ev; |
383 | rec = 0; | 383 | rec = 0; |
384 | 384 | ||
385 | while ( TRUE ) { | 385 | while ( TRUE ) { |
386 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) | 386 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) |
387 | ++i; | 387 | ++i; |
388 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) | 388 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) |
389 | break; | 389 | break; |
390 | 390 | ||
391 | 391 | ||
392 | // we have another attribute, read it. | 392 | // we have another attribute, read it. |
393 | int j = i; | 393 | int j = i; |
394 | while ( j < len && dt[j] != '=' ) | 394 | while ( j < len && dt[j] != '=' ) |
395 | ++j; | 395 | ++j; |
396 | QCString attr( dt+i, j-i+1); | 396 | QCString attr( dt+i, j-i+1); |
397 | 397 | ||
398 | i = ++j; // skip = | 398 | i = ++j; // skip = |
399 | 399 | ||
400 | // find the start of quotes | 400 | // find the start of quotes |
401 | while ( i < len && dt[i] != '"' ) | 401 | while ( i < len && dt[i] != '"' ) |
402 | ++i; | 402 | ++i; |
403 | j = ++i; | 403 | j = ++i; |
404 | 404 | ||
405 | bool haveUtf = FALSE; | 405 | bool haveUtf = FALSE; |
406 | bool haveEnt = FALSE; | 406 | bool haveEnt = FALSE; |
407 | while ( j < len && dt[j] != '"' ) { | 407 | while ( j < len && dt[j] != '"' ) { |
408 | if ( ((unsigned char)dt[j]) > 0x7f ) | 408 | if ( ((unsigned char)dt[j]) > 0x7f ) |
409 | haveUtf = TRUE; | 409 | haveUtf = TRUE; |
410 | if ( dt[j] == '&' ) | 410 | if ( dt[j] == '&' ) |
411 | haveEnt = TRUE; | 411 | haveEnt = TRUE; |
412 | ++j; | 412 | ++j; |
413 | } | 413 | } |
414 | if ( i == j ) { | 414 | if ( i == j ) { |
415 | // empty value | 415 | // empty value |
416 | i = j + 1; | 416 | i = j + 1; |
417 | continue; | 417 | continue; |
418 | } | 418 | } |
419 | 419 | ||
420 | QCString value( dt+i, j-i+1 ); | 420 | QCString value( dt+i, j-i+1 ); |
421 | i = j + 1; | 421 | i = j + 1; |
422 | 422 | ||
423 | QString str = (haveUtf ? QString::fromUtf8( value ) | 423 | QString str = (haveUtf ? QString::fromUtf8( value ) |
424 | : QString::fromLatin1( value ) ); | 424 | : QString::fromLatin1( value ) ); |
425 | if ( haveEnt ) | 425 | if ( haveEnt ) |
426 | str = Qtopia::plainString( str ); | 426 | str = Qtopia::plainString( str ); |
427 | 427 | ||
428 | /* | 428 | /* |
429 | * add key + value | 429 | * add key + value |
430 | */ | 430 | */ |
431 | find = dict[attr.data()]; | 431 | find = dict[attr.data()]; |
432 | if (!find) | 432 | if (!find) |
433 | ev.setCustomField( attr, value ); | 433 | ev.setCustomField( attr, str ); |
434 | else { | 434 | else { |
435 | setField( ev, *find, value ); | 435 | setField( ev, *find, str ); |
436 | } | 436 | } |
437 | } | 437 | } |
438 | /* time to finalize */ | 438 | /* time to finalize */ |
439 | finalizeRecord( ev ); | 439 | finalizeRecord( ev ); |
440 | delete rec; | 440 | delete rec; |
441 | } | 441 | } |
442 | ::munmap(map_addr, attribute.st_size ); | 442 | ::munmap(map_addr, attribute.st_size ); |
443 | m_changed = false; // changed during add | 443 | m_changed = false; // changed during add |
444 | 444 | ||
445 | return true; | 445 | return true; |
446 | } | 446 | } |
447 | void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { | 447 | void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { |
448 | /* AllDay is alway in UTC */ | 448 | /* AllDay is alway in UTC */ |
449 | if ( ev.isAllDay() ) { | 449 | if ( ev.isAllDay() ) { |
450 | OTimeZone utc = OTimeZone::utc(); | 450 | OTimeZone utc = OTimeZone::utc(); |
451 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); | 451 | ev.setStartDateTime( utc.fromUTCDateTime( start ) ); |
452 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); | 452 | ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); |
453 | ev.setTimeZone( "UTC"); // make sure it is really utc | 453 | ev.setTimeZone( "UTC"); // make sure it is really utc |
454 | }else { | 454 | }else { |
455 | /* to current date time */ | 455 | /* to current date time */ |
456 | qWarning(" Start is %d", start ); | 456 | // qWarning(" Start is %d", start ); |
457 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); | 457 | OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); |
458 | QDateTime date = zone.toDateTime( start ); | 458 | QDateTime date = zone.toDateTime( start ); |
459 | qWarning(" Start is %s", date.toString().latin1() ); | 459 | qWarning(" Start is %s", date.toString().latin1() ); |
460 | ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); | 460 | ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); |
461 | 461 | ||
462 | date = zone.toDateTime( end ); | 462 | date = zone.toDateTime( end ); |
463 | ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); | 463 | ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); |
464 | } | 464 | } |
465 | if ( rec && rec->doesRecur() ) { | 465 | if ( rec && rec->doesRecur() ) { |
466 | OTimeZone utc = OTimeZone::utc(); | 466 | OTimeZone utc = OTimeZone::utc(); |
467 | ORecur recu( *rec ); // call copy c'tor; | 467 | ORecur recu( *rec ); // call copy c'tor; |
468 | recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); | 468 | recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); |
469 | recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); | 469 | recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); |
470 | recu.setStart( ev.startDateTime().date() ); | 470 | recu.setStart( ev.startDateTime().date() ); |
471 | ev.setRecurrence( recu ); | 471 | ev.setRecurrence( recu ); |
472 | } | 472 | } |
473 | 473 | ||
474 | if (alarmTime != -1 ) { | 474 | if (alarmTime != -1 ) { |
475 | QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); | 475 | QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); |
476 | OPimAlarm al( snd , dt ); | 476 | OPimAlarm al( snd , dt ); |
477 | ev.notifiers().add( al ); | 477 | ev.notifiers().add( al ); |
478 | } | 478 | } |
479 | if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { | 479 | if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { |
480 | qWarning("already contains assign uid"); | 480 | qWarning("already contains assign uid"); |
481 | ev.setUid( 1 ); | 481 | ev.setUid( 1 ); |
482 | } | 482 | } |
483 | qWarning("addind %d %s", ev.uid(), ev.description().latin1() ); | 483 | qWarning("addind %d %s", ev.uid(), ev.description().latin1() ); |
484 | if ( ev.hasRecurrence() ) | 484 | if ( ev.hasRecurrence() ) |
485 | m_rep.insert( ev.uid(), ev ); | 485 | m_rep.insert( ev.uid(), ev ); |
486 | else | 486 | else |
487 | m_raw.insert( ev.uid(), ev ); | 487 | m_raw.insert( ev.uid(), ev ); |
488 | 488 | ||
489 | } | 489 | } |
490 | void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { | 490 | void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { |
491 | // qWarning(" setting %s", value.latin1() ); | 491 | // qWarning(" setting %s", value.latin1() ); |
492 | switch( id ) { | 492 | switch( id ) { |
493 | case FDescription: | 493 | case FDescription: |
494 | e.setDescription( value ); | 494 | e.setDescription( value ); |
495 | break; | 495 | break; |
496 | case FLocation: | 496 | case FLocation: |
497 | e.setLocation( value ); | 497 | e.setLocation( value ); |
498 | break; | 498 | break; |
499 | case FCategories: | 499 | case FCategories: |
500 | e.setCategories( e.idsFromString( value ) ); | 500 | e.setCategories( e.idsFromString( value ) ); |
501 | break; | 501 | break; |
502 | case FUid: | 502 | case FUid: |
503 | e.setUid( value.toInt() ); | 503 | e.setUid( value.toInt() ); |
504 | break; | 504 | break; |
505 | case FType: | 505 | case FType: |
506 | if ( value == "AllDay" ) { | 506 | if ( value == "AllDay" ) { |
507 | e.setAllDay( true ); | 507 | e.setAllDay( true ); |
508 | e.setTimeZone( "UTC" ); | 508 | e.setTimeZone( "UTC" ); |
509 | } | 509 | } |
510 | break; | 510 | break; |
511 | case FAlarm: | 511 | case FAlarm: |
512 | alarmTime = value.toInt(); | 512 | alarmTime = value.toInt(); |
513 | break; | 513 | break; |
514 | case FSound: | 514 | case FSound: |
515 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; | 515 | snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; |
516 | break; | 516 | break; |
517 | // recurrence stuff | 517 | // recurrence stuff |
518 | case FRType: | 518 | case FRType: |
519 | if ( value == "Daily" ) | 519 | if ( value == "Daily" ) |
520 | recur()->setType( ORecur::Daily ); | 520 | recur()->setType( ORecur::Daily ); |
521 | else if ( value == "Weekly" ) | 521 | else if ( value == "Weekly" ) |
522 | recur()->setType( ORecur::Weekly); | 522 | recur()->setType( ORecur::Weekly); |
523 | else if ( value == "MonthlyDay" ) | 523 | else if ( value == "MonthlyDay" ) |
524 | recur()->setType( ORecur::MonthlyDay ); | 524 | recur()->setType( ORecur::MonthlyDay ); |
525 | else if ( value == "MonthlyDate" ) | 525 | else if ( value == "MonthlyDate" ) |
526 | recur()->setType( ORecur::MonthlyDate ); | 526 | recur()->setType( ORecur::MonthlyDate ); |
527 | else if ( value == "Yearly" ) | 527 | else if ( value == "Yearly" ) |
528 | recur()->setType( ORecur::Yearly ); | 528 | recur()->setType( ORecur::Yearly ); |
529 | else | 529 | else |
530 | recur()->setType( ORecur::NoRepeat ); | 530 | recur()->setType( ORecur::NoRepeat ); |
531 | break; | 531 | break; |
532 | case FRWeekdays: | 532 | case FRWeekdays: |
533 | recur()->setDays( value.toInt() ); | 533 | recur()->setDays( value.toInt() ); |
534 | break; | 534 | break; |
535 | case FRPosition: | 535 | case FRPosition: |
536 | recur()->setPosition( value.toInt() ); | 536 | recur()->setPosition( value.toInt() ); |
537 | break; | 537 | break; |
538 | case FRFreq: | 538 | case FRFreq: |
539 | recur()->setFrequency( value.toInt() ); | 539 | recur()->setFrequency( value.toInt() ); |
540 | break; | 540 | break; |
541 | case FRHasEndDate: | 541 | case FRHasEndDate: |
542 | recur()->setHasEndDate( value.toInt() ); | 542 | recur()->setHasEndDate( value.toInt() ); |
543 | break; | 543 | break; |
544 | case FREndDate: { | 544 | case FREndDate: { |
545 | rp_end = (time_t) value.toLong(); | 545 | rp_end = (time_t) value.toLong(); |
546 | break; | 546 | break; |
547 | } | 547 | } |
548 | case FRStart: { | 548 | case FRStart: { |
549 | start = (time_t) value.toLong(); | 549 | start = (time_t) value.toLong(); |
550 | break; | 550 | break; |
551 | } | 551 | } |
552 | case FREnd: { | 552 | case FREnd: { |
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h index f4bbe35..c3d91f7 100644 --- a/libopie2/opiepim/backend/opimaccessbackend.h +++ b/libopie2/opiepim/backend/opimaccessbackend.h | |||
@@ -1,159 +1,159 @@ | |||
1 | #ifndef OPIE_PIM_ACCESS_BACKEND | 1 | #ifndef OPIE_PIM_ACCESS_BACKEND |
2 | #define OPIE_PIM_ACCESS_BACKEND | 2 | #define OPIE_PIM_ACCESS_BACKEND |
3 | 3 | ||
4 | #include <qarray.h> | 4 | #include <qarray.h> |
5 | 5 | ||
6 | #include <opie/otemplatebase.h> | 6 | #include <opie/otemplatebase.h> |
7 | #include <opie/opimrecord.h> | 7 | #include <opie/opimrecord.h> |
8 | 8 | ||
9 | 9 | ||
10 | class OPimAccessBackendPrivate; | ||
10 | /** | 11 | /** |
11 | * OPimAccessBackend is the base class | 12 | * OPimAccessBackend is the base class |
12 | * for all private backends | 13 | * for all private backends |
13 | * it operates on OPimRecord as the base class | 14 | * it operates on OPimRecord as the base class |
14 | * and it's responsible for fast manipulating | 15 | * and it's responsible for fast manipulating |
15 | * the resource the implementation takes care | 16 | * the resource the implementation takes care |
16 | * of | 17 | * of |
17 | */ | 18 | */ |
18 | template <class T = OPimRecord> | 19 | template <class T = OPimRecord> |
19 | class OPimAccessBackend { | 20 | class OPimAccessBackend { |
20 | public: | 21 | public: |
21 | typedef OTemplateBase<T> Frontend; | 22 | typedef OTemplateBase<T> Frontend; |
22 | 23 | ||
23 | /** The access hint from the frontend */ | 24 | /** The access hint from the frontend */ |
24 | OPimAccessBackend(int access = 0); | 25 | OPimAccessBackend(int access = 0); |
25 | virtual ~OPimAccessBackend(); | 26 | virtual ~OPimAccessBackend(); |
26 | 27 | ||
27 | /** | 28 | /** |
28 | * load the resource | 29 | * load the resource |
29 | */ | 30 | */ |
30 | virtual bool load() = 0; | 31 | virtual bool load() = 0; |
31 | 32 | ||
32 | /** | 33 | /** |
33 | * reload the resource | 34 | * reload the resource |
34 | */ | 35 | */ |
35 | virtual bool reload() = 0; | 36 | virtual bool reload() = 0; |
36 | 37 | ||
37 | /** | 38 | /** |
38 | * save the resource and | 39 | * save the resource and |
39 | * all it's changes | 40 | * all it's changes |
40 | */ | 41 | */ |
41 | virtual bool save() = 0; | 42 | virtual bool save() = 0; |
42 | 43 | ||
43 | /** | 44 | /** |
44 | * return an array of | 45 | * return an array of |
45 | * all available uids | 46 | * all available uids |
46 | */ | 47 | */ |
47 | virtual QArray<int> allRecords()const = 0; | 48 | virtual QArray<int> allRecords()const = 0; |
48 | 49 | ||
49 | /** | 50 | /** |
50 | * return a List of records | 51 | * return a List of records |
51 | * that match the regex | 52 | * that match the regex |
52 | */ | 53 | */ |
53 | virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; | 54 | virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; |
54 | 55 | ||
55 | /** | 56 | /** |
56 | * queryByExample for T with the given Settings | 57 | * queryByExample for T with the given Settings |
57 | * | 58 | * |
58 | */ | 59 | */ |
59 | virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; | 60 | virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; |
60 | 61 | ||
61 | /** | 62 | /** |
62 | * find the OPimRecord with uid @param uid | 63 | * find the OPimRecord with uid @param uid |
63 | * returns T and T.isEmpty() if nothing was found | 64 | * returns T and T.isEmpty() if nothing was found |
64 | */ | 65 | */ |
65 | virtual T find(int uid )const = 0; | 66 | virtual T find(int uid )const = 0; |
66 | 67 | ||
67 | virtual T find(int uid, const QArray<int>& items, | 68 | virtual T find(int uid, const QArray<int>& items, |
68 | uint current, typename Frontend::CacheDirection )const ; | 69 | uint current, typename Frontend::CacheDirection )const ; |
69 | /** | 70 | /** |
70 | * clear the back end | 71 | * clear the back end |
71 | */ | 72 | */ |
72 | virtual void clear() = 0; | 73 | virtual void clear() = 0; |
73 | 74 | ||
74 | /** | 75 | /** |
75 | * add T | 76 | * add T |
76 | */ | 77 | */ |
77 | virtual bool add( const T& t ) = 0; | 78 | virtual bool add( const T& t ) = 0; |
78 | 79 | ||
79 | /** | 80 | /** |
80 | * remove | 81 | * remove |
81 | */ | 82 | */ |
82 | virtual bool remove( int uid ) = 0; | 83 | virtual bool remove( int uid ) = 0; |
83 | 84 | ||
84 | /** | 85 | /** |
85 | * replace a record with T.uid() | 86 | * replace a record with T.uid() |
86 | */ | 87 | */ |
87 | virtual bool replace( const T& t ) = 0; | 88 | virtual bool replace( const T& t ) = 0; |
88 | 89 | ||
89 | /* | 90 | /* |
90 | * setTheFrontEnd!!! | 91 | * setTheFrontEnd!!! |
91 | */ | 92 | */ |
92 | void setFrontend( Frontend* front ); | 93 | void setFrontend( Frontend* front ); |
93 | 94 | ||
94 | /** | 95 | /** |
95 | * set the read ahead count | 96 | * set the read ahead count |
96 | */ | 97 | */ |
97 | void setReadAhead( uint count ); | 98 | void setReadAhead( uint count ); |
98 | protected: | 99 | protected: |
99 | int access()const; | 100 | int access()const; |
100 | void cache( const T& t )const; | 101 | void cache( const T& t )const; |
101 | 102 | ||
102 | /** | 103 | /** |
103 | * use a prime number here! | 104 | * use a prime number here! |
104 | */ | 105 | */ |
105 | void setSaneCacheSize( int ); | 106 | void setSaneCacheSize( int ); |
106 | 107 | ||
107 | uint readAhead()const; | 108 | uint readAhead()const; |
108 | 109 | ||
109 | private: | 110 | private: |
110 | class Private; | 111 | OPimAccessBackendPrivate *d; |
111 | Private* d; | ||
112 | Frontend* m_front; | 112 | Frontend* m_front; |
113 | uint m_read; | 113 | uint m_read; |
114 | int m_acc; | 114 | int m_acc; |
115 | 115 | ||
116 | }; | 116 | }; |
117 | 117 | ||
118 | template <class T> | 118 | template <class T> |
119 | OPimAccessBackend<T>::OPimAccessBackend(int acc) | 119 | OPimAccessBackend<T>::OPimAccessBackend(int acc) |
120 | : m_acc( acc ) | 120 | : m_acc( acc ) |
121 | { | 121 | { |
122 | m_front = 0l; | 122 | m_front = 0l; |
123 | } | 123 | } |
124 | template <class T> | 124 | template <class T> |
125 | OPimAccessBackend<T>::~OPimAccessBackend() { | 125 | OPimAccessBackend<T>::~OPimAccessBackend() { |
126 | 126 | ||
127 | } | 127 | } |
128 | template <class T> | 128 | template <class T> |
129 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { | 129 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { |
130 | m_front = fr; | 130 | m_front = fr; |
131 | } | 131 | } |
132 | template <class T> | 132 | template <class T> |
133 | void OPimAccessBackend<T>::cache( const T& t )const { | 133 | void OPimAccessBackend<T>::cache( const T& t )const { |
134 | if (m_front ) | 134 | if (m_front ) |
135 | m_front->cache( t ); | 135 | m_front->cache( t ); |
136 | } | 136 | } |
137 | template <class T> | 137 | template <class T> |
138 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { | 138 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { |
139 | if (m_front ) | 139 | if (m_front ) |
140 | m_front->setSaneCacheSize( size ); | 140 | m_front->setSaneCacheSize( size ); |
141 | } | 141 | } |
142 | template <class T> | 142 | template <class T> |
143 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, | 143 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, |
144 | uint, typename Frontend::CacheDirection )const { | 144 | uint, typename Frontend::CacheDirection )const { |
145 | return find( uid ); | 145 | return find( uid ); |
146 | } | 146 | } |
147 | template <class T> | 147 | template <class T> |
148 | void OPimAccessBackend<T>::setReadAhead( uint count ) { | 148 | void OPimAccessBackend<T>::setReadAhead( uint count ) { |
149 | m_read = count; | 149 | m_read = count; |
150 | } | 150 | } |
151 | template <class T> | 151 | template <class T> |
152 | uint OPimAccessBackend<T>::readAhead()const { | 152 | uint OPimAccessBackend<T>::readAhead()const { |
153 | return m_read; | 153 | return m_read; |
154 | } | 154 | } |
155 | template <class T> | 155 | template <class T> |
156 | int OPimAccessBackend<T>::access()const { | 156 | int OPimAccessBackend<T>::access()const { |
157 | return m_acc; | 157 | return m_acc; |
158 | } | 158 | } |
159 | #endif | 159 | #endif |
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.h b/libopie2/opiepim/backend/otodoaccessbackend.h index 05e8ca9..6be95bc 100644 --- a/libopie2/opiepim/backend/otodoaccessbackend.h +++ b/libopie2/opiepim/backend/otodoaccessbackend.h | |||
@@ -1,24 +1,28 @@ | |||
1 | #ifndef OPIE_TODO_ACCESS_BACKEND_H | 1 | #ifndef OPIE_TODO_ACCESS_BACKEND_H |
2 | #define OPIE_TODO_ACCESS_BACKEND_H | 2 | #define OPIE_TODO_ACCESS_BACKEND_H |
3 | 3 | ||
4 | #include <qbitarray.h> | 4 | #include <qbitarray.h> |
5 | 5 | ||
6 | #include "otodo.h" | 6 | #include "otodo.h" |
7 | #include "opimaccessbackend.h" | 7 | #include "opimaccessbackend.h" |
8 | 8 | ||
9 | class OTodoAccessBackend : public OPimAccessBackend<OTodo> { | 9 | class OTodoAccessBackend : public OPimAccessBackend<OTodo> { |
10 | public: | 10 | public: |
11 | OTodoAccessBackend(); | 11 | OTodoAccessBackend(); |
12 | ~OTodoAccessBackend(); | 12 | ~OTodoAccessBackend(); |
13 | virtual QArray<int> effectiveToDos( const QDate& start, | 13 | virtual QArray<int> effectiveToDos( const QDate& start, |
14 | const QDate& end, | 14 | const QDate& end, |
15 | bool includeNoDates ) = 0; | 15 | bool includeNoDates ) = 0; |
16 | virtual QArray<int> overDue() = 0; | 16 | virtual QArray<int> overDue() = 0; |
17 | virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter, | 17 | virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter, |
18 | int cat ) = 0; | 18 | int cat ) = 0; |
19 | virtual void removeAllCompleted() = 0; | 19 | virtual void removeAllCompleted() = 0; |
20 | virtual QBitArray supports()const = 0; | 20 | virtual QBitArray supports()const = 0; |
21 | |||
22 | private: | ||
23 | class Private; | ||
24 | Private *d; | ||
21 | 25 | ||
22 | }; | 26 | }; |
23 | 27 | ||
24 | #endif | 28 | #endif |
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp index 3577e14..6415952 100644 --- a/libopie2/opiepim/backend/otodoaccessvcal.cpp +++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp | |||
@@ -1,225 +1,249 @@ | |||
1 | #include <qfile.h> | 1 | #include <qfile.h> |
2 | 2 | ||
3 | #include <qtopia/private/vobject_p.h> | 3 | #include <qtopia/private/vobject_p.h> |
4 | #include <qtopia/timeconversion.h> | 4 | #include <qtopia/timeconversion.h> |
5 | #include <qtopia/private/qfiledirect_p.h> | 5 | #include <qtopia/private/qfiledirect_p.h> |
6 | 6 | ||
7 | #include "otodoaccessvcal.h" | 7 | #include "otodoaccessvcal.h" |
8 | 8 | ||
9 | namespace { | 9 | namespace { |
10 | static OTodo eventByVObj( VObject *obj ){ | 10 | static OTodo eventByVObj( VObject *obj ){ |
11 | OTodo event; | 11 | OTodo event; |
12 | VObject *ob; | 12 | VObject *ob; |
13 | QCString name; | 13 | QCString name; |
14 | // no uid, attendees, ... and no fun | 14 | // no uid, attendees, ... and no fun |
15 | // description | 15 | // description |
16 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ | 16 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ |
17 | name = vObjectStringZValue( ob ); | 17 | name = vObjectStringZValue( ob ); |
18 | #if 0 | ||
18 | event.setDescription( name ); | 19 | event.setDescription( name ); |
20 | #else | ||
21 | event.setSummary( name ); | ||
22 | #endif | ||
19 | } | 23 | } |
20 | // summary | 24 | // summary |
21 | if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { | 25 | if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { |
22 | name = vObjectStringZValue( ob ); | 26 | name = vObjectStringZValue( ob ); |
27 | #if 0 | ||
23 | event.setSummary( name ); | 28 | event.setSummary( name ); |
29 | #else | ||
30 | event.setDescription( name ); | ||
31 | #endif | ||
24 | } | 32 | } |
25 | // completed | 33 | // completed |
26 | if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ | 34 | if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ |
27 | name = vObjectStringZValue( ob ); | 35 | name = vObjectStringZValue( ob ); |
28 | if( name == "COMPLETED" ){ | 36 | if( name == "COMPLETED" ){ |
29 | event.setCompleted( true ); | 37 | event.setCompleted( true ); |
30 | }else{ | 38 | }else{ |
31 | event.setCompleted( false ); | 39 | event.setCompleted( false ); |
32 | } | 40 | } |
33 | }else | 41 | }else |
34 | event.setCompleted( false ); | 42 | event.setCompleted( false ); |
35 | // priority | 43 | // priority |
36 | if ((ob = isAPropertyOf(obj, VCPriorityProp))) { | 44 | if ((ob = isAPropertyOf(obj, VCPriorityProp))) { |
37 | name = vObjectStringZValue( ob ); | 45 | name = vObjectStringZValue( ob ); |
38 | bool ok; | 46 | bool ok; |
39 | event.setPriority(name.toInt(&ok) ); | 47 | event.setPriority(name.toInt(&ok) ); |
40 | } | 48 | } |
41 | //due date | 49 | //due date |
42 | if((ob = isAPropertyOf(obj, VCDueProp)) ){ | 50 | if((ob = isAPropertyOf(obj, VCDueProp)) ){ |
43 | event.setHasDueDate( true ); | 51 | event.setHasDueDate( true ); |
44 | name = vObjectStringZValue( ob ); | 52 | name = vObjectStringZValue( ob ); |
45 | event.setDueDate( TimeConversion::fromISO8601( name).date() ); | 53 | event.setDueDate( TimeConversion::fromISO8601( name).date() ); |
46 | } | 54 | } |
47 | // categories | 55 | // categories |
48 | if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ | 56 | if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ |
49 | name = vObjectStringZValue( ob ); | 57 | name = vObjectStringZValue( ob ); |
50 | qWarning("Categories:%s", name.data() ); | 58 | qWarning("Categories:%s", name.data() ); |
51 | } | 59 | } |
52 | 60 | ||
53 | event.setUid( 1 ); | 61 | event.setUid( 1 ); |
54 | return event; | 62 | return event; |
55 | }; | 63 | }; |
56 | static VObject *vobjByEvent( const OTodo &event ) { | 64 | static VObject *vobjByEvent( const OTodo &event ) { |
57 | VObject *task = newVObject( VCTodoProp ); | 65 | VObject *task = newVObject( VCTodoProp ); |
58 | if( task == 0 ) | 66 | if( task == 0 ) |
59 | return 0l; | 67 | return 0l; |
60 | 68 | ||
61 | if( event.hasDueDate() ) { | 69 | if( event.hasDueDate() ) { |
62 | QTime time(0, 0, 0); | 70 | QTime time(0, 0, 0); |
63 | QDateTime date(event.dueDate(), time ); | 71 | QDateTime date(event.dueDate(), time ); |
64 | addPropValue( task, VCDueProp, | 72 | addPropValue( task, VCDueProp, |
65 | TimeConversion::toISO8601( date ) ); | 73 | TimeConversion::toISO8601( date ) ); |
66 | } | 74 | } |
67 | 75 | ||
68 | if( event.isCompleted() ) | 76 | if( event.isCompleted() ) |
69 | addPropValue( task, VCStatusProp, "COMPLETED"); | 77 | addPropValue( task, VCStatusProp, "COMPLETED"); |
70 | 78 | ||
71 | QString string = QString::number(event.priority() ); | 79 | QString string = QString::number(event.priority() ); |
72 | addPropValue( task, VCPriorityProp, string.local8Bit() ); | 80 | addPropValue( task, VCPriorityProp, string.local8Bit() ); |
73 | 81 | ||
74 | addPropValue( task, VCCategoriesProp, | 82 | addPropValue( task, VCCategoriesProp, |
75 | event.idsToString( event.categories() ).local8Bit() ); | 83 | event.idsToString( event.categories() ).local8Bit() ); |
76 | 84 | ||
85 | #if 0 | ||
86 | |||
87 | // There seems a misrepresentation between summary in otodoevent | ||
88 | // and summary in vcard. | ||
89 | // The same with description.. | ||
90 | // Description is summary and vice versa.. Argh.. (eilers) | ||
91 | |||
92 | |||
77 | addPropValue( task, VCDescriptionProp, | 93 | addPropValue( task, VCDescriptionProp, |
78 | event.description().local8Bit() ); | 94 | event.description().local8Bit() ); |
79 | 95 | ||
80 | addPropValue( task, VCSummaryProp, | 96 | addPropValue( task, VCSummaryProp, |
81 | event.summary().local8Bit() ); | 97 | event.summary().local8Bit() ); |
98 | |||
99 | #else | ||
100 | addPropValue( task, VCDescriptionProp, | ||
101 | event.summary().local8Bit() ); | ||
102 | |||
103 | addPropValue( task, VCSummaryProp, | ||
104 | event.description().local8Bit() ); | ||
105 | #endif | ||
82 | return task; | 106 | return task; |
83 | }; | 107 | }; |
84 | } | 108 | } |
85 | 109 | ||
86 | OTodoAccessVCal::OTodoAccessVCal( const QString& path ) | 110 | OTodoAccessVCal::OTodoAccessVCal( const QString& path ) |
87 | : m_dirty(false), m_file( path ) | 111 | : m_dirty(false), m_file( path ) |
88 | { | 112 | { |
89 | } | 113 | } |
90 | OTodoAccessVCal::~OTodoAccessVCal() { | 114 | OTodoAccessVCal::~OTodoAccessVCal() { |
91 | } | 115 | } |
92 | bool OTodoAccessVCal::load() { | 116 | bool OTodoAccessVCal::load() { |
93 | m_map.clear(); | 117 | m_map.clear(); |
94 | m_dirty = false; | 118 | m_dirty = false; |
95 | 119 | ||
96 | VObject* vcal = 0l; | 120 | VObject* vcal = 0l; |
97 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); | 121 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); |
98 | if (!vcal ) | 122 | if (!vcal ) |
99 | return false; | 123 | return false; |
100 | 124 | ||
101 | // Iterate over the list | 125 | // Iterate over the list |
102 | VObjectIterator it; | 126 | VObjectIterator it; |
103 | VObject* vobj; | 127 | VObject* vobj; |
104 | 128 | ||
105 | initPropIterator(&it, vcal); | 129 | initPropIterator(&it, vcal); |
106 | 130 | ||
107 | while( moreIteration( &it ) ) { | 131 | while( moreIteration( &it ) ) { |
108 | vobj = ::nextVObject( &it ); | 132 | vobj = ::nextVObject( &it ); |
109 | QCString name = ::vObjectName( vobj ); | 133 | QCString name = ::vObjectName( vobj ); |
110 | if( name == VCTodoProp ){ | 134 | if( name == VCTodoProp ){ |
111 | OTodo to = eventByVObj( vobj ); | 135 | OTodo to = eventByVObj( vobj ); |
112 | m_map.insert( to.uid(), to ); | 136 | m_map.insert( to.uid(), to ); |
113 | } | 137 | } |
114 | } | 138 | } |
115 | 139 | ||
116 | // Should I do a delete vcal? | 140 | // Should I do a delete vcal? |
117 | 141 | ||
118 | return true; | 142 | return true; |
119 | } | 143 | } |
120 | bool OTodoAccessVCal::reload() { | 144 | bool OTodoAccessVCal::reload() { |
121 | return load(); | 145 | return load(); |
122 | } | 146 | } |
123 | bool OTodoAccessVCal::save() { | 147 | bool OTodoAccessVCal::save() { |
124 | if (!m_dirty ) | 148 | if (!m_dirty ) |
125 | return true; | 149 | return true; |
126 | 150 | ||
127 | QFileDirect file( m_file ); | 151 | QFileDirect file( m_file ); |
128 | if (!file.open(IO_WriteOnly ) ) | 152 | if (!file.open(IO_WriteOnly ) ) |
129 | return false; | 153 | return false; |
130 | 154 | ||
131 | VObject *obj; | 155 | VObject *obj; |
132 | obj = newVObject( VCCalProp ); | 156 | obj = newVObject( VCCalProp ); |
133 | addPropValue( obj, VCVersionProp, "1.0" ); | 157 | addPropValue( obj, VCVersionProp, "1.0" ); |
134 | VObject *vo; | 158 | VObject *vo; |
135 | for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ | 159 | for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ |
136 | vo = vobjByEvent( it.data() ); | 160 | vo = vobjByEvent( it.data() ); |
137 | addVObjectProp(obj, vo ); | 161 | addVObjectProp(obj, vo ); |
138 | } | 162 | } |
139 | writeVObject( file.directHandle(), obj ); | 163 | writeVObject( file.directHandle(), obj ); |
140 | cleanVObject( obj ); | 164 | cleanVObject( obj ); |
141 | cleanStrTbl(); | 165 | cleanStrTbl(); |
142 | 166 | ||
143 | m_dirty = false; | 167 | m_dirty = false; |
144 | return true; | 168 | return true; |
145 | } | 169 | } |
146 | void OTodoAccessVCal::clear() { | 170 | void OTodoAccessVCal::clear() { |
147 | m_map.clear(); | 171 | m_map.clear(); |
148 | m_dirty = true; | 172 | m_dirty = true; |
149 | } | 173 | } |
150 | bool OTodoAccessVCal::add( const OTodo& to ) { | 174 | bool OTodoAccessVCal::add( const OTodo& to ) { |
151 | m_map.insert( to.uid(), to ); | 175 | m_map.insert( to.uid(), to ); |
152 | m_dirty = true; | 176 | m_dirty = true; |
153 | return true; | 177 | return true; |
154 | } | 178 | } |
155 | bool OTodoAccessVCal::remove( int uid ) { | 179 | bool OTodoAccessVCal::remove( int uid ) { |
156 | m_map.remove( uid ); | 180 | m_map.remove( uid ); |
157 | m_dirty = true; | 181 | m_dirty = true; |
158 | return true; | 182 | return true; |
159 | } | 183 | } |
160 | void OTodoAccessVCal::removeAllCompleted() { | 184 | void OTodoAccessVCal::removeAllCompleted() { |
161 | for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { | 185 | for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { |
162 | if ( (*it).isCompleted() ) | 186 | if ( (*it).isCompleted() ) |
163 | m_map.remove( it ); | 187 | m_map.remove( it ); |
164 | } | 188 | } |
165 | } | 189 | } |
166 | bool OTodoAccessVCal::replace( const OTodo& to ) { | 190 | bool OTodoAccessVCal::replace( const OTodo& to ) { |
167 | m_map.replace( to.uid(), to ); | 191 | m_map.replace( to.uid(), to ); |
168 | m_dirty = true; | 192 | m_dirty = true; |
169 | return true; | 193 | return true; |
170 | } | 194 | } |
171 | OTodo OTodoAccessVCal::find(int uid )const { | 195 | OTodo OTodoAccessVCal::find(int uid )const { |
172 | return m_map[uid]; | 196 | return m_map[uid]; |
173 | } | 197 | } |
174 | QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { | 198 | QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { |
175 | QArray<int> ar(0); | 199 | QArray<int> ar(0); |
176 | return ar; | 200 | return ar; |
177 | } | 201 | } |
178 | QArray<int> OTodoAccessVCal::allRecords()const { | 202 | QArray<int> OTodoAccessVCal::allRecords()const { |
179 | QArray<int> ar( m_map.count() ); | 203 | QArray<int> ar( m_map.count() ); |
180 | QMap<int, OTodo>::ConstIterator it; | 204 | QMap<int, OTodo>::ConstIterator it; |
181 | int i = 0; | 205 | int i = 0; |
182 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | 206 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { |
183 | ar[i] = it.key(); | 207 | ar[i] = it.key(); |
184 | i++; | 208 | i++; |
185 | } | 209 | } |
186 | return ar; | 210 | return ar; |
187 | } | 211 | } |
188 | QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp &r)const { | 212 | QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const { |
189 | QArray<int> ar(0); | 213 | QArray<int> ar(0); |
190 | return ar; | 214 | return ar; |
191 | } | 215 | } |
192 | QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { | 216 | QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { |
193 | QArray<int> ar(0); | 217 | QArray<int> ar(0); |
194 | return ar; | 218 | return ar; |
195 | } | 219 | } |
196 | QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , | 220 | QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , |
197 | const QDate& , | 221 | const QDate& , |
198 | bool ) { | 222 | bool ) { |
199 | QArray<int> ar(0); | 223 | QArray<int> ar(0); |
200 | return ar; | 224 | return ar; |
201 | } | 225 | } |
202 | QArray<int> OTodoAccessVCal::overDue() { | 226 | QArray<int> OTodoAccessVCal::overDue() { |
203 | QArray<int> ar(0); | 227 | QArray<int> ar(0); |
204 | return ar; | 228 | return ar; |
205 | } | 229 | } |
206 | QBitArray OTodoAccessVCal::supports()const { | 230 | QBitArray OTodoAccessVCal::supports()const { |
207 | static QBitArray ar = sup(); | 231 | static QBitArray ar = sup(); |
208 | 232 | ||
209 | return ar; | 233 | return ar; |
210 | } | 234 | } |
211 | QBitArray OTodoAccessVCal::sup() { | 235 | QBitArray OTodoAccessVCal::sup() { |
212 | QBitArray ar ( OTodo::CompletedDate +1 ); | 236 | QBitArray ar ( OTodo::CompletedDate +1 ); |
213 | ar.fill( true ); | 237 | ar.fill( true ); |
214 | 238 | ||
215 | ar[OTodo::CrossReference] = false; | 239 | ar[OTodo::CrossReference] = false; |
216 | ar[OTodo::State ] = false; | 240 | ar[OTodo::State ] = false; |
217 | ar[OTodo::Reminders] = false; | 241 | ar[OTodo::Reminders] = false; |
218 | ar[OTodo::Notifiers] = false; | 242 | ar[OTodo::Notifiers] = false; |
219 | ar[OTodo::Maintainer] = false; | 243 | ar[OTodo::Maintainer] = false; |
220 | ar[OTodo::Progress] = false; | 244 | ar[OTodo::Progress] = false; |
221 | ar[OTodo::Alarms ] = false; | 245 | ar[OTodo::Alarms ] = false; |
222 | ar[OTodo::Recurrence] = false; | 246 | ar[OTodo::Recurrence] = false; |
223 | 247 | ||
224 | return ar; | 248 | return ar; |
225 | } | 249 | } |
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index 3d15354..f688735 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp | |||
@@ -1,186 +1,186 @@ | |||
1 | #include <errno.h> | 1 | #include <errno.h> |
2 | #include <fcntl.h> | 2 | #include <fcntl.h> |
3 | 3 | ||
4 | #include <sys/mman.h> | 4 | #include <sys/mman.h> |
5 | #include <sys/stat.h> | 5 | #include <sys/stat.h> |
6 | #include <sys/types.h> | 6 | #include <sys/types.h> |
7 | 7 | ||
8 | #include <unistd.h> | 8 | #include <unistd.h> |
9 | 9 | ||
10 | 10 | ||
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qvector.h> | 12 | #include <qvector.h> |
13 | 13 | ||
14 | #include <qpe/global.h> | 14 | #include <qpe/global.h> |
15 | #include <qpe/stringutil.h> | 15 | #include <qpe/stringutil.h> |
16 | #include <qpe/timeconversion.h> | 16 | #include <qpe/timeconversion.h> |
17 | 17 | ||
18 | #include "oconversion.h" | 18 | #include "oconversion.h" |
19 | #include "opimstate.h" | 19 | #include "opimstate.h" |
20 | #include "otimezone.h" | 20 | #include "otimezone.h" |
21 | #include "opimnotifymanager.h" | 21 | #include "opimnotifymanager.h" |
22 | #include "orecur.h" | 22 | #include "orecur.h" |
23 | #include "otodoaccessxml.h" | 23 | #include "otodoaccessxml.h" |
24 | 24 | ||
25 | namespace { | 25 | namespace { |
26 | time_t rp_end; | 26 | time_t rp_end; |
27 | ORecur* rec; | 27 | ORecur* rec; |
28 | ORecur *recur() { | 28 | ORecur *recur() { |
29 | if (!rec ) rec = new ORecur; | 29 | if (!rec ) rec = new ORecur; |
30 | return rec; | 30 | return rec; |
31 | } | 31 | } |
32 | int snd; | 32 | int snd; |
33 | enum MoreAttributes { | 33 | enum MoreAttributes { |
34 | FRType = OTodo::CompletedDate + 2, | 34 | FRType = OTodo::CompletedDate + 2, |
35 | FRWeekdays, | 35 | FRWeekdays, |
36 | FRPosition, | 36 | FRPosition, |
37 | FRFreq, | 37 | FRFreq, |
38 | FRHasEndDate, | 38 | FRHasEndDate, |
39 | FREndDate, | 39 | FREndDate, |
40 | FRStart, | 40 | FRStart, |
41 | FREnd | 41 | FREnd |
42 | }; | 42 | }; |
43 | // FROM TT again | 43 | // FROM TT again |
44 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | 44 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) |
45 | { | 45 | { |
46 | char needleChar; | 46 | char needleChar; |
47 | char haystackChar; | 47 | char haystackChar; |
48 | if (!needle || !haystack || !hLen || !nLen) | 48 | if (!needle || !haystack || !hLen || !nLen) |
49 | return 0; | 49 | return 0; |
50 | 50 | ||
51 | const char* hsearch = haystack; | 51 | const char* hsearch = haystack; |
52 | 52 | ||
53 | if ((needleChar = *needle++) != 0) { | 53 | if ((needleChar = *needle++) != 0) { |
54 | nLen--; //(to make up for needle++) | 54 | nLen--; //(to make up for needle++) |
55 | do { | 55 | do { |
56 | do { | 56 | do { |
57 | if ((haystackChar = *hsearch++) == 0) | 57 | if ((haystackChar = *hsearch++) == 0) |
58 | return (0); | 58 | return (0); |
59 | if (hsearch >= haystack + hLen) | 59 | if (hsearch >= haystack + hLen) |
60 | return (0); | 60 | return (0); |
61 | } while (haystackChar != needleChar); | 61 | } while (haystackChar != needleChar); |
62 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); | 62 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); |
63 | hsearch--; | 63 | hsearch--; |
64 | } | 64 | } |
65 | return ((char *)hsearch); | 65 | return ((char *)hsearch); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | 69 | ||
70 | OTodoAccessXML::OTodoAccessXML( const QString& appName, | 70 | OTodoAccessXML::OTodoAccessXML( const QString& appName, |
71 | const QString& fileName ) | 71 | const QString& fileName ) |
72 | : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) | 72 | : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) |
73 | { | 73 | { |
74 | if (!fileName.isEmpty() ) | 74 | if (!fileName.isEmpty() ) |
75 | m_file = fileName; | 75 | m_file = fileName; |
76 | else | 76 | else |
77 | m_file = Global::applicationFileName( "todolist", "todolist.xml" ); | 77 | m_file = Global::applicationFileName( "todolist", "todolist.xml" ); |
78 | } | 78 | } |
79 | OTodoAccessXML::~OTodoAccessXML() { | 79 | OTodoAccessXML::~OTodoAccessXML() { |
80 | 80 | ||
81 | } | 81 | } |
82 | bool OTodoAccessXML::load() { | 82 | bool OTodoAccessXML::load() { |
83 | rec = 0; | 83 | rec = 0; |
84 | m_opened = true; | 84 | m_opened = true; |
85 | m_changed = false; | 85 | m_changed = false; |
86 | /* initialize dict */ | 86 | /* initialize dict */ |
87 | /* | 87 | /* |
88 | * UPDATE dict if you change anything!!! | 88 | * UPDATE dict if you change anything!!! |
89 | */ | 89 | */ |
90 | QAsciiDict<int> dict(21); | 90 | QAsciiDict<int> dict(26); |
91 | dict.setAutoDelete( TRUE ); | 91 | dict.setAutoDelete( TRUE ); |
92 | dict.insert("Categories" , new int(OTodo::Category) ); | 92 | dict.insert("Categories" , new int(OTodo::Category) ); |
93 | dict.insert("Uid" , new int(OTodo::Uid) ); | 93 | dict.insert("Uid" , new int(OTodo::Uid) ); |
94 | dict.insert("HasDate" , new int(OTodo::HasDate) ); | 94 | dict.insert("HasDate" , new int(OTodo::HasDate) ); |
95 | dict.insert("Completed" , new int(OTodo::Completed) ); | 95 | dict.insert("Completed" , new int(OTodo::Completed) ); |
96 | dict.insert("Description" , new int(OTodo::Description) ); | 96 | dict.insert("Description" , new int(OTodo::Description) ); |
97 | dict.insert("Summary" , new int(OTodo::Summary) ); | 97 | dict.insert("Summary" , new int(OTodo::Summary) ); |
98 | dict.insert("Priority" , new int(OTodo::Priority) ); | 98 | dict.insert("Priority" , new int(OTodo::Priority) ); |
99 | dict.insert("DateDay" , new int(OTodo::DateDay) ); | 99 | dict.insert("DateDay" , new int(OTodo::DateDay) ); |
100 | dict.insert("DateMonth" , new int(OTodo::DateMonth) ); | 100 | dict.insert("DateMonth" , new int(OTodo::DateMonth) ); |
101 | dict.insert("DateYear" , new int(OTodo::DateYear) ); | 101 | dict.insert("DateYear" , new int(OTodo::DateYear) ); |
102 | dict.insert("Progress" , new int(OTodo::Progress) ); | 102 | dict.insert("Progress" , new int(OTodo::Progress) ); |
103 | dict.insert("CompletedDate", new int(OTodo::CompletedDate) ); | 103 | dict.insert("CompletedDate", new int(OTodo::CompletedDate) ); |
104 | dict.insert("StartDate", new int(OTodo::StartDate) ); | 104 | dict.insert("StartDate", new int(OTodo::StartDate) ); |
105 | dict.insert("CrossReference", new int(OTodo::CrossReference) ); | 105 | dict.insert("CrossReference", new int(OTodo::CrossReference) ); |
106 | dict.insert("State", new int(OTodo::State) ); | 106 | dict.insert("State", new int(OTodo::State) ); |
107 | dict.insert("Alarms", new int(OTodo::Alarms) ); | 107 | dict.insert("Alarms", new int(OTodo::Alarms) ); |
108 | dict.insert("Reminders", new int(OTodo::Reminders) ); | 108 | dict.insert("Reminders", new int(OTodo::Reminders) ); |
109 | dict.insert("Notifiers", new int(OTodo::Notifiers) ); | 109 | dict.insert("Notifiers", new int(OTodo::Notifiers) ); |
110 | dict.insert("Maintainer", new int(OTodo::Maintainer) ); | 110 | dict.insert("Maintainer", new int(OTodo::Maintainer) ); |
111 | dict.insert("rtype", new int(FRType) ); | 111 | dict.insert("rtype", new int(FRType) ); |
112 | dict.insert("rweekdays", new int(FRWeekdays) ); | 112 | dict.insert("rweekdays", new int(FRWeekdays) ); |
113 | dict.insert("rposition", new int(FRPosition) ); | 113 | dict.insert("rposition", new int(FRPosition) ); |
114 | dict.insert("rfreq", new int(FRFreq) ); | 114 | dict.insert("rfreq", new int(FRFreq) ); |
115 | dict.insert("start", new int(FRStart) ); | 115 | dict.insert("start", new int(FRStart) ); |
116 | dict.insert("rhasenddate", new int(FRHasEndDate) ); | 116 | dict.insert("rhasenddate", new int(FRHasEndDate) ); |
117 | dict.insert("enddt", new int(FREndDate) ); | 117 | dict.insert("enddt", new int(FREndDate) ); |
118 | 118 | ||
119 | // here the custom XML parser from TT it's GPL | 119 | // here the custom XML parser from TT it's GPL |
120 | // but we want to push OpiePIM... to TT..... | 120 | // but we want to push OpiePIM... to TT..... |
121 | // mmap part from zecke :) | 121 | // mmap part from zecke :) |
122 | int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY ); | 122 | int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY ); |
123 | struct stat attribut; | 123 | struct stat attribut; |
124 | if ( fd < 0 ) return false; | 124 | if ( fd < 0 ) return false; |
125 | 125 | ||
126 | if ( fstat(fd, &attribut ) == -1 ) { | 126 | if ( fstat(fd, &attribut ) == -1 ) { |
127 | ::close( fd ); | 127 | ::close( fd ); |
128 | return false; | 128 | return false; |
129 | } | 129 | } |
130 | void* map_addr = ::mmap(NULL, attribut.st_size, PROT_READ, MAP_SHARED, fd, 0 ); | 130 | void* map_addr = ::mmap(NULL, attribut.st_size, PROT_READ, MAP_SHARED, fd, 0 ); |
131 | if ( map_addr == ( (caddr_t)-1) ) { | 131 | if ( map_addr == ( (caddr_t)-1) ) { |
132 | ::close(fd ); | 132 | ::close(fd ); |
133 | return false; | 133 | return false; |
134 | } | 134 | } |
135 | /* advise the kernel who we want to read it */ | 135 | /* advise the kernel who we want to read it */ |
136 | ::madvise( map_addr, attribut.st_size, MADV_SEQUENTIAL ); | 136 | ::madvise( map_addr, attribut.st_size, MADV_SEQUENTIAL ); |
137 | /* we do not the file any more */ | 137 | /* we do not the file any more */ |
138 | ::close( fd ); | 138 | ::close( fd ); |
139 | 139 | ||
140 | char* dt = (char*)map_addr; | 140 | char* dt = (char*)map_addr; |
141 | int len = attribut.st_size; | 141 | int len = attribut.st_size; |
142 | int i = 0; | 142 | int i = 0; |
143 | char *point; | 143 | char *point; |
144 | const char* collectionString = "<Task "; | 144 | const char* collectionString = "<Task "; |
145 | int strLen = strlen(collectionString); | 145 | int strLen = strlen(collectionString); |
146 | while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { | 146 | while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { |
147 | i = point -dt; | 147 | i = point -dt; |
148 | i+= strLen; | 148 | i+= strLen; |
149 | qWarning("Found a start at %d %d", i, (point-dt) ); | 149 | qWarning("Found a start at %d %d", i, (point-dt) ); |
150 | 150 | ||
151 | OTodo ev; | 151 | OTodo ev; |
152 | m_year = m_month = m_day = 0; | 152 | m_year = m_month = m_day = 0; |
153 | 153 | ||
154 | while ( TRUE ) { | 154 | while ( TRUE ) { |
155 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) | 155 | while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) |
156 | ++i; | 156 | ++i; |
157 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) | 157 | if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) |
158 | break; | 158 | break; |
159 | 159 | ||
160 | // we have another attribute, read it. | 160 | // we have another attribute, read it. |
161 | int j = i; | 161 | int j = i; |
162 | while ( j < len && dt[j] != '=' ) | 162 | while ( j < len && dt[j] != '=' ) |
163 | ++j; | 163 | ++j; |
164 | QCString attr( dt+i, j-i+1); | 164 | QCString attr( dt+i, j-i+1); |
165 | 165 | ||
166 | i = ++j; // skip = | 166 | i = ++j; // skip = |
167 | 167 | ||
168 | // find the start of quotes | 168 | // find the start of quotes |
169 | while ( i < len && dt[i] != '"' ) | 169 | while ( i < len && dt[i] != '"' ) |
170 | ++i; | 170 | ++i; |
171 | j = ++i; | 171 | j = ++i; |
172 | 172 | ||
173 | bool haveUtf = FALSE; | 173 | bool haveUtf = FALSE; |
174 | bool haveEnt = FALSE; | 174 | bool haveEnt = FALSE; |
175 | while ( j < len && dt[j] != '"' ) { | 175 | while ( j < len && dt[j] != '"' ) { |
176 | if ( ((unsigned char)dt[j]) > 0x7f ) | 176 | if ( ((unsigned char)dt[j]) > 0x7f ) |
177 | haveUtf = TRUE; | 177 | haveUtf = TRUE; |
178 | if ( dt[j] == '&' ) | 178 | if ( dt[j] == '&' ) |
179 | haveEnt = TRUE; | 179 | haveEnt = TRUE; |
180 | ++j; | 180 | ++j; |
181 | } | 181 | } |
182 | if ( i == j ) { | 182 | if ( i == j ) { |
183 | // empty value | 183 | // empty value |
184 | i = j + 1; | 184 | i = j + 1; |
185 | continue; | 185 | continue; |
186 | } | 186 | } |
@@ -743,132 +743,134 @@ public: | |||
743 | if ( ret ) | 743 | if ( ret ) |
744 | return ret; | 744 | return ret; |
745 | 745 | ||
746 | // default did not gave difference let's try it other way around | 746 | // default did not gave difference let's try it other way around |
747 | /* | 747 | /* |
748 | * General try if already checked if not test | 748 | * General try if already checked if not test |
749 | * and return | 749 | * and return |
750 | * 1.Completed | 750 | * 1.Completed |
751 | * 2.Priority | 751 | * 2.Priority |
752 | * 3.Description | 752 | * 3.Description |
753 | * 4.DueDate | 753 | * 4.DueDate |
754 | */ | 754 | */ |
755 | if (!seComp ) { | 755 | if (!seComp ) { |
756 | if ( (ret = completed( con1->todo, con2->todo ) ) ) { | 756 | if ( (ret = completed( con1->todo, con2->todo ) ) ) { |
757 | if (!m_asc ) ret *= -1; | 757 | if (!m_asc ) ret *= -1; |
758 | return ret; | 758 | return ret; |
759 | } | 759 | } |
760 | } | 760 | } |
761 | if (!sePrio ) { | 761 | if (!sePrio ) { |
762 | if ( (ret = priority( con1->todo, con2->todo ) ) ) { | 762 | if ( (ret = priority( con1->todo, con2->todo ) ) ) { |
763 | if (!m_asc ) ret *= -1; | 763 | if (!m_asc ) ret *= -1; |
764 | return ret; | 764 | return ret; |
765 | } | 765 | } |
766 | } | 766 | } |
767 | if (!seDesc ) { | 767 | if (!seDesc ) { |
768 | if ( (ret = description(con1->todo, con2->todo ) ) ) { | 768 | if ( (ret = description(con1->todo, con2->todo ) ) ) { |
769 | if (!m_asc) ret *= -1; | 769 | if (!m_asc) ret *= -1; |
770 | return ret; | 770 | return ret; |
771 | } | 771 | } |
772 | } | 772 | } |
773 | if (!seDeadline) { | 773 | if (!seDeadline) { |
774 | if ( (ret = deadline( con1->todo, con2->todo ) ) ) { | 774 | if ( (ret = deadline( con1->todo, con2->todo ) ) ) { |
775 | if (!m_asc) ret *= -1; | 775 | if (!m_asc) ret *= -1; |
776 | return ret; | 776 | return ret; |
777 | } | 777 | } |
778 | } | 778 | } |
779 | 779 | ||
780 | return 0; | 780 | return 0; |
781 | } | 781 | } |
782 | private: | 782 | private: |
783 | bool m_asc; | 783 | bool m_asc; |
784 | int m_sort; | 784 | int m_sort; |
785 | 785 | ||
786 | }; | 786 | }; |
787 | 787 | ||
788 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, | 788 | QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, |
789 | int sortFilter, int cat ) { | 789 | int sortFilter, int cat ) { |
790 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); | 790 | OTodoXMLVector vector(m_events.count(), asc,sortOrder ); |
791 | QMap<int, OTodo>::Iterator it; | 791 | QMap<int, OTodo>::Iterator it; |
792 | int item = 0; | 792 | int item = 0; |
793 | 793 | ||
794 | bool bCat = sortFilter & 1 ? true : false; | 794 | bool bCat = sortFilter & 1 ? true : false; |
795 | bool bOnly = sortFilter & 2 ? true : false; | 795 | bool bOnly = sortFilter & 2 ? true : false; |
796 | bool comp = sortFilter & 4 ? true : false; | 796 | bool comp = sortFilter & 4 ? true : false; |
797 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { | 797 | for ( it = m_events.begin(); it != m_events.end(); ++it ) { |
798 | 798 | ||
799 | /* show category */ | 799 | /* show category */ |
800 | /* -1 == unfiled */ | 800 | /* -1 == unfiled */ |
801 | if ( bCat && cat == -1 ) { | 801 | if ( bCat && cat == -1 ) { |
802 | if(!(*it).categories().isEmpty() ) | 802 | if(!(*it).categories().isEmpty() ) |
803 | continue; | 803 | continue; |
804 | }else if ( bCat && cat != 0) | 804 | }else if ( bCat && cat != 0) |
805 | if (!(*it).categories().contains( cat ) ) { | 805 | if (!(*it).categories().contains( cat ) ) { |
806 | continue; | 806 | continue; |
807 | } | 807 | } |
808 | /* isOverdue but we should not show overdue - why?*/ | 808 | /* isOverdue but we should not show overdue - why?*/ |
809 | /* if ( (*it).isOverdue() && !bOnly ) { | 809 | /* if ( (*it).isOverdue() && !bOnly ) { |
810 | qWarning("item is overdue but !bOnly"); | 810 | qWarning("item is overdue but !bOnly"); |
811 | continue; | 811 | continue; |
812 | } | 812 | } |
813 | */ | 813 | */ |
814 | if ( !(*it).isOverdue() && bOnly ) { | 814 | if ( !(*it).isOverdue() && bOnly ) { |
815 | continue; | 815 | continue; |
816 | } | 816 | } |
817 | 817 | ||
818 | if ((*it).isCompleted() && comp ) { | 818 | if ((*it).isCompleted() && comp ) { |
819 | continue; | 819 | continue; |
820 | } | 820 | } |
821 | 821 | ||
822 | 822 | ||
823 | OTodoXMLContainer* con = new OTodoXMLContainer(); | 823 | OTodoXMLContainer* con = new OTodoXMLContainer(); |
824 | con->todo = (*it); | 824 | con->todo = (*it); |
825 | vector.insert(item, con ); | 825 | vector.insert(item, con ); |
826 | item++; | 826 | item++; |
827 | } | 827 | } |
828 | vector.resize( item ); | 828 | vector.resize( item ); |
829 | /* sort it now */ | 829 | /* sort it now */ |
830 | vector.sort(); | 830 | vector.sort(); |
831 | /* now get the uids */ | 831 | /* now get the uids */ |
832 | QArray<int> array( vector.count() ); | 832 | QArray<int> array( vector.count() ); |
833 | for (uint i= 0; i < vector.count(); i++ ) { | 833 | for (uint i= 0; i < vector.count(); i++ ) { |
834 | array[i] = ( vector.at(i) )->todo.uid(); | 834 | array[i] = ( vector.at(i) )->todo.uid(); |
835 | } | 835 | } |
836 | return array; | 836 | return array; |
837 | }; | 837 | }; |
838 | void OTodoAccessXML::removeAllCompleted() { | 838 | void OTodoAccessXML::removeAllCompleted() { |
839 | QMap<int, OTodo> events = m_events; | ||
839 | for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { | 840 | for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { |
840 | if ( (*it).isCompleted() ) | 841 | if ( (*it).isCompleted() ) |
841 | m_events.remove( it ); | 842 | events.remove( it.key() ); |
842 | } | 843 | } |
844 | m_events = events; | ||
843 | } | 845 | } |
844 | QBitArray OTodoAccessXML::supports()const { | 846 | QBitArray OTodoAccessXML::supports()const { |
845 | static QBitArray ar = sup(); | 847 | static QBitArray ar = sup(); |
846 | return ar; | 848 | return ar; |
847 | } | 849 | } |
848 | QBitArray OTodoAccessXML::sup() { | 850 | QBitArray OTodoAccessXML::sup() { |
849 | QBitArray ar( OTodo::CompletedDate +1 ); | 851 | QBitArray ar( OTodo::CompletedDate +1 ); |
850 | ar.fill( true ); | 852 | ar.fill( true ); |
851 | ar[OTodo::CrossReference] = false; | 853 | ar[OTodo::CrossReference] = false; |
852 | ar[OTodo::State ] = false; | 854 | ar[OTodo::State ] = false; |
853 | ar[OTodo::Reminders] = false; | 855 | ar[OTodo::Reminders] = false; |
854 | ar[OTodo::Notifiers] = false; | 856 | ar[OTodo::Notifiers] = false; |
855 | ar[OTodo::Maintainer] = false; | 857 | ar[OTodo::Maintainer] = false; |
856 | 858 | ||
857 | return ar; | 859 | return ar; |
858 | } | 860 | } |
859 | QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const | 861 | QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const |
860 | { | 862 | { |
861 | QArray<int> m_currentQuery( m_events.count() ); | 863 | QArray<int> m_currentQuery( m_events.count() ); |
862 | uint arraycounter = 0; | 864 | uint arraycounter = 0; |
863 | 865 | ||
864 | QMap<int, OTodo>::ConstIterator it; | 866 | QMap<int, OTodo>::ConstIterator it; |
865 | for (it = m_events.begin(); it != m_events.end(); ++it ) { | 867 | for (it = m_events.begin(); it != m_events.end(); ++it ) { |
866 | if ( it.data().match( r ) ) | 868 | if ( it.data().match( r ) ) |
867 | m_currentQuery[arraycounter++] = it.data().uid(); | 869 | m_currentQuery[arraycounter++] = it.data().uid(); |
868 | 870 | ||
869 | } | 871 | } |
870 | // Shrink to fit.. | 872 | // Shrink to fit.. |
871 | m_currentQuery.resize(arraycounter); | 873 | m_currentQuery.resize(arraycounter); |
872 | 874 | ||
873 | return m_currentQuery; | 875 | return m_currentQuery; |
874 | } | 876 | } |
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h index e90db32..9b0a719 100644 --- a/libopie2/opiepim/core/ocontactaccess.h +++ b/libopie2/opiepim/core/ocontactaccess.h | |||
@@ -1,170 +1,181 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage the Contacts. | 2 | * Class to manage the Contacts. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) | 5 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) |
6 | * | 6 | * |
7 | * ===================================================================== | 7 | * ===================================================================== |
8 | *This program is free software; you can redistribute it and/or | 8 | *This program is free software; you can redistribute it and/or |
9 | *modify it under the terms of the GNU Library General Public | 9 | *modify it under the terms of the GNU Library General Public |
10 | * License as published by the Free Software Foundation; | 10 | * License as published by the Free Software Foundation; |
11 | * either version 2 of the License, or (at your option) any later | 11 | * either version 2 of the License, or (at your option) any later |
12 | * version. | 12 | * version. |
13 | * ===================================================================== | 13 | * ===================================================================== |
14 | * ToDo: Define enum for query settings | 14 | * ToDo: Define enum for query settings |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * Version: $Id$ | 16 | * Version: $Id$ |
17 | * ===================================================================== | 17 | * ===================================================================== |
18 | * History: | 18 | * History: |
19 | * $Log$ | 19 | * $Log$ |
20 | * Revision 1.9 2003/08/01 12:30:16 eilers | ||
21 | * Merging changes from BRANCH_1_0 to HEAD | ||
22 | * | ||
23 | * Revision 1.8.2.1 2003/06/30 14:34:19 eilers | ||
24 | * Patches from Zecke: | ||
25 | * Fixing and cleaning up extraMap handling | ||
26 | * Adding d_ptr for binary compatibility in the future | ||
27 | * | ||
20 | * Revision 1.8 2003/05/08 13:55:09 tille | 28 | * Revision 1.8 2003/05/08 13:55:09 tille |
21 | * search stuff | 29 | * search stuff |
22 | * and match, toRichText & toShortText in oevent | 30 | * and match, toRichText & toShortText in oevent |
23 | * | 31 | * |
24 | * Revision 1.7 2003/04/13 18:07:10 zecke | 32 | * Revision 1.7 2003/04/13 18:07:10 zecke |
25 | * More API doc | 33 | * More API doc |
26 | * QString -> const QString& | 34 | * QString -> const QString& |
27 | * QString = 0l -> QString::null | 35 | * QString = 0l -> QString::null |
28 | * | 36 | * |
29 | * Revision 1.6 2003/01/02 14:27:12 eilers | 37 | * Revision 1.6 2003/01/02 14:27:12 eilers |
30 | * Improved query by example: Search by date is possible.. First step | 38 | * Improved query by example: Search by date is possible.. First step |
31 | * for a today plugin for birthdays.. | 39 | * for a today plugin for birthdays.. |
32 | * | 40 | * |
33 | * Revision 1.5 2002/11/13 14:14:51 eilers | 41 | * Revision 1.5 2002/11/13 14:14:51 eilers |
34 | * Added sorted for Contacts.. | 42 | * Added sorted for Contacts.. |
35 | * | 43 | * |
36 | * Revision 1.4 2002/11/01 15:10:42 eilers | 44 | * Revision 1.4 2002/11/01 15:10:42 eilers |
37 | * Added regExp-search in database for all fields in a contact. | 45 | * Added regExp-search in database for all fields in a contact. |
38 | * | 46 | * |
39 | * Revision 1.3 2002/10/16 10:52:40 eilers | 47 | * Revision 1.3 2002/10/16 10:52:40 eilers |
40 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | 48 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) |
41 | * | 49 | * |
42 | * Revision 1.2 2002/10/14 16:21:54 eilers | 50 | * Revision 1.2 2002/10/14 16:21:54 eilers |
43 | * Some minor interface updates | 51 | * Some minor interface updates |
44 | * | 52 | * |
45 | * Revision 1.1 2002/09/27 17:11:44 eilers | 53 | * Revision 1.1 2002/09/27 17:11:44 eilers |
46 | * Added API for accessing the Contact-Database ! It is compiling, but | 54 | * Added API for accessing the Contact-Database ! It is compiling, but |
47 | * please do not expect that anything is working ! | 55 | * please do not expect that anything is working ! |
48 | * I will debug that stuff in the next time .. | 56 | * I will debug that stuff in the next time .. |
49 | * Please read README_COMPILE for compiling ! | 57 | * Please read README_COMPILE for compiling ! |
50 | * | 58 | * |
51 | * ===================================================================== | 59 | * ===================================================================== |
52 | */ | 60 | */ |
53 | #ifndef _OCONTACTACCESS_H | 61 | #ifndef _OCONTACTACCESS_H |
54 | #define _OCONTACTACCESS_H | 62 | #define _OCONTACTACCESS_H |
55 | 63 | ||
56 | #include <qobject.h> | 64 | #include <qobject.h> |
57 | 65 | ||
58 | #include <qpe/qcopenvelope_qws.h> | 66 | #include <qpe/qcopenvelope_qws.h> |
59 | 67 | ||
60 | #include <qvaluelist.h> | 68 | #include <qvaluelist.h> |
61 | #include <qfileinfo.h> | 69 | #include <qfileinfo.h> |
62 | 70 | ||
63 | #include "ocontact.h" | 71 | #include "ocontact.h" |
64 | #include "ocontactaccessbackend.h" | 72 | #include "ocontactaccessbackend.h" |
65 | #include "opimaccesstemplate.h" | 73 | #include "opimaccesstemplate.h" |
66 | 74 | ||
67 | /** | 75 | /** |
68 | * Class to access the contacts database. | 76 | * Class to access the contacts database. |
69 | * This is just a frontend for the real database handling which is | 77 | * This is just a frontend for the real database handling which is |
70 | * done by the backend. | 78 | * done by the backend. |
71 | * This class is used to access the Contacts on a system. This class as any OPIE PIM | 79 | * This class is used to access the Contacts on a system. This class as any OPIE PIM |
72 | * class is backend independent. | 80 | * class is backend independent. |
73 | 81 | ||
74 | * @see OPimAccessTemplate | 82 | * @see OPimAccessTemplate |
75 | */ | 83 | */ |
76 | class OContactAccess: public QObject, public OPimAccessTemplate<OContact> | 84 | class OContactAccess: public QObject, public OPimAccessTemplate<OContact> |
77 | { | 85 | { |
78 | Q_OBJECT | 86 | Q_OBJECT |
79 | 87 | ||
80 | public: | 88 | public: |
81 | /** | 89 | /** |
82 | * Create Database with contacts (addressbook). | 90 | * Create Database with contacts (addressbook). |
83 | * @param appname Name of application which wants access to the database | 91 | * @param appname Name of application which wants access to the database |
84 | * (i.e. "todolist") | 92 | * (i.e. "todolist") |
85 | * @param filename The name of the database file. If not set, the default one | 93 | * @param filename The name of the database file. If not set, the default one |
86 | * is used. | 94 | * is used. |
87 | * @param backend Pointer to an alternative Backend. If not set, we will use | 95 | * @param backend Pointer to an alternative Backend. If not set, we will use |
88 | * the default backend. | 96 | * the default backend. |
89 | * @param handlesync If <b>true</b> the database stores the current state | 97 | * @param handlesync If <b>true</b> the database stores the current state |
90 | * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> | 98 | * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> |
91 | * which are used before and after synchronisation. If the application wants | 99 | * which are used before and after synchronisation. If the application wants |
92 | * to react itself, it should be disabled by setting it to <b>false</b> | 100 | * to react itself, it should be disabled by setting it to <b>false</b> |
93 | * @see OContactAccessBackend | 101 | * @see OContactAccessBackend |
94 | */ | 102 | */ |
95 | OContactAccess (const QString appname, const QString filename = 0l, | 103 | OContactAccess (const QString appname, const QString filename = 0l, |
96 | OContactAccessBackend* backend = 0l, bool handlesync = true); | 104 | OContactAccessBackend* backend = 0l, bool handlesync = true); |
97 | ~OContactAccess (); | 105 | ~OContactAccess (); |
98 | 106 | ||
99 | /** Constants for query. | 107 | /** Constants for query. |
100 | * Use this constants to set the query parameters. | 108 | * Use this constants to set the query parameters. |
101 | * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! | 109 | * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! |
102 | * @see queryByExample() | 110 | * @see queryByExample() |
103 | */ | 111 | */ |
104 | enum QuerySettings { | 112 | enum QuerySettings { |
105 | WildCards = 0x0001, | 113 | WildCards = 0x0001, |
106 | IgnoreCase = 0x0002, | 114 | IgnoreCase = 0x0002, |
107 | RegExp = 0x0004, | 115 | RegExp = 0x0004, |
108 | ExactMatch = 0x0008, | 116 | ExactMatch = 0x0008, |
109 | MatchOne = 0x0010, // Only one Entry must match | 117 | MatchOne = 0x0010, // Only one Entry must match |
110 | DateDiff = 0x0020, // Find all entries from today until given date | 118 | DateDiff = 0x0020, // Find all entries from today until given date |
111 | DateYear = 0x0040, // The year matches | 119 | DateYear = 0x0040, // The year matches |
112 | DateMonth = 0x0080, // The month matches | 120 | DateMonth = 0x0080, // The month matches |
113 | DateDay = 0x0100, // The day matches | 121 | DateDay = 0x0100, // The day matches |
114 | }; | 122 | }; |
115 | 123 | ||
116 | 124 | ||
117 | /** Return all Contacts in a sorted manner. | 125 | /** Return all Contacts in a sorted manner. |
118 | * @param ascending true: Sorted in acending order. | 126 | * @param ascending true: Sorted in acending order. |
119 | * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess | 127 | * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess |
120 | * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess | 128 | * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess |
121 | * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess | 129 | * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess |
122 | */ | 130 | */ |
123 | List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; | 131 | List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; |
124 | 132 | ||
125 | /** Return all possible settings. | 133 | /** Return all possible settings. |
126 | * @return All settings provided by the current backend | 134 | * @return All settings provided by the current backend |
127 | * (i.e.: query_WildCards & query_IgnoreCase) | 135 | * (i.e.: query_WildCards & query_IgnoreCase) |
128 | */ | 136 | */ |
129 | const uint querySettings(); | 137 | const uint querySettings(); |
130 | 138 | ||
131 | /** Check whether settings are correct. | 139 | /** Check whether settings are correct. |
132 | * @return <i>true</i> if the given settings are correct and possible. | 140 | * @return <i>true</i> if the given settings are correct and possible. |
133 | */ | 141 | */ |
134 | bool hasQuerySettings ( int querySettings ) const; | 142 | bool hasQuerySettings ( int querySettings ) const; |
135 | 143 | ||
136 | /** | 144 | /** |
137 | * if the resource was changed externally. | 145 | * if the resource was changed externally. |
138 | * You should use the signal instead of polling possible changes ! | 146 | * You should use the signal instead of polling possible changes ! |
139 | */ | 147 | */ |
140 | bool wasChangedExternally()const; | 148 | bool wasChangedExternally()const; |
141 | 149 | ||
142 | 150 | ||
143 | /** Save contacts database. | 151 | /** Save contacts database. |
144 | * Save is more a "commit". After calling this function, all changes are public available. | 152 | * Save is more a "commit". After calling this function, all changes are public available. |
145 | * @return true if successful | 153 | * @return true if successful |
146 | */ | 154 | */ |
147 | bool save(); | 155 | bool save(); |
148 | 156 | ||
149 | signals: | 157 | signals: |
150 | /* Signal is emitted if the database was changed. Therefore | 158 | /* Signal is emitted if the database was changed. Therefore |
151 | * we may need to reload to stay consistent. | 159 | * we may need to reload to stay consistent. |
152 | * @param which Pointer to the database who created this event. This pointer | 160 | * @param which Pointer to the database who created this event. This pointer |
153 | * is useful if an application has to handle multiple databases at the same time. | 161 | * is useful if an application has to handle multiple databases at the same time. |
154 | * @see reload() | 162 | * @see reload() |
155 | */ | 163 | */ |
156 | void signalChanged ( const OContactAccess *which ); | 164 | void signalChanged ( const OContactAccess *which ); |
157 | 165 | ||
158 | 166 | ||
159 | private: | 167 | private: |
160 | // class OContactAccessPrivate; | 168 | // class OContactAccessPrivate; |
161 | // OContactAccessPrivate* d; | 169 | // OContactAccessPrivate* d; |
162 | OContactAccessBackend *m_backEnd; | 170 | OContactAccessBackend *m_backEnd; |
163 | bool m_loading:1; | 171 | bool m_loading:1; |
164 | 172 | ||
165 | private slots: | 173 | private slots: |
166 | void copMessage( const QCString &msg, const QByteArray &data ); | 174 | void copMessage( const QCString &msg, const QByteArray &data ); |
167 | 175 | ||
176 | private: | ||
177 | class Private; | ||
178 | Private *d; | ||
168 | 179 | ||
169 | }; | 180 | }; |
170 | #endif | 181 | #endif |
diff --git a/libopie2/opiepim/core/oconversion.h b/libopie2/opiepim/core/oconversion.h index 13367e1..4c0a497 100644 --- a/libopie2/opiepim/core/oconversion.h +++ b/libopie2/opiepim/core/oconversion.h | |||
@@ -1,43 +1,48 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 13 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
14 | ** | 14 | ** |
15 | ** Contact info@trolltech.com if any conditions of this licensing are | 15 | ** Contact info@trolltech.com if any conditions of this licensing are |
16 | ** not clear to you. | 16 | ** not clear to you. |
17 | **********************************************************************/ | 17 | **********************************************************************/ |
18 | 18 | ||
19 | #ifndef __oconversion_h__ | 19 | #ifndef __oconversion_h__ |
20 | #define __oconversion_h__ | 20 | #define __oconversion_h__ |
21 | 21 | ||
22 | /* #include <time.h> */ | 22 | /* #include <time.h> */ |
23 | /* #include <sys/types.h> */ | 23 | /* #include <sys/types.h> */ |
24 | #include <qdatetime.h> | 24 | #include <qdatetime.h> |
25 | 25 | ||
26 | /* FIXME namespace? -zecke */ | 26 | /* FIXME namespace? -zecke */ |
27 | class OConversion | 27 | class OConversion |
28 | { | 28 | { |
29 | public: | 29 | public: |
30 | static QString dateToString( const QDate &d ); | 30 | static QString dateToString( const QDate &d ); |
31 | static QDate dateFromString( const QString &datestr ); | 31 | static QDate dateFromString( const QString &datestr ); |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * simple function to store DateTime as string and read from string | 34 | * simple function to store DateTime as string and read from string |
35 | * no timezone changing is done | 35 | * no timezone changing is done |
36 | * DDMMYYYYHHMMSS is the simple format | 36 | * DDMMYYYYHHMMSS is the simple format |
37 | */ | 37 | */ |
38 | static QString dateTimeToString( const QDateTime& ); | 38 | static QString dateTimeToString( const QDateTime& ); |
39 | static QDateTime dateTimeFromString( const QString& ); | 39 | static QDateTime dateTimeFromString( const QString& ); |
40 | |||
41 | private: | ||
42 | class Private; | ||
43 | Private* d; | ||
44 | |||
40 | }; | 45 | }; |
41 | 46 | ||
42 | #endif // __oconversion_h__ | 47 | #endif // __oconversion_h__ |
43 | 48 | ||
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index 8ff205c..ecbeb68 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h | |||
@@ -1,250 +1,254 @@ | |||
1 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H | 1 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H |
2 | #define OPIE_PIM_ACCESS_TEMPLATE_H | 2 | #define OPIE_PIM_ACCESS_TEMPLATE_H |
3 | 3 | ||
4 | #include <qarray.h> | 4 | #include <qarray.h> |
5 | 5 | ||
6 | #include <opie/opimrecord.h> | 6 | #include <opie/opimrecord.h> |
7 | #include <opie/opimaccessbackend.h> | 7 | #include <opie/opimaccessbackend.h> |
8 | #include <opie/orecordlist.h> | 8 | #include <opie/orecordlist.h> |
9 | 9 | ||
10 | #include "opimcache.h" | 10 | #include "opimcache.h" |
11 | #include "otemplatebase.h" | 11 | #include "otemplatebase.h" |
12 | 12 | ||
13 | class OPimAccessTemplatePrivate; | ||
13 | /** | 14 | /** |
14 | * Thats the frontend to our OPIE PIM | 15 | * Thats the frontend to our OPIE PIM |
15 | * Library. Either you want to use it's | 16 | * Library. Either you want to use it's |
16 | * interface or you want to implement | 17 | * interface or you want to implement |
17 | * your own Access lib | 18 | * your own Access lib |
18 | * Just create a OPimRecord and inherit from | 19 | * Just create a OPimRecord and inherit from |
19 | * the plugins | 20 | * the plugins |
20 | */ | 21 | */ |
21 | 22 | ||
22 | template <class T = OPimRecord > | 23 | template <class T = OPimRecord > |
23 | class OPimAccessTemplate : public OTemplateBase<T> { | 24 | class OPimAccessTemplate : public OTemplateBase<T> { |
24 | public: | 25 | public: |
25 | enum Access { | 26 | enum Access { |
26 | Random = 0, | 27 | Random = 0, |
27 | SortedAccess | 28 | SortedAccess |
28 | }; | 29 | }; |
29 | typedef ORecordList<T> List; | 30 | typedef ORecordList<T> List; |
30 | typedef OPimAccessBackend<T> BackEnd; | 31 | typedef OPimAccessBackend<T> BackEnd; |
31 | typedef OPimCache<T> Cache; | 32 | typedef OPimCache<T> Cache; |
32 | 33 | ||
33 | /** | 34 | /** |
34 | * c'tor BackEnd | 35 | * c'tor BackEnd |
35 | * enum Access a small hint on how to handle the backend | 36 | * enum Access a small hint on how to handle the backend |
36 | */ | 37 | */ |
37 | OPimAccessTemplate( BackEnd* end); | 38 | OPimAccessTemplate( BackEnd* end); |
38 | 39 | ||
39 | virtual ~OPimAccessTemplate(); | 40 | virtual ~OPimAccessTemplate(); |
40 | 41 | ||
41 | /** | 42 | /** |
42 | * load from the backend | 43 | * load from the backend |
43 | */ | 44 | */ |
44 | bool load(); | 45 | bool load(); |
45 | 46 | ||
46 | /** Reload database. | 47 | /** Reload database. |
47 | * You should execute this function if the external database | 48 | * You should execute this function if the external database |
48 | * was changed. | 49 | * was changed. |
49 | * This function will load the external database and afterwards | 50 | * This function will load the external database and afterwards |
50 | * rejoin the local changes. Therefore the local database will be set consistent. | 51 | * rejoin the local changes. Therefore the local database will be set consistent. |
51 | */ | 52 | */ |
52 | virtual bool reload(); | 53 | virtual bool reload(); |
53 | 54 | ||
54 | /** Save contacts database. | 55 | /** Save contacts database. |
55 | * Save is more a "commit". After calling this function, all changes are public available. | 56 | * Save is more a "commit". After calling this function, all changes are public available. |
56 | * @return true if successful | 57 | * @return true if successful |
57 | */ | 58 | */ |
58 | bool save(); | 59 | bool save(); |
59 | 60 | ||
60 | /** | 61 | /** |
61 | * if the resource was changed externally | 62 | * if the resource was changed externally |
62 | * You should use the signal handling instead of polling possible changes ! | 63 | * You should use the signal handling instead of polling possible changes ! |
63 | * zecke: Do you implement a signal for otodoaccess ? | 64 | * zecke: Do you implement a signal for otodoaccess ? |
64 | */ | 65 | */ |
65 | bool wasChangedExternally()const; | 66 | bool wasChangedExternally()const; |
66 | 67 | ||
67 | /** | 68 | /** |
68 | * return a List of records | 69 | * return a List of records |
69 | * you can iterate over them | 70 | * you can iterate over them |
70 | */ | 71 | */ |
71 | virtual List allRecords()const; | 72 | virtual List allRecords()const; |
72 | 73 | ||
73 | /** | 74 | /** |
74 | * return a List of records | 75 | * return a List of records |
75 | * that match the regex | 76 | * that match the regex |
76 | */ | 77 | */ |
77 | virtual List matchRegexp( const QRegExp &r ) const; | 78 | virtual List matchRegexp( const QRegExp &r ) const; |
78 | 79 | ||
79 | /** | 80 | /** |
80 | * queryByExample. | 81 | * queryByExample. |
81 | * @see otodoaccess, ocontactaccess | 82 | * @see otodoaccess, ocontactaccess |
82 | */ | 83 | */ |
83 | virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); | 84 | virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); |
84 | 85 | ||
85 | /** | 86 | /** |
86 | * find the OPimRecord uid | 87 | * find the OPimRecord uid |
87 | */ | 88 | */ |
88 | virtual T find( int uid )const; | 89 | virtual T find( int uid )const; |
89 | 90 | ||
90 | /** | 91 | /** |
91 | * read ahead cache find method ;) | 92 | * read ahead cache find method ;) |
92 | */ | 93 | */ |
93 | virtual T find( int uid, const QArray<int>&, | 94 | virtual T find( int uid, const QArray<int>&, |
94 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; | 95 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; |
95 | 96 | ||
96 | /* invalidate cache here */ | 97 | /* invalidate cache here */ |
97 | /** | 98 | /** |
98 | * clears the backend and invalidates the backend | 99 | * clears the backend and invalidates the backend |
99 | */ | 100 | */ |
100 | void clear() ; | 101 | void clear() ; |
101 | 102 | ||
102 | /** | 103 | /** |
103 | * add T to the backend | 104 | * add T to the backend |
104 | * @param t The item to add. | 105 | * @param t The item to add. |
105 | * @return <i>true</i> if added successfully. | 106 | * @return <i>true</i> if added successfully. |
106 | */ | 107 | */ |
107 | virtual bool add( const T& t ) ; | 108 | virtual bool add( const T& t ) ; |
108 | bool add( const OPimRecord& ); | 109 | bool add( const OPimRecord& ); |
109 | 110 | ||
110 | /* only the uid matters */ | 111 | /* only the uid matters */ |
111 | /** | 112 | /** |
112 | * remove T from the backend | 113 | * remove T from the backend |
113 | * @param t The item to remove | 114 | * @param t The item to remove |
114 | * @return <i>true</i> if successful. | 115 | * @return <i>true</i> if successful. |
115 | */ | 116 | */ |
116 | virtual bool remove( const T& t ); | 117 | virtual bool remove( const T& t ); |
117 | 118 | ||
118 | /** | 119 | /** |
119 | * remove the OPimRecord with uid | 120 | * remove the OPimRecord with uid |
120 | * @param uid The ID of the item to remove | 121 | * @param uid The ID of the item to remove |
121 | * @return <i>true</i> if successful. | 122 | * @return <i>true</i> if successful. |
122 | */ | 123 | */ |
123 | bool remove( int uid ); | 124 | bool remove( int uid ); |
124 | bool remove( const OPimRecord& ); | 125 | bool remove( const OPimRecord& ); |
125 | 126 | ||
126 | /** | 127 | /** |
127 | * replace T from backend | 128 | * replace T from backend |
128 | * @param t The item to replace | 129 | * @param t The item to replace |
129 | * @return <i>true</i> if successful. | 130 | * @return <i>true</i> if successful. |
130 | */ | 131 | */ |
131 | virtual bool replace( const T& t) ; | 132 | virtual bool replace( const T& t) ; |
132 | 133 | ||
133 | void setReadAhead( uint count ); | 134 | void setReadAhead( uint count ); |
134 | /** | 135 | /** |
135 | * @internal | 136 | * @internal |
136 | */ | 137 | */ |
137 | void cache( const T& )const; | 138 | void cache( const T& )const; |
138 | void setSaneCacheSize( int ); | 139 | void setSaneCacheSize( int ); |
139 | 140 | ||
140 | QArray<int> records()const; | 141 | QArray<int> records()const; |
141 | protected: | 142 | protected: |
142 | /** | 143 | /** |
143 | * invalidate the cache | 144 | * invalidate the cache |
144 | */ | 145 | */ |
145 | void invalidateCache(); | 146 | void invalidateCache(); |
146 | 147 | ||
147 | void setBackEnd( BackEnd* end ); | 148 | void setBackEnd( BackEnd* end ); |
148 | /** | 149 | /** |
149 | * returns the backend | 150 | * returns the backend |
150 | */ | 151 | */ |
151 | BackEnd* backEnd(); | 152 | BackEnd* backEnd(); |
152 | BackEnd* m_backEnd; | 153 | BackEnd* m_backEnd; |
153 | Cache m_cache; | 154 | Cache m_cache; |
154 | 155 | ||
156 | private: | ||
157 | OPimAccessTemplatePrivate *d; | ||
158 | |||
155 | }; | 159 | }; |
156 | 160 | ||
157 | template <class T> | 161 | template <class T> |
158 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) | 162 | OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) |
159 | : OTemplateBase<T>(), m_backEnd( end ) | 163 | : OTemplateBase<T>(), m_backEnd( end ) |
160 | { | 164 | { |
161 | if (end ) | 165 | if (end ) |
162 | end->setFrontend( this ); | 166 | end->setFrontend( this ); |
163 | } | 167 | } |
164 | template <class T> | 168 | template <class T> |
165 | OPimAccessTemplate<T>::~OPimAccessTemplate() { | 169 | OPimAccessTemplate<T>::~OPimAccessTemplate() { |
166 | qWarning("~OPimAccessTemplate<T>"); | 170 | qWarning("~OPimAccessTemplate<T>"); |
167 | delete m_backEnd; | 171 | delete m_backEnd; |
168 | } | 172 | } |
169 | template <class T> | 173 | template <class T> |
170 | bool OPimAccessTemplate<T>::load() { | 174 | bool OPimAccessTemplate<T>::load() { |
171 | invalidateCache(); | 175 | invalidateCache(); |
172 | return m_backEnd->load(); | 176 | return m_backEnd->load(); |
173 | } | 177 | } |
174 | template <class T> | 178 | template <class T> |
175 | bool OPimAccessTemplate<T>::reload() { | 179 | bool OPimAccessTemplate<T>::reload() { |
176 | invalidateCache(); // zecke: I think this should be added (se) | 180 | invalidateCache(); // zecke: I think this should be added (se) |
177 | return m_backEnd->reload(); | 181 | return m_backEnd->reload(); |
178 | } | 182 | } |
179 | template <class T> | 183 | template <class T> |
180 | bool OPimAccessTemplate<T>::save() { | 184 | bool OPimAccessTemplate<T>::save() { |
181 | return m_backEnd->save(); | 185 | return m_backEnd->save(); |
182 | } | 186 | } |
183 | template <class T> | 187 | template <class T> |
184 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { | 188 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { |
185 | QArray<int> ints = m_backEnd->allRecords(); | 189 | QArray<int> ints = m_backEnd->allRecords(); |
186 | List lis(ints, this ); | 190 | List lis(ints, this ); |
187 | return lis; | 191 | return lis; |
188 | } | 192 | } |
189 | template <class T> | 193 | template <class T> |
190 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const { | 194 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const { |
191 | QArray<int> ints = m_backEnd->matchRegexp( r ); | 195 | QArray<int> ints = m_backEnd->matchRegexp( r ); |
192 | List lis(ints, this ); | 196 | List lis(ints, this ); |
193 | return lis; | 197 | return lis; |
194 | } | 198 | } |
195 | template <class T> | 199 | template <class T> |
196 | QArray<int> OPimAccessTemplate<T>::records()const { | 200 | QArray<int> OPimAccessTemplate<T>::records()const { |
197 | return m_backEnd->allRecords(); | 201 | return m_backEnd->allRecords(); |
198 | } | 202 | } |
199 | template <class T> | 203 | template <class T> |
200 | typename OPimAccessTemplate<T>::List | 204 | typename OPimAccessTemplate<T>::List |
201 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { | 205 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { |
202 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); | 206 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); |
203 | 207 | ||
204 | List lis(ints, this ); | 208 | List lis(ints, this ); |
205 | return lis; | 209 | return lis; |
206 | } | 210 | } |
207 | template <class T> | 211 | template <class T> |
208 | T OPimAccessTemplate<T>::find( int uid ) const{ | 212 | T OPimAccessTemplate<T>::find( int uid ) const{ |
209 | T t = m_backEnd->find( uid ); | 213 | T t = m_backEnd->find( uid ); |
210 | cache( t ); | 214 | cache( t ); |
211 | return t; | 215 | return t; |
212 | } | 216 | } |
213 | template <class T> | 217 | template <class T> |
214 | T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, | 218 | T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, |
215 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { | 219 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { |
216 | /* | 220 | /* |
217 | * better do T.isEmpty() | 221 | * better do T.isEmpty() |
218 | * after a find this way we would | 222 | * after a find this way we would |
219 | * avoid two finds in QCache... | 223 | * avoid two finds in QCache... |
220 | */ | 224 | */ |
221 | // qWarning("find it now %d", uid ); | 225 | // qWarning("find it now %d", uid ); |
222 | if (m_cache.contains( uid ) ) { | 226 | if (m_cache.contains( uid ) ) { |
223 | return m_cache.find( uid ); | 227 | return m_cache.find( uid ); |
224 | } | 228 | } |
225 | 229 | ||
226 | T t = m_backEnd->find( uid, ar, current, dir ); | 230 | T t = m_backEnd->find( uid, ar, current, dir ); |
227 | cache( t ); | 231 | cache( t ); |
228 | return t; | 232 | return t; |
229 | } | 233 | } |
230 | template <class T> | 234 | template <class T> |
231 | void OPimAccessTemplate<T>::clear() { | 235 | void OPimAccessTemplate<T>::clear() { |
232 | invalidateCache(); | 236 | invalidateCache(); |
233 | m_backEnd->clear(); | 237 | m_backEnd->clear(); |
234 | } | 238 | } |
235 | template <class T> | 239 | template <class T> |
236 | bool OPimAccessTemplate<T>::add( const T& t ) { | 240 | bool OPimAccessTemplate<T>::add( const T& t ) { |
237 | cache( t ); | 241 | cache( t ); |
238 | return m_backEnd->add( t ); | 242 | return m_backEnd->add( t ); |
239 | } | 243 | } |
240 | template <class T> | 244 | template <class T> |
241 | bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { | 245 | bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { |
242 | /* same type */ | 246 | /* same type */ |
243 | if ( rec.rtti() == T::rtti() ) { | 247 | if ( rec.rtti() == T::rtti() ) { |
244 | const T &t = static_cast<const T&>(rec); | 248 | const T &t = static_cast<const T&>(rec); |
245 | return add(t); | 249 | return add(t); |
246 | } | 250 | } |
247 | return false; | 251 | return false; |
248 | } | 252 | } |
249 | template <class T> | 253 | template <class T> |
250 | bool OPimAccessTemplate<T>::remove( const T& t ) { | 254 | bool OPimAccessTemplate<T>::remove( const T& t ) { |
diff --git a/libopie2/opiepim/core/opimcache.h b/libopie2/opiepim/core/opimcache.h index 73414e5..7f7cff5 100644 --- a/libopie2/opiepim/core/opimcache.h +++ b/libopie2/opiepim/core/opimcache.h | |||
@@ -1,125 +1,131 @@ | |||
1 | #ifndef OPIE_PIM_CACHE_H | 1 | #ifndef OPIE_PIM_CACHE_H |
2 | #define OPIE_PIM_CACHE_H | 2 | #define OPIE_PIM_CACHE_H |
3 | 3 | ||
4 | #include <qintcache.h> | 4 | #include <qintcache.h> |
5 | 5 | ||
6 | #include "opimrecord.h" | 6 | #include "opimrecord.h" |
7 | 7 | ||
8 | class OPimCacheItemPrivate; | ||
9 | |||
8 | template <class T = OPimRecord> | 10 | template <class T = OPimRecord> |
9 | class OPimCacheItem { | 11 | class OPimCacheItem { |
10 | public: | 12 | public: |
11 | OPimCacheItem( const T& t = T() ); | 13 | OPimCacheItem( const T& t = T() ); |
12 | OPimCacheItem( const OPimCacheItem& ); | 14 | OPimCacheItem( const OPimCacheItem& ); |
13 | ~OPimCacheItem(); | 15 | ~OPimCacheItem(); |
14 | 16 | ||
15 | OPimCacheItem &operator=( const OPimCacheItem& ); | 17 | OPimCacheItem &operator=( const OPimCacheItem& ); |
16 | 18 | ||
17 | T record()const; | 19 | T record()const; |
18 | void setRecord( const T& ); | 20 | void setRecord( const T& ); |
19 | private: | 21 | private: |
20 | T m_t; | 22 | T m_t; |
23 | OPimCacheItemPrivate *d; | ||
21 | }; | 24 | }; |
22 | 25 | ||
26 | |||
27 | class OPimCachePrivate; | ||
23 | /** | 28 | /** |
24 | * OPimCache for caching the items | 29 | * OPimCache for caching the items |
25 | * We support adding, removing | 30 | * We support adding, removing |
26 | * and finding | 31 | * and finding |
27 | */ | 32 | */ |
28 | template <class T = OPimRecord> | 33 | template <class T = OPimRecord> |
29 | class OPimCache { | 34 | class OPimCache { |
30 | public: | 35 | public: |
31 | typedef OPimCacheItem<T> Item; | 36 | typedef OPimCacheItem<T> Item; |
32 | OPimCache(); | 37 | OPimCache(); |
33 | OPimCache( const OPimCache& ); | 38 | OPimCache( const OPimCache& ); |
34 | ~OPimCache(); | 39 | ~OPimCache(); |
35 | 40 | ||
36 | OPimCache &operator=( const OPimCache& ); | 41 | OPimCache &operator=( const OPimCache& ); |
37 | 42 | ||
38 | bool contains(int uid)const; | 43 | bool contains(int uid)const; |
39 | void invalidate(); | 44 | void invalidate(); |
40 | void setSize( int size ); | 45 | void setSize( int size ); |
41 | 46 | ||
42 | T find(int uid )const; | 47 | T find(int uid )const; |
43 | void add( const T& ); | 48 | void add( const T& ); |
44 | void remove( int uid ); | 49 | void remove( int uid ); |
45 | void replace( const T& ); | 50 | void replace( const T& ); |
46 | 51 | ||
47 | private: | 52 | private: |
48 | QIntCache<Item> m_cache; | 53 | QIntCache<Item> m_cache; |
54 | OPimCachePrivate* d; | ||
49 | }; | 55 | }; |
50 | 56 | ||
51 | // Implementation | 57 | // Implementation |
52 | template <class T> | 58 | template <class T> |
53 | OPimCacheItem<T>::OPimCacheItem( const T& t ) | 59 | OPimCacheItem<T>::OPimCacheItem( const T& t ) |
54 | : m_t(t) { | 60 | : m_t(t) { |
55 | } | 61 | } |
56 | template <class T> | 62 | template <class T> |
57 | OPimCacheItem<T>::~OPimCacheItem() { | 63 | OPimCacheItem<T>::~OPimCacheItem() { |
58 | 64 | ||
59 | } | 65 | } |
60 | template <class T> | 66 | template <class T> |
61 | T OPimCacheItem<T>::record()const { | 67 | T OPimCacheItem<T>::record()const { |
62 | return m_t; | 68 | return m_t; |
63 | } | 69 | } |
64 | template <class T> | 70 | template <class T> |
65 | void OPimCacheItem<T>::setRecord( const T& t ) { | 71 | void OPimCacheItem<T>::setRecord( const T& t ) { |
66 | m_t = t; | 72 | m_t = t; |
67 | } | 73 | } |
68 | // Cache | 74 | // Cache |
69 | template <class T> | 75 | template <class T> |
70 | OPimCache<T>::OPimCache() | 76 | OPimCache<T>::OPimCache() |
71 | : m_cache(100, 53 ) | 77 | : m_cache(100, 53 ) |
72 | { | 78 | { |
73 | m_cache.setAutoDelete( TRUE ); | 79 | m_cache.setAutoDelete( TRUE ); |
74 | } | 80 | } |
75 | template <class T> | 81 | template <class T> |
76 | OPimCache<T>::~OPimCache() { | 82 | OPimCache<T>::~OPimCache() { |
77 | 83 | ||
78 | } | 84 | } |
79 | template <class T> | 85 | template <class T> |
80 | bool OPimCache<T>::contains(int uid )const { | 86 | bool OPimCache<T>::contains(int uid )const { |
81 | Item* it = m_cache.find( uid, FALSE ); | 87 | Item* it = m_cache.find( uid, FALSE ); |
82 | if (!it) | 88 | if (!it) |
83 | return false; | 89 | return false; |
84 | return true; | 90 | return true; |
85 | } | 91 | } |
86 | template <class T> | 92 | template <class T> |
87 | void OPimCache<T>::invalidate() { | 93 | void OPimCache<T>::invalidate() { |
88 | m_cache.clear(); | 94 | m_cache.clear(); |
89 | } | 95 | } |
90 | template <class T> | 96 | template <class T> |
91 | void OPimCache<T>::setSize( int size ) { | 97 | void OPimCache<T>::setSize( int size ) { |
92 | m_cache.setMaxCost( size ); | 98 | m_cache.setMaxCost( size ); |
93 | } | 99 | } |
94 | template <class T> | 100 | template <class T> |
95 | T OPimCache<T>::find(int uid )const { | 101 | T OPimCache<T>::find(int uid )const { |
96 | Item *it = m_cache.find( uid ); | 102 | Item *it = m_cache.find( uid ); |
97 | if (it) | 103 | if (it) |
98 | return it->record(); | 104 | return it->record(); |
99 | return T(); | 105 | return T(); |
100 | } | 106 | } |
101 | template <class T> | 107 | template <class T> |
102 | void OPimCache<T>::add( const T& t ) { | 108 | void OPimCache<T>::add( const T& t ) { |
103 | Item* it = 0l; | 109 | Item* it = 0l; |
104 | it = m_cache.find(t.uid(), FALSE ); | 110 | it = m_cache.find(t.uid(), FALSE ); |
105 | 111 | ||
106 | if (it ) | 112 | if (it ) |
107 | it->setRecord( t ); | 113 | it->setRecord( t ); |
108 | 114 | ||
109 | it = new Item( t ); | 115 | it = new Item( t ); |
110 | if (!m_cache.insert( t.uid(), it ) ) | 116 | if (!m_cache.insert( t.uid(), it ) ) |
111 | delete it; | 117 | delete it; |
112 | } | 118 | } |
113 | template <class T> | 119 | template <class T> |
114 | void OPimCache<T>::remove( int uid ) { | 120 | void OPimCache<T>::remove( int uid ) { |
115 | m_cache.remove( uid ); | 121 | m_cache.remove( uid ); |
116 | } | 122 | } |
117 | template <class T> | 123 | template <class T> |
118 | void OPimCache<T>::replace( const T& t) { | 124 | void OPimCache<T>::replace( const T& t) { |
119 | Item *it = m_cache.find( t.uid() ); | 125 | Item *it = m_cache.find( t.uid() ); |
120 | if ( it ) { | 126 | if ( it ) { |
121 | it->setRecord( t ); | 127 | it->setRecord( t ); |
122 | } | 128 | } |
123 | } | 129 | } |
124 | 130 | ||
125 | #endif | 131 | #endif |
diff --git a/libopie2/opiepim/core/opimxrefmanager.h b/libopie2/opiepim/core/opimxrefmanager.h index 39e5eef..c485e98 100644 --- a/libopie2/opiepim/core/opimxrefmanager.h +++ b/libopie2/opiepim/core/opimxrefmanager.h | |||
@@ -1,41 +1,43 @@ | |||
1 | #ifndef OPIM_XREF_MANAGER_H | 1 | #ifndef OPIM_XREF_MANAGER_H |
2 | #define OPIM_XREF_MANAGER_H | 2 | #define OPIM_XREF_MANAGER_H |
3 | 3 | ||
4 | #include <qstringlist.h> | 4 | #include <qstringlist.h> |
5 | 5 | ||
6 | #include <opie/opimxref.h> | 6 | #include <opie/opimxref.h> |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * This is a simple manager for | 9 | * This is a simple manager for |
10 | * OPimXRefs. | 10 | * OPimXRefs. |
11 | * It allows addition, removing, replacing | 11 | * It allows addition, removing, replacing |
12 | * clearing and 'querying' the XRef... | 12 | * clearing and 'querying' the XRef... |
13 | */ | 13 | */ |
14 | class OPimXRefManager { | 14 | class OPimXRefManager { |
15 | public: | 15 | public: |
16 | OPimXRefManager(); | 16 | OPimXRefManager(); |
17 | OPimXRefManager( const OPimXRefManager& ); | 17 | OPimXRefManager( const OPimXRefManager& ); |
18 | ~OPimXRefManager(); | 18 | ~OPimXRefManager(); |
19 | 19 | ||
20 | OPimXRefManager& operator=( const OPimXRefManager& ); | 20 | OPimXRefManager& operator=( const OPimXRefManager& ); |
21 | bool operator==( const OPimXRefManager& ); | 21 | bool operator==( const OPimXRefManager& ); |
22 | 22 | ||
23 | void add( const OPimXRef& ); | 23 | void add( const OPimXRef& ); |
24 | void remove( const OPimXRef& ); | 24 | void remove( const OPimXRef& ); |
25 | void replace( const OPimXRef& ); | 25 | void replace( const OPimXRef& ); |
26 | 26 | ||
27 | void clear(); | 27 | void clear(); |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * apps participating | 30 | * apps participating |
31 | */ | 31 | */ |
32 | QStringList apps()const; | 32 | QStringList apps()const; |
33 | OPimXRef::ValueList list()const; | 33 | OPimXRef::ValueList list()const; |
34 | OPimXRef::ValueList list( const QString& service )const; | 34 | OPimXRef::ValueList list( const QString& service )const; |
35 | OPimXRef::ValueList list( int uid )const; | 35 | OPimXRef::ValueList list( int uid )const; |
36 | 36 | ||
37 | private: | 37 | private: |
38 | OPimXRef::ValueList m_list; | 38 | OPimXRef::ValueList m_list; |
39 | class Private; | ||
40 | Private *d; | ||
39 | }; | 41 | }; |
40 | 42 | ||
41 | #endif | 43 | #endif |
diff --git a/libopie2/opiepim/core/otemplatebase.h b/libopie2/opiepim/core/otemplatebase.h index 29fb6ec..cadac74 100644 --- a/libopie2/opiepim/core/otemplatebase.h +++ b/libopie2/opiepim/core/otemplatebase.h | |||
@@ -1,91 +1,98 @@ | |||
1 | #ifndef OPIE_TEMPLATE_BASE_H | 1 | #ifndef OPIE_TEMPLATE_BASE_H |
2 | #define OPIE_TEMPLATE_BASE_H | 2 | #define OPIE_TEMPLATE_BASE_H |
3 | 3 | ||
4 | #include <qarray.h> | 4 | #include <qarray.h> |
5 | 5 | ||
6 | #include <opie/opimrecord.h> | 6 | #include <opie/opimrecord.h> |
7 | 7 | ||
8 | 8 | ||
9 | /** | 9 | /** |
10 | * Templates do not have a base class, This is why | 10 | * Templates do not have a base class, This is why |
11 | * we've this class | 11 | * we've this class |
12 | * this is here to give us the possibility | 12 | * this is here to give us the possibility |
13 | * to have a common base class | 13 | * to have a common base class |
14 | * You may not want to use that interface internaly | 14 | * You may not want to use that interface internaly |
15 | * POOR mans interface | 15 | * POOR mans interface |
16 | */ | 16 | */ |
17 | class OPimBasePrivate; | ||
17 | struct OPimBase { | 18 | struct OPimBase { |
18 | /** | 19 | /** |
19 | * return the rtti | 20 | * return the rtti |
20 | */ | 21 | */ |
21 | virtual int rtti()= 0; | 22 | virtual int rtti()= 0; |
22 | virtual OPimRecord* record()const = 0; | 23 | virtual OPimRecord* record()const = 0; |
23 | virtual OPimRecord* record(int uid)const = 0; | 24 | virtual OPimRecord* record(int uid)const = 0; |
24 | virtual bool add( const OPimRecord& ) = 0; | 25 | virtual bool add( const OPimRecord& ) = 0; |
25 | virtual bool remove( int uid ) = 0; | 26 | virtual bool remove( int uid ) = 0; |
26 | virtual bool remove( const OPimRecord& ) = 0; | 27 | virtual bool remove( const OPimRecord& ) = 0; |
27 | virtual void clear() = 0; | 28 | virtual void clear() = 0; |
28 | virtual bool load() = 0; | 29 | virtual bool load() = 0; |
29 | virtual bool save() = 0; | 30 | virtual bool save() = 0; |
30 | virtual QArray<int> records()const = 0; | 31 | virtual QArray<int> records()const = 0; |
31 | /* | 32 | /* |
32 | * ADD editing here? | 33 | * ADD editing here? |
33 | * -zecke | 34 | * -zecke |
34 | */ | 35 | */ |
36 | private: | ||
37 | OPimBasePrivate* d; | ||
35 | 38 | ||
36 | }; | 39 | }; |
37 | /** | 40 | /** |
38 | * internal template base | 41 | * internal template base |
39 | * T needs to implement the copy c'tor!!! | 42 | * T needs to implement the copy c'tor!!! |
40 | */ | 43 | */ |
44 | class OTemplateBasePrivate; | ||
41 | template <class T = OPimRecord> | 45 | template <class T = OPimRecord> |
42 | class OTemplateBase : public OPimBase { | 46 | class OTemplateBase : public OPimBase { |
43 | public: | 47 | public: |
44 | enum CacheDirection { Forward=0, Reverse }; | 48 | enum CacheDirection { Forward=0, Reverse }; |
45 | OTemplateBase() { | 49 | OTemplateBase() { |
46 | }; | 50 | }; |
47 | virtual ~OTemplateBase() { | 51 | virtual ~OTemplateBase() { |
48 | } | 52 | } |
49 | virtual T find( int uid )const = 0; | 53 | virtual T find( int uid )const = 0; |
50 | 54 | ||
51 | /** | 55 | /** |
52 | * read ahead find | 56 | * read ahead find |
53 | */ | 57 | */ |
54 | virtual T find( int uid, const QArray<int>& items, | 58 | virtual T find( int uid, const QArray<int>& items, |
55 | uint current, CacheDirection dir = Forward )const = 0; | 59 | uint current, CacheDirection dir = Forward )const = 0; |
56 | virtual void cache( const T& )const = 0; | 60 | virtual void cache( const T& )const = 0; |
57 | virtual void setSaneCacheSize( int ) = 0; | 61 | virtual void setSaneCacheSize( int ) = 0; |
58 | 62 | ||
59 | /* reimplement of OPimBase */ | 63 | /* reimplement of OPimBase */ |
60 | int rtti(); | 64 | int rtti(); |
61 | OPimRecord* record()const; | 65 | OPimRecord* record()const; |
62 | OPimRecord* record(int uid )const; | 66 | OPimRecord* record(int uid )const; |
63 | static T* rec(); | 67 | static T* rec(); |
68 | |||
69 | private: | ||
70 | OTemplateBasePrivate *d; | ||
64 | }; | 71 | }; |
65 | 72 | ||
66 | /* | 73 | /* |
67 | * implementation | 74 | * implementation |
68 | */ | 75 | */ |
69 | template <class T> | 76 | template <class T> |
70 | int | 77 | int |
71 | OTemplateBase<T>::rtti() { | 78 | OTemplateBase<T>::rtti() { |
72 | return T::rtti(); | 79 | return T::rtti(); |
73 | } | 80 | } |
74 | template <class T> | 81 | template <class T> |
75 | OPimRecord* OTemplateBase<T>::record()const { | 82 | OPimRecord* OTemplateBase<T>::record()const { |
76 | T* t = new T; | 83 | T* t = new T; |
77 | return t; | 84 | return t; |
78 | } | 85 | } |
79 | template <class T> | 86 | template <class T> |
80 | OPimRecord* OTemplateBase<T>::record(int uid )const { | 87 | OPimRecord* OTemplateBase<T>::record(int uid )const { |
81 | T t2 = find(uid ); | 88 | T t2 = find(uid ); |
82 | T* t1 = new T(t2); | 89 | T* t1 = new T(t2); |
83 | 90 | ||
84 | return t1; | 91 | return t1; |
85 | }; | 92 | }; |
86 | template <class T> | 93 | template <class T> |
87 | T* OTemplateBase<T>::rec() { | 94 | T* OTemplateBase<T>::rec() { |
88 | return new T; | 95 | return new T; |
89 | } | 96 | } |
90 | 97 | ||
91 | #endif | 98 | #endif |
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index be4ce0a..3473baa 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp | |||
@@ -1,123 +1,124 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 13 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
14 | ** | 14 | ** |
15 | ** Contact info@trolltech.com if any conditions of this licensing are | 15 | ** Contact info@trolltech.com if any conditions of this licensing are |
16 | ** not clear to you. | 16 | ** not clear to you. |
17 | ** | 17 | ** |
18 | **********************************************************************/ | 18 | **********************************************************************/ |
19 | 19 | ||
20 | #define QTOPIA_INTERNAL_CONTACT_MRE | 20 | #define QTOPIA_INTERNAL_CONTACT_MRE |
21 | 21 | ||
22 | #include "ocontact.h" | 22 | #include "ocontact.h" |
23 | #include "opimresolver.h" | 23 | #include "opimresolver.h" |
24 | #include "oconversion.h" | ||
24 | 25 | ||
25 | #include <qpe/stringutil.h> | 26 | #include <qpe/stringutil.h> |
26 | #include "oconversion.h" | ||
27 | #include <qpe/timestring.h> | 27 | #include <qpe/timestring.h> |
28 | #include <qpe/config.h> | ||
28 | 29 | ||
29 | #include <qobject.h> | 30 | #include <qobject.h> |
30 | #include <qregexp.h> | 31 | #include <qregexp.h> |
31 | #include <qstylesheet.h> | 32 | #include <qstylesheet.h> |
32 | #include <qfileinfo.h> | 33 | #include <qfileinfo.h> |
33 | #include <qmap.h> | 34 | #include <qmap.h> |
34 | 35 | ||
35 | #include <stdio.h> | 36 | #include <stdio.h> |
36 | 37 | ||
37 | /*! | 38 | /*! |
38 | \class Contact contact.h | 39 | \class Contact contact.h |
39 | \brief The Contact class holds the data of an address book entry. | 40 | \brief The Contact class holds the data of an address book entry. |
40 | 41 | ||
41 | This data includes information the name of the person, contact | 42 | This data includes information the name of the person, contact |
42 | information, and business information such as deparment and job title. | 43 | information, and business information such as deparment and job title. |
43 | 44 | ||
44 | \ingroup qtopiaemb | 45 | \ingroup qtopiaemb |
45 | \ingroup qtopiadesktop | 46 | \ingroup qtopiadesktop |
46 | */ | 47 | */ |
47 | 48 | ||
48 | 49 | ||
49 | /*! | 50 | /*! |
50 | Creates a new, empty contact. | 51 | Creates a new, empty contact. |
51 | */ | 52 | */ |
52 | OContact::OContact() | 53 | OContact::OContact() |
53 | : OPimRecord(), mMap(), d( 0 ) | 54 | : OPimRecord(), mMap(), d( 0 ) |
54 | { | 55 | { |
55 | } | 56 | } |
56 | 57 | ||
57 | /*! | 58 | /*! |
58 | \internal | 59 | \internal |
59 | Creates a new contact. The properties of the contact are | 60 | Creates a new contact. The properties of the contact are |
60 | set from \a fromMap. | 61 | set from \a fromMap. |
61 | */ | 62 | */ |
62 | OContact::OContact( const QMap<int, QString> &fromMap ) : | 63 | OContact::OContact( const QMap<int, QString> &fromMap ) : |
63 | OPimRecord(), mMap( fromMap ), d( 0 ) | 64 | OPimRecord(), mMap( fromMap ), d( 0 ) |
64 | { | 65 | { |
65 | QString cats = mMap[ Qtopia::AddressCategory ]; | 66 | QString cats = mMap[ Qtopia::AddressCategory ]; |
66 | if ( !cats.isEmpty() ) | 67 | if ( !cats.isEmpty() ) |
67 | setCategories( idsFromString( cats ) ); | 68 | setCategories( idsFromString( cats ) ); |
68 | 69 | ||
69 | QString uidStr = find( Qtopia::AddressUid ); | 70 | QString uidStr = find( Qtopia::AddressUid ); |
70 | 71 | ||
71 | if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ | 72 | if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ |
72 | qWarning( "Invalid UID found. Generate new one.." ); | 73 | qWarning( "Invalid UID found. Generate new one.." ); |
73 | setUid( uidGen().generate() ); | 74 | setUid( uidGen().generate() ); |
74 | }else | 75 | }else |
75 | setUid( uidStr.toInt() ); | 76 | setUid( uidStr.toInt() ); |
76 | 77 | ||
77 | // if ( !uidStr.isEmpty() ) | 78 | // if ( !uidStr.isEmpty() ) |
78 | // setUid( uidStr.toInt() ); | 79 | // setUid( uidStr.toInt() ); |
79 | } | 80 | } |
80 | 81 | ||
81 | /*! | 82 | /*! |
82 | Destroys a contact. | 83 | Destroys a contact. |
83 | */ | 84 | */ |
84 | OContact::~OContact() | 85 | OContact::~OContact() |
85 | { | 86 | { |
86 | } | 87 | } |
87 | 88 | ||
88 | /*! \fn void OContact::setTitle( const QString &str ) | 89 | /*! \fn void OContact::setTitle( const QString &str ) |
89 | Sets the title of the contact to \a str. | 90 | Sets the title of the contact to \a str. |
90 | */ | 91 | */ |
91 | 92 | ||
92 | /*! \fn void OContact::setFirstName( const QString &str ) | 93 | /*! \fn void OContact::setFirstName( const QString &str ) |
93 | Sets the first name of the contact to \a str. | 94 | Sets the first name of the contact to \a str. |
94 | */ | 95 | */ |
95 | 96 | ||
96 | /*! \fn void OContact::setMiddleName( const QString &str ) | 97 | /*! \fn void OContact::setMiddleName( const QString &str ) |
97 | Sets the middle name of the contact to \a str. | 98 | Sets the middle name of the contact to \a str. |
98 | */ | 99 | */ |
99 | 100 | ||
100 | /*! \fn void OContact::setLastName( const QString &str ) | 101 | /*! \fn void OContact::setLastName( const QString &str ) |
101 | Sets the last name of the contact to \a str. | 102 | Sets the last name of the contact to \a str. |
102 | */ | 103 | */ |
103 | 104 | ||
104 | /*! \fn void OContact::setSuffix( const QString &str ) | 105 | /*! \fn void OContact::setSuffix( const QString &str ) |
105 | Sets the suffix of the contact to \a str. | 106 | Sets the suffix of the contact to \a str. |
106 | */ | 107 | */ |
107 | 108 | ||
108 | /*! \fn void OContact::setFileAs( const QString &str ) | 109 | /*! \fn void OContact::setFileAs( const QString &str ) |
109 | Sets the contact to filed as \a str. | 110 | Sets the contact to filed as \a str. |
110 | */ | 111 | */ |
111 | 112 | ||
112 | /*! \fn void OContact::setDefaultEmail( const QString &str ) | 113 | /*! \fn void OContact::setDefaultEmail( const QString &str ) |
113 | Sets the default email of the contact to \a str. | 114 | Sets the default email of the contact to \a str. |
114 | */ | 115 | */ |
115 | 116 | ||
116 | /*! \fn void OContact::setHomeStreet( const QString &str ) | 117 | /*! \fn void OContact::setHomeStreet( const QString &str ) |
117 | Sets the home street address of the contact to \a str. | 118 | Sets the home street address of the contact to \a str. |
118 | */ | 119 | */ |
119 | 120 | ||
120 | /*! \fn void OContact::setHomeCity( const QString &str ) | 121 | /*! \fn void OContact::setHomeCity( const QString &str ) |
121 | Sets the home city of the contact to \a str. | 122 | Sets the home city of the contact to \a str. |
122 | */ | 123 | */ |
123 | 124 | ||
@@ -345,388 +346,460 @@ OContact::~OContact() | |||
345 | /*! \fn QString OContact::businessZip() const | 346 | /*! \fn QString OContact::businessZip() const |
346 | Returns the business zip of the contact. | 347 | Returns the business zip of the contact. |
347 | */ | 348 | */ |
348 | 349 | ||
349 | /*! \fn QString OContact::businessCountry() const | 350 | /*! \fn QString OContact::businessCountry() const |
350 | Returns the business country of the contact. | 351 | Returns the business country of the contact. |
351 | */ | 352 | */ |
352 | 353 | ||
353 | /*! \fn QString OContact::businessPhone() const | 354 | /*! \fn QString OContact::businessPhone() const |
354 | Returns the business phone number of the contact. | 355 | Returns the business phone number of the contact. |
355 | */ | 356 | */ |
356 | 357 | ||
357 | /*! \fn QString OContact::businessFax() const | 358 | /*! \fn QString OContact::businessFax() const |
358 | Returns the business fax number of the contact. | 359 | Returns the business fax number of the contact. |
359 | */ | 360 | */ |
360 | 361 | ||
361 | /*! \fn QString OContact::businessMobile() const | 362 | /*! \fn QString OContact::businessMobile() const |
362 | Returns the business mobile number of the contact. | 363 | Returns the business mobile number of the contact. |
363 | */ | 364 | */ |
364 | 365 | ||
365 | /*! \fn QString OContact::businessPager() const | 366 | /*! \fn QString OContact::businessPager() const |
366 | Returns the business pager number of the contact. | 367 | Returns the business pager number of the contact. |
367 | */ | 368 | */ |
368 | 369 | ||
369 | /*! \fn QString OContact::businessWebpage() const | 370 | /*! \fn QString OContact::businessWebpage() const |
370 | Returns the business webpage of the contact. | 371 | Returns the business webpage of the contact. |
371 | */ | 372 | */ |
372 | 373 | ||
373 | /*! \fn QString OContact::spouse() const | 374 | /*! \fn QString OContact::spouse() const |
374 | Returns the spouse of the contact. | 375 | Returns the spouse of the contact. |
375 | */ | 376 | */ |
376 | 377 | ||
377 | /*! \fn QString OContact::gender() const | 378 | /*! \fn QString OContact::gender() const |
378 | Returns the gender of the contact. | 379 | Returns the gender of the contact. |
379 | */ | 380 | */ |
380 | 381 | ||
381 | /*! \fn QString OContact::nickname() const | 382 | /*! \fn QString OContact::nickname() const |
382 | Returns the nickname of the contact. | 383 | Returns the nickname of the contact. |
383 | */ | 384 | */ |
384 | 385 | ||
385 | /*! \fn QString OContact::children() const | 386 | /*! \fn QString OContact::children() const |
386 | Returns the children of the contact. | 387 | Returns the children of the contact. |
387 | */ | 388 | */ |
388 | 389 | ||
389 | /*! \fn QString OContact::notes() const | 390 | /*! \fn QString OContact::notes() const |
390 | Returns the notes relating to the the contact. | 391 | Returns the notes relating to the the contact. |
391 | */ | 392 | */ |
392 | 393 | ||
393 | /*! \fn QString OContact::groups() const | 394 | /*! \fn QString OContact::groups() const |
394 | \internal | 395 | \internal |
395 | Returns the groups for the contact. | 396 | Returns the groups for the contact. |
396 | */ | 397 | */ |
397 | 398 | ||
398 | /*! \fn QStringList OContact::groupList() const | 399 | /*! \fn QStringList OContact::groupList() const |
399 | \internal | 400 | \internal |
400 | */ | 401 | */ |
401 | 402 | ||
402 | /*! \fn QString OContact::field(int) const | 403 | /*! \fn QString OContact::field(int) const |
403 | \internal | 404 | \internal |
404 | */ | 405 | */ |
405 | 406 | ||
406 | /*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) | 407 | /*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) |
407 | \internal | 408 | \internal |
408 | */ | 409 | */ |
409 | 410 | ||
410 | /*! \fn void OContact::setUid( int id ) | 411 | /*! \fn void OContact::setUid( int id ) |
411 | \internal | 412 | \internal |
412 | Sets the uid for this record to \a id. | 413 | Sets the uid for this record to \a id. |
413 | */ | 414 | */ |
414 | 415 | ||
415 | /*! \enum OContact::journal_action | 416 | /*! \enum OContact::journal_action |
416 | \internal | 417 | \internal |
417 | */ | 418 | */ |
418 | 419 | ||
419 | /*! | 420 | /*! |
420 | \internal | 421 | \internal |
421 | */ | 422 | */ |
422 | QMap<int, QString> OContact::toMap() const | 423 | QMap<int, QString> OContact::toMap() const |
423 | { | 424 | { |
424 | QMap<int, QString> map = mMap; | 425 | QMap<int, QString> map = mMap; |
425 | QString cats = idsToString( categories() ); | 426 | QString cats = idsToString( categories() ); |
426 | if ( !cats.isEmpty() ) | 427 | if ( !cats.isEmpty() ) |
427 | map.insert( Qtopia::AddressCategory, cats ); | 428 | map.insert( Qtopia::AddressCategory, cats ); |
428 | return map; | 429 | return map; |
429 | } | 430 | } |
430 | 431 | ||
431 | /*! | 432 | /*! |
432 | Returns a rich text formatted QString representing the contents the contact. | 433 | Returns a rich text formatted QString representing the contents the contact. |
433 | */ | 434 | */ |
434 | QString OContact::toRichText() const | 435 | QString OContact::toRichText() const |
435 | { | 436 | { |
436 | QString text; | 437 | QString text; |
437 | QString value, comp, state; | 438 | QString value, comp, state; |
438 | QString str; | 439 | QString str; |
439 | bool marker = false; | 440 | bool marker = false; |
440 | 441 | ||
442 | Config cfg("qpe"); | ||
443 | cfg.setGroup("Appearance"); | ||
444 | int addressformat = cfg.readNumEntry( "AddressFormat", Zip_City_State ); | ||
445 | |||
441 | // name, jobtitle and company | 446 | // name, jobtitle and company |
442 | if ( !(value = fullName()).isEmpty() ) | 447 | if ( !(value = fullName()).isEmpty() ) |
443 | text += "<b><h3><img src=\"addressbook/AddressBook\">" + Qtopia::escapeString(value) + "</h3></b>"; | 448 | text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString(value) + "</h3></b>"; |
444 | 449 | ||
445 | if ( !(value = jobTitle()).isEmpty() ) | 450 | if ( !(value = jobTitle()).isEmpty() ) |
446 | text += Qtopia::escapeString(value) + "<br>"; | 451 | text += Qtopia::escapeString(value); |
447 | 452 | ||
448 | comp = company(); | 453 | comp = company(); |
449 | if ( !(value = department()).isEmpty() ) { | 454 | if ( !(value = department()).isEmpty() ) { |
450 | text += Qtopia::escapeString(value); | 455 | text += Qtopia::escapeString(value); |
451 | if ( comp ) | 456 | if ( comp ) |
452 | text += ", "; | 457 | text += ", "; |
453 | else | 458 | else |
454 | text += "<br>"; | 459 | text += "<br>"; |
455 | } | 460 | } |
456 | if ( !comp.isEmpty() ) | 461 | if ( !comp.isEmpty() ) |
457 | text += Qtopia::escapeString(comp) + "<br>"; | 462 | text += Qtopia::escapeString(comp); |
458 | 463 | ||
459 | text += "<hr><br>"; | 464 | text += "<br><hr>"; |
460 | 465 | ||
461 | // defailt email | 466 | // defailt email |
462 | QString defEmail = defaultEmail(); | 467 | QString defEmail = defaultEmail(); |
463 | if ( !defEmail.isEmpty() ) | 468 | if ( !defEmail.isEmpty() ){ |
464 | text += "<b><img src=\"addressbook/email\">" + QObject::tr("Default Email: ") + "</b>" | 469 | text += "<b><img src=\"addressbook/email\"> " + QObject::tr("Default Email: ") + "</b>" |
465 | + Qtopia::escapeString(defEmail) + "<br>"; | 470 | + Qtopia::escapeString(defEmail); |
466 | 471 | marker = true; | |
467 | text += "<br>"; | 472 | } |
468 | 473 | ||
469 | // business address | 474 | // business address |
470 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || | 475 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || |
471 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { | 476 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { |
472 | text += QObject::tr( "<b>Work Address:</b>" ); | 477 | text += QObject::tr( "<br><br><b>Work Address:</b>" ); |
473 | text += "<br>"; | ||
474 | marker = true; | 478 | marker = true; |
475 | } | 479 | } |
476 | 480 | ||
477 | if ( !(value = businessStreet()).isEmpty() ) | 481 | if ( !(value = businessStreet()).isEmpty() ){ |
478 | text += Qtopia::escapeString(value) + "<br>"; | 482 | text += "<br>" + Qtopia::escapeString(value); |
479 | state = businessState(); | 483 | marker = true; |
480 | if ( !(value = businessZip()).isEmpty() ) | 484 | } |
481 | text += Qtopia::escapeString(value) + " "; | 485 | |
482 | if ( !(value = businessCity()).isEmpty() ) { | 486 | switch( addressformat ){ |
483 | text += Qtopia::escapeString(value); | 487 | case Zip_City_State:{ // Zip_Code City, State |
484 | if ( state ) | 488 | state = businessState(); |
485 | text += ", " + Qtopia::escapeString(state); | 489 | if ( !(value = businessZip()).isEmpty() ){ |
486 | text += "<br>"; | 490 | text += "<br>" + Qtopia::escapeString(value) + " "; |
487 | } else if ( !state.isEmpty() ) | 491 | marker = true; |
488 | text += Qtopia::escapeString(state) + "<br>"; | 492 | |
493 | } else | ||
494 | text += "<br>"; | ||
495 | |||
496 | if ( !(value = businessCity()).isEmpty() ) { | ||
497 | marker = true; | ||
498 | text += Qtopia::escapeString(value); | ||
499 | if ( state ) | ||
500 | text += ", " + Qtopia::escapeString(state); | ||
501 | } else if ( !state.isEmpty() ){ | ||
502 | text += "<br>" + Qtopia::escapeString(state); | ||
503 | marker = true; | ||
504 | } | ||
505 | break; | ||
506 | } | ||
507 | case City_State_Zip:{ // City, State Zip_Code | ||
508 | state = businessState(); | ||
509 | if ( !(value = businessCity()).isEmpty() ) { | ||
510 | marker = true; | ||
511 | text += "<br>" + Qtopia::escapeString(value); | ||
512 | if ( state ) | ||
513 | text += ", " + Qtopia::escapeString(state); | ||
514 | } else if ( !state.isEmpty() ){ | ||
515 | text += "<br>" + Qtopia::escapeString(state); | ||
516 | marker = true; | ||
517 | } | ||
518 | if ( !(value = businessZip()).isEmpty() ){ | ||
519 | text += " " + Qtopia::escapeString(value); | ||
520 | marker = true; | ||
521 | } | ||
522 | break; | ||
523 | } | ||
524 | } | ||
489 | 525 | ||
490 | if ( !(value = businessCountry()).isEmpty() ) | 526 | if ( !(value = businessCountry()).isEmpty() ){ |
491 | text += Qtopia::escapeString(value) + "<br>"; | 527 | text += "<br>" + Qtopia::escapeString(value); |
528 | marker = true; | ||
529 | } | ||
492 | 530 | ||
493 | // rest of Business data | 531 | // rest of Business data |
494 | str = office(); | 532 | str = office(); |
495 | if ( !str.isEmpty() ){ | 533 | if ( !str.isEmpty() ){ |
496 | text += "<b>" + QObject::tr("Office: ") + "</b>" | 534 | text += "<br><b>" + QObject::tr("Office: ") + "</b>" |
497 | + Qtopia::escapeString(str) + "<br>"; | 535 | + Qtopia::escapeString(str); |
498 | marker = true; | 536 | marker = true; |
499 | } | 537 | } |
500 | str = businessWebpage(); | 538 | str = businessWebpage(); |
501 | if ( !str.isEmpty() ){ | 539 | if ( !str.isEmpty() ){ |
502 | text += "<b><img src=\"addressbook/webpagework\">" + QObject::tr("Business Web Page: ") + "</b>" | 540 | text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr("Business Web Page: ") + "</b>" |
503 | + Qtopia::escapeString(str) + "<br>"; | 541 | + Qtopia::escapeString(str); |
504 | marker = true; | 542 | marker = true; |
505 | } | 543 | } |
506 | str = businessPhone(); | 544 | str = businessPhone(); |
507 | if ( !str.isEmpty() ){ | 545 | if ( !str.isEmpty() ){ |
508 | text += "<b><img src=\"addressbook/phonework\">" + QObject::tr("Business Phone: ") + "</b>" | 546 | text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr("Business Phone: ") + "</b>" |
509 | + Qtopia::escapeString(str) + "<br>"; | 547 | + Qtopia::escapeString(str); |
510 | marker = true; | 548 | marker = true; |
511 | } | 549 | } |
512 | str = businessFax(); | 550 | str = businessFax(); |
513 | if ( !str.isEmpty() ){ | 551 | if ( !str.isEmpty() ){ |
514 | text += "<b><img src=\"addressbook/faxwork\">" + QObject::tr("Business Fax: ") + "</b>" | 552 | text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr("Business Fax: ") + "</b>" |
515 | + Qtopia::escapeString(str) + "<br>"; | 553 | + Qtopia::escapeString(str); |
516 | marker = true; | 554 | marker = true; |
517 | } | 555 | } |
518 | str = businessMobile(); | 556 | str = businessMobile(); |
519 | if ( !str.isEmpty() ){ | 557 | if ( !str.isEmpty() ){ |
520 | text += "<b><img src=\"addressbook/mobilework\">" + QObject::tr("Business Mobile: ") + "</b>" | 558 | text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr("Business Mobile: ") + "</b>" |
521 | + Qtopia::escapeString(str) + "<br>"; | 559 | + Qtopia::escapeString(str); |
522 | marker = true; | 560 | marker = true; |
523 | } | 561 | } |
524 | str = businessPager(); | 562 | str = businessPager(); |
525 | if ( !str.isEmpty() ){ | 563 | if ( !str.isEmpty() ){ |
526 | text += "<b>" + QObject::tr("Business Pager: ") + "</b>" | 564 | text += "<br><b>" + QObject::tr("Business Pager: ") + "</b>" |
527 | + Qtopia::escapeString(str) + "<br>"; | 565 | + Qtopia::escapeString(str); |
528 | marker = true; | 566 | marker = true; |
529 | } | 567 | } |
530 | 568 | ||
531 | text += "<br>"; | 569 | text += "<br>"; |
532 | 570 | ||
533 | // home address | 571 | // home address |
534 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || | 572 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || |
535 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { | 573 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { |
536 | text += QObject::tr( "<b>Home Address:</b>" ); | 574 | text += QObject::tr( "<br><br><b>Home Address:</b>" ); |
537 | text += "<br>"; | 575 | marker = true; |
538 | } | 576 | } |
539 | 577 | ||
540 | if ( !(value = homeStreet()).isEmpty() ) | 578 | if ( !(value = homeStreet()).isEmpty() ){ |
541 | text += Qtopia::escapeString(value) + "<br>"; | 579 | text += "<br>" + Qtopia::escapeString(value); |
542 | state = homeState(); | 580 | marker = true; |
543 | if ( !(value = homeZip()).isEmpty() ) | 581 | } |
544 | text += Qtopia::escapeString(value) + " "; | 582 | |
545 | if ( !(value = homeCity()).isEmpty() ) { | 583 | switch( addressformat ){ |
546 | text += Qtopia::escapeString(value); | 584 | case Zip_City_State:{ // Zip_Code City, State |
547 | if ( !state.isEmpty() ) | 585 | state = homeState(); |
548 | text += ", " + Qtopia::escapeString(state); | 586 | if ( !(value = homeZip()).isEmpty() ){ |
549 | text += "<br>"; | 587 | text += "<br>" + Qtopia::escapeString(value) + " "; |
550 | } else if (!state.isEmpty()) | 588 | marker = true; |
551 | text += Qtopia::escapeString(state) + "<br>"; | 589 | } else |
552 | if ( !(value = homeCountry()).isEmpty() ) | 590 | text += "<br>"; |
553 | text += Qtopia::escapeString(value) + "<br>"; | 591 | |
592 | if ( !(value = homeCity()).isEmpty() ) { | ||
593 | marker = true; | ||
594 | text += Qtopia::escapeString(value); | ||
595 | if ( !state.isEmpty() ) | ||
596 | text += ", " + Qtopia::escapeString(state); | ||
597 | } else if (!state.isEmpty()) { | ||
598 | text += "<br>" + Qtopia::escapeString(state); | ||
599 | marker = true; | ||
600 | } | ||
601 | break; | ||
602 | } | ||
603 | case City_State_Zip:{ // City, State Zip_Code | ||
604 | state = homeState(); | ||
605 | if ( !(value = homeCity()).isEmpty() ) { | ||
606 | marker = true; | ||
607 | text += "<br>" + Qtopia::escapeString(value); | ||
608 | if ( state ) | ||
609 | text += ", " + Qtopia::escapeString(state); | ||
610 | } else if ( !state.isEmpty() ){ | ||
611 | text += "<br>" + Qtopia::escapeString(state); | ||
612 | marker = true; | ||
613 | } | ||
614 | if ( !(value = homeZip()).isEmpty() ){ | ||
615 | text += " " + Qtopia::escapeString(value); | ||
616 | marker = true; | ||
617 | } | ||
618 | break; | ||
619 | } | ||
620 | } | ||
621 | |||
622 | if ( !(value = homeCountry()).isEmpty() ){ | ||
623 | text += "<br>" + Qtopia::escapeString(value); | ||
624 | marker = true; | ||
625 | } | ||
554 | 626 | ||
555 | // rest of Home data | 627 | // rest of Home data |
556 | str = homeWebpage(); | 628 | str = homeWebpage(); |
557 | if ( !str.isEmpty() ){ | 629 | if ( !str.isEmpty() ){ |
558 | text += "<b><img src=\"addressbook/webpagehome\">" + QObject::tr("Home Web Page: ") + "</b>" | 630 | text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr("Home Web Page: ") + "</b>" |
559 | + Qtopia::escapeString(str) + "<br>"; | 631 | + Qtopia::escapeString(str); |
560 | marker = true; | 632 | marker = true; |
561 | } | 633 | } |
562 | str = homePhone(); | 634 | str = homePhone(); |
563 | if ( !str.isEmpty() ){ | 635 | if ( !str.isEmpty() ){ |
564 | text += "<b><img src=\"addressbook/phonehome\">" + QObject::tr("Home Phone: ") + "</b>" | 636 | text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr("Home Phone: ") + "</b>" |
565 | + Qtopia::escapeString(str) + "<br>"; | 637 | + Qtopia::escapeString(str); |
566 | marker = true; | 638 | marker = true; |
567 | } | 639 | } |
568 | str = homeFax(); | 640 | str = homeFax(); |
569 | if ( !str.isEmpty() ){ | 641 | if ( !str.isEmpty() ){ |
570 | text += "<b><img src=\"addressbook/faxhome\">" + QObject::tr("Home Fax: ") + "</b>" | 642 | text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr("Home Fax: ") + "</b>" |
571 | + Qtopia::escapeString(str) + "<br>"; | 643 | + Qtopia::escapeString(str); |
572 | marker = true; | 644 | marker = true; |
573 | } | 645 | } |
574 | str = homeMobile(); | 646 | str = homeMobile(); |
575 | if ( !str.isEmpty() ){ | 647 | if ( !str.isEmpty() ){ |
576 | text += "<b><img src=\"addressbook/mobilehome\">" + QObject::tr("Home Mobile: ") + "</b>" | 648 | text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr("Home Mobile: ") + "</b>" |
577 | + Qtopia::escapeString(str) + "<br>"; | 649 | + Qtopia::escapeString(str); |
578 | marker = true; | 650 | marker = true; |
579 | } | 651 | } |
580 | 652 | ||
581 | if ( marker ) | 653 | if ( marker ) |
582 | text += "<br><hr><br>"; | 654 | text += "<br><hr>"; |
583 | // the others... | 655 | |
656 | // the rest... | ||
584 | str = emails(); | 657 | str = emails(); |
585 | if ( !str.isEmpty() && ( str != defEmail ) ) | 658 | if ( !str.isEmpty() && ( str != defEmail ) ) |
586 | text += "<b>" + QObject::tr("All Emails: ") + "</b>" | 659 | text += "<br><b>" + QObject::tr("All Emails: ") + "</b>" |
587 | + Qtopia::escapeString(str) + "<br>"; | 660 | + Qtopia::escapeString(str); |
588 | str = profession(); | 661 | str = profession(); |
589 | if ( !str.isEmpty() ) | 662 | if ( !str.isEmpty() ) |
590 | text += "<b>" + QObject::tr("Profession: ") + "</b>" | 663 | text += "<br><b>" + QObject::tr("Profession: ") + "</b>" |
591 | + Qtopia::escapeString(str) + "<br>"; | 664 | + Qtopia::escapeString(str); |
592 | str = assistant(); | 665 | str = assistant(); |
593 | if ( !str.isEmpty() ) | 666 | if ( !str.isEmpty() ) |
594 | text += "<b>" + QObject::tr("Assistant: ") + "</b>" | 667 | text += "<br><b>" + QObject::tr("Assistant: ") + "</b>" |
595 | + Qtopia::escapeString(str) + "<br>"; | 668 | + Qtopia::escapeString(str); |
596 | str = manager(); | 669 | str = manager(); |
597 | if ( !str.isEmpty() ) | 670 | if ( !str.isEmpty() ) |
598 | text += "<b>" + QObject::tr("Manager: ") + "</b>" | 671 | text += "<br><b>" + QObject::tr("Manager: ") + "</b>" |
599 | + Qtopia::escapeString(str) + "<br>"; | 672 | + Qtopia::escapeString(str); |
600 | str = gender(); | 673 | str = gender(); |
601 | if ( !str.isEmpty() && str.toInt() != 0 ) { | 674 | if ( !str.isEmpty() && str.toInt() != 0 ) { |
602 | if ( str.toInt() == 1 ) | 675 | text += "<br>"; |
603 | str = QObject::tr( "Male" ); | 676 | if ( str.toInt() == 1 ) |
604 | else if ( str.toInt() == 2 ) | 677 | str = QObject::tr( "Male" ); |
605 | str = QObject::tr( "Female" ); | 678 | else if ( str.toInt() == 2 ) |
606 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; | 679 | str = QObject::tr( "Female" ); |
680 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str; | ||
607 | } | 681 | } |
608 | str = spouse(); | 682 | str = spouse(); |
609 | if ( !str.isEmpty() ) | 683 | if ( !str.isEmpty() ) |
610 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" | 684 | text += "<br><b>" + QObject::tr("Spouse: ") + "</b>" |
611 | + Qtopia::escapeString(str) + "<br>"; | 685 | + Qtopia::escapeString(str); |
612 | if ( birthday().isValid() ){ | 686 | if ( birthday().isValid() ){ |
613 | str = TimeString::numberDateString( birthday() ); | 687 | str = TimeString::numberDateString( birthday() ); |
614 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" | 688 | text += "<br><b>" + QObject::tr("Birthday: ") + "</b>" |
615 | + Qtopia::escapeString(str) + "<br>"; | 689 | + Qtopia::escapeString(str); |
616 | } | 690 | } |
617 | if ( anniversary().isValid() ){ | 691 | if ( anniversary().isValid() ){ |
618 | str = TimeString::numberDateString( anniversary() ); | 692 | str = TimeString::numberDateString( anniversary() ); |
619 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" | 693 | text += "<br><b>" + QObject::tr("Anniversary: ") + "</b>" |
620 | + Qtopia::escapeString(str) + "<br>"; | 694 | + Qtopia::escapeString(str); |
621 | } | 695 | } |
622 | str = children(); | 696 | str = children(); |
623 | if ( !str.isEmpty() ) | 697 | if ( !str.isEmpty() ) |
624 | text += "<b>" + QObject::tr("Children: ") + "</b>" | 698 | text += "<br><b>" + QObject::tr("Children: ") + "</b>" |
625 | + Qtopia::escapeString(str) + "<br>"; | 699 | + Qtopia::escapeString(str); |
626 | 700 | ||
627 | str = nickname(); | 701 | str = nickname(); |
628 | if ( !str.isEmpty() ) | 702 | if ( !str.isEmpty() ) |
629 | text += "<b>" + QObject::tr("Nickname: ") + "</b>" | 703 | text += "<br><b>" + QObject::tr("Nickname: ") + "</b>" |
630 | + Qtopia::escapeString(str) + "<br>"; | 704 | + Qtopia::escapeString(str); |
631 | 705 | ||
632 | // categories | 706 | // categories |
633 | if ( categoryNames("Contacts").count() ){ | 707 | if ( categoryNames("Contacts").count() ){ |
634 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 708 | text += "<br><b>" + QObject::tr( "Category:") + "</b> "; |
635 | text += categoryNames("Contacts").join(", "); | 709 | text += categoryNames("Contacts").join(", "); |
636 | text += "<br>"; | ||
637 | } | 710 | } |
638 | 711 | ||
639 | // notes last | 712 | // notes last |
640 | if ( !(value = notes()).isEmpty() ) { | 713 | if ( !(value = notes()).isEmpty() ) { |
641 | text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; | 714 | text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; |
642 | QRegExp reg("\n"); | 715 | QRegExp reg("\n"); |
643 | 716 | ||
644 | //QString tmp = Qtopia::escapeString(value); | 717 | //QString tmp = Qtopia::escapeString(value); |
645 | QString tmp = QStyleSheet::convertFromPlainText(value); | 718 | QString tmp = QStyleSheet::convertFromPlainText(value); |
646 | //tmp.replace( reg, "<br>" ); | 719 | //tmp.replace( reg, "<br>" ); |
647 | text += "<br>" + tmp + "<br>"; | 720 | text += "<br>" + tmp + "<br>"; |
648 | } | 721 | } |
649 | return text; | 722 | return text; |
650 | } | 723 | } |
651 | 724 | ||
652 | /*! | 725 | /*! |
653 | \internal | 726 | \internal |
654 | */ | 727 | */ |
655 | void OContact::insert( int key, const QString &v ) | 728 | void OContact::insert( int key, const QString &v ) |
656 | { | 729 | { |
657 | QString value = v.stripWhiteSpace(); | 730 | QString value = v.stripWhiteSpace(); |
658 | if ( value.isEmpty() ) | 731 | if ( value.isEmpty() ) |
659 | mMap.remove( key ); | 732 | mMap.remove( key ); |
660 | else | 733 | else |
661 | mMap.insert( key, value ); | 734 | mMap.insert( key, value ); |
662 | } | 735 | } |
663 | 736 | ||
664 | /*! | 737 | /*! |
665 | \internal | 738 | \internal |
666 | */ | 739 | */ |
667 | void OContact::replace( int key, const QString & v ) | 740 | void OContact::replace( int key, const QString & v ) |
668 | { | 741 | { |
669 | QString value = v.stripWhiteSpace(); | 742 | QString value = v.stripWhiteSpace(); |
670 | if ( value.isEmpty() ) | 743 | if ( value.isEmpty() ) |
671 | mMap.remove( key ); | 744 | mMap.remove( key ); |
672 | else | 745 | else |
673 | mMap.replace( key, value ); | 746 | mMap.replace( key, value ); |
674 | } | 747 | } |
675 | 748 | ||
676 | /*! | 749 | /*! |
677 | \internal | 750 | \internal |
678 | */ | 751 | */ |
679 | QString OContact::find( int key ) const | 752 | QString OContact::find( int key ) const |
680 | { | 753 | { |
681 | return mMap[key]; | 754 | return mMap[key]; |
682 | } | 755 | } |
683 | 756 | ||
684 | /*! | 757 | /*! |
685 | \internal | 758 | \internal |
686 | */ | 759 | */ |
687 | QString OContact::displayAddress( const QString &street, | 760 | QString OContact::displayAddress( const QString &street, |
688 | const QString &city, | 761 | const QString &city, |
689 | const QString &state, | 762 | const QString &state, |
690 | const QString &zip, | 763 | const QString &zip, |
691 | const QString &country ) const | 764 | const QString &country ) const |
692 | { | 765 | { |
693 | QString s = street; | 766 | QString s = street; |
694 | if ( !street.isEmpty() ) | 767 | if ( !street.isEmpty() ) |
695 | s+= "\n"; | 768 | s+= "\n"; |
696 | s += city; | 769 | s += city; |
697 | if ( !city.isEmpty() && !state.isEmpty() ) | 770 | if ( !city.isEmpty() && !state.isEmpty() ) |
698 | s += ", "; | 771 | s += ", "; |
699 | s += state; | 772 | s += state; |
700 | if ( !state.isEmpty() && !zip.isEmpty() ) | 773 | if ( !state.isEmpty() && !zip.isEmpty() ) |
701 | s += " "; | 774 | s += " "; |
702 | s += zip; | 775 | s += zip; |
703 | if ( !country.isEmpty() && !s.isEmpty() ) | 776 | if ( !country.isEmpty() && !s.isEmpty() ) |
704 | s += "\n"; | 777 | s += "\n"; |
705 | s += country; | 778 | s += country; |
706 | return s; | 779 | return s; |
707 | } | 780 | } |
708 | 781 | ||
709 | /*! | 782 | /*! |
710 | \internal | 783 | \internal |
711 | */ | 784 | */ |
712 | QString OContact::displayBusinessAddress() const | 785 | QString OContact::displayBusinessAddress() const |
713 | { | 786 | { |
714 | return displayAddress( businessStreet(), businessCity(), | 787 | return displayAddress( businessStreet(), businessCity(), |
715 | businessState(), businessZip(), | 788 | businessState(), businessZip(), |
716 | businessCountry() ); | 789 | businessCountry() ); |
717 | } | 790 | } |
718 | 791 | ||
719 | /*! | 792 | /*! |
720 | \internal | 793 | \internal |
721 | */ | 794 | */ |
722 | QString OContact::displayHomeAddress() const | 795 | QString OContact::displayHomeAddress() const |
723 | { | 796 | { |
724 | return displayAddress( homeStreet(), homeCity(), | 797 | return displayAddress( homeStreet(), homeCity(), |
725 | homeState(), homeZip(), | 798 | homeState(), homeZip(), |
726 | homeCountry() ); | 799 | homeCountry() ); |
727 | } | 800 | } |
728 | 801 | ||
729 | /*! | 802 | /*! |
730 | Returns the full name of the contact | 803 | Returns the full name of the contact |
731 | */ | 804 | */ |
732 | QString OContact::fullName() const | 805 | QString OContact::fullName() const |
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h index dd2de17..9a1a8dc 100644 --- a/libopie2/opiepim/ocontact.h +++ b/libopie2/opiepim/ocontact.h | |||
@@ -1,240 +1,245 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2002-2003 by Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 13 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
14 | ** | 14 | ** |
15 | ** Contact info@trolltech.com if any conditions of this licensing are | 15 | ** Contact info@trolltech.com if any conditions of this licensing are |
16 | ** not clear to you. | 16 | ** not clear to you. |
17 | ** | 17 | ** |
18 | **********************************************************************/ | 18 | **********************************************************************/ |
19 | 19 | ||
20 | #ifndef __OCONTACT_H__ | 20 | #ifndef __OCONTACT_H__ |
21 | #define __OCONTACT_H__ | 21 | #define __OCONTACT_H__ |
22 | 22 | ||
23 | #include <opie/opimrecord.h> | 23 | #include <opie/opimrecord.h> |
24 | #include <qpe/recordfields.h> | 24 | #include <qpe/recordfields.h> |
25 | 25 | ||
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | 28 | ||
29 | #if defined(QPC_TEMPLATEDLL) | 29 | #if defined(QPC_TEMPLATEDLL) |
30 | // MOC_SKIP_BEGIN | 30 | // MOC_SKIP_BEGIN |
31 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; | 31 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; |
32 | // MOC_SKIP_END | 32 | // MOC_SKIP_END |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | class ContactPrivate; | 35 | class OContactPrivate; |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * OContact class represents a specialised PIM Record for contacts. | 38 | * OContact class represents a specialised PIM Record for contacts. |
39 | * It does store all kind of persopn related information. | 39 | * It does store all kind of persopn related information. |
40 | * | 40 | * |
41 | * @short Contact Container | 41 | * @short Contact Container |
42 | * @author TT, Stefan Eiler, Holger Freyther | 42 | * @author TT, Stefan Eiler, Holger Freyther |
43 | */ | 43 | */ |
44 | class QPC_EXPORT OContact : public OPimRecord | 44 | class QPC_EXPORT OContact : public OPimRecord |
45 | { | 45 | { |
46 | friend class DataSet; | 46 | friend class DataSet; |
47 | public: | 47 | public: |
48 | OContact(); | 48 | OContact(); |
49 | OContact( const QMap<int, QString> &fromMap ); | 49 | OContact( const QMap<int, QString> &fromMap ); |
50 | virtual ~OContact(); | 50 | virtual ~OContact(); |
51 | 51 | ||
52 | enum DateFormat{ | ||
53 | Zip_City_State = 0, | ||
54 | City_State_Zip | ||
55 | }; | ||
56 | |||
52 | /* | 57 | /* |
53 | * do we need to inline them | 58 | * do we need to inline them |
54 | * if yes do we need to inline them this way? | 59 | * if yes do we need to inline them this way? |
55 | * -zecke | 60 | * -zecke |
56 | */ | 61 | */ |
57 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } | 62 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } |
58 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } | 63 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } |
59 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } | 64 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } |
60 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } | 65 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } |
61 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } | 66 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } |
62 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } | 67 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } |
63 | void setFileAs(); | 68 | void setFileAs(); |
64 | 69 | ||
65 | // default email address | 70 | // default email address |
66 | void setDefaultEmail( const QString &v ); | 71 | void setDefaultEmail( const QString &v ); |
67 | // inserts email to list and ensure's doesn't already exist | 72 | // inserts email to list and ensure's doesn't already exist |
68 | void insertEmail( const QString &v ); | 73 | void insertEmail( const QString &v ); |
69 | void removeEmail( const QString &v ); | 74 | void removeEmail( const QString &v ); |
70 | void clearEmails(); | 75 | void clearEmails(); |
71 | void insertEmails( const QStringList &v ); | 76 | void insertEmails( const QStringList &v ); |
72 | 77 | ||
73 | // home | 78 | // home |
74 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } | 79 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } |
75 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } | 80 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } |
76 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } | 81 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } |
77 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } | 82 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } |
78 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } | 83 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } |
79 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } | 84 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } |
80 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } | 85 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } |
81 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } | 86 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } |
82 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } | 87 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } |
83 | 88 | ||
84 | // business | 89 | // business |
85 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } | 90 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } |
86 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } | 91 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } |
87 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } | 92 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } |
88 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } | 93 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } |
89 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 94 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
90 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 95 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
91 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 96 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
92 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 97 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
93 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 98 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
94 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 99 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
95 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 100 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
96 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 101 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
97 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 102 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
98 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 103 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
99 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 104 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
100 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 105 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
101 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 106 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
102 | 107 | ||
103 | // personal | 108 | // personal |
104 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 109 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
105 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 110 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
106 | void setBirthday( const QDate &v ); | 111 | void setBirthday( const QDate &v ); |
107 | void setAnniversary( const QDate &v ); | 112 | void setAnniversary( const QDate &v ); |
108 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 113 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
109 | void setChildren( const QString &v ); | 114 | void setChildren( const QString &v ); |
110 | 115 | ||
111 | // other | 116 | // other |
112 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 117 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } |
113 | 118 | ||
114 | virtual bool match( const QRegExp ®exp ) const; | 119 | virtual bool match( const QRegExp ®exp ) const; |
115 | 120 | ||
116 | // // custom | 121 | // // custom |
117 | // void setCustomField( const QString &key, const QString &v ) | 122 | // void setCustomField( const QString &key, const QString &v ) |
118 | // { replace(Custom- + key, v ); } | 123 | // { replace(Custom- + key, v ); } |
119 | 124 | ||
120 | // name | 125 | // name |
121 | QString fullName() const; | 126 | QString fullName() const; |
122 | QString title() const { return find( Qtopia::Title ); } | 127 | QString title() const { return find( Qtopia::Title ); } |
123 | QString firstName() const { return find( Qtopia::FirstName ); } | 128 | QString firstName() const { return find( Qtopia::FirstName ); } |
124 | QString middleName() const { return find( Qtopia::MiddleName ); } | 129 | QString middleName() const { return find( Qtopia::MiddleName ); } |
125 | QString lastName() const { return find( Qtopia::LastName ); } | 130 | QString lastName() const { return find( Qtopia::LastName ); } |
126 | QString suffix() const { return find( Qtopia::Suffix ); } | 131 | QString suffix() const { return find( Qtopia::Suffix ); } |
127 | QString fileAs() const { return find( Qtopia::FileAs ); } | 132 | QString fileAs() const { return find( Qtopia::FileAs ); } |
128 | 133 | ||
129 | 134 | ||
130 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 135 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
131 | QStringList emailList() const; | 136 | QStringList emailList() const; |
132 | 137 | ||
133 | // home | 138 | // home |
134 | /* | 139 | /* |
135 | * OPimAddress address(enum Location)const; | 140 | * OPimAddress address(enum Location)const; |
136 | * would be some how nicer... | 141 | * would be some how nicer... |
137 | * -zecke | 142 | * -zecke |
138 | */ | 143 | */ |
139 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 144 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
140 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 145 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
141 | QString homeState() const { return find( Qtopia::HomeState ); } | 146 | QString homeState() const { return find( Qtopia::HomeState ); } |
142 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 147 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
143 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 148 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
144 | QString homePhone() const { return find( Qtopia::HomePhone ); } | 149 | QString homePhone() const { return find( Qtopia::HomePhone ); } |
145 | QString homeFax() const { return find( Qtopia::HomeFax ); } | 150 | QString homeFax() const { return find( Qtopia::HomeFax ); } |
146 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } | 151 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } |
147 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } | 152 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } |
148 | /** Multi line string containing all non-empty address info in the form | 153 | /** Multi line string containing all non-empty address info in the form |
149 | * Street | 154 | * Street |
150 | * City, State Zip | 155 | * City, State Zip |
151 | * Country | 156 | * Country |
152 | */ | 157 | */ |
153 | QString displayHomeAddress() const; | 158 | QString displayHomeAddress() const; |
154 | 159 | ||
155 | // business | 160 | // business |
156 | QString company() const { return find( Qtopia::Company ); } | 161 | QString company() const { return find( Qtopia::Company ); } |
157 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } | 162 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } |
158 | QString businessCity() const { return find( Qtopia::BusinessCity ); } | 163 | QString businessCity() const { return find( Qtopia::BusinessCity ); } |
159 | QString businessState() const { return find( Qtopia::BusinessState ); } | 164 | QString businessState() const { return find( Qtopia::BusinessState ); } |
160 | QString businessZip() const { return find( Qtopia::BusinessZip ); } | 165 | QString businessZip() const { return find( Qtopia::BusinessZip ); } |
161 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } | 166 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } |
162 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | 167 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } |
163 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 168 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
164 | QString department() const { return find( Qtopia::Department ); } | 169 | QString department() const { return find( Qtopia::Department ); } |
165 | QString office() const { return find( Qtopia::Office ); } | 170 | QString office() const { return find( Qtopia::Office ); } |
166 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 171 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
167 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 172 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
168 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 173 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
169 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 174 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
170 | QString profession() const { return find( Qtopia::Profession ); } | 175 | QString profession() const { return find( Qtopia::Profession ); } |
171 | QString assistant() const { return find( Qtopia::Assistant ); } | 176 | QString assistant() const { return find( Qtopia::Assistant ); } |
172 | QString manager() const { return find( Qtopia::Manager ); } | 177 | QString manager() const { return find( Qtopia::Manager ); } |
173 | /** Multi line string containing all non-empty address info in the form | 178 | /** Multi line string containing all non-empty address info in the form |
174 | * Street | 179 | * Street |
175 | * City, State Zip | 180 | * City, State Zip |
176 | * Country | 181 | * Country |
177 | */ | 182 | */ |
178 | QString displayBusinessAddress() const; | 183 | QString displayBusinessAddress() const; |
179 | 184 | ||
180 | //personal | 185 | //personal |
181 | QString spouse() const { return find( Qtopia::Spouse ); } | 186 | QString spouse() const { return find( Qtopia::Spouse ); } |
182 | QString gender() const { return find( Qtopia::Gender ); } | 187 | QString gender() const { return find( Qtopia::Gender ); } |
183 | QDate birthday() const; | 188 | QDate birthday() const; |
184 | QDate anniversary() const; | 189 | QDate anniversary() const; |
185 | QString nickname() const { return find( Qtopia::Nickname ); } | 190 | QString nickname() const { return find( Qtopia::Nickname ); } |
186 | QString children() const { return find( Qtopia::Children ); } | 191 | QString children() const { return find( Qtopia::Children ); } |
187 | QStringList childrenList() const; | 192 | QStringList childrenList() const; |
188 | 193 | ||
189 | // other | 194 | // other |
190 | QString notes() const { return find( Qtopia::Notes ); } | 195 | QString notes() const { return find( Qtopia::Notes ); } |
191 | QString groups() const { return find( Qtopia::Groups ); } | 196 | QString groups() const { return find( Qtopia::Groups ); } |
192 | QStringList groupList() const; | 197 | QStringList groupList() const; |
193 | 198 | ||
194 | // // custom | 199 | // // custom |
195 | // const QString &customField( const QString &key ) | 200 | // const QString &customField( const QString &key ) |
196 | // { return find( Custom- + key ); } | 201 | // { return find( Custom- + key ); } |
197 | 202 | ||
198 | 203 | ||
199 | QString toRichText() const; | 204 | QString toRichText() const; |
200 | QMap<int, QString> toMap() const; | 205 | QMap<int, QString> toMap() const; |
201 | QString field( int key ) const { return find( key ); } | 206 | QString field( int key ) const { return find( key ); } |
202 | 207 | ||
203 | 208 | ||
204 | void setUid( int i ); | 209 | void setUid( int i ); |
205 | 210 | ||
206 | QString toShortText()const; | 211 | QString toShortText()const; |
207 | QString OContact::type()const; | 212 | QString OContact::type()const; |
208 | QMap<QString,QString> OContact::toExtraMap() const; | 213 | QMap<QString,QString> OContact::toExtraMap() const; |
209 | class QString OContact::recordField(int) const; | 214 | class QString OContact::recordField(int) const; |
210 | 215 | ||
211 | // Why private ? (eilers,se) | 216 | // Why private ? (eilers,se) |
212 | QString emailSeparator() const { return " "; } | 217 | QString emailSeparator() const { return " "; } |
213 | // the emails should be seperated by a comma | 218 | // the emails should be seperated by a comma |
214 | void setEmails( const QString &v ); | 219 | void setEmails( const QString &v ); |
215 | QString emails() const { return find( Qtopia::Emails ); } | 220 | QString emails() const { return find( Qtopia::Emails ); } |
216 | static int rtti(); | 221 | static int rtti(); |
217 | 222 | ||
218 | private: | 223 | private: |
219 | // The XML-Backend needs some access to the private functions | 224 | // The XML-Backend needs some access to the private functions |
220 | friend class OContactAccessBackend_XML; | 225 | friend class OContactAccessBackend_XML; |
221 | 226 | ||
222 | void insert( int key, const QString &value ); | 227 | void insert( int key, const QString &value ); |
223 | void replace( int key, const QString &value ); | 228 | void replace( int key, const QString &value ); |
224 | QString find( int key ) const; | 229 | QString find( int key ) const; |
225 | static QStringList fields(); | 230 | static QStringList fields(); |
226 | 231 | ||
227 | void save( QString &buf ) const; | 232 | void save( QString &buf ) const; |
228 | 233 | ||
229 | QString displayAddress( const QString &street, | 234 | QString displayAddress( const QString &street, |
230 | const QString &city, | 235 | const QString &city, |
231 | const QString &state, | 236 | const QString &state, |
232 | const QString &zip, | 237 | const QString &zip, |
233 | const QString &country ) const; | 238 | const QString &country ) const; |
234 | 239 | ||
235 | QMap<int, QString> mMap; | 240 | QMap<int, QString> mMap; |
236 | ContactPrivate *d; | 241 | OContactPrivate *d; |
237 | }; | 242 | }; |
238 | 243 | ||
239 | 244 | ||
240 | #endif | 245 | #endif |
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/orecordlist.h index edcd729..5211f57 100644 --- a/libopie2/opiepim/orecordlist.h +++ b/libopie2/opiepim/orecordlist.h | |||
@@ -1,300 +1,306 @@ | |||
1 | 1 | ||
2 | #ifndef OPIE_RECORD_LIST_H | 2 | #ifndef OPIE_RECORD_LIST_H |
3 | #define OPIE_RECORD_LIST_H | 3 | #define OPIE_RECORD_LIST_H |
4 | 4 | ||
5 | #include <qarray.h> | 5 | #include <qarray.h> |
6 | 6 | ||
7 | #include "otemplatebase.h" | 7 | #include "otemplatebase.h" |
8 | #include "opimrecord.h" | 8 | #include "opimrecord.h" |
9 | 9 | ||
10 | class ORecordListIteratorPrivate; | ||
10 | /** | 11 | /** |
11 | * Our List Iterator | 12 | * Our List Iterator |
12 | * it behaves like STL or Qt | 13 | * it behaves like STL or Qt |
13 | * | 14 | * |
14 | * for(it = list.begin(); it != list.end(); ++it ) | 15 | * for(it = list.begin(); it != list.end(); ++it ) |
15 | * doSomeCoolStuff( (*it) ); | 16 | * doSomeCoolStuff( (*it) ); |
16 | */ | 17 | */ |
17 | template <class T> class ORecordList; | 18 | template <class T> class ORecordList; |
18 | template <class T = OPimRecord> | 19 | template <class T = OPimRecord> |
19 | class ORecordListIterator { | 20 | class ORecordListIterator { |
20 | friend class ORecordList<T>; | 21 | friend class ORecordList<T>; |
21 | public: | 22 | public: |
22 | typedef OTemplateBase<T> Base; | 23 | typedef OTemplateBase<T> Base; |
23 | 24 | ||
24 | /** | 25 | /** |
25 | * The c'tor used internally from | 26 | * The c'tor used internally from |
26 | * ORecordList | 27 | * ORecordList |
27 | */ | 28 | */ |
28 | ORecordListIterator( const QArray<int>, const Base* ); | 29 | ORecordListIterator( const QArray<int>, const Base* ); |
29 | 30 | ||
30 | /** | 31 | /** |
31 | * The standard c'tor | 32 | * The standard c'tor |
32 | */ | 33 | */ |
33 | ORecordListIterator(); | 34 | ORecordListIterator(); |
34 | ~ORecordListIterator(); | 35 | ~ORecordListIterator(); |
35 | 36 | ||
36 | ORecordListIterator( const ORecordListIterator& ); | 37 | ORecordListIterator( const ORecordListIterator& ); |
37 | ORecordListIterator &operator=(const ORecordListIterator& ); | 38 | ORecordListIterator &operator=(const ORecordListIterator& ); |
38 | 39 | ||
39 | /** | 40 | /** |
40 | * a * operator ;) | 41 | * a * operator ;) |
41 | * use it like this T = (*it); | 42 | * use it like this T = (*it); |
42 | */ | 43 | */ |
43 | T operator*(); | 44 | T operator*(); |
44 | ORecordListIterator &operator++(); | 45 | ORecordListIterator &operator++(); |
45 | ORecordListIterator &operator--(); | 46 | ORecordListIterator &operator--(); |
46 | 47 | ||
47 | bool operator==( const ORecordListIterator& it ); | 48 | bool operator==( const ORecordListIterator& it ); |
48 | bool operator!=( const ORecordListIterator& it ); | 49 | bool operator!=( const ORecordListIterator& it ); |
49 | 50 | ||
50 | /** | 51 | /** |
51 | * the current item | 52 | * the current item |
52 | */ | 53 | */ |
53 | uint current()const; | 54 | uint current()const; |
54 | 55 | ||
55 | /** | 56 | /** |
56 | * the number of items | 57 | * the number of items |
57 | */ | 58 | */ |
58 | uint count()const; | 59 | uint count()const; |
59 | 60 | ||
60 | /** | 61 | /** |
61 | * sets the current item | 62 | * sets the current item |
62 | */ | 63 | */ |
63 | void setCurrent( uint cur ); | 64 | void setCurrent( uint cur ); |
64 | 65 | ||
65 | private: | 66 | private: |
66 | QArray<int> m_uids; | 67 | QArray<int> m_uids; |
67 | uint m_current; | 68 | uint m_current; |
68 | const Base* m_temp; | 69 | const Base* m_temp; |
69 | bool m_end : 1; | 70 | bool m_end : 1; |
70 | T m_record; | 71 | T m_record; |
71 | bool m_direction :1; | 72 | bool m_direction :1; |
72 | 73 | ||
73 | /* d pointer for future versions */ | 74 | /* d pointer for future versions */ |
74 | class IteratorPrivate; | 75 | ORecordListIteratorPrivate *d; |
75 | IteratorPrivate *d; | ||
76 | }; | 76 | }; |
77 | |||
78 | class ORecordListPrivate; | ||
77 | /** | 79 | /** |
78 | * The recordlist used as a return type | 80 | * The recordlist used as a return type |
79 | * from OPimAccessTemplate | 81 | * from OPimAccessTemplate |
80 | */ | 82 | */ |
81 | template <class T = OPimRecord > | 83 | template <class T = OPimRecord > |
82 | class ORecordList { | 84 | class ORecordList { |
83 | public: | 85 | public: |
84 | typedef OTemplateBase<T> Base; | 86 | typedef OTemplateBase<T> Base; |
85 | typedef ORecordListIterator<T> Iterator; | 87 | typedef ORecordListIterator<T> Iterator; |
86 | 88 | ||
87 | /** | 89 | /** |
88 | * c'tor | 90 | * c'tor |
89 | */ | 91 | */ |
90 | ORecordList () { | 92 | ORecordList () { |
91 | } | 93 | } |
92 | ORecordList( const QArray<int>& ids, | 94 | ORecordList( const QArray<int>& ids, |
93 | const Base* ); | 95 | const Base* ); |
94 | ~ORecordList(); | 96 | ~ORecordList(); |
95 | 97 | ||
96 | /** | 98 | /** |
97 | * the first iterator | 99 | * the first iterator |
98 | */ | 100 | */ |
99 | Iterator begin(); | 101 | Iterator begin(); |
100 | 102 | ||
101 | /** | 103 | /** |
102 | * the end | 104 | * the end |
103 | */ | 105 | */ |
104 | Iterator end(); | 106 | Iterator end(); |
105 | 107 | ||
106 | /** | 108 | /** |
107 | * the number of items in the list | 109 | * the number of items in the list |
108 | */ | 110 | */ |
109 | uint count()const; | 111 | uint count()const; |
110 | 112 | ||
111 | T operator[]( uint i ); | 113 | T operator[]( uint i ); |
112 | int uidAt(uint i ); | 114 | int uidAt(uint i ); |
113 | 115 | ||
114 | /** | 116 | /** |
115 | * Remove the contact with given uid | 117 | * Remove the contact with given uid |
116 | */ | 118 | */ |
117 | bool remove( int uid ); | 119 | bool remove( int uid ); |
118 | 120 | ||
119 | /* | 121 | /* |
120 | ConstIterator begin()const; | 122 | ConstIterator begin()const; |
121 | ConstIterator end()const; | 123 | ConstIterator end()const; |
122 | */ | 124 | */ |
123 | private: | 125 | private: |
124 | QArray<int> m_ids; | 126 | QArray<int> m_ids; |
125 | const Base* m_acc; | 127 | const Base* m_acc; |
128 | ORecordListPrivate *d; | ||
126 | }; | 129 | }; |
127 | 130 | ||
128 | /* ok now implement it */ | 131 | /* ok now implement it */ |
129 | template <class T> | 132 | template <class T> |
130 | ORecordListIterator<T>::ORecordListIterator() { | 133 | ORecordListIterator<T>::ORecordListIterator() { |
131 | m_current = 0; | 134 | m_current = 0; |
132 | m_temp = 0l; | 135 | m_temp = 0l; |
133 | m_end = true; | 136 | m_end = true; |
134 | m_record = T(); | 137 | m_record = T(); |
135 | /* forward */ | 138 | /* forward */ |
136 | m_direction = TRUE; | 139 | m_direction = TRUE; |
137 | } | 140 | } |
138 | template <class T> | 141 | template <class T> |
139 | ORecordListIterator<T>::~ORecordListIterator() { | 142 | ORecordListIterator<T>::~ORecordListIterator() { |
140 | /* nothing to delete */ | 143 | /* nothing to delete */ |
141 | } | 144 | } |
142 | 145 | ||
143 | template <class T> | 146 | template <class T> |
144 | ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { | 147 | ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { |
145 | // qWarning("ORecordListIterator copy c'tor"); | 148 | // qWarning("ORecordListIterator copy c'tor"); |
146 | m_uids = it.m_uids; | 149 | m_uids = it.m_uids; |
147 | m_current = it.m_current; | 150 | m_current = it.m_current; |
148 | m_temp = it.m_temp; | 151 | m_temp = it.m_temp; |
149 | m_end = it.m_end; | 152 | m_end = it.m_end; |
150 | m_record = it.m_record; | 153 | m_record = it.m_record; |
151 | m_direction = it.m_direction; | 154 | m_direction = it.m_direction; |
152 | } | 155 | } |
153 | 156 | ||
154 | template <class T> | 157 | template <class T> |
155 | ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { | 158 | ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { |
156 | m_uids = it.m_uids; | 159 | m_uids = it.m_uids; |
157 | m_current = it.m_current; | 160 | m_current = it.m_current; |
158 | m_temp = it.m_temp; | 161 | m_temp = it.m_temp; |
159 | m_end = it.m_end; | 162 | m_end = it.m_end; |
160 | m_record = it.m_record; | 163 | m_record = it.m_record; |
161 | 164 | ||
162 | return *this; | 165 | return *this; |
163 | } | 166 | } |
164 | 167 | ||
165 | template <class T> | 168 | template <class T> |
166 | T ORecordListIterator<T>::operator*() { | 169 | T ORecordListIterator<T>::operator*() { |
167 | //qWarning("operator* %d %d", m_current, m_uids[m_current] ); | 170 | //qWarning("operator* %d %d", m_current, m_uids[m_current] ); |
168 | if (!m_end ) | 171 | if (!m_end ) |
169 | m_record = m_temp->find( m_uids[m_current], m_uids, m_current, | 172 | m_record = m_temp->find( m_uids[m_current], m_uids, m_current, |
170 | m_direction ? Base::Forward : | 173 | m_direction ? Base::Forward : |
171 | Base::Reverse ); | 174 | Base::Reverse ); |
172 | else | 175 | else |
173 | m_record = T(); | 176 | m_record = T(); |
174 | 177 | ||
175 | return m_record; | 178 | return m_record; |
176 | } | 179 | } |
177 | 180 | ||
178 | template <class T> | 181 | template <class T> |
179 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { | 182 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { |
180 | m_direction = true; | 183 | m_direction = true; |
181 | if (m_current < m_uids.count() ) { | 184 | if (m_current < m_uids.count() ) { |
182 | m_end = false; | 185 | m_end = false; |
183 | ++m_current; | 186 | ++m_current; |
184 | }else | 187 | }else |
185 | m_end = true; | 188 | m_end = true; |
186 | 189 | ||
187 | return *this; | 190 | return *this; |
188 | } | 191 | } |
189 | template <class T> | 192 | template <class T> |
190 | ORecordListIterator<T> &ORecordListIterator<T>::operator--() { | 193 | ORecordListIterator<T> &ORecordListIterator<T>::operator--() { |
191 | m_direction = false; | 194 | m_direction = false; |
192 | if ( m_current > 0 ) { | 195 | if ( m_current > 0 ) { |
193 | --m_current; | 196 | --m_current; |
194 | m_end = false; | 197 | m_end = false; |
195 | } else | 198 | } else |
196 | m_end = true; | 199 | m_end = true; |
197 | 200 | ||
198 | return *this; | 201 | return *this; |
199 | } | 202 | } |
200 | 203 | ||
201 | template <class T> | 204 | template <class T> |
202 | bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { | 205 | bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { |
203 | 206 | ||
204 | /* if both are at we're the same.... */ | 207 | /* if both are at we're the same.... */ |
205 | if ( m_end == it.m_end ) return true; | 208 | if ( m_end == it.m_end ) return true; |
206 | 209 | ||
207 | if ( m_uids != it.m_uids ) return false; | 210 | if ( m_uids != it.m_uids ) return false; |
208 | if ( m_current != it.m_current ) return false; | 211 | if ( m_current != it.m_current ) return false; |
209 | if ( m_temp != it.m_temp ) return false; | 212 | if ( m_temp != it.m_temp ) return false; |
210 | 213 | ||
211 | return true; | 214 | return true; |
212 | } | 215 | } |
213 | template <class T> | 216 | template <class T> |
214 | bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { | 217 | bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { |
215 | return !(*this == it ); | 218 | return !(*this == it ); |
216 | } | 219 | } |
217 | template <class T> | 220 | template <class T> |
218 | ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, | 221 | ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, |
219 | const Base* t ) | 222 | const Base* t ) |
220 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), | 223 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), |
221 | m_direction( false ) | 224 | m_direction( false ) |
222 | { | 225 | { |
226 | /* if the list is empty we're already at the end of the list */ | ||
227 | if (uids.count() == 0 ) | ||
228 | m_end = true; | ||
223 | } | 229 | } |
224 | template <class T> | 230 | template <class T> |
225 | uint ORecordListIterator<T>::current()const { | 231 | uint ORecordListIterator<T>::current()const { |
226 | return m_current; | 232 | return m_current; |
227 | } | 233 | } |
228 | template <class T> | 234 | template <class T> |
229 | void ORecordListIterator<T>::setCurrent( uint cur ) { | 235 | void ORecordListIterator<T>::setCurrent( uint cur ) { |
230 | if( cur < m_uids.count() ) { | 236 | if( cur < m_uids.count() ) { |
231 | m_end = false; | 237 | m_end = false; |
232 | m_current= cur; | 238 | m_current= cur; |
233 | } | 239 | } |
234 | } | 240 | } |
235 | template <class T> | 241 | template <class T> |
236 | uint ORecordListIterator<T>::count()const { | 242 | uint ORecordListIterator<T>::count()const { |
237 | return m_uids.count(); | 243 | return m_uids.count(); |
238 | } | 244 | } |
239 | template <class T> | 245 | template <class T> |
240 | ORecordList<T>::ORecordList( const QArray<int>& ids, | 246 | ORecordList<T>::ORecordList( const QArray<int>& ids, |
241 | const Base* acc ) | 247 | const Base* acc ) |
242 | : m_ids( ids ), m_acc( acc ) | 248 | : m_ids( ids ), m_acc( acc ) |
243 | { | 249 | { |
244 | } | 250 | } |
245 | template <class T> | 251 | template <class T> |
246 | ORecordList<T>::~ORecordList() { | 252 | ORecordList<T>::~ORecordList() { |
247 | /* nothing to do here */ | 253 | /* nothing to do here */ |
248 | } | 254 | } |
249 | template <class T> | 255 | template <class T> |
250 | typename ORecordList<T>::Iterator ORecordList<T>::begin() { | 256 | typename ORecordList<T>::Iterator ORecordList<T>::begin() { |
251 | Iterator it( m_ids, m_acc ); | 257 | Iterator it( m_ids, m_acc ); |
252 | return it; | 258 | return it; |
253 | } | 259 | } |
254 | template <class T> | 260 | template <class T> |
255 | typename ORecordList<T>::Iterator ORecordList<T>::end() { | 261 | typename ORecordList<T>::Iterator ORecordList<T>::end() { |
256 | Iterator it( m_ids, m_acc ); | 262 | Iterator it( m_ids, m_acc ); |
257 | it.m_end = true; | 263 | it.m_end = true; |
258 | it.m_current = m_ids.count(); | 264 | it.m_current = m_ids.count(); |
259 | 265 | ||
260 | return it; | 266 | return it; |
261 | } | 267 | } |
262 | template <class T> | 268 | template <class T> |
263 | uint ORecordList<T>::count()const { | 269 | uint ORecordList<T>::count()const { |
264 | return m_ids.count(); | 270 | return m_ids.count(); |
265 | } | 271 | } |
266 | template <class T> | 272 | template <class T> |
267 | T ORecordList<T>::operator[]( uint i ) { | 273 | T ORecordList<T>::operator[]( uint i ) { |
268 | if ( i >= m_ids.count() ) | 274 | if ( i >= m_ids.count() ) |
269 | return T(); | 275 | return T(); |
270 | /* forward */ | 276 | /* forward */ |
271 | return m_acc->find( m_ids[i], m_ids, i ); | 277 | return m_acc->find( m_ids[i], m_ids, i ); |
272 | } | 278 | } |
273 | template <class T> | 279 | template <class T> |
274 | int ORecordList<T>::uidAt( uint i ) { | 280 | int ORecordList<T>::uidAt( uint i ) { |
275 | return m_ids[i]; | 281 | return m_ids[i]; |
276 | } | 282 | } |
277 | 283 | ||
278 | template <class T> | 284 | template <class T> |
279 | bool ORecordList<T>::remove( int uid ) { | 285 | bool ORecordList<T>::remove( int uid ) { |
280 | QArray<int> copy( m_ids.count() ); | 286 | QArray<int> copy( m_ids.count() ); |
281 | int counter = 0; | 287 | int counter = 0; |
282 | bool ret_val = false; | 288 | bool ret_val = false; |
283 | 289 | ||
284 | for (uint i = 0; i < m_ids.count(); i++){ | 290 | for (uint i = 0; i < m_ids.count(); i++){ |
285 | if ( m_ids[i] != uid ){ | 291 | if ( m_ids[i] != uid ){ |
286 | copy[counter++] = m_ids[i]; | 292 | copy[counter++] = m_ids[i]; |
287 | 293 | ||
288 | }else | 294 | }else |
289 | ret_val = true; | 295 | ret_val = true; |
290 | } | 296 | } |
291 | 297 | ||
292 | copy.resize( counter ); | 298 | copy.resize( counter ); |
293 | m_ids = copy; | 299 | m_ids = copy; |
294 | 300 | ||
295 | 301 | ||
296 | return ret_val; | 302 | return ret_val; |
297 | } | 303 | } |
298 | 304 | ||
299 | 305 | ||
300 | #endif | 306 | #endif |
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp index 38b93f7..5a18c37 100644 --- a/libopie2/opiepim/otodo.cpp +++ b/libopie2/opiepim/otodo.cpp | |||
@@ -1,126 +1,131 @@ | |||
1 | 1 | ||
2 | #include <qobject.h> | 2 | #include <qobject.h> |
3 | #include <qshared.h> | 3 | #include <qshared.h> |
4 | 4 | ||
5 | 5 | ||
6 | 6 | ||
7 | #include <qpe/palmtopuidgen.h> | 7 | #include <qpe/palmtopuidgen.h> |
8 | #include <qpe/stringutil.h> | 8 | #include <qpe/stringutil.h> |
9 | #include <qpe/palmtoprecord.h> | 9 | #include <qpe/palmtoprecord.h> |
10 | #include <qpe/stringutil.h> | 10 | #include <qpe/stringutil.h> |
11 | #include <qpe/categories.h> | 11 | #include <qpe/categories.h> |
12 | #include <qpe/categoryselect.h> | 12 | #include <qpe/categoryselect.h> |
13 | 13 | ||
14 | 14 | ||
15 | #include "opimstate.h" | 15 | #include "opimstate.h" |
16 | #include "orecur.h" | 16 | #include "orecur.h" |
17 | #include "opimmaintainer.h" | 17 | #include "opimmaintainer.h" |
18 | #include "opimnotifymanager.h" | 18 | #include "opimnotifymanager.h" |
19 | #include "opimresolver.h" | 19 | #include "opimresolver.h" |
20 | 20 | ||
21 | #include "otodo.h" | 21 | #include "otodo.h" |
22 | 22 | ||
23 | 23 | ||
24 | struct OTodo::OTodoData : public QShared { | 24 | struct OTodo::OTodoData : public QShared { |
25 | OTodoData() : QShared() { | 25 | OTodoData() : QShared() { |
26 | recur = 0; | 26 | recur = 0; |
27 | state = 0; | 27 | state = 0; |
28 | maintainer = 0; | 28 | maintainer = 0; |
29 | notifiers = 0; | 29 | notifiers = 0; |
30 | }; | 30 | }; |
31 | ~OTodoData() { | ||
32 | delete recur; | ||
33 | delete maintainer; | ||
34 | delete notifiers; | ||
35 | } | ||
31 | 36 | ||
32 | QDate date; | 37 | QDate date; |
33 | bool isCompleted:1; | 38 | bool isCompleted:1; |
34 | bool hasDate:1; | 39 | bool hasDate:1; |
35 | int priority; | 40 | int priority; |
36 | QString desc; | 41 | QString desc; |
37 | QString sum; | 42 | QString sum; |
38 | QMap<QString, QString> extra; | 43 | QMap<QString, QString> extra; |
39 | ushort prog; | 44 | ushort prog; |
40 | OPimState *state; | 45 | OPimState *state; |
41 | ORecur *recur; | 46 | ORecur *recur; |
42 | OPimMaintainer *maintainer; | 47 | OPimMaintainer *maintainer; |
43 | QDate start; | 48 | QDate start; |
44 | QDate completed; | 49 | QDate completed; |
45 | OPimNotifyManager *notifiers; | 50 | OPimNotifyManager *notifiers; |
46 | }; | 51 | }; |
47 | 52 | ||
48 | OTodo::OTodo(const OTodo &event ) | 53 | OTodo::OTodo(const OTodo &event ) |
49 | : OPimRecord( event ), data( event.data ) | 54 | : OPimRecord( event ), data( event.data ) |
50 | { | 55 | { |
51 | data->ref(); | 56 | data->ref(); |
52 | // qWarning("ref up"); | 57 | // qWarning("ref up"); |
53 | } | 58 | } |
54 | OTodo::~OTodo() { | 59 | OTodo::~OTodo() { |
55 | 60 | ||
56 | // qWarning("~OTodo " ); | 61 | // qWarning("~OTodo " ); |
57 | if ( data->deref() ) { | 62 | if ( data->deref() ) { |
58 | // qWarning("OTodo::dereffing"); | 63 | // qWarning("OTodo::dereffing"); |
59 | delete data; | 64 | delete data; |
60 | data = 0l; | 65 | data = 0l; |
61 | } | 66 | } |
62 | } | 67 | } |
63 | OTodo::OTodo(bool completed, int priority, | 68 | OTodo::OTodo(bool completed, int priority, |
64 | const QArray<int> &category, | 69 | const QArray<int> &category, |
65 | const QString& summary, | 70 | const QString& summary, |
66 | const QString &description, | 71 | const QString &description, |
67 | ushort progress, | 72 | ushort progress, |
68 | bool hasDate, QDate date, int uid ) | 73 | bool hasDate, QDate date, int uid ) |
69 | : OPimRecord( uid ) | 74 | : OPimRecord( uid ) |
70 | { | 75 | { |
71 | // qWarning("OTodoData " + summary); | 76 | // qWarning("OTodoData " + summary); |
72 | setCategories( category ); | 77 | setCategories( category ); |
73 | 78 | ||
74 | data = new OTodoData; | 79 | data = new OTodoData; |
75 | 80 | ||
76 | data->date = date; | 81 | data->date = date; |
77 | data->isCompleted = completed; | 82 | data->isCompleted = completed; |
78 | data->hasDate = hasDate; | 83 | data->hasDate = hasDate; |
79 | data->priority = priority; | 84 | data->priority = priority; |
80 | data->sum = summary; | 85 | data->sum = summary; |
81 | data->prog = progress; | 86 | data->prog = progress; |
82 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 87 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
83 | } | 88 | } |
84 | OTodo::OTodo(bool completed, int priority, | 89 | OTodo::OTodo(bool completed, int priority, |
85 | const QStringList &category, | 90 | const QStringList &category, |
86 | const QString& summary, | 91 | const QString& summary, |
87 | const QString &description, | 92 | const QString &description, |
88 | ushort progress, | 93 | ushort progress, |
89 | bool hasDate, QDate date, int uid ) | 94 | bool hasDate, QDate date, int uid ) |
90 | : OPimRecord( uid ) | 95 | : OPimRecord( uid ) |
91 | { | 96 | { |
92 | // qWarning("OTodoData" + summary); | 97 | // qWarning("OTodoData" + summary); |
93 | setCategories( idsFromString( category.join(";") ) ); | 98 | setCategories( idsFromString( category.join(";") ) ); |
94 | 99 | ||
95 | data = new OTodoData; | 100 | data = new OTodoData; |
96 | 101 | ||
97 | data->date = date; | 102 | data->date = date; |
98 | data->isCompleted = completed; | 103 | data->isCompleted = completed; |
99 | data->hasDate = hasDate; | 104 | data->hasDate = hasDate; |
100 | data->priority = priority; | 105 | data->priority = priority; |
101 | data->sum = summary; | 106 | data->sum = summary; |
102 | data->prog = progress; | 107 | data->prog = progress; |
103 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 108 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
104 | } | 109 | } |
105 | bool OTodo::match( const QRegExp ®Exp )const | 110 | bool OTodo::match( const QRegExp ®Exp )const |
106 | { | 111 | { |
107 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 112 | if( QString::number( data->priority ).find( regExp ) != -1 ){ |
108 | setLastHitField( Priority ); | 113 | setLastHitField( Priority ); |
109 | return true; | 114 | return true; |
110 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ | 115 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ |
111 | setLastHitField( HasDate ); | 116 | setLastHitField( HasDate ); |
112 | return true; | 117 | return true; |
113 | }else if(data->desc.find( regExp ) != -1 ){ | 118 | }else if(data->desc.find( regExp ) != -1 ){ |
114 | setLastHitField( Description ); | 119 | setLastHitField( Description ); |
115 | return true; | 120 | return true; |
116 | }else if(data->sum.find( regExp ) != -1 ) { | 121 | }else if(data->sum.find( regExp ) != -1 ) { |
117 | setLastHitField( Summary ); | 122 | setLastHitField( Summary ); |
118 | return true; | 123 | return true; |
119 | } | 124 | } |
120 | return false; | 125 | return false; |
121 | } | 126 | } |
122 | bool OTodo::isCompleted() const | 127 | bool OTodo::isCompleted() const |
123 | { | 128 | { |
124 | return data->isCompleted; | 129 | return data->isCompleted; |
125 | } | 130 | } |
126 | bool OTodo::hasDueDate() const | 131 | bool OTodo::hasDueDate() const |
@@ -181,210 +186,209 @@ ORecur OTodo::recurrence()const { | |||
181 | return (*data->recur); | 186 | return (*data->recur); |
182 | } | 187 | } |
183 | bool OTodo::hasMaintainer()const { | 188 | bool OTodo::hasMaintainer()const { |
184 | if (!data->maintainer) return false; | 189 | if (!data->maintainer) return false; |
185 | 190 | ||
186 | return (data->maintainer->mode() != OPimMaintainer::Undefined ); | 191 | return (data->maintainer->mode() != OPimMaintainer::Undefined ); |
187 | } | 192 | } |
188 | OPimMaintainer OTodo::maintainer()const { | 193 | OPimMaintainer OTodo::maintainer()const { |
189 | if (!data->maintainer) return OPimMaintainer(); | 194 | if (!data->maintainer) return OPimMaintainer(); |
190 | 195 | ||
191 | return (*data->maintainer); | 196 | return (*data->maintainer); |
192 | } | 197 | } |
193 | void OTodo::setCompleted( bool completed ) | 198 | void OTodo::setCompleted( bool completed ) |
194 | { | 199 | { |
195 | changeOrModify(); | 200 | changeOrModify(); |
196 | data->isCompleted = completed; | 201 | data->isCompleted = completed; |
197 | } | 202 | } |
198 | void OTodo::setHasDueDate( bool hasDate ) | 203 | void OTodo::setHasDueDate( bool hasDate ) |
199 | { | 204 | { |
200 | changeOrModify(); | 205 | changeOrModify(); |
201 | data->hasDate = hasDate; | 206 | data->hasDate = hasDate; |
202 | } | 207 | } |
203 | void OTodo::setDescription(const QString &desc ) | 208 | void OTodo::setDescription(const QString &desc ) |
204 | { | 209 | { |
205 | // qWarning( "desc " + desc ); | 210 | // qWarning( "desc " + desc ); |
206 | changeOrModify(); | 211 | changeOrModify(); |
207 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); | 212 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); |
208 | } | 213 | } |
209 | void OTodo::setSummary( const QString& sum ) | 214 | void OTodo::setSummary( const QString& sum ) |
210 | { | 215 | { |
211 | changeOrModify(); | 216 | changeOrModify(); |
212 | data->sum = sum; | 217 | data->sum = sum; |
213 | } | 218 | } |
214 | void OTodo::setPriority(int prio ) | 219 | void OTodo::setPriority(int prio ) |
215 | { | 220 | { |
216 | changeOrModify(); | 221 | changeOrModify(); |
217 | data->priority = prio; | 222 | data->priority = prio; |
218 | } | 223 | } |
219 | void OTodo::setDueDate( const QDate& date ) | 224 | void OTodo::setDueDate( const QDate& date ) |
220 | { | 225 | { |
221 | changeOrModify(); | 226 | changeOrModify(); |
222 | data->date = date; | 227 | data->date = date; |
223 | } | 228 | } |
224 | void OTodo::setStartDate( const QDate& date ) { | 229 | void OTodo::setStartDate( const QDate& date ) { |
225 | changeOrModify(); | 230 | changeOrModify(); |
226 | data->start = date; | 231 | data->start = date; |
227 | } | 232 | } |
228 | void OTodo::setCompletedDate( const QDate& date ) { | 233 | void OTodo::setCompletedDate( const QDate& date ) { |
229 | changeOrModify(); | 234 | changeOrModify(); |
230 | data->completed = date; | 235 | data->completed = date; |
231 | } | 236 | } |
232 | void OTodo::setState( const OPimState& state ) { | 237 | void OTodo::setState( const OPimState& state ) { |
233 | changeOrModify(); | 238 | changeOrModify(); |
234 | if (data->state ) | 239 | if (data->state ) |
235 | (*data->state) = state; | 240 | (*data->state) = state; |
236 | else | 241 | else |
237 | data->state = new OPimState( state ); | 242 | data->state = new OPimState( state ); |
238 | } | 243 | } |
239 | void OTodo::setRecurrence( const ORecur& rec) { | 244 | void OTodo::setRecurrence( const ORecur& rec) { |
240 | changeOrModify(); | 245 | changeOrModify(); |
241 | if (data->recur ) | 246 | if (data->recur ) |
242 | (*data->recur) = rec; | 247 | (*data->recur) = rec; |
243 | else | 248 | else |
244 | data->recur = new ORecur( rec ); | 249 | data->recur = new ORecur( rec ); |
245 | } | 250 | } |
246 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { | 251 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { |
247 | changeOrModify(); | 252 | changeOrModify(); |
248 | 253 | ||
249 | if (data->maintainer ) | 254 | if (data->maintainer ) |
250 | (*data->maintainer) = pim; | 255 | (*data->maintainer) = pim; |
251 | else | 256 | else |
252 | data->maintainer = new OPimMaintainer( pim ); | 257 | data->maintainer = new OPimMaintainer( pim ); |
253 | } | 258 | } |
254 | bool OTodo::isOverdue( ) | 259 | bool OTodo::isOverdue( ) |
255 | { | 260 | { |
256 | if( data->hasDate && !data->isCompleted) | 261 | if( data->hasDate && !data->isCompleted) |
257 | return QDate::currentDate() > data->date; | 262 | return QDate::currentDate() > data->date; |
258 | return false; | 263 | return false; |
259 | } | 264 | } |
260 | void OTodo::setProgress(ushort progress ) | 265 | void OTodo::setProgress(ushort progress ) |
261 | { | 266 | { |
262 | changeOrModify(); | 267 | changeOrModify(); |
263 | data->prog = progress; | 268 | data->prog = progress; |
264 | } | 269 | } |
265 | QString OTodo::toShortText() const { | 270 | QString OTodo::toShortText() const { |
266 | return summary(); | 271 | return summary(); |
267 | } | 272 | } |
268 | /*! | 273 | /*! |
269 | Returns a richt text string | 274 | Returns a richt text string |
270 | */ | 275 | */ |
271 | QString OTodo::toRichText() const | 276 | QString OTodo::toRichText() const |
272 | { | 277 | { |
273 | QString text; | 278 | QString text; |
274 | QStringList catlist; | 279 | QStringList catlist; |
275 | 280 | ||
276 | // summary | 281 | // summary |
277 | text += "<b><h3><img src=\"todo/TodoList\">"; | 282 | text += "<b><h3><img src=\"todo/TodoList\"> "; |
278 | if ( !summary().isEmpty() ) { | 283 | if ( !summary().isEmpty() ) { |
279 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); | 284 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); |
280 | } | 285 | } |
281 | text += "</h3></b><br><hr><br>"; | 286 | text += "</h3></b><br><hr><br>"; |
282 | 287 | ||
283 | // description | 288 | // description |
284 | if( !description().isEmpty() ){ | 289 | if( !description().isEmpty() ){ |
285 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 290 | text += "<b>" + QObject::tr( "Notes:" ) + "</b><br>"; |
286 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; | 291 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
287 | } | 292 | } |
288 | 293 | ||
289 | // priority | 294 | // priority |
290 | int priorityval = priority(); | 295 | int priorityval = priority(); |
291 | text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" + | 296 | text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" + |
292 | QString::number( priorityval ) + "\">"; | 297 | QString::number( priorityval ) + "\"> "; |
293 | // text += "<b>" + QObject::tr( "Priority:") +"</b><img src=\"todo/priority" + | 298 | |
294 | // QString::number( priority() ) + "\"><br>"; | ||
295 | switch ( priorityval ) | 299 | switch ( priorityval ) |
296 | { | 300 | { |
297 | case 1 : text += QObject::tr( "Very high" ); | 301 | case 1 : text += QObject::tr( "Very high" ); |
298 | break; | 302 | break; |
299 | case 2 : text += QObject::tr( "High" ); | 303 | case 2 : text += QObject::tr( "High" ); |
300 | break; | 304 | break; |
301 | case 3 : text += QObject::tr( "Normal" ); | 305 | case 3 : text += QObject::tr( "Normal" ); |
302 | break; | 306 | break; |
303 | case 4 : text += QObject::tr( "Low" ); | 307 | case 4 : text += QObject::tr( "Low" ); |
304 | break; | 308 | break; |
305 | case 5 : text += QObject::tr( "Very low" ); | 309 | case 5 : text += QObject::tr( "Very low" ); |
306 | break; | 310 | break; |
307 | }; | 311 | }; |
308 | text += "<br>"; | 312 | text += "<br>"; |
309 | 313 | ||
310 | // progress | 314 | // progress |
311 | text += "<b>" + QObject::tr( "Progress:") + " </b>" | 315 | text += "<b>" + QObject::tr( "Progress:") + " </b>" |
312 | + QString::number( progress() ) + " %<br>"; | 316 | + QString::number( progress() ) + " %<br>"; |
313 | 317 | ||
314 | // due date | 318 | // due date |
315 | if (hasDueDate() ){ | 319 | if (hasDueDate() ){ |
316 | QDate dd = dueDate(); | 320 | QDate dd = dueDate(); |
317 | int off = QDate::currentDate().daysTo( dd ); | 321 | int off = QDate::currentDate().daysTo( dd ); |
318 | 322 | ||
319 | text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; | 323 | text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; |
320 | if ( off < 0 ) | 324 | if ( off < 0 ) |
321 | text += "#FF0000"; | 325 | text += "#FF0000"; |
322 | else if ( off == 0 ) | 326 | else if ( off == 0 ) |
323 | text += "#FFFF00"; | 327 | text += "#FFFF00"; |
324 | else if ( off > 0 ) | 328 | else if ( off > 0 ) |
325 | text += "#00FF00"; | 329 | text += "#00FF00"; |
326 | 330 | ||
327 | text += "\">" + dd.toString() + "</font><br>"; | 331 | text += "\">" + dd.toString() + "</font><br>"; |
328 | } | 332 | } |
329 | 333 | ||
330 | // categories | 334 | // categories |
331 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 335 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
332 | text += categoryNames( "Todo List" ).join(", "); | 336 | text += categoryNames( "Todo List" ).join(", "); |
333 | text += "<br>"; | 337 | text += "<br>"; |
334 | 338 | ||
335 | return text; | 339 | return text; |
336 | } | 340 | } |
337 | bool OTodo::hasNotifiers()const { | 341 | bool OTodo::hasNotifiers()const { |
338 | if (!data->notifiers) return false; | 342 | if (!data->notifiers) return false; |
339 | return !data->notifiers->isEmpty(); | 343 | return !data->notifiers->isEmpty(); |
340 | } | 344 | } |
341 | OPimNotifyManager& OTodo::notifiers() { | 345 | OPimNotifyManager& OTodo::notifiers() { |
342 | if (!data->notifiers ) | 346 | if (!data->notifiers ) |
343 | data->notifiers = new OPimNotifyManager; | 347 | data->notifiers = new OPimNotifyManager; |
344 | return (*data->notifiers); | 348 | return (*data->notifiers); |
345 | } | 349 | } |
346 | const OPimNotifyManager& OTodo::notifiers()const{ | 350 | const OPimNotifyManager& OTodo::notifiers()const{ |
347 | if (!data->notifiers ) | 351 | if (!data->notifiers ) |
348 | data->notifiers = new OPimNotifyManager; | 352 | data->notifiers = new OPimNotifyManager; |
349 | 353 | ||
350 | return (*data->notifiers); | 354 | return (*data->notifiers); |
351 | } | 355 | } |
352 | 356 | ||
353 | bool OTodo::operator<( const OTodo &toDoEvent )const{ | 357 | bool OTodo::operator<( const OTodo &toDoEvent )const{ |
354 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 358 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
355 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 359 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
356 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 360 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
357 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 361 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
358 | return priority() < toDoEvent.priority(); | 362 | return priority() < toDoEvent.priority(); |
359 | }else{ | 363 | }else{ |
360 | return dueDate() < toDoEvent.dueDate(); | 364 | return dueDate() < toDoEvent.dueDate(); |
361 | } | 365 | } |
362 | } | 366 | } |
363 | return false; | 367 | return false; |
364 | } | 368 | } |
365 | bool OTodo::operator<=(const OTodo &toDoEvent )const | 369 | bool OTodo::operator<=(const OTodo &toDoEvent )const |
366 | { | 370 | { |
367 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 371 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
368 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; | 372 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; |
369 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 373 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
370 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 374 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
371 | return priority() <= toDoEvent.priority(); | 375 | return priority() <= toDoEvent.priority(); |
372 | }else{ | 376 | }else{ |
373 | return dueDate() <= toDoEvent.dueDate(); | 377 | return dueDate() <= toDoEvent.dueDate(); |
374 | } | 378 | } |
375 | } | 379 | } |
376 | return true; | 380 | return true; |
377 | } | 381 | } |
378 | bool OTodo::operator>(const OTodo &toDoEvent )const | 382 | bool OTodo::operator>(const OTodo &toDoEvent )const |
379 | { | 383 | { |
380 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; | 384 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; |
381 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 385 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
382 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 386 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
383 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 387 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
384 | return priority() > toDoEvent.priority(); | 388 | return priority() > toDoEvent.priority(); |
385 | }else{ | 389 | }else{ |
386 | return dueDate() > toDoEvent.dueDate(); | 390 | return dueDate() > toDoEvent.dueDate(); |
387 | } | 391 | } |
388 | } | 392 | } |
389 | return false; | 393 | return false; |
390 | } | 394 | } |
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/otodo.h index f9a345a..6df98b9 100644 --- a/libopie2/opiepim/otodo.h +++ b/libopie2/opiepim/otodo.h | |||
@@ -5,290 +5,281 @@ | |||
5 | 5 | ||
6 | #include <qarray.h> | 6 | #include <qarray.h> |
7 | #include <qmap.h> | 7 | #include <qmap.h> |
8 | #include <qregexp.h> | 8 | #include <qregexp.h> |
9 | #include <qstringlist.h> | 9 | #include <qstringlist.h> |
10 | #include <qdatetime.h> | 10 | #include <qdatetime.h> |
11 | #include <qvaluelist.h> | 11 | #include <qvaluelist.h> |
12 | 12 | ||
13 | #include <qpe/recordfields.h> | 13 | #include <qpe/recordfields.h> |
14 | #include <qpe/palmtopuidgen.h> | 14 | #include <qpe/palmtopuidgen.h> |
15 | 15 | ||
16 | #include <opie/opimrecord.h> | 16 | #include <opie/opimrecord.h> |
17 | 17 | ||
18 | 18 | ||
19 | class OPimState; | 19 | class OPimState; |
20 | class ORecur; | 20 | class ORecur; |
21 | class OPimMaintainer; | 21 | class OPimMaintainer; |
22 | class OPimNotifyManager; | 22 | class OPimNotifyManager; |
23 | class OTodo : public OPimRecord { | 23 | class OTodo : public OPimRecord { |
24 | public: | 24 | public: |
25 | typedef QValueList<OTodo> ValueList; | 25 | typedef QValueList<OTodo> ValueList; |
26 | enum RecordFields { | 26 | enum RecordFields { |
27 | Uid = Qtopia::UID_ID, | 27 | Uid = Qtopia::UID_ID, |
28 | Category = Qtopia::CATEGORY_ID, | 28 | Category = Qtopia::CATEGORY_ID, |
29 | HasDate, | 29 | HasDate, |
30 | Completed, | 30 | Completed, |
31 | Description, | 31 | Description, |
32 | Summary, | 32 | Summary, |
33 | Priority, | 33 | Priority, |
34 | DateDay, | 34 | DateDay, |
35 | DateMonth, | 35 | DateMonth, |
36 | DateYear, | 36 | DateYear, |
37 | Progress, | 37 | Progress, |
38 | CrossReference, | 38 | CrossReference, |
39 | State, | 39 | State, |
40 | Recurrence, | 40 | Recurrence, |
41 | Alarms, | 41 | Alarms, |
42 | Reminders, | 42 | Reminders, |
43 | Notifiers, | 43 | Notifiers, |
44 | Maintainer, | 44 | Maintainer, |
45 | StartDate, | 45 | StartDate, |
46 | CompletedDate | 46 | CompletedDate |
47 | }; | 47 | }; |
48 | public: | 48 | public: |
49 | // priorities from Very low to very high | 49 | // priorities from Very low to very high |
50 | enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; | 50 | enum TaskPriority { VeryHigh=1, High, Normal, Low, VeryLow }; |
51 | 51 | ||
52 | /* Constructs a new ToDoEvent | 52 | /* Constructs a new ToDoEvent |
53 | @param completed Is the TodoEvent completed | 53 | @param completed Is the TodoEvent completed |
54 | @param priority What is the priority of this ToDoEvent | 54 | @param priority What is the priority of this ToDoEvent |
55 | @param category Which category does it belong( uid ) | 55 | @param category Which category does it belong( uid ) |
56 | @param summary A small summary of the todo | 56 | @param summary A small summary of the todo |
57 | @param description What is this ToDoEvent about | 57 | @param description What is this ToDoEvent about |
58 | @param hasDate Does this Event got a deadline | 58 | @param hasDate Does this Event got a deadline |
59 | @param date what is the deadline? | 59 | @param date what is the deadline? |
60 | @param uid what is the UUID of this Event | 60 | @param uid what is the UUID of this Event |
61 | **/ | 61 | **/ |
62 | OTodo( bool completed = false, int priority = Normal, | 62 | OTodo( bool completed = false, int priority = Normal, |
63 | const QStringList &category = QStringList(), | 63 | const QStringList &category = QStringList(), |
64 | const QString &summary = QString::null , | 64 | const QString &summary = QString::null , |
65 | const QString &description = QString::null, | 65 | const QString &description = QString::null, |
66 | ushort progress = 0, | 66 | ushort progress = 0, |
67 | bool hasDate = false, QDate date = QDate::currentDate(), | 67 | bool hasDate = false, QDate date = QDate::currentDate(), |
68 | int uid = 0 /*empty*/ ); | 68 | int uid = 0 /*empty*/ ); |
69 | 69 | ||
70 | OTodo( bool completed, int priority, | 70 | OTodo( bool completed, int priority, |
71 | const QArray<int>& category, | 71 | const QArray<int>& category, |
72 | const QString& summary = QString::null, | 72 | const QString& summary = QString::null, |
73 | const QString& description = QString::null, | 73 | const QString& description = QString::null, |
74 | ushort progress = 0, | 74 | ushort progress = 0, |
75 | bool hasDate = false, QDate date = QDate::currentDate(), | 75 | bool hasDate = false, QDate date = QDate::currentDate(), |
76 | int uid = 0 /* empty */ ); | 76 | int uid = 0 /* empty */ ); |
77 | 77 | ||
78 | /** Copy c'tor | 78 | /** Copy c'tor |
79 | * | 79 | * |
80 | */ | 80 | */ |
81 | OTodo(const OTodo & ); | 81 | OTodo(const OTodo & ); |
82 | 82 | ||
83 | /** | 83 | /** |
84 | *destructor | 84 | *destructor |
85 | */ | 85 | */ |
86 | ~OTodo(); | 86 | ~OTodo(); |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Is this event completed? | 89 | * Is this event completed? |
90 | */ | 90 | */ |
91 | bool isCompleted() const; | 91 | bool isCompleted() const; |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Does this Event have a deadline | 94 | * Does this Event have a deadline |
95 | */ | 95 | */ |
96 | bool hasDueDate() const; | 96 | bool hasDueDate() const; |
97 | bool hasStartDate()const; | 97 | bool hasStartDate()const; |
98 | bool hasCompletedDate()const; | 98 | bool hasCompletedDate()const; |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Does this Event has an alarm time ? | ||
102 | */ | ||
103 | bool hasAlarmDateTime() const; | ||
104 | |||
105 | /** | ||
106 | * What is the priority? | 101 | * What is the priority? |
107 | */ | 102 | */ |
108 | int priority()const ; | 103 | int priority()const ; |
109 | 104 | ||
110 | /** | 105 | /** |
111 | * progress as ushort 0, 20, 40, 60, 80 or 100% | 106 | * progress as ushort 0, 20, 40, 60, 80 or 100% |
112 | */ | 107 | */ |
113 | ushort progress() const; | 108 | ushort progress() const; |
114 | 109 | ||
115 | /** | 110 | /** |
116 | * The due Date | 111 | * The due Date |
117 | */ | 112 | */ |
118 | QDate dueDate()const; | 113 | QDate dueDate()const; |
119 | 114 | ||
120 | /** | 115 | /** |
121 | * When did it start? | 116 | * When did it start? |
122 | */ | 117 | */ |
123 | QDate startDate()const; | 118 | QDate startDate()const; |
124 | 119 | ||
125 | /** | 120 | /** |
126 | * When was it completed? | 121 | * When was it completed? |
127 | */ | 122 | */ |
128 | QDate completedDate()const; | 123 | QDate completedDate()const; |
129 | 124 | ||
130 | /** | 125 | /** |
131 | * does it have a state? | 126 | * does it have a state? |
132 | */ | 127 | */ |
133 | bool hasState()const; | 128 | bool hasState()const; |
134 | 129 | ||
135 | /** | 130 | /** |
136 | * What is the state of this OTodo? | 131 | * What is the state of this OTodo? |
137 | */ | 132 | */ |
138 | OPimState state()const; | 133 | OPimState state()const; |
139 | 134 | ||
140 | /** | 135 | /** |
141 | * has recurrence? | 136 | * has recurrence? |
142 | */ | 137 | */ |
143 | bool hasRecurrence()const; | 138 | bool hasRecurrence()const; |
144 | 139 | ||
145 | /** | 140 | /** |
146 | * the recurrance of this | 141 | * the recurrance of this |
147 | */ | 142 | */ |
148 | ORecur recurrence()const; | 143 | ORecur recurrence()const; |
149 | 144 | ||
150 | /** | 145 | /** |
151 | * does this OTodo have a maintainer? | 146 | * does this OTodo have a maintainer? |
152 | */ | 147 | */ |
153 | bool hasMaintainer()const; | 148 | bool hasMaintainer()const; |
154 | 149 | ||
155 | /** | 150 | /** |
156 | * the Maintainer of this OTodo | 151 | * the Maintainer of this OTodo |
157 | */ | 152 | */ |
158 | OPimMaintainer maintainer()const; | 153 | OPimMaintainer maintainer()const; |
159 | 154 | ||
160 | /** | 155 | /** |
161 | * The description of the todo | 156 | * The description of the todo |
162 | */ | 157 | */ |
163 | QString description()const; | 158 | QString description()const; |
164 | 159 | ||
165 | /** | 160 | /** |
166 | * A small summary of the todo | 161 | * A small summary of the todo |
167 | */ | 162 | */ |
168 | QString summary() const; | 163 | QString summary() const; |
169 | 164 | ||
170 | /** | 165 | /** |
171 | * @reimplemented | 166 | * @reimplemented |
172 | * Return this todoevent in a RichText formatted QString | 167 | * Return this todoevent in a RichText formatted QString |
173 | */ | 168 | */ |
174 | QString toRichText() const; | 169 | QString toRichText() const; |
175 | 170 | ||
176 | bool hasNotifiers()const; | 171 | bool hasNotifiers()const; |
177 | /* | 172 | /* |
178 | * FIXME check if the sharing is still fine!! -zecke | 173 | * FIXME check if the sharing is still fine!! -zecke |
179 | * ### CHECK If API is fine | 174 | * ### CHECK If API is fine |
180 | */ | 175 | */ |
181 | /** | 176 | /** |
182 | * return a reference to our notifiers... | 177 | * return a reference to our notifiers... |
183 | */ | 178 | */ |
184 | OPimNotifyManager ¬ifiers(); | 179 | OPimNotifyManager ¬ifiers(); |
185 | 180 | ||
186 | /** | 181 | /** |
187 | * | 182 | * |
188 | */ | 183 | */ |
189 | const OPimNotifyManager ¬ifiers()const; | 184 | const OPimNotifyManager ¬ifiers()const; |
190 | 185 | ||
191 | /** | 186 | /** |
192 | * reimplementations | 187 | * reimplementations |
193 | */ | 188 | */ |
194 | QString type()const; | 189 | QString type()const; |
195 | QString toShortText()const; | 190 | QString toShortText()const; |
196 | QString recordField(int id )const; | 191 | QString recordField(int id )const; |
197 | 192 | ||
198 | /** | 193 | /** |
199 | * toMap puts all data into the map. int relates | 194 | * toMap puts all data into the map. int relates |
200 | * to ToDoEvent RecordFields enum | 195 | * to ToDoEvent RecordFields enum |
201 | */ | 196 | */ |
202 | QMap<int, QString> toMap()const; | 197 | QMap<int, QString> toMap()const; |
203 | 198 | ||
204 | /** | 199 | /** |
205 | * Set if this Todo is completed | 200 | * Set if this Todo is completed |
206 | */ | 201 | */ |
207 | void setCompleted(bool completed ); | 202 | void setCompleted(bool completed ); |
208 | 203 | ||
209 | /** | 204 | /** |
210 | * set if this todo got an end data | 205 | * set if this todo got an end data |
211 | */ | 206 | */ |
212 | void setHasDueDate( bool hasDate ); | 207 | void setHasDueDate( bool hasDate ); |
213 | // FIXME we do not have these for start, completed | 208 | // FIXME we do not have these for start, completed |
214 | // cause we'll use the isNull() of QDate for figuring | 209 | // cause we'll use the isNull() of QDate for figuring |
215 | // out if it's has a date... | 210 | // out if it's has a date... |
216 | // decide what to do here? -zecke | 211 | // decide what to do here? -zecke |
217 | 212 | ||
218 | /** | 213 | /** |
219 | * Set the priority of the Todo | 214 | * Set the priority of the Todo |
220 | */ | 215 | */ |
221 | void setPriority(int priority ); | 216 | void setPriority(int priority ); |
222 | 217 | ||
223 | /** | 218 | /** |
224 | * Set the progress. | 219 | * Set the progress. |
225 | */ | 220 | */ |
226 | void setProgress( ushort progress ); | 221 | void setProgress( ushort progress ); |
227 | 222 | ||
228 | /** | 223 | /** |
229 | * set the end date | 224 | * set the end date |
230 | */ | 225 | */ |
231 | void setDueDate( const QDate& date ); | 226 | void setDueDate( const QDate& date ); |
232 | 227 | ||
233 | /** | 228 | /** |
234 | * set the start date | 229 | * set the start date |
235 | */ | 230 | */ |
236 | void setStartDate( const QDate& date ); | 231 | void setStartDate( const QDate& date ); |
237 | 232 | ||
238 | /** | 233 | /** |
239 | * set the completed date | 234 | * set the completed date |
240 | */ | 235 | */ |
241 | void setCompletedDate( const QDate& date ); | 236 | void setCompletedDate( const QDate& date ); |
242 | 237 | ||
243 | void setRecurrence( const ORecur& ); | 238 | void setRecurrence( const ORecur& ); |
244 | /** | ||
245 | * set the alarm time | ||
246 | */ | ||
247 | void setAlarmDateTime ( const QDateTime& alarm ); | ||
248 | 239 | ||
249 | void setDescription(const QString& ); | 240 | void setDescription(const QString& ); |
250 | void setSummary(const QString& ); | 241 | void setSummary(const QString& ); |
251 | 242 | ||
252 | /** | 243 | /** |
253 | * set the state of a Todo | 244 | * set the state of a Todo |
254 | * @param state State what the todo should take | 245 | * @param state State what the todo should take |
255 | */ | 246 | */ |
256 | void setState( const OPimState& state); | 247 | void setState( const OPimState& state); |
257 | 248 | ||
258 | /** | 249 | /** |
259 | * set the Maintainer Mode | 250 | * set the Maintainer Mode |
260 | */ | 251 | */ |
261 | void setMaintainer( const OPimMaintainer& ); | 252 | void setMaintainer( const OPimMaintainer& ); |
262 | 253 | ||
263 | bool isOverdue(); | 254 | bool isOverdue(); |
264 | 255 | ||
265 | 256 | ||
266 | virtual bool match( const QRegExp &r )const; | 257 | virtual bool match( const QRegExp &r )const; |
267 | 258 | ||
268 | bool operator<(const OTodo &toDoEvent )const; | 259 | bool operator<(const OTodo &toDoEvent )const; |
269 | bool operator<=(const OTodo &toDoEvent )const; | 260 | bool operator<=(const OTodo &toDoEvent )const; |
270 | bool operator!=(const OTodo &toDoEvent )const; | 261 | bool operator!=(const OTodo &toDoEvent )const; |
271 | bool operator>(const OTodo &toDoEvent )const; | 262 | bool operator>(const OTodo &toDoEvent )const; |
272 | bool operator>=(const OTodo &toDoEvent)const; | 263 | bool operator>=(const OTodo &toDoEvent)const; |
273 | bool operator==(const OTodo &toDoEvent )const; | 264 | bool operator==(const OTodo &toDoEvent )const; |
274 | OTodo &operator=(const OTodo &toDoEvent ); | 265 | OTodo &operator=(const OTodo &toDoEvent ); |
275 | 266 | ||
276 | static int rtti(); | 267 | static int rtti(); |
277 | 268 | ||
278 | private: | 269 | private: |
279 | class OTodoPrivate; | 270 | class OTodoPrivate; |
280 | struct OTodoData; | 271 | struct OTodoData; |
281 | 272 | ||
282 | void deref(); | 273 | void deref(); |
283 | inline void changeOrModify(); | 274 | inline void changeOrModify(); |
284 | void copy( OTodoData* src, OTodoData* dest ); | 275 | void copy( OTodoData* src, OTodoData* dest ); |
285 | OTodoPrivate *d; | 276 | OTodoPrivate *d; |
286 | OTodoData *data; | 277 | OTodoData *data; |
287 | 278 | ||
288 | }; | 279 | }; |
289 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { | 280 | inline bool OTodo::operator!=(const OTodo &toDoEvent )const { |
290 | return !(*this == toDoEvent); | 281 | return !(*this == toDoEvent); |
291 | } | 282 | } |
292 | 283 | ||
293 | 284 | ||
294 | #endif | 285 | #endif |
diff --git a/libopie2/opiepim/ui/opimmainwindow.cpp b/libopie2/opiepim/ui/opimmainwindow.cpp index 4044bc1..2739e26 100644 --- a/libopie2/opiepim/ui/opimmainwindow.cpp +++ b/libopie2/opiepim/ui/opimmainwindow.cpp | |||
@@ -1,138 +1,150 @@ | |||
1 | #include <qapplication.h> | 1 | #include <qapplication.h> |
2 | #include <qdatetime.h> | 2 | #include <qdatetime.h> |
3 | #include <qcopchannel_qws.h> | 3 | #include <qcopchannel_qws.h> |
4 | 4 | ||
5 | #include <qpe/sound.h> | 5 | #include <qpe/sound.h> |
6 | #include <qpe/qcopenvelope_qws.h> | 6 | #include <qpe/qcopenvelope_qws.h> |
7 | #include <qpe/qpeapplication.h> | ||
7 | 8 | ||
8 | #include "opimresolver.h" | 9 | #include "opimresolver.h" |
9 | #include "opimmainwindow.h" | 10 | #include "opimmainwindow.h" |
10 | 11 | ||
11 | OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, | 12 | OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, |
12 | const char* name, WFlags flag ) | 13 | const char* name, WFlags flag ) |
13 | : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { | 14 | : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { |
14 | 15 | ||
15 | /* | 16 | /* |
16 | * let's generate our QCopChannel | 17 | * let's generate our QCopChannel |
17 | */ | 18 | */ |
18 | m_str = QString("QPE/"+m_service).local8Bit(); | 19 | m_str = QString("QPE/"+m_service).local8Bit(); |
19 | m_channel= new QCopChannel(m_str, this ); | 20 | m_channel= new QCopChannel(m_str, this ); |
20 | connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), | 21 | connect(m_channel, SIGNAL(received(const QCString&, const QByteArray& ) ), |
21 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | 22 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); |
22 | connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), | 23 | connect(qApp, SIGNAL(appMessage(const QCString&, const QByteArray& ) ), |
23 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); | 24 | this, SLOT( appMessage( const QCString&, const QByteArray& ) ) ); |
24 | 25 | ||
25 | /* connect flush and reload */ | 26 | /* connect flush and reload */ |
26 | connect(qApp, SIGNAL(flush() ), | 27 | connect(qApp, SIGNAL(flush() ), |
27 | this, SLOT(flush() ) ); | 28 | this, SLOT(flush() ) ); |
28 | connect(qApp, SIGNAL(reload() ), | 29 | connect(qApp, SIGNAL(reload() ), |
29 | this, SLOT(reload() ) ); | 30 | this, SLOT(reload() ) ); |
30 | } | 31 | } |
31 | OPimMainWindow::~OPimMainWindow() { | 32 | OPimMainWindow::~OPimMainWindow() { |
32 | delete m_channel; | 33 | delete m_channel; |
33 | } | 34 | } |
34 | QCopChannel* OPimMainWindow::channel() { | 35 | QCopChannel* OPimMainWindow::channel() { |
35 | return m_channel; | 36 | return m_channel; |
36 | } | 37 | } |
37 | void OPimMainWindow::doSetDocument( const QString& ) { | 38 | void OPimMainWindow::doSetDocument( const QString& ) { |
38 | 39 | ||
39 | } | 40 | } |
40 | void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { | 41 | void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array ) { |
42 | bool needShow = false; | ||
41 | /* | 43 | /* |
42 | * create demands to create | 44 | * create demands to create |
43 | * a new record... | 45 | * a new record... |
44 | */ | 46 | */ |
45 | QDataStream stream(array, IO_ReadOnly); | 47 | QDataStream stream(array, IO_ReadOnly); |
46 | if ( cmd == "create()" ) { | 48 | if ( cmd == "create()" ) { |
49 | raise(); | ||
47 | int uid = create(); | 50 | int uid = create(); |
48 | QCopEnvelope e(m_str, "created(int)" ); | 51 | QCopEnvelope e(m_str, "created(int)" ); |
49 | e << uid; | 52 | e << uid; |
53 | needShow = true; | ||
50 | }else if ( cmd == "remove(int)" ) { | 54 | }else if ( cmd == "remove(int)" ) { |
51 | int uid; | 55 | int uid; |
52 | stream >> uid; | 56 | stream >> uid; |
53 | bool rem = remove( uid ); | 57 | bool rem = remove( uid ); |
54 | QCopEnvelope e(m_str, "removed(bool)" ); | 58 | QCopEnvelope e(m_str, "removed(bool)" ); |
55 | e << rem; | 59 | e << rem; |
60 | needShow = true; | ||
56 | }else if ( cmd == "beam(int)" ) { | 61 | }else if ( cmd == "beam(int)" ) { |
57 | int uid; | 62 | int uid; |
58 | stream >> uid; | 63 | stream >> uid; |
59 | beam( uid); | 64 | beam( uid); |
60 | }else if ( cmd == "show(int)" ) { | 65 | }else if ( cmd == "show(int)" ) { |
66 | raise(); | ||
61 | int uid; | 67 | int uid; |
62 | stream >> uid; | 68 | stream >> uid; |
63 | show( uid ); | 69 | show( uid ); |
70 | needShow = true; | ||
64 | }else if ( cmd == "edit(int)" ) { | 71 | }else if ( cmd == "edit(int)" ) { |
72 | raise(); | ||
65 | int uid; | 73 | int uid; |
66 | stream >> uid; | 74 | stream >> uid; |
67 | edit( uid ); | 75 | edit( uid ); |
68 | }else if ( cmd == "add(int,QByteArray)" ) { | 76 | }else if ( cmd == "add(int,QByteArray)" ) { |
69 | int rtti; | 77 | int rtti; |
70 | QByteArray array; | 78 | QByteArray array; |
71 | stream >> rtti; | 79 | stream >> rtti; |
72 | stream >> array; | 80 | stream >> array; |
73 | m_fallBack = record(rtti, array ); | 81 | m_fallBack = record(rtti, array ); |
74 | if (!m_fallBack) return; | 82 | if (!m_fallBack) return; |
75 | add( *m_fallBack ); | 83 | add( *m_fallBack ); |
76 | delete m_fallBack; | 84 | delete m_fallBack; |
77 | }else if ( cmd == "alarm(QDateTime,int)" ) { | 85 | }else if ( cmd == "alarm(QDateTime,int)" ) { |
86 | raise(); | ||
78 | QDateTime dt; int uid; | 87 | QDateTime dt; int uid; |
79 | stream >> dt; | 88 | stream >> dt; |
80 | stream >> uid; | 89 | stream >> uid; |
81 | qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid ); | 90 | qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid ); |
82 | QDateTime current = QDateTime::currentDateTime(); | 91 | QDateTime current = QDateTime::currentDateTime(); |
83 | if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) | 92 | if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) |
84 | return; | 93 | return; |
85 | doAlarm( dt, uid ); | 94 | doAlarm( dt, uid ); |
86 | 95 | needShow = true; | |
87 | } | 96 | } |
97 | |||
98 | if (needShow ) | ||
99 | QPEApplication::setKeepRunning(); | ||
88 | } | 100 | } |
89 | /* implement the url scripting here */ | 101 | /* implement the url scripting here */ |
90 | void OPimMainWindow::setDocument( const QString& str) { | 102 | void OPimMainWindow::setDocument( const QString& str) { |
91 | doSetDocument( str ); | 103 | doSetDocument( str ); |
92 | } | 104 | } |
93 | /* | 105 | /* |
94 | * we now try to get the array demarshalled | 106 | * we now try to get the array demarshalled |
95 | * check if the rtti matches this one | 107 | * check if the rtti matches this one |
96 | */ | 108 | */ |
97 | OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { | 109 | OPimRecord* OPimMainWindow::record( int rtti, const QByteArray& array ) { |
98 | if ( service() != rtti ) | 110 | if ( service() != rtti ) |
99 | return 0l; | 111 | return 0l; |
100 | 112 | ||
101 | OPimRecord* record = OPimResolver::self()->record( rtti ); | 113 | OPimRecord* record = OPimResolver::self()->record( rtti ); |
102 | QDataStream str(array, IO_ReadOnly ); | 114 | QDataStream str(array, IO_ReadOnly ); |
103 | if ( !record || !record->loadFromStream(str) ) { | 115 | if ( !record || !record->loadFromStream(str) ) { |
104 | delete record; | 116 | delete record; |
105 | record = 0l; | 117 | record = 0l; |
106 | } | 118 | } |
107 | 119 | ||
108 | return record; | 120 | return record; |
109 | } | 121 | } |
110 | /* | 122 | /* |
111 | * get the rtti for the service | 123 | * get the rtti for the service |
112 | */ | 124 | */ |
113 | int OPimMainWindow::service() { | 125 | int OPimMainWindow::service() { |
114 | if ( m_rtti == -1 ) | 126 | if ( m_rtti == -1 ) |
115 | m_rtti = OPimResolver::self()->serviceId( m_service ); | 127 | m_rtti = OPimResolver::self()->serviceId( m_service ); |
116 | 128 | ||
117 | return m_rtti; | 129 | return m_rtti; |
118 | } | 130 | } |
119 | void OPimMainWindow::doAlarm( const QDateTime&, int ) { | 131 | void OPimMainWindow::doAlarm( const QDateTime&, int ) { |
120 | 132 | ||
121 | } | 133 | } |
122 | void OPimMainWindow::startAlarm(int count ) { | 134 | void OPimMainWindow::startAlarm(int count ) { |
123 | m_alarmCount = count; | 135 | m_alarmCount = count; |
124 | m_playedCount = 0; | 136 | m_playedCount = 0; |
125 | Sound::soundAlarm(); | 137 | Sound::soundAlarm(); |
126 | m_timerId = startTimer( 5000 ); | 138 | m_timerId = startTimer( 5000 ); |
127 | } | 139 | } |
128 | void OPimMainWindow::killAlarm() { | 140 | void OPimMainWindow::killAlarm() { |
129 | killTimer( m_timerId ); | 141 | killTimer( m_timerId ); |
130 | } | 142 | } |
131 | void OPimMainWindow::timerEvent( QTimerEvent* e) { | 143 | void OPimMainWindow::timerEvent( QTimerEvent* e) { |
132 | if ( m_playedCount <m_alarmCount ) { | 144 | if ( m_playedCount <m_alarmCount ) { |
133 | m_playedCount++; | 145 | m_playedCount++; |
134 | Sound::soundAlarm(); | 146 | Sound::soundAlarm(); |
135 | }else { | 147 | }else { |
136 | killTimer( e->timerId() ); | 148 | killTimer( e->timerId() ); |
137 | } | 149 | } |
138 | } | 150 | } |