author | zautrix <zautrix> | 2004-07-07 03:28:52 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-07 03:28:52 (UTC) |
commit | 816db8f76a1fd8b5cc586dfd5ebf8d6298221801 (patch) (unidiff) | |
tree | e418207a02e60c0807e75731a19c44a58d0fb896 | |
parent | 3db5c4e190d1031f2471516f8a52114f06d1a3eb (diff) | |
download | kdepimpi-816db8f76a1fd8b5cc586dfd5ebf8d6298221801.zip kdepimpi-816db8f76a1fd8b5cc586dfd5ebf8d6298221801.tar.gz kdepimpi-816db8f76a1fd8b5cc586dfd5ebf8d6298221801.tar.bz2 |
Changed some strings. Removed some kdebug
-rw-r--r-- | kabc/addressbook.cpp | 2 | ||||
-rw-r--r-- | kabc/plugins/file/resourcefile.cpp | 8 | ||||
-rw-r--r-- | kabc/stdaddressbook.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 2 | ||||
-rw-r--r-- | microkde/kresources/factory.cpp | 10 | ||||
-rw-r--r-- | microkde/kresources/resource.cpp | 3 |
6 files changed, 14 insertions, 13 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index 97bd3ef..0838157 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -1,641 +1,641 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | /*US | 28 | /*US |
29 | 29 | ||
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | #include <kapplication.h> | 34 | #include <kapplication.h> |
35 | #include <kinstance.h> | 35 | #include <kinstance.h> |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | 37 | ||
38 | #include "errorhandler.h" | 38 | #include "errorhandler.h" |
39 | */ | 39 | */ |
40 | #include <qptrlist.h> | 40 | #include <qptrlist.h> |
41 | 41 | ||
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | #include <klocale.h> | 43 | #include <klocale.h> |
44 | #include <kdebug.h> | 44 | #include <kdebug.h> |
45 | #include "addressbook.h" | 45 | #include "addressbook.h" |
46 | #include "resource.h" | 46 | #include "resource.h" |
47 | 47 | ||
48 | //US #include "addressbook.moc" | 48 | //US #include "addressbook.moc" |
49 | 49 | ||
50 | using namespace KABC; | 50 | using namespace KABC; |
51 | 51 | ||
52 | struct AddressBook::AddressBookData | 52 | struct AddressBook::AddressBookData |
53 | { | 53 | { |
54 | Addressee::List mAddressees; | 54 | Addressee::List mAddressees; |
55 | Addressee::List mRemovedAddressees; | 55 | Addressee::List mRemovedAddressees; |
56 | Field::List mAllFields; | 56 | Field::List mAllFields; |
57 | KConfig *mConfig; | 57 | KConfig *mConfig; |
58 | KRES::Manager<Resource> *mManager; | 58 | KRES::Manager<Resource> *mManager; |
59 | //US ErrorHandler *mErrorHandler; | 59 | //US ErrorHandler *mErrorHandler; |
60 | }; | 60 | }; |
61 | 61 | ||
62 | struct AddressBook::Iterator::IteratorData | 62 | struct AddressBook::Iterator::IteratorData |
63 | { | 63 | { |
64 | Addressee::List::Iterator mIt; | 64 | Addressee::List::Iterator mIt; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | struct AddressBook::ConstIterator::ConstIteratorData | 67 | struct AddressBook::ConstIterator::ConstIteratorData |
68 | { | 68 | { |
69 | Addressee::List::ConstIterator mIt; | 69 | Addressee::List::ConstIterator mIt; |
70 | }; | 70 | }; |
71 | 71 | ||
72 | AddressBook::Iterator::Iterator() | 72 | AddressBook::Iterator::Iterator() |
73 | { | 73 | { |
74 | d = new IteratorData; | 74 | d = new IteratorData; |
75 | } | 75 | } |
76 | 76 | ||
77 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) | 77 | AddressBook::Iterator::Iterator( const AddressBook::Iterator &i ) |
78 | { | 78 | { |
79 | d = new IteratorData; | 79 | d = new IteratorData; |
80 | d->mIt = i.d->mIt; | 80 | d->mIt = i.d->mIt; |
81 | } | 81 | } |
82 | 82 | ||
83 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) | 83 | AddressBook::Iterator &AddressBook::Iterator::operator=( const AddressBook::Iterator &i ) |
84 | { | 84 | { |
85 | if( this == &i ) return *this; // guard against self assignment | 85 | if( this == &i ) return *this; // guard against self assignment |
86 | delete d; // delete the old data the Iterator was completely constructed before | 86 | delete d; // delete the old data the Iterator was completely constructed before |
87 | d = new IteratorData; | 87 | d = new IteratorData; |
88 | d->mIt = i.d->mIt; | 88 | d->mIt = i.d->mIt; |
89 | return *this; | 89 | return *this; |
90 | } | 90 | } |
91 | 91 | ||
92 | AddressBook::Iterator::~Iterator() | 92 | AddressBook::Iterator::~Iterator() |
93 | { | 93 | { |
94 | delete d; | 94 | delete d; |
95 | } | 95 | } |
96 | 96 | ||
97 | const Addressee &AddressBook::Iterator::operator*() const | 97 | const Addressee &AddressBook::Iterator::operator*() const |
98 | { | 98 | { |
99 | return *(d->mIt); | 99 | return *(d->mIt); |
100 | } | 100 | } |
101 | 101 | ||
102 | Addressee &AddressBook::Iterator::operator*() | 102 | Addressee &AddressBook::Iterator::operator*() |
103 | { | 103 | { |
104 | return *(d->mIt); | 104 | return *(d->mIt); |
105 | } | 105 | } |
106 | 106 | ||
107 | Addressee *AddressBook::Iterator::operator->() | 107 | Addressee *AddressBook::Iterator::operator->() |
108 | { | 108 | { |
109 | return &(*(d->mIt)); | 109 | return &(*(d->mIt)); |
110 | } | 110 | } |
111 | 111 | ||
112 | AddressBook::Iterator &AddressBook::Iterator::operator++() | 112 | AddressBook::Iterator &AddressBook::Iterator::operator++() |
113 | { | 113 | { |
114 | (d->mIt)++; | 114 | (d->mIt)++; |
115 | return *this; | 115 | return *this; |
116 | } | 116 | } |
117 | 117 | ||
118 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) | 118 | AddressBook::Iterator &AddressBook::Iterator::operator++(int) |
119 | { | 119 | { |
120 | (d->mIt)++; | 120 | (d->mIt)++; |
121 | return *this; | 121 | return *this; |
122 | } | 122 | } |
123 | 123 | ||
124 | AddressBook::Iterator &AddressBook::Iterator::operator--() | 124 | AddressBook::Iterator &AddressBook::Iterator::operator--() |
125 | { | 125 | { |
126 | (d->mIt)--; | 126 | (d->mIt)--; |
127 | return *this; | 127 | return *this; |
128 | } | 128 | } |
129 | 129 | ||
130 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) | 130 | AddressBook::Iterator &AddressBook::Iterator::operator--(int) |
131 | { | 131 | { |
132 | (d->mIt)--; | 132 | (d->mIt)--; |
133 | return *this; | 133 | return *this; |
134 | } | 134 | } |
135 | 135 | ||
136 | bool AddressBook::Iterator::operator==( const Iterator &it ) | 136 | bool AddressBook::Iterator::operator==( const Iterator &it ) |
137 | { | 137 | { |
138 | return ( d->mIt == it.d->mIt ); | 138 | return ( d->mIt == it.d->mIt ); |
139 | } | 139 | } |
140 | 140 | ||
141 | bool AddressBook::Iterator::operator!=( const Iterator &it ) | 141 | bool AddressBook::Iterator::operator!=( const Iterator &it ) |
142 | { | 142 | { |
143 | return ( d->mIt != it.d->mIt ); | 143 | return ( d->mIt != it.d->mIt ); |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | AddressBook::ConstIterator::ConstIterator() | 147 | AddressBook::ConstIterator::ConstIterator() |
148 | { | 148 | { |
149 | d = new ConstIteratorData; | 149 | d = new ConstIteratorData; |
150 | } | 150 | } |
151 | 151 | ||
152 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) | 152 | AddressBook::ConstIterator::ConstIterator( const AddressBook::ConstIterator &i ) |
153 | { | 153 | { |
154 | d = new ConstIteratorData; | 154 | d = new ConstIteratorData; |
155 | d->mIt = i.d->mIt; | 155 | d->mIt = i.d->mIt; |
156 | } | 156 | } |
157 | 157 | ||
158 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) | 158 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator=( const AddressBook::ConstIterator &i ) |
159 | { | 159 | { |
160 | if( this == &i ) return *this; // guard for self assignment | 160 | if( this == &i ) return *this; // guard for self assignment |
161 | delete d; // delete the old data because the Iterator was really constructed before | 161 | delete d; // delete the old data because the Iterator was really constructed before |
162 | d = new ConstIteratorData; | 162 | d = new ConstIteratorData; |
163 | d->mIt = i.d->mIt; | 163 | d->mIt = i.d->mIt; |
164 | return *this; | 164 | return *this; |
165 | } | 165 | } |
166 | 166 | ||
167 | AddressBook::ConstIterator::~ConstIterator() | 167 | AddressBook::ConstIterator::~ConstIterator() |
168 | { | 168 | { |
169 | delete d; | 169 | delete d; |
170 | } | 170 | } |
171 | 171 | ||
172 | const Addressee &AddressBook::ConstIterator::operator*() const | 172 | const Addressee &AddressBook::ConstIterator::operator*() const |
173 | { | 173 | { |
174 | return *(d->mIt); | 174 | return *(d->mIt); |
175 | } | 175 | } |
176 | 176 | ||
177 | const Addressee* AddressBook::ConstIterator::operator->() const | 177 | const Addressee* AddressBook::ConstIterator::operator->() const |
178 | { | 178 | { |
179 | return &(*(d->mIt)); | 179 | return &(*(d->mIt)); |
180 | } | 180 | } |
181 | 181 | ||
182 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() | 182 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++() |
183 | { | 183 | { |
184 | (d->mIt)++; | 184 | (d->mIt)++; |
185 | return *this; | 185 | return *this; |
186 | } | 186 | } |
187 | 187 | ||
188 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) | 188 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator++(int) |
189 | { | 189 | { |
190 | (d->mIt)++; | 190 | (d->mIt)++; |
191 | return *this; | 191 | return *this; |
192 | } | 192 | } |
193 | 193 | ||
194 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() | 194 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--() |
195 | { | 195 | { |
196 | (d->mIt)--; | 196 | (d->mIt)--; |
197 | return *this; | 197 | return *this; |
198 | } | 198 | } |
199 | 199 | ||
200 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) | 200 | AddressBook::ConstIterator &AddressBook::ConstIterator::operator--(int) |
201 | { | 201 | { |
202 | (d->mIt)--; | 202 | (d->mIt)--; |
203 | return *this; | 203 | return *this; |
204 | } | 204 | } |
205 | 205 | ||
206 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) | 206 | bool AddressBook::ConstIterator::operator==( const ConstIterator &it ) |
207 | { | 207 | { |
208 | return ( d->mIt == it.d->mIt ); | 208 | return ( d->mIt == it.d->mIt ); |
209 | } | 209 | } |
210 | 210 | ||
211 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) | 211 | bool AddressBook::ConstIterator::operator!=( const ConstIterator &it ) |
212 | { | 212 | { |
213 | return ( d->mIt != it.d->mIt ); | 213 | return ( d->mIt != it.d->mIt ); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | AddressBook::AddressBook() | 217 | AddressBook::AddressBook() |
218 | { | 218 | { |
219 | init(0); | 219 | init(0); |
220 | } | 220 | } |
221 | 221 | ||
222 | AddressBook::AddressBook( const QString &config ) | 222 | AddressBook::AddressBook( const QString &config ) |
223 | { | 223 | { |
224 | init(config); | 224 | init(config); |
225 | } | 225 | } |
226 | 226 | ||
227 | void AddressBook::init(const QString &config) | 227 | void AddressBook::init(const QString &config) |
228 | { | 228 | { |
229 | d = new AddressBookData; | 229 | d = new AddressBookData; |
230 | if (config != 0) { | 230 | if (config != 0) { |
231 | d->mConfig = new KConfig( config ); | 231 | d->mConfig = new KConfig( config ); |
232 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); | 232 | // qDebug("AddressBook::init 1 config=%s",config.latin1() ); |
233 | } | 233 | } |
234 | else { | 234 | else { |
235 | d->mConfig = 0; | 235 | d->mConfig = 0; |
236 | // qDebug("AddressBook::init 1 config=0"); | 236 | // qDebug("AddressBook::init 1 config=0"); |
237 | } | 237 | } |
238 | 238 | ||
239 | //US d->mErrorHandler = 0; | 239 | //US d->mErrorHandler = 0; |
240 | d->mManager = new KRES::Manager<Resource>( "contact" ); | 240 | d->mManager = new KRES::Manager<Resource>( "contact" ); |
241 | d->mManager->readConfig( d->mConfig ); | 241 | d->mManager->readConfig( d->mConfig ); |
242 | } | 242 | } |
243 | 243 | ||
244 | AddressBook::~AddressBook() | 244 | AddressBook::~AddressBook() |
245 | { | 245 | { |
246 | delete d->mConfig; d->mConfig = 0; | 246 | delete d->mConfig; d->mConfig = 0; |
247 | delete d->mManager; d->mManager = 0; | 247 | delete d->mManager; d->mManager = 0; |
248 | //US delete d->mErrorHandler; d->mErrorHandler = 0; | 248 | //US delete d->mErrorHandler; d->mErrorHandler = 0; |
249 | delete d; d = 0; | 249 | delete d; d = 0; |
250 | } | 250 | } |
251 | 251 | ||
252 | bool AddressBook::load() | 252 | bool AddressBook::load() |
253 | { | 253 | { |
254 | kdDebug(5700) << "AddressBook::load()" << endl; | 254 | |
255 | 255 | ||
256 | clear(); | 256 | clear(); |
257 | 257 | ||
258 | KRES::Manager<Resource>::ActiveIterator it; | 258 | KRES::Manager<Resource>::ActiveIterator it; |
259 | bool ok = true; | 259 | bool ok = true; |
260 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 260 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
261 | if ( !(*it)->load() ) { | 261 | if ( !(*it)->load() ) { |
262 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); | 262 | error( i18n("Unable to load resource '%1'").arg( (*it)->resourceName() ) ); |
263 | ok = false; | 263 | ok = false; |
264 | } | 264 | } |
265 | 265 | ||
266 | // mark all addressees as unchanged | 266 | // mark all addressees as unchanged |
267 | Addressee::List::Iterator addrIt; | 267 | Addressee::List::Iterator addrIt; |
268 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) | 268 | for ( addrIt = d->mAddressees.begin(); addrIt != d->mAddressees.end(); ++addrIt ) |
269 | (*addrIt).setChanged( false ); | 269 | (*addrIt).setChanged( false ); |
270 | 270 | ||
271 | return ok; | 271 | return ok; |
272 | } | 272 | } |
273 | 273 | ||
274 | bool AddressBook::save( Ticket *ticket ) | 274 | bool AddressBook::save( Ticket *ticket ) |
275 | { | 275 | { |
276 | kdDebug(5700) << "AddressBook::save()"<< endl; | 276 | kdDebug(5700) << "AddressBook::save()"<< endl; |
277 | 277 | ||
278 | if ( ticket->resource() ) { | 278 | if ( ticket->resource() ) { |
279 | deleteRemovedAddressees(); | 279 | deleteRemovedAddressees(); |
280 | 280 | ||
281 | return ticket->resource()->save( ticket ); | 281 | return ticket->resource()->save( ticket ); |
282 | } | 282 | } |
283 | 283 | ||
284 | return false; | 284 | return false; |
285 | } | 285 | } |
286 | 286 | ||
287 | AddressBook::Iterator AddressBook::begin() | 287 | AddressBook::Iterator AddressBook::begin() |
288 | { | 288 | { |
289 | Iterator it = Iterator(); | 289 | Iterator it = Iterator(); |
290 | it.d->mIt = d->mAddressees.begin(); | 290 | it.d->mIt = d->mAddressees.begin(); |
291 | return it; | 291 | return it; |
292 | } | 292 | } |
293 | 293 | ||
294 | AddressBook::ConstIterator AddressBook::begin() const | 294 | AddressBook::ConstIterator AddressBook::begin() const |
295 | { | 295 | { |
296 | ConstIterator it = ConstIterator(); | 296 | ConstIterator it = ConstIterator(); |
297 | it.d->mIt = d->mAddressees.begin(); | 297 | it.d->mIt = d->mAddressees.begin(); |
298 | return it; | 298 | return it; |
299 | } | 299 | } |
300 | 300 | ||
301 | AddressBook::Iterator AddressBook::end() | 301 | AddressBook::Iterator AddressBook::end() |
302 | { | 302 | { |
303 | Iterator it = Iterator(); | 303 | Iterator it = Iterator(); |
304 | it.d->mIt = d->mAddressees.end(); | 304 | it.d->mIt = d->mAddressees.end(); |
305 | return it; | 305 | return it; |
306 | } | 306 | } |
307 | 307 | ||
308 | AddressBook::ConstIterator AddressBook::end() const | 308 | AddressBook::ConstIterator AddressBook::end() const |
309 | { | 309 | { |
310 | ConstIterator it = ConstIterator(); | 310 | ConstIterator it = ConstIterator(); |
311 | it.d->mIt = d->mAddressees.end(); | 311 | it.d->mIt = d->mAddressees.end(); |
312 | return it; | 312 | return it; |
313 | } | 313 | } |
314 | 314 | ||
315 | void AddressBook::clear() | 315 | void AddressBook::clear() |
316 | { | 316 | { |
317 | d->mAddressees.clear(); | 317 | d->mAddressees.clear(); |
318 | } | 318 | } |
319 | 319 | ||
320 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) | 320 | Ticket *AddressBook::requestSaveTicket( Resource *resource ) |
321 | { | 321 | { |
322 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; | 322 | kdDebug(5700) << "AddressBook::requestSaveTicket()" << endl; |
323 | 323 | ||
324 | if ( !resource ) | 324 | if ( !resource ) |
325 | { | 325 | { |
326 | qDebug("AddressBook::requestSaveTicket no resource" ); | 326 | qDebug("AddressBook::requestSaveTicket no resource" ); |
327 | resource = standardResource(); | 327 | resource = standardResource(); |
328 | } | 328 | } |
329 | 329 | ||
330 | KRES::Manager<Resource>::ActiveIterator it; | 330 | KRES::Manager<Resource>::ActiveIterator it; |
331 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 331 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
332 | if ( (*it) == resource ) { | 332 | if ( (*it) == resource ) { |
333 | if ( (*it)->readOnly() || !(*it)->isOpen() ) | 333 | if ( (*it)->readOnly() || !(*it)->isOpen() ) |
334 | return 0; | 334 | return 0; |
335 | else | 335 | else |
336 | return (*it)->requestSaveTicket(); | 336 | return (*it)->requestSaveTicket(); |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
340 | return 0; | 340 | return 0; |
341 | } | 341 | } |
342 | 342 | ||
343 | void AddressBook::insertAddressee( const Addressee &a ) | 343 | void AddressBook::insertAddressee( const Addressee &a ) |
344 | { | 344 | { |
345 | Addressee::List::Iterator it; | 345 | Addressee::List::Iterator it; |
346 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { | 346 | for ( it = d->mAddressees.begin(); it != d->mAddressees.end(); ++it ) { |
347 | if ( a.uid() == (*it).uid() ) { | 347 | if ( a.uid() == (*it).uid() ) { |
348 | bool changed = false; | 348 | bool changed = false; |
349 | Addressee addr = a; | 349 | Addressee addr = a; |
350 | if ( addr != (*it) ) | 350 | if ( addr != (*it) ) |
351 | changed = true; | 351 | changed = true; |
352 | 352 | ||
353 | (*it) = a; | 353 | (*it) = a; |
354 | if ( (*it).resource() == 0 ) | 354 | if ( (*it).resource() == 0 ) |
355 | (*it).setResource( standardResource() ); | 355 | (*it).setResource( standardResource() ); |
356 | 356 | ||
357 | if ( changed ) { | 357 | if ( changed ) { |
358 | (*it).setRevision( QDateTime::currentDateTime() ); | 358 | (*it).setRevision( QDateTime::currentDateTime() ); |
359 | (*it).setChanged( true ); | 359 | (*it).setChanged( true ); |
360 | } | 360 | } |
361 | 361 | ||
362 | return; | 362 | return; |
363 | } | 363 | } |
364 | } | 364 | } |
365 | d->mAddressees.append( a ); | 365 | d->mAddressees.append( a ); |
366 | Addressee& addr = d->mAddressees.last(); | 366 | Addressee& addr = d->mAddressees.last(); |
367 | if ( addr.resource() == 0 ) | 367 | if ( addr.resource() == 0 ) |
368 | addr.setResource( standardResource() ); | 368 | addr.setResource( standardResource() ); |
369 | 369 | ||
370 | addr.setChanged( true ); | 370 | addr.setChanged( true ); |
371 | } | 371 | } |
372 | 372 | ||
373 | void AddressBook::removeAddressee( const Addressee &a ) | 373 | void AddressBook::removeAddressee( const Addressee &a ) |
374 | { | 374 | { |
375 | Iterator it; | 375 | Iterator it; |
376 | for ( it = begin(); it != end(); ++it ) { | 376 | for ( it = begin(); it != end(); ++it ) { |
377 | if ( a.uid() == (*it).uid() ) { | 377 | if ( a.uid() == (*it).uid() ) { |
378 | removeAddressee( it ); | 378 | removeAddressee( it ); |
379 | return; | 379 | return; |
380 | } | 380 | } |
381 | } | 381 | } |
382 | } | 382 | } |
383 | 383 | ||
384 | void AddressBook::removeAddressee( const Iterator &it ) | 384 | void AddressBook::removeAddressee( const Iterator &it ) |
385 | { | 385 | { |
386 | d->mRemovedAddressees.append( (*it) ); | 386 | d->mRemovedAddressees.append( (*it) ); |
387 | d->mAddressees.remove( it.d->mIt ); | 387 | d->mAddressees.remove( it.d->mIt ); |
388 | } | 388 | } |
389 | 389 | ||
390 | AddressBook::Iterator AddressBook::find( const Addressee &a ) | 390 | AddressBook::Iterator AddressBook::find( const Addressee &a ) |
391 | { | 391 | { |
392 | Iterator it; | 392 | Iterator it; |
393 | for ( it = begin(); it != end(); ++it ) { | 393 | for ( it = begin(); it != end(); ++it ) { |
394 | if ( a.uid() == (*it).uid() ) { | 394 | if ( a.uid() == (*it).uid() ) { |
395 | return it; | 395 | return it; |
396 | } | 396 | } |
397 | } | 397 | } |
398 | return end(); | 398 | return end(); |
399 | } | 399 | } |
400 | 400 | ||
401 | Addressee AddressBook::findByUid( const QString &uid ) | 401 | Addressee AddressBook::findByUid( const QString &uid ) |
402 | { | 402 | { |
403 | Iterator it; | 403 | Iterator it; |
404 | for ( it = begin(); it != end(); ++it ) { | 404 | for ( it = begin(); it != end(); ++it ) { |
405 | if ( uid == (*it).uid() ) { | 405 | if ( uid == (*it).uid() ) { |
406 | return *it; | 406 | return *it; |
407 | } | 407 | } |
408 | } | 408 | } |
409 | return Addressee(); | 409 | return Addressee(); |
410 | } | 410 | } |
411 | 411 | ||
412 | Addressee::List AddressBook::allAddressees() | 412 | Addressee::List AddressBook::allAddressees() |
413 | { | 413 | { |
414 | return d->mAddressees; | 414 | return d->mAddressees; |
415 | } | 415 | } |
416 | 416 | ||
417 | Addressee::List AddressBook::findByName( const QString &name ) | 417 | Addressee::List AddressBook::findByName( const QString &name ) |
418 | { | 418 | { |
419 | Addressee::List results; | 419 | Addressee::List results; |
420 | 420 | ||
421 | Iterator it; | 421 | Iterator it; |
422 | for ( it = begin(); it != end(); ++it ) { | 422 | for ( it = begin(); it != end(); ++it ) { |
423 | if ( name == (*it).name() ) { | 423 | if ( name == (*it).name() ) { |
424 | results.append( *it ); | 424 | results.append( *it ); |
425 | } | 425 | } |
426 | } | 426 | } |
427 | 427 | ||
428 | return results; | 428 | return results; |
429 | } | 429 | } |
430 | 430 | ||
431 | Addressee::List AddressBook::findByEmail( const QString &email ) | 431 | Addressee::List AddressBook::findByEmail( const QString &email ) |
432 | { | 432 | { |
433 | Addressee::List results; | 433 | Addressee::List results; |
434 | QStringList mailList; | 434 | QStringList mailList; |
435 | 435 | ||
436 | Iterator it; | 436 | Iterator it; |
437 | for ( it = begin(); it != end(); ++it ) { | 437 | for ( it = begin(); it != end(); ++it ) { |
438 | mailList = (*it).emails(); | 438 | mailList = (*it).emails(); |
439 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { | 439 | for ( QStringList::Iterator ite = mailList.begin(); ite != mailList.end(); ++ite ) { |
440 | if ( email == (*ite) ) { | 440 | if ( email == (*ite) ) { |
441 | results.append( *it ); | 441 | results.append( *it ); |
442 | } | 442 | } |
443 | } | 443 | } |
444 | } | 444 | } |
445 | 445 | ||
446 | return results; | 446 | return results; |
447 | } | 447 | } |
448 | 448 | ||
449 | Addressee::List AddressBook::findByCategory( const QString &category ) | 449 | Addressee::List AddressBook::findByCategory( const QString &category ) |
450 | { | 450 | { |
451 | Addressee::List results; | 451 | Addressee::List results; |
452 | 452 | ||
453 | Iterator it; | 453 | Iterator it; |
454 | for ( it = begin(); it != end(); ++it ) { | 454 | for ( it = begin(); it != end(); ++it ) { |
455 | if ( (*it).hasCategory( category) ) { | 455 | if ( (*it).hasCategory( category) ) { |
456 | results.append( *it ); | 456 | results.append( *it ); |
457 | } | 457 | } |
458 | } | 458 | } |
459 | 459 | ||
460 | return results; | 460 | return results; |
461 | } | 461 | } |
462 | 462 | ||
463 | void AddressBook::dump() const | 463 | void AddressBook::dump() const |
464 | { | 464 | { |
465 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; | 465 | kdDebug(5700) << "AddressBook::dump() --- begin ---" << endl; |
466 | 466 | ||
467 | ConstIterator it; | 467 | ConstIterator it; |
468 | for( it = begin(); it != end(); ++it ) { | 468 | for( it = begin(); it != end(); ++it ) { |
469 | (*it).dump(); | 469 | (*it).dump(); |
470 | } | 470 | } |
471 | 471 | ||
472 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; | 472 | kdDebug(5700) << "AddressBook::dump() --- end ---" << endl; |
473 | } | 473 | } |
474 | 474 | ||
475 | QString AddressBook::identifier() | 475 | QString AddressBook::identifier() |
476 | { | 476 | { |
477 | QStringList identifier; | 477 | QStringList identifier; |
478 | 478 | ||
479 | 479 | ||
480 | KRES::Manager<Resource>::ActiveIterator it; | 480 | KRES::Manager<Resource>::ActiveIterator it; |
481 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 481 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
482 | if ( !(*it)->identifier().isEmpty() ) | 482 | if ( !(*it)->identifier().isEmpty() ) |
483 | identifier.append( (*it)->identifier() ); | 483 | identifier.append( (*it)->identifier() ); |
484 | } | 484 | } |
485 | 485 | ||
486 | return identifier.join( ":" ); | 486 | return identifier.join( ":" ); |
487 | } | 487 | } |
488 | 488 | ||
489 | Field::List AddressBook::fields( int category ) | 489 | Field::List AddressBook::fields( int category ) |
490 | { | 490 | { |
491 | if ( d->mAllFields.isEmpty() ) { | 491 | if ( d->mAllFields.isEmpty() ) { |
492 | d->mAllFields = Field::allFields(); | 492 | d->mAllFields = Field::allFields(); |
493 | } | 493 | } |
494 | 494 | ||
495 | if ( category == Field::All ) return d->mAllFields; | 495 | if ( category == Field::All ) return d->mAllFields; |
496 | 496 | ||
497 | Field::List result; | 497 | Field::List result; |
498 | Field::List::ConstIterator it; | 498 | Field::List::ConstIterator it; |
499 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { | 499 | for( it = d->mAllFields.begin(); it != d->mAllFields.end(); ++it ) { |
500 | if ( (*it)->category() & category ) result.append( *it ); | 500 | if ( (*it)->category() & category ) result.append( *it ); |
501 | } | 501 | } |
502 | 502 | ||
503 | return result; | 503 | return result; |
504 | } | 504 | } |
505 | 505 | ||
506 | bool AddressBook::addCustomField( const QString &label, int category, | 506 | bool AddressBook::addCustomField( const QString &label, int category, |
507 | const QString &key, const QString &app ) | 507 | const QString &key, const QString &app ) |
508 | { | 508 | { |
509 | if ( d->mAllFields.isEmpty() ) { | 509 | if ( d->mAllFields.isEmpty() ) { |
510 | d->mAllFields = Field::allFields(); | 510 | d->mAllFields = Field::allFields(); |
511 | } | 511 | } |
512 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; | 512 | //US QString a = app.isNull() ? KGlobal::instance()->instanceName() : app; |
513 | QString a = app.isNull() ? KGlobal::getAppName() : app; | 513 | QString a = app.isNull() ? KGlobal::getAppName() : app; |
514 | 514 | ||
515 | QString k = key.isNull() ? label : key; | 515 | QString k = key.isNull() ? label : key; |
516 | 516 | ||
517 | Field *field = Field::createCustomField( label, category, k, a ); | 517 | Field *field = Field::createCustomField( label, category, k, a ); |
518 | 518 | ||
519 | if ( !field ) return false; | 519 | if ( !field ) return false; |
520 | 520 | ||
521 | d->mAllFields.append( field ); | 521 | d->mAllFields.append( field ); |
522 | 522 | ||
523 | return true; | 523 | return true; |
524 | } | 524 | } |
525 | 525 | ||
526 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) | 526 | QDataStream &KABC::operator<<( QDataStream &s, const AddressBook &ab ) |
527 | { | 527 | { |
528 | if (!ab.d) return s; | 528 | if (!ab.d) return s; |
529 | 529 | ||
530 | return s << ab.d->mAddressees; | 530 | return s << ab.d->mAddressees; |
531 | } | 531 | } |
532 | 532 | ||
533 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) | 533 | QDataStream &KABC::operator>>( QDataStream &s, AddressBook &ab ) |
534 | { | 534 | { |
535 | if (!ab.d) return s; | 535 | if (!ab.d) return s; |
536 | 536 | ||
537 | s >> ab.d->mAddressees; | 537 | s >> ab.d->mAddressees; |
538 | 538 | ||
539 | return s; | 539 | return s; |
540 | } | 540 | } |
541 | 541 | ||
542 | bool AddressBook::addResource( Resource *resource ) | 542 | bool AddressBook::addResource( Resource *resource ) |
543 | { | 543 | { |
544 | qDebug("AddressBook::addResource 1"); | 544 | qDebug("AddressBook::addResource 1"); |
545 | 545 | ||
546 | if ( !resource->open() ) { | 546 | if ( !resource->open() ) { |
547 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; | 547 | kdDebug(5700) << "AddressBook::addResource(): can't add resource" << endl; |
548 | return false; | 548 | return false; |
549 | } | 549 | } |
550 | 550 | ||
551 | resource->setAddressBook( this ); | 551 | resource->setAddressBook( this ); |
552 | 552 | ||
553 | d->mManager->add( resource ); | 553 | d->mManager->add( resource ); |
554 | return true; | 554 | return true; |
555 | } | 555 | } |
556 | 556 | ||
557 | bool AddressBook::removeResource( Resource *resource ) | 557 | bool AddressBook::removeResource( Resource *resource ) |
558 | { | 558 | { |
559 | resource->close(); | 559 | resource->close(); |
560 | 560 | ||
561 | if ( resource == standardResource() ) | 561 | if ( resource == standardResource() ) |
562 | d->mManager->setStandardResource( 0 ); | 562 | d->mManager->setStandardResource( 0 ); |
563 | 563 | ||
564 | resource->setAddressBook( 0 ); | 564 | resource->setAddressBook( 0 ); |
565 | 565 | ||
566 | d->mManager->remove( resource ); | 566 | d->mManager->remove( resource ); |
567 | return true; | 567 | return true; |
568 | } | 568 | } |
569 | 569 | ||
570 | QPtrList<Resource> AddressBook::resources() | 570 | QPtrList<Resource> AddressBook::resources() |
571 | { | 571 | { |
572 | QPtrList<Resource> list; | 572 | QPtrList<Resource> list; |
573 | 573 | ||
574 | // qDebug("AddressBook::resources() 1"); | 574 | // qDebug("AddressBook::resources() 1"); |
575 | 575 | ||
576 | KRES::Manager<Resource>::ActiveIterator it; | 576 | KRES::Manager<Resource>::ActiveIterator it; |
577 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) | 577 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) |
578 | list.append( *it ); | 578 | list.append( *it ); |
579 | 579 | ||
580 | return list; | 580 | return list; |
581 | } | 581 | } |
582 | 582 | ||
583 | /*US | 583 | /*US |
584 | void AddressBook::setErrorHandler( ErrorHandler *handler ) | 584 | void AddressBook::setErrorHandler( ErrorHandler *handler ) |
585 | { | 585 | { |
586 | delete d->mErrorHandler; | 586 | delete d->mErrorHandler; |
587 | d->mErrorHandler = handler; | 587 | d->mErrorHandler = handler; |
588 | } | 588 | } |
589 | */ | 589 | */ |
590 | 590 | ||
591 | void AddressBook::error( const QString& msg ) | 591 | void AddressBook::error( const QString& msg ) |
592 | { | 592 | { |
593 | /*US | 593 | /*US |
594 | if ( !d->mErrorHandler ) // create default error handler | 594 | if ( !d->mErrorHandler ) // create default error handler |
595 | d->mErrorHandler = new ConsoleErrorHandler; | 595 | d->mErrorHandler = new ConsoleErrorHandler; |
596 | 596 | ||
597 | if ( d->mErrorHandler ) | 597 | if ( d->mErrorHandler ) |
598 | d->mErrorHandler->error( msg ); | 598 | d->mErrorHandler->error( msg ); |
599 | else | 599 | else |
600 | kdError(5700) << "no error handler defined" << endl; | 600 | kdError(5700) << "no error handler defined" << endl; |
601 | */ | 601 | */ |
602 | kdDebug(5700) << "msg" << endl; | 602 | kdDebug(5700) << "msg" << endl; |
603 | qDebug(msg); | 603 | qDebug(msg); |
604 | } | 604 | } |
605 | 605 | ||
606 | void AddressBook::deleteRemovedAddressees() | 606 | void AddressBook::deleteRemovedAddressees() |
607 | { | 607 | { |
608 | Addressee::List::Iterator it; | 608 | Addressee::List::Iterator it; |
609 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { | 609 | for ( it = d->mRemovedAddressees.begin(); it != d->mRemovedAddressees.end(); ++it ) { |
610 | Resource *resource = (*it).resource(); | 610 | Resource *resource = (*it).resource(); |
611 | if ( resource && !resource->readOnly() && resource->isOpen() ) | 611 | if ( resource && !resource->readOnly() && resource->isOpen() ) |
612 | resource->removeAddressee( *it ); | 612 | resource->removeAddressee( *it ); |
613 | } | 613 | } |
614 | 614 | ||
615 | d->mRemovedAddressees.clear(); | 615 | d->mRemovedAddressees.clear(); |
616 | } | 616 | } |
617 | 617 | ||
618 | void AddressBook::setStandardResource( Resource *resource ) | 618 | void AddressBook::setStandardResource( Resource *resource ) |
619 | { | 619 | { |
620 | // qDebug("AddressBook::setStandardResource 1"); | 620 | // qDebug("AddressBook::setStandardResource 1"); |
621 | d->mManager->setStandardResource( resource ); | 621 | d->mManager->setStandardResource( resource ); |
622 | } | 622 | } |
623 | 623 | ||
624 | Resource *AddressBook::standardResource() | 624 | Resource *AddressBook::standardResource() |
625 | { | 625 | { |
626 | return d->mManager->standardResource(); | 626 | return d->mManager->standardResource(); |
627 | } | 627 | } |
628 | 628 | ||
629 | KRES::Manager<Resource> *AddressBook::resourceManager() | 629 | KRES::Manager<Resource> *AddressBook::resourceManager() |
630 | { | 630 | { |
631 | return d->mManager; | 631 | return d->mManager; |
632 | } | 632 | } |
633 | 633 | ||
634 | void AddressBook::cleanUp() | 634 | void AddressBook::cleanUp() |
635 | { | 635 | { |
636 | KRES::Manager<Resource>::ActiveIterator it; | 636 | KRES::Manager<Resource>::ActiveIterator it; |
637 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { | 637 | for ( it = d->mManager->activeBegin(); it != d->mManager->activeEnd(); ++it ) { |
638 | if ( !(*it)->readOnly() && (*it)->isOpen() ) | 638 | if ( !(*it)->readOnly() && (*it)->isOpen() ) |
639 | (*it)->cleanUp(); | 639 | (*it)->cleanUp(); |
640 | } | 640 | } |
641 | } | 641 | } |
diff --git a/kabc/plugins/file/resourcefile.cpp b/kabc/plugins/file/resourcefile.cpp index 80af841..3920f69 100644 --- a/kabc/plugins/file/resourcefile.cpp +++ b/kabc/plugins/file/resourcefile.cpp | |||
@@ -1,389 +1,389 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <sys/types.h> | 28 | #include <sys/types.h> |
29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
30 | #ifndef _WIN32_ | 30 | #ifndef _WIN32_ |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qfileinfo.h> | 35 | #include <qfileinfo.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | 38 | ||
39 | #include <kapplication.h> | 39 | #include <kapplication.h> |
40 | #include <kconfig.h> | 40 | #include <kconfig.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <klocale.h> | 42 | #include <klocale.h> |
43 | //US #include <ksavefile.h> | 43 | //US #include <ksavefile.h> |
44 | #include <kstandarddirs.h> | 44 | #include <kstandarddirs.h> |
45 | 45 | ||
46 | #include "formatfactory.h" | 46 | #include "formatfactory.h" |
47 | 47 | ||
48 | #include "resource.h" | 48 | #include "resource.h" |
49 | #include "resourcefileconfig.h" | 49 | #include "resourcefileconfig.h" |
50 | #include "stdaddressbook.h" | 50 | #include "stdaddressbook.h" |
51 | 51 | ||
52 | //US #include "../../formats/vcardformatplugin2.h" | 52 | //US #include "../../formats/vcardformatplugin2.h" |
53 | //US #include "../../formats/binaryformat.h" | 53 | //US #include "../../formats/binaryformat.h" |
54 | 54 | ||
55 | 55 | ||
56 | #include "resourcefile.h" | 56 | #include "resourcefile.h" |
57 | 57 | ||
58 | using namespace KABC; | 58 | using namespace KABC; |
59 | 59 | ||
60 | extern "C" | 60 | extern "C" |
61 | { | 61 | { |
62 | //US void *init_kabc_file() | 62 | //US void *init_kabc_file() |
63 | void *init_microkabc_file() | 63 | void *init_microkabc_file() |
64 | { | 64 | { |
65 | return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>(); | 65 | return new KRES::PluginFactory<ResourceFile,ResourceFileConfig>(); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | 69 | ||
70 | ResourceFile::ResourceFile( const KConfig *config ) | 70 | ResourceFile::ResourceFile( const KConfig *config ) |
71 | : Resource( config ) , mFormat( 0 ) | 71 | : Resource( config ) , mFormat( 0 ) |
72 | { | 72 | { |
73 | QString fileName, formatName; | 73 | QString fileName, formatName; |
74 | 74 | ||
75 | KConfig *cfg = (KConfig *)config; | 75 | KConfig *cfg = (KConfig *)config; |
76 | if ( cfg ) { | 76 | if ( cfg ) { |
77 | fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() ); | 77 | fileName = cfg->readEntry( "FileName", StdAddressBook::fileName() ); |
78 | formatName = cfg->readEntry( "FileFormat", "vcard" ); | 78 | formatName = cfg->readEntry( "FileFormat", "vcard" ); |
79 | // qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() ); | 79 | // qDebug("ResourceFile::ResourceFile : 1 %s, %s", fileName.latin1(), formatName.latin1() ); |
80 | } else { | 80 | } else { |
81 | fileName = StdAddressBook::fileName(); | 81 | fileName = StdAddressBook::fileName(); |
82 | formatName = "vcard"; | 82 | formatName = "vcard"; |
83 | // qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() ); | 83 | // qDebug("ResourceFile::ResourceFile : 2 %s, %s", fileName.latin1(), formatName.latin1() ); |
84 | } | 84 | } |
85 | 85 | ||
86 | init( fileName, formatName ); | 86 | init( fileName, formatName ); |
87 | } | 87 | } |
88 | 88 | ||
89 | ResourceFile::ResourceFile( const QString &fileName, | 89 | ResourceFile::ResourceFile( const QString &fileName, |
90 | const QString &formatName ) | 90 | const QString &formatName ) |
91 | : Resource( 0 ) | 91 | : Resource( 0 ) |
92 | { | 92 | { |
93 | // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); | 93 | // qDebug("ResourceFile::ResourceFile : 3 %s, %s", fileName.latin1(), formatName.latin1()); |
94 | init( fileName, formatName ); | 94 | init( fileName, formatName ); |
95 | } | 95 | } |
96 | 96 | ||
97 | void ResourceFile::init( const QString &fileName, const QString &formatName ) | 97 | void ResourceFile::init( const QString &fileName, const QString &formatName ) |
98 | { | 98 | { |
99 | mFormatName = formatName; | 99 | mFormatName = formatName; |
100 | 100 | ||
101 | FormatFactory *factory = FormatFactory::self(); | 101 | FormatFactory *factory = FormatFactory::self(); |
102 | mFormat = factory->format( mFormatName ); | 102 | mFormat = factory->format( mFormatName ); |
103 | 103 | ||
104 | if ( !mFormat ) { | 104 | if ( !mFormat ) { |
105 | mFormatName = "vcard"; | 105 | mFormatName = "vcard"; |
106 | mFormat = factory->format( mFormatName ); | 106 | mFormat = factory->format( mFormatName ); |
107 | } | 107 | } |
108 | 108 | ||
109 | /*US | 109 | /*US |
110 | //US qDebug("ResourceFile::init initialized with format %s ", formatName.latin1()); | 110 | //US qDebug("ResourceFile::init initialized with format %s ", formatName.latin1()); |
111 | if (mFormatName == "vcard") { | 111 | if (mFormatName == "vcard") { |
112 | mFormat = new VCardFormatPlugin2(); | 112 | mFormat = new VCardFormatPlugin2(); |
113 | // qDebug("ResourceFile::init format VCardFormatPlugin2"); | 113 | // qDebug("ResourceFile::init format VCardFormatPlugin2"); |
114 | } | 114 | } |
115 | else if (mFormatName == "binary") { | 115 | else if (mFormatName == "binary") { |
116 | mFormat = new BinaryFormat(); | 116 | mFormat = new BinaryFormat(); |
117 | // qDebug("ResourceFile::init format BinaryFormat"); | 117 | // qDebug("ResourceFile::init format BinaryFormat"); |
118 | } | 118 | } |
119 | else | 119 | else |
120 | qDebug("ResourceFile::init format unknown !!! %s ", formatName.latin1()); | 120 | qDebug("ResourceFile::init format unknown !!! %s ", formatName.latin1()); |
121 | */ | 121 | */ |
122 | 122 | ||
123 | /*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods | 123 | /*US we have no KDirWatch. SO simulate the signals from inside the apropriate methods |
124 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | 124 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); |
125 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | 125 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); |
126 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 126 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
127 | */ | 127 | */ |
128 | 128 | ||
129 | setFileName( fileName ); | 129 | setFileName( fileName ); |
130 | } | 130 | } |
131 | 131 | ||
132 | ResourceFile::~ResourceFile() | 132 | ResourceFile::~ResourceFile() |
133 | { | 133 | { |
134 | delete mFormat; | 134 | delete mFormat; |
135 | mFormat = 0; | 135 | mFormat = 0; |
136 | } | 136 | } |
137 | 137 | ||
138 | void ResourceFile::writeConfig( KConfig *config ) | 138 | void ResourceFile::writeConfig( KConfig *config ) |
139 | { | 139 | { |
140 | Resource::writeConfig( config ); | 140 | Resource::writeConfig( config ); |
141 | 141 | ||
142 | config->writeEntry( "FileName", mFileName ); | 142 | config->writeEntry( "FileName", mFileName ); |
143 | config->writeEntry( "FileFormat", mFormatName ); | 143 | config->writeEntry( "FileFormat", mFormatName ); |
144 | 144 | ||
145 | // qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 145 | // qDebug("ResourceFile::writeConfig format %s, %s", mFileName.latin1(), mFormatName.latin1()); |
146 | 146 | ||
147 | } | 147 | } |
148 | 148 | ||
149 | Ticket *ResourceFile::requestSaveTicket() | 149 | Ticket *ResourceFile::requestSaveTicket() |
150 | { | 150 | { |
151 | kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; | 151 | kdDebug(5700) << "ResourceFile::requestSaveTicket()" << endl; |
152 | 152 | ||
153 | if ( !addressBook() ) return 0; | 153 | if ( !addressBook() ) return 0; |
154 | 154 | ||
155 | if ( !lock( mFileName ) ) { | 155 | if ( !lock( mFileName ) ) { |
156 | kdDebug(5700) << "ResourceFile::requestSaveTicket(): Unable to lock file '" | 156 | kdDebug(5700) << "ResourceFile::requestSaveTicket(): Unable to lock file '" |
157 | << mFileName << "'" << endl; | 157 | << mFileName << "'" << endl; |
158 | return 0; | 158 | return 0; |
159 | } | 159 | } |
160 | return createTicket( this ); | 160 | return createTicket( this ); |
161 | } | 161 | } |
162 | 162 | ||
163 | 163 | ||
164 | bool ResourceFile::doOpen() | 164 | bool ResourceFile::doOpen() |
165 | { | 165 | { |
166 | QFile file( mFileName ); | 166 | QFile file( mFileName ); |
167 | 167 | ||
168 | if ( !file.exists() ) { | 168 | if ( !file.exists() ) { |
169 | // try to create the file | 169 | // try to create the file |
170 | bool ok = file.open( IO_WriteOnly ); | 170 | bool ok = file.open( IO_WriteOnly ); |
171 | if ( ok ) | 171 | if ( ok ) |
172 | file.close(); | 172 | file.close(); |
173 | 173 | ||
174 | return ok; | 174 | return ok; |
175 | } else { | 175 | } else { |
176 | if ( !file.open( IO_ReadWrite ) ) | 176 | if ( !file.open( IO_ReadWrite ) ) |
177 | return false; | 177 | return false; |
178 | 178 | ||
179 | if ( file.size() == 0 ) { | 179 | if ( file.size() == 0 ) { |
180 | file.close(); | 180 | file.close(); |
181 | return true; | 181 | return true; |
182 | } | 182 | } |
183 | 183 | ||
184 | bool ok = mFormat->checkFormat( &file ); | 184 | bool ok = mFormat->checkFormat( &file ); |
185 | file.close(); | 185 | file.close(); |
186 | 186 | ||
187 | return ok; | 187 | return ok; |
188 | } | 188 | } |
189 | } | 189 | } |
190 | 190 | ||
191 | void ResourceFile::doClose() | 191 | void ResourceFile::doClose() |
192 | { | 192 | { |
193 | } | 193 | } |
194 | 194 | ||
195 | bool ResourceFile::load() | 195 | bool ResourceFile::load() |
196 | { | 196 | { |
197 | kdDebug(5700) << "ResourceFile::load(): '" << mFileName << "'" << endl; | 197 | |
198 | 198 | ||
199 | QFile file( mFileName ); | 199 | QFile file( mFileName ); |
200 | if ( !file.open( IO_ReadOnly ) ) { | 200 | if ( !file.open( IO_ReadOnly ) ) { |
201 | addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) ); | 201 | addressBook()->error( i18n( "Unable to open file '%1'." ).arg( mFileName ) ); |
202 | return false; | 202 | return false; |
203 | } | 203 | } |
204 | 204 | ||
205 | // qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 205 | // qDebug("ResourceFile::load format %s, %s", mFileName.latin1(), mFormatName.latin1()); |
206 | 206 | ||
207 | return mFormat->loadAll( addressBook(), this, &file ); | 207 | return mFormat->loadAll( addressBook(), this, &file ); |
208 | } | 208 | } |
209 | 209 | ||
210 | bool ResourceFile::save( Ticket *ticket ) | 210 | bool ResourceFile::save( Ticket *ticket ) |
211 | { | 211 | { |
212 | // qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); | 212 | // qDebug("ResourceFile::save format %s, %s", mFileName.latin1(), mFormatName.latin1()); |
213 | kdDebug(5700) << "ResourceFile::save()" << endl; | 213 | |
214 | 214 | ||
215 | // create backup file | 215 | // create backup file |
216 | QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); | 216 | QString extension = "_" + QString::number( QDate::currentDate().dayOfWeek() ); |
217 | 217 | ||
218 | /*US we use a simpler method to create a backupfile | 218 | /*US we use a simpler method to create a backupfile |
219 | 219 | ||
220 | (void) KSaveFile::backupFile( mFileName, QString::null | 220 | (void) KSaveFile::backupFile( mFileName, QString::null |
221 | ,extension ); | 221 | ,extension ); |
222 | 222 | ||
223 | KSaveFile saveFile( mFileName ); | 223 | KSaveFile saveFile( mFileName ); |
224 | bool ok = false; | 224 | bool ok = false; |
225 | if ( saveFile.status() == 0 && saveFile.file() ) | 225 | if ( saveFile.status() == 0 && saveFile.file() ) |
226 | { | 226 | { |
227 | mFormat->saveAll( addressBook(), this, saveFile.file() ); | 227 | mFormat->saveAll( addressBook(), this, saveFile.file() ); |
228 | ok = saveFile.close(); | 228 | ok = saveFile.close(); |
229 | } | 229 | } |
230 | */ | 230 | */ |
231 | 231 | ||
232 | //US ToDo: write backupfile | 232 | //US ToDo: write backupfile |
233 | QFile info; | 233 | QFile info; |
234 | info.setName( mFileName ); | 234 | info.setName( mFileName ); |
235 | bool ok = info.open( IO_WriteOnly ); | 235 | bool ok = info.open( IO_WriteOnly ); |
236 | if ( ok ) { | 236 | if ( ok ) { |
237 | mFormat->saveAll( addressBook(), this, &info ); | 237 | mFormat->saveAll( addressBook(), this, &info ); |
238 | 238 | ||
239 | info.close(); | 239 | info.close(); |
240 | ok = true; | 240 | ok = true; |
241 | } | 241 | } |
242 | else { | 242 | else { |
243 | 243 | ||
244 | } | 244 | } |
245 | 245 | ||
246 | if ( !ok ) | 246 | if ( !ok ) |
247 | addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); | 247 | addressBook()->error( i18n( "Unable to save file '%1'." ).arg( mFileName ) ); |
248 | 248 | ||
249 | delete ticket; | 249 | delete ticket; |
250 | unlock( mFileName ); | 250 | unlock( mFileName ); |
251 | 251 | ||
252 | return ok; | 252 | return ok; |
253 | 253 | ||
254 | qDebug("ResourceFile::save has to be changed"); | 254 | qDebug("ResourceFile::save has to be changed"); |
255 | return true; | 255 | return true; |
256 | } | 256 | } |
257 | 257 | ||
258 | bool ResourceFile::lock( const QString &fileName ) | 258 | bool ResourceFile::lock( const QString &fileName ) |
259 | { | 259 | { |
260 | kdDebug(5700) << "ResourceFile::lock()" << endl; | 260 | |
261 | 261 | ||
262 | QString fn = fileName; | 262 | QString fn = fileName; |
263 | 263 | ||
264 | //US change the implementation how the lockfilename is getting created | 264 | //US change the implementation how the lockfilename is getting created |
265 | //US fn.replace( QRegExp("/"), "_" ); | 265 | //US fn.replace( QRegExp("/"), "_" ); |
266 | //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); | 266 | //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); |
267 | 267 | ||
268 | KURL url(fn); | 268 | KURL url(fn); |
269 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 269 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
270 | 270 | ||
271 | kdDebug(5700) << "-- lock name: " << lockName << endl; | 271 | |
272 | 272 | ||
273 | if (QFile::exists( lockName )) return false; | 273 | if (QFile::exists( lockName )) return false; |
274 | 274 | ||
275 | QString lockUniqueName; | 275 | QString lockUniqueName; |
276 | lockUniqueName = fn + KApplication::randomString( 8 ); | 276 | lockUniqueName = fn + KApplication::randomString( 8 ); |
277 | 277 | ||
278 | url = lockUniqueName; | 278 | url = lockUniqueName; |
279 | //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); | 279 | //US mLockUniqueName = locateLocal( "data", "kabc/lock/" + lockUniqueName ); |
280 | mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); | 280 | mLockUniqueName = locateLocal( "data", "kabc/lock/" + url.fileName() ); |
281 | kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; | 281 | kdDebug(5700) << "-- lock unique name: " << mLockUniqueName << endl; |
282 | 282 | ||
283 | // Create unique file | 283 | // Create unique file |
284 | QFile file( mLockUniqueName ); | 284 | QFile file( mLockUniqueName ); |
285 | file.open( IO_WriteOnly ); | 285 | file.open( IO_WriteOnly ); |
286 | file.close(); | 286 | file.close(); |
287 | 287 | ||
288 | // Create lock file | 288 | // Create lock file |
289 | int result = ::link( QFile::encodeName( mLockUniqueName ), | 289 | int result = ::link( QFile::encodeName( mLockUniqueName ), |
290 | QFile::encodeName( lockName ) ); | 290 | QFile::encodeName( lockName ) ); |
291 | 291 | ||
292 | if ( result == 0 ) { | 292 | if ( result == 0 ) { |
293 | addressBook()->emitAddressBookLocked(); | 293 | addressBook()->emitAddressBookLocked(); |
294 | return true; | 294 | return true; |
295 | } | 295 | } |
296 | 296 | ||
297 | // TODO: check stat | 297 | // TODO: check stat |
298 | 298 | ||
299 | return false; | 299 | return false; |
300 | } | 300 | } |
301 | 301 | ||
302 | void ResourceFile::unlock( const QString &fileName ) | 302 | void ResourceFile::unlock( const QString &fileName ) |
303 | { | 303 | { |
304 | QString fn = fileName; | 304 | QString fn = fileName; |
305 | //US change the implementation how the lockfilename is getting created | 305 | //US change the implementation how the lockfilename is getting created |
306 | //US fn.replace( QRegExp( "/" ), "_" ); | 306 | //US fn.replace( QRegExp( "/" ), "_" ); |
307 | //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); | 307 | //US QString lockName = locateLocal( "data", "kabc/lock/" + fn + ".lock" ); |
308 | //US QString lockName = fn + ".lock"; | 308 | //US QString lockName = fn + ".lock"; |
309 | KURL url(fn); | 309 | KURL url(fn); |
310 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); | 310 | QString lockName = locateLocal( "data", "kabc/lock/" + url.fileName() + ".lock" ); |
311 | 311 | ||
312 | QFile::remove( lockName ); | 312 | QFile::remove( lockName ); |
313 | QFile::remove( mLockUniqueName ); | 313 | QFile::remove( mLockUniqueName ); |
314 | addressBook()->emitAddressBookUnlocked(); | 314 | addressBook()->emitAddressBookUnlocked(); |
315 | } | 315 | } |
316 | 316 | ||
317 | void ResourceFile::setFileName( const QString &fileName ) | 317 | void ResourceFile::setFileName( const QString &fileName ) |
318 | { | 318 | { |
319 | /*US ToDo: no synchronization so far. Has to be changed in the future | 319 | /*US ToDo: no synchronization so far. Has to be changed in the future |
320 | mDirWatch.stopScan(); | 320 | mDirWatch.stopScan(); |
321 | mDirWatch.removeFile( mFileName ); | 321 | mDirWatch.removeFile( mFileName ); |
322 | */ | 322 | */ |
323 | mFileName = fileName; | 323 | mFileName = fileName; |
324 | 324 | ||
325 | 325 | ||
326 | /*US ToDo: no synchronization so far. Has to be changed in the future | 326 | /*US ToDo: no synchronization so far. Has to be changed in the future |
327 | mDirWatch.addFile( mFileName ); | 327 | mDirWatch.addFile( mFileName ); |
328 | mDirWatch.startScan(); | 328 | mDirWatch.startScan(); |
329 | */ | 329 | */ |
330 | //US simulate KDirWatch event | 330 | //US simulate KDirWatch event |
331 | fileChanged(); | 331 | fileChanged(); |
332 | } | 332 | } |
333 | 333 | ||
334 | QString ResourceFile::fileName() const | 334 | QString ResourceFile::fileName() const |
335 | { | 335 | { |
336 | return mFileName; | 336 | return mFileName; |
337 | } | 337 | } |
338 | 338 | ||
339 | void ResourceFile::setFormat( const QString &format ) | 339 | void ResourceFile::setFormat( const QString &format ) |
340 | { | 340 | { |
341 | mFormatName = format; | 341 | mFormatName = format; |
342 | delete mFormat; | 342 | delete mFormat; |
343 | 343 | ||
344 | FormatFactory *factory = FormatFactory::self(); | 344 | FormatFactory *factory = FormatFactory::self(); |
345 | mFormat = factory->format( mFormatName ); | 345 | mFormat = factory->format( mFormatName ); |
346 | /*US | 346 | /*US |
347 | //qDebug("ResourceFile::setFormat initialized with format %s ", format.latin1()); | 347 | //qDebug("ResourceFile::setFormat initialized with format %s ", format.latin1()); |
348 | if (mFormatName == "vcard") { | 348 | if (mFormatName == "vcard") { |
349 | mFormat = new VCardFormatPlugin2(); | 349 | mFormat = new VCardFormatPlugin2(); |
350 | // qDebug("ResourceFile::setFormat format %s", mFormatName.latin1()); | 350 | // qDebug("ResourceFile::setFormat format %s", mFormatName.latin1()); |
351 | } | 351 | } |
352 | else if (mFormatName == "binary") { | 352 | else if (mFormatName == "binary") { |
353 | mFormat = new BinaryFormat(); | 353 | mFormat = new BinaryFormat(); |
354 | // qDebug("ResourceFile::setFormat format %s", mFormatName.latin1()); | 354 | // qDebug("ResourceFile::setFormat format %s", mFormatName.latin1()); |
355 | } | 355 | } |
356 | else | 356 | else |
357 | qDebug("ResourceFile::setFormat format unknown !!! %s ", format.latin1()); | 357 | qDebug("ResourceFile::setFormat format unknown !!! %s ", format.latin1()); |
358 | */ | 358 | */ |
359 | 359 | ||
360 | } | 360 | } |
361 | 361 | ||
362 | QString ResourceFile::format() const | 362 | QString ResourceFile::format() const |
363 | { | 363 | { |
364 | return mFormatName; | 364 | return mFormatName; |
365 | } | 365 | } |
366 | 366 | ||
367 | void ResourceFile::fileChanged() | 367 | void ResourceFile::fileChanged() |
368 | { | 368 | { |
369 | // There is a small theoretical chance that KDirWatch calls us before | 369 | // There is a small theoretical chance that KDirWatch calls us before |
370 | // we are fully constructed | 370 | // we are fully constructed |
371 | if (!addressBook()) | 371 | if (!addressBook()) |
372 | return; | 372 | return; |
373 | load(); | 373 | load(); |
374 | addressBook()->emitAddressBookChanged(); | 374 | addressBook()->emitAddressBookChanged(); |
375 | } | 375 | } |
376 | 376 | ||
377 | void ResourceFile::removeAddressee( const Addressee &addr ) | 377 | void ResourceFile::removeAddressee( const Addressee &addr ) |
378 | { | 378 | { |
379 | QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) ); | 379 | QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/photos/" ) + addr.uid() ) ); |
380 | QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) ); | 380 | QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/logos/" ) + addr.uid() ) ); |
381 | QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) ); | 381 | QFile::remove( QFile::encodeName( locateLocal( "data", "kabc/sounds/" ) + addr.uid() ) ); |
382 | } | 382 | } |
383 | 383 | ||
384 | void ResourceFile::cleanUp() | 384 | void ResourceFile::cleanUp() |
385 | { | 385 | { |
386 | unlock( mFileName ); | 386 | unlock( mFileName ); |
387 | } | 387 | } |
388 | 388 | ||
389 | //US #include "resourcefile.moc" | 389 | //US #include "resourcefile.moc" |
diff --git a/kabc/stdaddressbook.cpp b/kabc/stdaddressbook.cpp index 075f12f..1e00cc6 100644 --- a/kabc/stdaddressbook.cpp +++ b/kabc/stdaddressbook.cpp | |||
@@ -1,228 +1,228 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include "resource.h" | 29 | #include "resource.h" |
30 | #include <kresources/manager.h> | 30 | #include <kresources/manager.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <klocale.h> | 32 | #include <klocale.h> |
33 | #include <kstaticdeleter.h> | 33 | #include <kstaticdeleter.h> |
34 | #include <kstandarddirs.h> | 34 | #include <kstandarddirs.h> |
35 | 35 | ||
36 | #include "stdaddressbook.h" | 36 | #include "stdaddressbook.h" |
37 | 37 | ||
38 | using namespace KABC; | 38 | using namespace KABC; |
39 | 39 | ||
40 | StdAddressBook *StdAddressBook::mSelf = 0; | 40 | StdAddressBook *StdAddressBook::mSelf = 0; |
41 | bool StdAddressBook::mAutomaticSave = true; | 41 | bool StdAddressBook::mAutomaticSave = true; |
42 | 42 | ||
43 | static KStaticDeleter<StdAddressBook> addressBookDeleter; | 43 | static KStaticDeleter<StdAddressBook> addressBookDeleter; |
44 | 44 | ||
45 | QString StdAddressBook::fileName() | 45 | QString StdAddressBook::fileName() |
46 | { | 46 | { |
47 | return locateLocal( "data", "kabc/std.vcf" ); | 47 | return locateLocal( "data", "kabc/std.vcf" ); |
48 | } | 48 | } |
49 | 49 | ||
50 | QString StdAddressBook::directoryName() | 50 | QString StdAddressBook::directoryName() |
51 | { | 51 | { |
52 | return locateLocal( "data", "kabc/stdvcf" ); | 52 | return locateLocal( "data", "kabc/stdvcf" ); |
53 | } | 53 | } |
54 | 54 | ||
55 | void StdAddressBook::handleCrash() | 55 | void StdAddressBook::handleCrash() |
56 | { | 56 | { |
57 | StdAddressBook::self()->cleanUp(); | 57 | StdAddressBook::self()->cleanUp(); |
58 | } | 58 | } |
59 | 59 | ||
60 | StdAddressBook *StdAddressBook::self() | 60 | StdAddressBook *StdAddressBook::self() |
61 | { | 61 | { |
62 | 62 | ||
63 | if ( !mSelf ) | 63 | if ( !mSelf ) |
64 | { | 64 | { |
65 | QString appdir = StdAddressBook::setTempAppDir(); | 65 | QString appdir = StdAddressBook::setTempAppDir(); |
66 | 66 | ||
67 | kdDebug(5700) << "StdAddressBook::self()" << endl; | 67 | kdDebug(5700) << "StdAddressBook::self()" << endl; |
68 | // US im am not sure why I have to use the other format here?? | 68 | // US im am not sure why I have to use the other format here?? |
69 | #ifdef KAB_EMBEDDED | 69 | #ifdef KAB_EMBEDDED |
70 | mSelf = addressBookDeleter.setObject( new StdAddressBook ); | 70 | mSelf = addressBookDeleter.setObject( new StdAddressBook ); |
71 | #else //KAB_EMBEDDED | 71 | #else //KAB_EMBEDDED |
72 | addressBookDeleter.setObject( mSelf, new StdAddressBook ); | 72 | addressBookDeleter.setObject( mSelf, new StdAddressBook ); |
73 | #endif //KAB_EMBEDDED | 73 | #endif //KAB_EMBEDDED |
74 | KStandardDirs::setAppDir( appdir ); | 74 | KStandardDirs::setAppDir( appdir ); |
75 | } | 75 | } |
76 | 76 | ||
77 | return mSelf; | 77 | return mSelf; |
78 | } | 78 | } |
79 | 79 | ||
80 | QString StdAddressBook::setTempAppDir() | 80 | QString StdAddressBook::setTempAppDir() |
81 | { | 81 | { |
82 | QString appDIR = KStandardDirs::appDir(); | 82 | QString appDIR = KStandardDirs::appDir(); |
83 | #ifdef DESKTOP_VERSION | 83 | #ifdef DESKTOP_VERSION |
84 | QString appdir = QDir::homeDirPath(); | 84 | QString appdir = QDir::homeDirPath(); |
85 | if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) | 85 | if ( appdir.right(1) == "\\" || appdir.right(1) == "/" ) |
86 | appdir += "kaddressbook/"; | 86 | appdir += "kaddressbook/"; |
87 | else | 87 | else |
88 | appdir += "/kaddressbook/"; | 88 | appdir += "/kaddressbook/"; |
89 | KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); | 89 | KStandardDirs::setAppDir( QDir::convertSeparators( appdir )); |
90 | #else | 90 | #else |
91 | QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook"; | 91 | QString appdir = QDir::homeDirPath() + "/kdepim/apps/kaddressbook"; |
92 | 92 | ||
93 | KStandardDirs::setAppDir( appdir ); | 93 | KStandardDirs::setAppDir( appdir ); |
94 | #endif | 94 | #endif |
95 | 95 | ||
96 | return appDIR; | 96 | return appDIR; |
97 | } | 97 | } |
98 | StdAddressBook *StdAddressBook::self( bool onlyFastResources ) | 98 | StdAddressBook *StdAddressBook::self( bool onlyFastResources ) |
99 | { | 99 | { |
100 | 100 | ||
101 | if ( !mSelf ) | 101 | if ( !mSelf ) |
102 | { | 102 | { |
103 | QString appdir =StdAddressBook::setTempAppDir(); | 103 | QString appdir =StdAddressBook::setTempAppDir(); |
104 | #ifdef KAB_EMBEDDED | 104 | #ifdef KAB_EMBEDDED |
105 | mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); | 105 | mSelf = addressBookDeleter.setObject( new StdAddressBook( onlyFastResources ) ); |
106 | #else //KAB_EMBEDDED | 106 | #else //KAB_EMBEDDED |
107 | addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); | 107 | addressBookDeleter.setObject( mSelf, new StdAddressBook( onlyFastResources ) ); |
108 | #endif //KAB_EMBEDDED | 108 | #endif //KAB_EMBEDDED |
109 | KStandardDirs::setAppDir( appdir ); | 109 | KStandardDirs::setAppDir( appdir ); |
110 | } | 110 | } |
111 | return mSelf; | 111 | return mSelf; |
112 | } | 112 | } |
113 | 113 | ||
114 | StdAddressBook::StdAddressBook() | 114 | StdAddressBook::StdAddressBook() |
115 | //US : AddressBook( "kabcrc" ) | 115 | //US : AddressBook( "kabcrc" ) |
116 | : AddressBook( locateLocal( "config", "kabcrc") ) | 116 | : AddressBook( locateLocal( "config", "kabcrc") ) |
117 | { | 117 | { |
118 | 118 | ||
119 | init( false ); | 119 | init( false ); |
120 | } | 120 | } |
121 | 121 | ||
122 | StdAddressBook::StdAddressBook( bool onlyFastResources ) | 122 | StdAddressBook::StdAddressBook( bool onlyFastResources ) |
123 | //US : AddressBook( "kabcrc" ) | 123 | //US : AddressBook( "kabcrc" ) |
124 | : AddressBook( locateLocal( "config", "kabcrc") ) | 124 | : AddressBook( locateLocal( "config", "kabcrc") ) |
125 | { | 125 | { |
126 | 126 | ||
127 | init( onlyFastResources ); | 127 | init( onlyFastResources ); |
128 | } | 128 | } |
129 | 129 | ||
130 | StdAddressBook::~StdAddressBook() | 130 | StdAddressBook::~StdAddressBook() |
131 | { | 131 | { |
132 | if ( mAutomaticSave ) | 132 | if ( mAutomaticSave ) |
133 | save(); | 133 | save(); |
134 | } | 134 | } |
135 | 135 | ||
136 | void StdAddressBook::init( bool ) | 136 | void StdAddressBook::init( bool ) |
137 | { | 137 | { |
138 | KRES::Manager<Resource> *manager = resourceManager(); | 138 | KRES::Manager<Resource> *manager = resourceManager(); |
139 | KRES::Manager<Resource>::ActiveIterator it; | 139 | KRES::Manager<Resource>::ActiveIterator it; |
140 | 140 | ||
141 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 141 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
142 | (*it)->setAddressBook( this ); | 142 | (*it)->setAddressBook( this ); |
143 | if ( !(*it)->open() ) | 143 | if ( !(*it)->open() ) |
144 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); | 144 | error( QString( "Unable to open resource '%1'!" ).arg( (*it)->resourceName() ) ); |
145 | } | 145 | } |
146 | 146 | ||
147 | Resource *res = standardResource(); | 147 | Resource *res = standardResource(); |
148 | if ( !res ) { | 148 | if ( !res ) { |
149 | res = manager->createResource( "file" ); | 149 | res = manager->createResource( "file" ); |
150 | if ( res ) | 150 | if ( res ) |
151 | { | 151 | { |
152 | addResource( res ); | 152 | addResource( res ); |
153 | } | 153 | } |
154 | else | 154 | else |
155 | kdDebug(5700) << "No resource available!!!" << endl; | 155 | qDebug(" No resource available!!!"); |
156 | } | 156 | } |
157 | 157 | ||
158 | setStandardResource( res ); | 158 | setStandardResource( res ); |
159 | manager->writeConfig(); | 159 | manager->writeConfig(); |
160 | 160 | ||
161 | load(); | 161 | load(); |
162 | } | 162 | } |
163 | 163 | ||
164 | bool StdAddressBook::save() | 164 | bool StdAddressBook::save() |
165 | { | 165 | { |
166 | kdDebug(5700) << "StdAddressBook::save()" << endl; | 166 | kdDebug(5700) << "StdAddressBook::save()" << endl; |
167 | 167 | ||
168 | bool ok = true; | 168 | bool ok = true; |
169 | AddressBook *ab = self(); | 169 | AddressBook *ab = self(); |
170 | 170 | ||
171 | ab->deleteRemovedAddressees(); | 171 | ab->deleteRemovedAddressees(); |
172 | 172 | ||
173 | KRES::Manager<Resource>::ActiveIterator it; | 173 | KRES::Manager<Resource>::ActiveIterator it; |
174 | KRES::Manager<Resource> *manager = ab->resourceManager(); | 174 | KRES::Manager<Resource> *manager = ab->resourceManager(); |
175 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { | 175 | for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) { |
176 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { | 176 | if ( !(*it)->readOnly() && (*it)->isOpen() ) { |
177 | Ticket *ticket = ab->requestSaveTicket( *it ); | 177 | Ticket *ticket = ab->requestSaveTicket( *it ); |
178 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); | 178 | // qDebug("StdAddressBook::save '%s'", (*it)->resourceName().latin1() ); |
179 | if ( !ticket ) { | 179 | if ( !ticket ) { |
180 | ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) | 180 | ab->error( i18n( "Unable to save to resource '%1'. It is locked." ) |
181 | .arg( (*it)->resourceName() ) ); | 181 | .arg( (*it)->resourceName() ) ); |
182 | return false; | 182 | return false; |
183 | } | 183 | } |
184 | 184 | ||
185 | if ( !ab->save( ticket ) ) | 185 | if ( !ab->save( ticket ) ) |
186 | ok = false; | 186 | ok = false; |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | return ok; | 190 | return ok; |
191 | } | 191 | } |
192 | 192 | ||
193 | void StdAddressBook::close() | 193 | void StdAddressBook::close() |
194 | { | 194 | { |
195 | //US destructObject is not defined on my system???. Is setObject(0) the same ??? | 195 | //US destructObject is not defined on my system???. Is setObject(0) the same ??? |
196 | //US addressBookDeleter.destructObject(); | 196 | //US addressBookDeleter.destructObject(); |
197 | addressBookDeleter.setObject(0); | 197 | addressBookDeleter.setObject(0); |
198 | 198 | ||
199 | } | 199 | } |
200 | 200 | ||
201 | void StdAddressBook::setAutomaticSave( bool enable ) | 201 | void StdAddressBook::setAutomaticSave( bool enable ) |
202 | { | 202 | { |
203 | mAutomaticSave = enable; | 203 | mAutomaticSave = enable; |
204 | } | 204 | } |
205 | 205 | ||
206 | bool StdAddressBook::automaticSave() | 206 | bool StdAddressBook::automaticSave() |
207 | { | 207 | { |
208 | return mAutomaticSave; | 208 | return mAutomaticSave; |
209 | } | 209 | } |
210 | 210 | ||
211 | // should get const for 4.X | 211 | // should get const for 4.X |
212 | Addressee StdAddressBook::whoAmI() | 212 | Addressee StdAddressBook::whoAmI() |
213 | { | 213 | { |
214 | //US KConfig config( "kabcrc" ); | 214 | //US KConfig config( "kabcrc" ); |
215 | KConfig config( locateLocal("config", "kabcrc") ); | 215 | KConfig config( locateLocal("config", "kabcrc") ); |
216 | config.setGroup( "General" ); | 216 | config.setGroup( "General" ); |
217 | 217 | ||
218 | return findByUid( config.readEntry( "WhoAmI" ) ); | 218 | return findByUid( config.readEntry( "WhoAmI" ) ); |
219 | } | 219 | } |
220 | 220 | ||
221 | void StdAddressBook::setWhoAmI( const Addressee &addr ) | 221 | void StdAddressBook::setWhoAmI( const Addressee &addr ) |
222 | { | 222 | { |
223 | //US KConfig config( "kabcrc" ); | 223 | //US KConfig config( "kabcrc" ); |
224 | KConfig config( locateLocal("config", "kabcrc") ); | 224 | KConfig config( locateLocal("config", "kabcrc") ); |
225 | config.setGroup( "General" ); | 225 | config.setGroup( "General" ); |
226 | 226 | ||
227 | config.writeEntry( "WhoAmI", addr.uid() ); | 227 | config.writeEntry( "WhoAmI", addr.uid() ); |
228 | } | 228 | } |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 3ae23e8..a0fec91 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -1,1602 +1,1602 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressbook. | 2 | This file is part of KAddressbook. |
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include "kabcore.h" | 24 | #include "kabcore.h" |
25 | 25 | ||
26 | #include <stdaddressbook.h> | 26 | #include <stdaddressbook.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | #ifndef KAB_EMBEDDED | 29 | #ifndef KAB_EMBEDDED |
30 | #include <qclipboard.h> | 30 | #include <qclipboard.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qapplicaton.h> | 33 | #include <qapplicaton.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | #include <qvbox.h> | 36 | #include <qvbox.h> |
37 | #include <kabc/addresseelist.h> | 37 | #include <kabc/addresseelist.h> |
38 | #include <kabc/errorhandler.h> | 38 | #include <kabc/errorhandler.h> |
39 | #include <kabc/resource.h> | 39 | #include <kabc/resource.h> |
40 | #include <kabc/vcardconverter.h> | 40 | #include <kabc/vcardconverter.h> |
41 | #include <kapplication.h> | 41 | #include <kapplication.h> |
42 | #include <kactionclasses.h> | 42 | #include <kactionclasses.h> |
43 | #include <kcmultidialog.h> | 43 | #include <kcmultidialog.h> |
44 | #include <kdebug.h> | 44 | #include <kdebug.h> |
45 | #include <kdeversion.h> | 45 | #include <kdeversion.h> |
46 | #include <kkeydialog.h> | 46 | #include <kkeydialog.h> |
47 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> |
48 | #include <kprinter.h> | 48 | #include <kprinter.h> |
49 | #include <kprotocolinfo.h> | 49 | #include <kprotocolinfo.h> |
50 | #include <kresources/selectdialog.h> | 50 | #include <kresources/selectdialog.h> |
51 | #include <kstandarddirs.h> | 51 | #include <kstandarddirs.h> |
52 | #include <ktempfile.h> | 52 | #include <ktempfile.h> |
53 | #include <kxmlguiclient.h> | 53 | #include <kxmlguiclient.h> |
54 | #include <kaboutdata.h> | 54 | #include <kaboutdata.h> |
55 | #include <libkdepim/categoryselectdialog.h> | 55 | #include <libkdepim/categoryselectdialog.h> |
56 | 56 | ||
57 | #include "addresseeutil.h" | 57 | #include "addresseeutil.h" |
58 | #include "addresseeeditordialog.h" | 58 | #include "addresseeeditordialog.h" |
59 | #include "extensionmanager.h" | 59 | #include "extensionmanager.h" |
60 | #include "kstdaction.h" | 60 | #include "kstdaction.h" |
61 | #include "kaddressbookservice.h" | 61 | #include "kaddressbookservice.h" |
62 | #include "ldapsearchdialog.h" | 62 | #include "ldapsearchdialog.h" |
63 | #include "printing/printingwizard.h" | 63 | #include "printing/printingwizard.h" |
64 | #else // KAB_EMBEDDED | 64 | #else // KAB_EMBEDDED |
65 | 65 | ||
66 | #include <kapplication.h> | 66 | #include <kapplication.h> |
67 | #include "KDGanttMinimizeSplitter.h" | 67 | #include "KDGanttMinimizeSplitter.h" |
68 | #include "kaddressbookmain.h" | 68 | #include "kaddressbookmain.h" |
69 | #include "kactioncollection.h" | 69 | #include "kactioncollection.h" |
70 | #include <qapp.h> | 70 | #include <qapp.h> |
71 | #include <qmenubar.h> | 71 | #include <qmenubar.h> |
72 | //#include <qtoolbar.h> | 72 | //#include <qtoolbar.h> |
73 | #include <qmessagebox.h> | 73 | #include <qmessagebox.h> |
74 | #include <kdebug.h> | 74 | #include <kdebug.h> |
75 | #include <kiconloader.h> // needed for SmallIcon | 75 | #include <kiconloader.h> // needed for SmallIcon |
76 | #include <kresources/kcmkresources.h> | 76 | #include <kresources/kcmkresources.h> |
77 | #include <ktoolbar.h> | 77 | #include <ktoolbar.h> |
78 | 78 | ||
79 | #include <kcmkabconfig.h> | 79 | #include <kcmkabconfig.h> |
80 | 80 | ||
81 | //US#include <qpe/resource.h> // needed for Resource::loadPixmap | 81 | //US#include <qpe/resource.h> // needed for Resource::loadPixmap |
82 | //#include <qlabel.h> | 82 | //#include <qlabel.h> |
83 | #endif // KAB_EMBEDDED | 83 | #endif // KAB_EMBEDDED |
84 | #include <kcmkabconfig.h> | 84 | #include <kcmkabconfig.h> |
85 | 85 | ||
86 | 86 | ||
87 | #include <kresources/selectdialog.h> | 87 | #include <kresources/selectdialog.h> |
88 | #include <kmessagebox.h> | 88 | #include <kmessagebox.h> |
89 | 89 | ||
90 | #include <picture.h> | 90 | #include <picture.h> |
91 | #include <resource.h> | 91 | #include <resource.h> |
92 | 92 | ||
93 | //US#include <qsplitter.h> | 93 | //US#include <qsplitter.h> |
94 | #include <qvbox.h> | 94 | #include <qvbox.h> |
95 | #include <qlayout.h> | 95 | #include <qlayout.h> |
96 | #include <qclipboard.h> | 96 | #include <qclipboard.h> |
97 | 97 | ||
98 | #include <libkdepim/categoryselectdialog.h> | 98 | #include <libkdepim/categoryselectdialog.h> |
99 | 99 | ||
100 | #include "addresseeutil.h" | 100 | #include "addresseeutil.h" |
101 | #include "undocmds.h" | 101 | #include "undocmds.h" |
102 | #include "addresseeeditordialog.h" | 102 | #include "addresseeeditordialog.h" |
103 | #include "viewmanager.h" | 103 | #include "viewmanager.h" |
104 | #include "details/detailsviewcontainer.h" | 104 | #include "details/detailsviewcontainer.h" |
105 | #include "kabprefs.h" | 105 | #include "kabprefs.h" |
106 | #include "xxportmanager.h" | 106 | #include "xxportmanager.h" |
107 | #include "incsearchwidget.h" | 107 | #include "incsearchwidget.h" |
108 | #include "jumpbuttonbar.h" | 108 | #include "jumpbuttonbar.h" |
109 | #include "extensionmanager.h" | 109 | #include "extensionmanager.h" |
110 | #include "addresseeconfig.h" | 110 | #include "addresseeconfig.h" |
111 | #include <kcmultidialog.h> | 111 | #include <kcmultidialog.h> |
112 | 112 | ||
113 | 113 | ||
114 | #ifdef KAB_EMBEDDED | 114 | #ifdef KAB_EMBEDDED |
115 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) | 115 | KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) |
116 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 116 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
117 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ | 117 | mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ |
118 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) | 118 | mReadWrite( readWrite ), mModified( false ), mMainWindow(client) |
119 | #else //KAB_EMBEDDED | 119 | #else //KAB_EMBEDDED |
120 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) | 120 | KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) |
121 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), | 121 | : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), |
122 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), | 122 | mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), |
123 | mReadWrite( readWrite ), mModified( false ) | 123 | mReadWrite( readWrite ), mModified( false ) |
124 | #endif //KAB_EMBEDDED | 124 | #endif //KAB_EMBEDDED |
125 | { | 125 | { |
126 | #ifdef KAB_EMBEDDED | 126 | #ifdef KAB_EMBEDDED |
127 | //US we define here our own global actioncollection. | 127 | //US we define here our own global actioncollection. |
128 | //mActionCollection = new KActionCollection(this); | 128 | //mActionCollection = new KActionCollection(this); |
129 | #endif //KAB_EMBEDDED | 129 | #endif //KAB_EMBEDDED |
130 | mExtensionBarSplitter = 0; | 130 | mExtensionBarSplitter = 0; |
131 | mIsPart = !parent->inherits( "KAddressBookMain" ); | 131 | mIsPart = !parent->inherits( "KAddressBookMain" ); |
132 | 132 | ||
133 | mAddressBook = KABC::StdAddressBook::self(); | 133 | mAddressBook = KABC::StdAddressBook::self(); |
134 | KABC::StdAddressBook::setAutomaticSave( true ); | 134 | KABC::StdAddressBook::setAutomaticSave( false ); |
135 | 135 | ||
136 | #ifndef KAB_EMBEDDED | 136 | #ifndef KAB_EMBEDDED |
137 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); | 137 | mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); |
138 | #endif //KAB_EMBEDDED | 138 | #endif //KAB_EMBEDDED |
139 | 139 | ||
140 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), | 140 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), |
141 | SLOT( addressBookChanged() ) ); | 141 | SLOT( addressBookChanged() ) ); |
142 | 142 | ||
143 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, | 143 | mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, |
144 | "X-Department", "KADDRESSBOOK" ); | 144 | "X-Department", "KADDRESSBOOK" ); |
145 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, | 145 | mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, |
146 | "X-Profession", "KADDRESSBOOK" ); | 146 | "X-Profession", "KADDRESSBOOK" ); |
147 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, | 147 | mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, |
148 | "X-AssistantsName", "KADDRESSBOOK" ); | 148 | "X-AssistantsName", "KADDRESSBOOK" ); |
149 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, | 149 | mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, |
150 | "X-ManagersName", "KADDRESSBOOK" ); | 150 | "X-ManagersName", "KADDRESSBOOK" ); |
151 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, | 151 | mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, |
152 | "X-SpousesName", "KADDRESSBOOK" ); | 152 | "X-SpousesName", "KADDRESSBOOK" ); |
153 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, | 153 | mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, |
154 | "X-Office", "KADDRESSBOOK" ); | 154 | "X-Office", "KADDRESSBOOK" ); |
155 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, | 155 | mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, |
156 | "X-IMAddress", "KADDRESSBOOK" ); | 156 | "X-IMAddress", "KADDRESSBOOK" ); |
157 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, | 157 | mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, |
158 | "X-Anniversary", "KADDRESSBOOK" ); | 158 | "X-Anniversary", "KADDRESSBOOK" ); |
159 | 159 | ||
160 | //US added this field to become compatible with Opie addressbook | 160 | //US added this field to become compatible with Opie addressbook |
161 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, | 161 | mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, |
162 | "X-Gender", "KADDRESSBOOK" ); | 162 | "X-Gender", "KADDRESSBOOK" ); |
163 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, | 163 | mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, |
164 | "X-Children", "KADDRESSBOOK" ); | 164 | "X-Children", "KADDRESSBOOK" ); |
165 | 165 | ||
166 | initGUI(); | 166 | initGUI(); |
167 | 167 | ||
168 | mIncSearchWidget->setFocus(); | 168 | mIncSearchWidget->setFocus(); |
169 | 169 | ||
170 | 170 | ||
171 | connect( mViewManager, SIGNAL( selected( const QString& ) ), | 171 | connect( mViewManager, SIGNAL( selected( const QString& ) ), |
172 | SLOT( setContactSelected( const QString& ) ) ); | 172 | SLOT( setContactSelected( const QString& ) ) ); |
173 | connect( mViewManager, SIGNAL( executed( const QString& ) ), | 173 | connect( mViewManager, SIGNAL( executed( const QString& ) ), |
174 | SLOT( editContact( const QString& ) ) ); | 174 | SLOT( editContact( const QString& ) ) ); |
175 | connect( mViewManager, SIGNAL( deleteRequest( ) ), | 175 | connect( mViewManager, SIGNAL( deleteRequest( ) ), |
176 | SLOT( deleteContacts( ) ) ); | 176 | SLOT( deleteContacts( ) ) ); |
177 | connect( mViewManager, SIGNAL( modified() ), | 177 | connect( mViewManager, SIGNAL( modified() ), |
178 | SLOT( setModified() ) ); | 178 | SLOT( setModified() ) ); |
179 | 179 | ||
180 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); | 180 | connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); |
181 | 181 | ||
182 | connect( mXXPortManager, SIGNAL( modified() ), | 182 | connect( mXXPortManager, SIGNAL( modified() ), |
183 | SLOT( setModified() ) ); | 183 | SLOT( setModified() ) ); |
184 | 184 | ||
185 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), | 185 | connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), |
186 | SLOT( incrementalSearch( const QString& ) ) ); | 186 | SLOT( incrementalSearch( const QString& ) ) ); |
187 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), | 187 | connect( mIncSearchWidget, SIGNAL( fieldChanged() ), |
188 | mJumpButtonBar, SLOT( recreateButtons() ) ); | 188 | mJumpButtonBar, SLOT( recreateButtons() ) ); |
189 | 189 | ||
190 | #ifndef KAB_EMBEDDED | 190 | #ifndef KAB_EMBEDDED |
191 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 191 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
192 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 192 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
193 | 193 | ||
194 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), | 194 | connect( mDetails, SIGNAL( sendEmail( const QString& ) ), |
195 | SLOT( sendMail( const QString& ) ) ); | 195 | SLOT( sendMail( const QString& ) ) ); |
196 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 196 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
197 | SLOT( browse( const QString& ) ) ); | 197 | SLOT( browse( const QString& ) ) ); |
198 | 198 | ||
199 | mAddressBookService = new KAddressBookService( this ); | 199 | mAddressBookService = new KAddressBookService( this ); |
200 | 200 | ||
201 | #endif //KAB_EMBEDDED | 201 | #endif //KAB_EMBEDDED |
202 | mEditorDialog = 0; | 202 | mEditorDialog = 0; |
203 | createAddresseeEditorDialog( this ); | 203 | createAddresseeEditorDialog( this ); |
204 | setModified( false ); | 204 | setModified( false ); |
205 | } | 205 | } |
206 | 206 | ||
207 | KABCore::~KABCore() | 207 | KABCore::~KABCore() |
208 | { | 208 | { |
209 | // save(); | 209 | // save(); |
210 | //saveSettings(); | 210 | //saveSettings(); |
211 | //KABPrefs::instance()->writeConfig(); | 211 | //KABPrefs::instance()->writeConfig(); |
212 | delete AddresseeConfig::instance(); | 212 | delete AddresseeConfig::instance(); |
213 | mAddressBook = 0; | 213 | mAddressBook = 0; |
214 | KABC::StdAddressBook::close(); | 214 | KABC::StdAddressBook::close(); |
215 | 215 | ||
216 | #ifdef KAB_EMBEDDED | 216 | #ifdef KAB_EMBEDDED |
217 | //US we define here our own global actioncollection. | 217 | //US we define here our own global actioncollection. |
218 | // delete mActionCollection; | 218 | // delete mActionCollection; |
219 | #endif //KAB_EMBEDDED | 219 | #endif //KAB_EMBEDDED |
220 | 220 | ||
221 | } | 221 | } |
222 | 222 | ||
223 | void KABCore::restoreSettings() | 223 | void KABCore::restoreSettings() |
224 | { | 224 | { |
225 | bool state = KABPrefs::instance()->mJumpButtonBarVisible; | 225 | bool state = KABPrefs::instance()->mJumpButtonBarVisible; |
226 | 226 | ||
227 | mActionJumpBar->setChecked( state ); | 227 | mActionJumpBar->setChecked( state ); |
228 | setJumpButtonBarVisible( state ); | 228 | setJumpButtonBarVisible( state ); |
229 | 229 | ||
230 | state = KABPrefs::instance()->mDetailsPageVisible; | 230 | state = KABPrefs::instance()->mDetailsPageVisible; |
231 | 231 | ||
232 | mActionDetails->setChecked( state ); | 232 | mActionDetails->setChecked( state ); |
233 | setDetailsVisible( state ); | 233 | setDetailsVisible( state ); |
234 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 234 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
235 | if ( splitterSize.count() == 0 ) { | 235 | if ( splitterSize.count() == 0 ) { |
236 | splitterSize.append( width() / 2 ); | 236 | splitterSize.append( width() / 2 ); |
237 | splitterSize.append( width() / 2 ); | 237 | splitterSize.append( width() / 2 ); |
238 | } | 238 | } |
239 | mMiniSplitter->setSizes( splitterSize ); | 239 | mMiniSplitter->setSizes( splitterSize ); |
240 | if ( mExtensionBarSplitter ) { | 240 | if ( mExtensionBarSplitter ) { |
241 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 241 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
242 | if ( splitterSize.count() == 0 ) { | 242 | if ( splitterSize.count() == 0 ) { |
243 | splitterSize.append( width() / 2 ); | 243 | splitterSize.append( width() / 2 ); |
244 | splitterSize.append( width() / 2 ); | 244 | splitterSize.append( width() / 2 ); |
245 | } | 245 | } |
246 | mExtensionBarSplitter->setSizes( splitterSize ); | 246 | mExtensionBarSplitter->setSizes( splitterSize ); |
247 | 247 | ||
248 | } | 248 | } |
249 | #ifndef KAB_EMBEDDED | 249 | #ifndef KAB_EMBEDDED |
250 | QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 250 | QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
251 | if ( splitterSize.count() == 0 ) { | 251 | if ( splitterSize.count() == 0 ) { |
252 | splitterSize.append( width() / 2 ); | 252 | splitterSize.append( width() / 2 ); |
253 | splitterSize.append( width() / 2 ); | 253 | splitterSize.append( width() / 2 ); |
254 | } | 254 | } |
255 | mExtensionBarSplitter->setSizes( splitterSize ); | 255 | mExtensionBarSplitter->setSizes( splitterSize ); |
256 | 256 | ||
257 | splitterSize = KABPrefs::instance()->mDetailsSplitter; | 257 | splitterSize = KABPrefs::instance()->mDetailsSplitter; |
258 | if ( splitterSize.count() == 0 ) { | 258 | if ( splitterSize.count() == 0 ) { |
259 | splitterSize.append( height() / 2 ); | 259 | splitterSize.append( height() / 2 ); |
260 | splitterSize.append( height() / 2 ); | 260 | splitterSize.append( height() / 2 ); |
261 | } | 261 | } |
262 | mDetailsSplitter->setSizes( splitterSize ); | 262 | mDetailsSplitter->setSizes( splitterSize ); |
263 | 263 | ||
264 | mExtensionManager->restoreSettings(); | 264 | mExtensionManager->restoreSettings(); |
265 | 265 | ||
266 | #endif //KAB_EMBEDDED | 266 | #endif //KAB_EMBEDDED |
267 | 267 | ||
268 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 268 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
269 | 269 | ||
270 | mViewManager->restoreSettings(); | 270 | mViewManager->restoreSettings(); |
271 | mExtensionManager->restoreSettings(); | 271 | mExtensionManager->restoreSettings(); |
272 | } | 272 | } |
273 | 273 | ||
274 | void KABCore::saveSettings() | 274 | void KABCore::saveSettings() |
275 | { | 275 | { |
276 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 276 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
277 | if ( mExtensionBarSplitter ) | 277 | if ( mExtensionBarSplitter ) |
278 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 278 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
279 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 279 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
280 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 280 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
281 | #ifndef KAB_EMBEDDED | 281 | #ifndef KAB_EMBEDDED |
282 | 282 | ||
283 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 283 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
284 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 284 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
285 | #endif //KAB_EMBEDDED | 285 | #endif //KAB_EMBEDDED |
286 | mExtensionManager->saveSettings(); | 286 | mExtensionManager->saveSettings(); |
287 | mViewManager->saveSettings(); | 287 | mViewManager->saveSettings(); |
288 | 288 | ||
289 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 289 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
290 | 290 | ||
291 | } | 291 | } |
292 | 292 | ||
293 | KABC::AddressBook *KABCore::addressBook() const | 293 | KABC::AddressBook *KABCore::addressBook() const |
294 | { | 294 | { |
295 | return mAddressBook; | 295 | return mAddressBook; |
296 | } | 296 | } |
297 | 297 | ||
298 | KConfig *KABCore::config() | 298 | KConfig *KABCore::config() |
299 | { | 299 | { |
300 | #ifndef KAB_EMBEDDED | 300 | #ifndef KAB_EMBEDDED |
301 | return KABPrefs::instance()->config(); | 301 | return KABPrefs::instance()->config(); |
302 | #else //KAB_EMBEDDED | 302 | #else //KAB_EMBEDDED |
303 | return KABPrefs::instance()->getConfig(); | 303 | return KABPrefs::instance()->getConfig(); |
304 | #endif //KAB_EMBEDDED | 304 | #endif //KAB_EMBEDDED |
305 | } | 305 | } |
306 | 306 | ||
307 | KActionCollection *KABCore::actionCollection() const | 307 | KActionCollection *KABCore::actionCollection() const |
308 | { | 308 | { |
309 | return mGUIClient->actionCollection(); | 309 | return mGUIClient->actionCollection(); |
310 | } | 310 | } |
311 | 311 | ||
312 | KABC::Field *KABCore::currentSearchField() const | 312 | KABC::Field *KABCore::currentSearchField() const |
313 | { | 313 | { |
314 | if (mIncSearchWidget) | 314 | if (mIncSearchWidget) |
315 | return mIncSearchWidget->currentField(); | 315 | return mIncSearchWidget->currentField(); |
316 | else | 316 | else |
317 | return 0; | 317 | return 0; |
318 | } | 318 | } |
319 | 319 | ||
320 | QStringList KABCore::selectedUIDs() const | 320 | QStringList KABCore::selectedUIDs() const |
321 | { | 321 | { |
322 | return mViewManager->selectedUids(); | 322 | return mViewManager->selectedUids(); |
323 | } | 323 | } |
324 | 324 | ||
325 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 325 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
326 | { | 326 | { |
327 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 327 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
328 | 328 | ||
329 | QPtrList<KRES::Resource> kresResources; | 329 | QPtrList<KRES::Resource> kresResources; |
330 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 330 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
331 | KABC::Resource *resource; | 331 | KABC::Resource *resource; |
332 | while ( ( resource = resIt.current() ) != 0 ) { | 332 | while ( ( resource = resIt.current() ) != 0 ) { |
333 | ++resIt; | 333 | ++resIt; |
334 | if ( !resource->readOnly() ) { | 334 | if ( !resource->readOnly() ) { |
335 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 335 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
336 | if ( res ) | 336 | if ( res ) |
337 | kresResources.append( res ); | 337 | kresResources.append( res ); |
338 | } | 338 | } |
339 | } | 339 | } |
340 | 340 | ||
341 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 341 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
342 | return static_cast<KABC::Resource*>( res ); | 342 | return static_cast<KABC::Resource*>( res ); |
343 | } | 343 | } |
344 | 344 | ||
345 | #ifndef KAB_EMBEDDED | 345 | #ifndef KAB_EMBEDDED |
346 | KAboutData *KABCore::createAboutData() | 346 | KAboutData *KABCore::createAboutData() |
347 | #else //KAB_EMBEDDED | 347 | #else //KAB_EMBEDDED |
348 | void KABCore::createAboutData() | 348 | void KABCore::createAboutData() |
349 | #endif //KAB_EMBEDDED | 349 | #endif //KAB_EMBEDDED |
350 | { | 350 | { |
351 | #ifndef KAB_EMBEDDED | 351 | #ifndef KAB_EMBEDDED |
352 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 352 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
353 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 353 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
354 | KAboutData::License_GPL_V2, | 354 | KAboutData::License_GPL_V2, |
355 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 355 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
356 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 356 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
357 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 357 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
358 | about->addAuthor( "Cornelius Schumacher", | 358 | about->addAuthor( "Cornelius Schumacher", |
359 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 359 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
360 | "schumacher@kde.org" ); | 360 | "schumacher@kde.org" ); |
361 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 361 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
362 | "mpilone@slac.com" ); | 362 | "mpilone@slac.com" ); |
363 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 363 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
364 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 364 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
365 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 365 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
366 | "michel@klaralvdalens-datakonsult.se" ); | 366 | "michel@klaralvdalens-datakonsult.se" ); |
367 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 367 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
368 | "hansen@kde.org" ); | 368 | "hansen@kde.org" ); |
369 | 369 | ||
370 | return about; | 370 | return about; |
371 | #endif //KAB_EMBEDDED | 371 | #endif //KAB_EMBEDDED |
372 | 372 | ||
373 | QString version; | 373 | QString version; |
374 | #include <../version> | 374 | #include <../version> |
375 | QMessageBox::about( this, "About KAddressbook/Pi", | 375 | QMessageBox::about( this, "About KAddressbook/Pi", |
376 | "KAddressbook/Platform-independent\n" | 376 | "KAddressbook/Platform-independent\n" |
377 | "(KA/Pi) " +version + " - " + | 377 | "(KA/Pi) " +version + " - " + |
378 | #ifdef DESKTOP_VERSION | 378 | #ifdef DESKTOP_VERSION |
379 | "Desktop Edition\n" | 379 | "Desktop Edition\n" |
380 | #else | 380 | #else |
381 | "PDA-Edition\n" | 381 | "PDA-Edition\n" |
382 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 382 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
383 | #endif | 383 | #endif |
384 | 384 | ||
385 | "(c) 2004 Ulf Schenk\n" | 385 | "(c) 2004 Ulf Schenk\n" |
386 | "(c) 1997-2003, The KDE PIM Team\n" | 386 | "(c) 1997-2003, The KDE PIM Team\n" |
387 | "Tobias Koenig Current maintainer tokoe@kde.org\n" | 387 | "Tobias Koenig Current maintainer tokoe@kde.org\n" |
388 | "Don Sanders Original author\n" | 388 | "Don Sanders Original author\n" |
389 | "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" | 389 | "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" |
390 | "Mike Pilone GUI and framework redesign mpilone@slac.com\n" | 390 | "Mike Pilone GUI and framework redesign mpilone@slac.com\n" |
391 | "Greg Stern DCOP interface\n" | 391 | "Greg Stern DCOP interface\n" |
392 | "Mark Westcot Contact pinning\n" | 392 | "Mark Westcot Contact pinning\n" |
393 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 393 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
394 | "Steffen Hansen LDAP Lookup hansen@kde.org\n" ); | 394 | "Steffen Hansen LDAP Lookup hansen@kde.org\n" ); |
395 | } | 395 | } |
396 | 396 | ||
397 | void KABCore::setContactSelected( const QString &uid ) | 397 | void KABCore::setContactSelected( const QString &uid ) |
398 | { | 398 | { |
399 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 399 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
400 | if ( !mDetails->isHidden() ) | 400 | if ( !mDetails->isHidden() ) |
401 | mDetails->setAddressee( addr ); | 401 | mDetails->setAddressee( addr ); |
402 | 402 | ||
403 | if ( !addr.isEmpty() ) { | 403 | if ( !addr.isEmpty() ) { |
404 | emit contactSelected( addr.formattedName() ); | 404 | emit contactSelected( addr.formattedName() ); |
405 | KABC::Picture pic = addr.photo(); | 405 | KABC::Picture pic = addr.photo(); |
406 | if ( pic.isIntern() ) { | 406 | if ( pic.isIntern() ) { |
407 | //US emit contactSelected( pic.data() ); | 407 | //US emit contactSelected( pic.data() ); |
408 | //US instead use: | 408 | //US instead use: |
409 | QPixmap px; | 409 | QPixmap px; |
410 | if (pic.data().isNull() != true) | 410 | if (pic.data().isNull() != true) |
411 | { | 411 | { |
412 | px.convertFromImage(pic.data()); | 412 | px.convertFromImage(pic.data()); |
413 | } | 413 | } |
414 | 414 | ||
415 | emit contactSelected( px ); | 415 | emit contactSelected( px ); |
416 | } | 416 | } |
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | mExtensionManager->setSelectionChanged(); | 420 | mExtensionManager->setSelectionChanged(); |
421 | 421 | ||
422 | // update the actions | 422 | // update the actions |
423 | bool selected = !uid.isEmpty(); | 423 | bool selected = !uid.isEmpty(); |
424 | 424 | ||
425 | if ( mReadWrite ) { | 425 | if ( mReadWrite ) { |
426 | mActionCut->setEnabled( selected ); | 426 | mActionCut->setEnabled( selected ); |
427 | mActionPaste->setEnabled( selected ); | 427 | mActionPaste->setEnabled( selected ); |
428 | } | 428 | } |
429 | 429 | ||
430 | mActionCopy->setEnabled( selected ); | 430 | mActionCopy->setEnabled( selected ); |
431 | mActionDelete->setEnabled( selected ); | 431 | mActionDelete->setEnabled( selected ); |
432 | mActionEditAddressee->setEnabled( selected ); | 432 | mActionEditAddressee->setEnabled( selected ); |
433 | mActionMail->setEnabled( selected ); | 433 | mActionMail->setEnabled( selected ); |
434 | mActionMailVCard->setEnabled( selected ); | 434 | mActionMailVCard->setEnabled( selected ); |
435 | mActionWhoAmI->setEnabled( selected ); | 435 | mActionWhoAmI->setEnabled( selected ); |
436 | mActionCategories->setEnabled( selected ); | 436 | mActionCategories->setEnabled( selected ); |
437 | } | 437 | } |
438 | 438 | ||
439 | void KABCore::sendMail() | 439 | void KABCore::sendMail() |
440 | { | 440 | { |
441 | #ifndef KAB_EMBEDDED | 441 | #ifndef KAB_EMBEDDED |
442 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 442 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
443 | #else //KAB_EMBEDDED | 443 | #else //KAB_EMBEDDED |
444 | qDebug("KABCore::sendMail() ust be fixed"); | 444 | qDebug("KABCore::sendMail() ust be fixed"); |
445 | #endif //KAB_EMBEDDED | 445 | #endif //KAB_EMBEDDED |
446 | } | 446 | } |
447 | 447 | ||
448 | void KABCore::sendMail( const QString& email ) | 448 | void KABCore::sendMail( const QString& email ) |
449 | { | 449 | { |
450 | #ifndef KAB_EMBEDDED | 450 | #ifndef KAB_EMBEDDED |
451 | kapp->invokeMailer( email, "" ); | 451 | kapp->invokeMailer( email, "" ); |
452 | #else //KAB_EMBEDDED | 452 | #else //KAB_EMBEDDED |
453 | qDebug("KABCore::sendMail(const QString& email) ust be fixed"); | 453 | qDebug("KABCore::sendMail(const QString& email) ust be fixed"); |
454 | #endif //KAB_EMBEDDED | 454 | #endif //KAB_EMBEDDED |
455 | } | 455 | } |
456 | 456 | ||
457 | void KABCore::mailVCard() | 457 | void KABCore::mailVCard() |
458 | { | 458 | { |
459 | #ifndef KAB_EMBEDDED | 459 | #ifndef KAB_EMBEDDED |
460 | QStringList uids = mViewManager->selectedUids(); | 460 | QStringList uids = mViewManager->selectedUids(); |
461 | if ( !uids.isEmpty() ) | 461 | if ( !uids.isEmpty() ) |
462 | mailVCard( uids ); | 462 | mailVCard( uids ); |
463 | #else //KAB_EMBEDDED | 463 | #else //KAB_EMBEDDED |
464 | qDebug("KABCore::mailVCard() must be fixed"); | 464 | qDebug("KABCore::mailVCard() must be fixed"); |
465 | #endif //KAB_EMBEDDED | 465 | #endif //KAB_EMBEDDED |
466 | } | 466 | } |
467 | 467 | ||
468 | void KABCore::mailVCard( const QStringList& uids ) | 468 | void KABCore::mailVCard( const QStringList& uids ) |
469 | { | 469 | { |
470 | #ifndef KAB_EMBEDDED | 470 | #ifndef KAB_EMBEDDED |
471 | QStringList urls; | 471 | QStringList urls; |
472 | 472 | ||
473 | // Create a temp dir, so that we can put the files in it with proper names | 473 | // Create a temp dir, so that we can put the files in it with proper names |
474 | KTempFile tempDir; | 474 | KTempFile tempDir; |
475 | if ( tempDir.status() != 0 ) { | 475 | if ( tempDir.status() != 0 ) { |
476 | kdWarning() << strerror( tempDir.status() ) << endl; | 476 | kdWarning() << strerror( tempDir.status() ) << endl; |
477 | return; | 477 | return; |
478 | } | 478 | } |
479 | 479 | ||
480 | QString dirName = tempDir.name(); | 480 | QString dirName = tempDir.name(); |
481 | tempDir.unlink(); | 481 | tempDir.unlink(); |
482 | QDir().mkdir( dirName, true ); | 482 | QDir().mkdir( dirName, true ); |
483 | 483 | ||
484 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 484 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
485 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 485 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
486 | 486 | ||
487 | if ( a.isEmpty() ) | 487 | if ( a.isEmpty() ) |
488 | continue; | 488 | continue; |
489 | 489 | ||
490 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 490 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
491 | 491 | ||
492 | QString fileName = dirName + "/" + name; | 492 | QString fileName = dirName + "/" + name; |
493 | 493 | ||
494 | QFile outFile(fileName); | 494 | QFile outFile(fileName); |
495 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 495 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
496 | KABC::VCardConverter converter; | 496 | KABC::VCardConverter converter; |
497 | QString vcard; | 497 | QString vcard; |
498 | 498 | ||
499 | converter.addresseeToVCard( a, vcard ); | 499 | converter.addresseeToVCard( a, vcard ); |
500 | 500 | ||
501 | QTextStream t( &outFile ); // use a text stream | 501 | QTextStream t( &outFile ); // use a text stream |
502 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 502 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
503 | t << vcard; | 503 | t << vcard; |
504 | 504 | ||
505 | outFile.close(); | 505 | outFile.close(); |
506 | 506 | ||
507 | urls.append( fileName ); | 507 | urls.append( fileName ); |
508 | } | 508 | } |
509 | } | 509 | } |
510 | 510 | ||
511 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 511 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
512 | QString::null, // subject | 512 | QString::null, // subject |
513 | QString::null, // body | 513 | QString::null, // body |
514 | QString::null, | 514 | QString::null, |
515 | urls ); // attachments | 515 | urls ); // attachments |
516 | #else //KAB_EMBEDDED | 516 | #else //KAB_EMBEDDED |
517 | qDebug("KABCore::mailVCard( must be fixed"); | 517 | qDebug("KABCore::mailVCard( must be fixed"); |
518 | #endif //KAB_EMBEDDED | 518 | #endif //KAB_EMBEDDED |
519 | 519 | ||
520 | } | 520 | } |
521 | 521 | ||
522 | void KABCore::browse( const QString& url ) | 522 | void KABCore::browse( const QString& url ) |
523 | { | 523 | { |
524 | #ifndef KAB_EMBEDDED | 524 | #ifndef KAB_EMBEDDED |
525 | kapp->invokeBrowser( url ); | 525 | kapp->invokeBrowser( url ); |
526 | #else //KAB_EMBEDDED | 526 | #else //KAB_EMBEDDED |
527 | qDebug("KABCore::browse must be fixed"); | 527 | qDebug("KABCore::browse must be fixed"); |
528 | #endif //KAB_EMBEDDED | 528 | #endif //KAB_EMBEDDED |
529 | } | 529 | } |
530 | 530 | ||
531 | void KABCore::selectAllContacts() | 531 | void KABCore::selectAllContacts() |
532 | { | 532 | { |
533 | mViewManager->setSelected( QString::null, true ); | 533 | mViewManager->setSelected( QString::null, true ); |
534 | } | 534 | } |
535 | 535 | ||
536 | void KABCore::deleteContacts() | 536 | void KABCore::deleteContacts() |
537 | { | 537 | { |
538 | QStringList uidList = mViewManager->selectedUids(); | 538 | QStringList uidList = mViewManager->selectedUids(); |
539 | deleteContacts( uidList ); | 539 | deleteContacts( uidList ); |
540 | } | 540 | } |
541 | 541 | ||
542 | void KABCore::deleteContacts( const QStringList &uids ) | 542 | void KABCore::deleteContacts( const QStringList &uids ) |
543 | { | 543 | { |
544 | if ( uids.count() > 0 ) { | 544 | if ( uids.count() > 0 ) { |
545 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 545 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
546 | UndoStack::instance()->push( command ); | 546 | UndoStack::instance()->push( command ); |
547 | RedoStack::instance()->clear(); | 547 | RedoStack::instance()->clear(); |
548 | 548 | ||
549 | // now if we deleted anything, refresh | 549 | // now if we deleted anything, refresh |
550 | setContactSelected( QString::null ); | 550 | setContactSelected( QString::null ); |
551 | setModified( true ); | 551 | setModified( true ); |
552 | } | 552 | } |
553 | } | 553 | } |
554 | 554 | ||
555 | void KABCore::copyContacts() | 555 | void KABCore::copyContacts() |
556 | { | 556 | { |
557 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 557 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
558 | 558 | ||
559 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 559 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
560 | 560 | ||
561 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 561 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
562 | 562 | ||
563 | QClipboard *cb = QApplication::clipboard(); | 563 | QClipboard *cb = QApplication::clipboard(); |
564 | cb->setText( clipText ); | 564 | cb->setText( clipText ); |
565 | } | 565 | } |
566 | 566 | ||
567 | void KABCore::cutContacts() | 567 | void KABCore::cutContacts() |
568 | { | 568 | { |
569 | QStringList uidList = mViewManager->selectedUids(); | 569 | QStringList uidList = mViewManager->selectedUids(); |
570 | 570 | ||
571 | //US if ( uidList.size() > 0 ) { | 571 | //US if ( uidList.size() > 0 ) { |
572 | if ( uidList.count() > 0 ) { | 572 | if ( uidList.count() > 0 ) { |
573 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 573 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
574 | UndoStack::instance()->push( command ); | 574 | UndoStack::instance()->push( command ); |
575 | RedoStack::instance()->clear(); | 575 | RedoStack::instance()->clear(); |
576 | 576 | ||
577 | setModified( true ); | 577 | setModified( true ); |
578 | } | 578 | } |
579 | } | 579 | } |
580 | 580 | ||
581 | void KABCore::pasteContacts() | 581 | void KABCore::pasteContacts() |
582 | { | 582 | { |
583 | QClipboard *cb = QApplication::clipboard(); | 583 | QClipboard *cb = QApplication::clipboard(); |
584 | 584 | ||
585 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 585 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
586 | 586 | ||
587 | pasteContacts( list ); | 587 | pasteContacts( list ); |
588 | } | 588 | } |
589 | 589 | ||
590 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 590 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
591 | { | 591 | { |
592 | KABC::Resource *resource = requestResource( this ); | 592 | KABC::Resource *resource = requestResource( this ); |
593 | KABC::Addressee::List::Iterator it; | 593 | KABC::Addressee::List::Iterator it; |
594 | for ( it = list.begin(); it != list.end(); ++it ) | 594 | for ( it = list.begin(); it != list.end(); ++it ) |
595 | (*it).setResource( resource ); | 595 | (*it).setResource( resource ); |
596 | 596 | ||
597 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 597 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
598 | UndoStack::instance()->push( command ); | 598 | UndoStack::instance()->push( command ); |
599 | RedoStack::instance()->clear(); | 599 | RedoStack::instance()->clear(); |
600 | 600 | ||
601 | setModified( true ); | 601 | setModified( true ); |
602 | } | 602 | } |
603 | 603 | ||
604 | void KABCore::setWhoAmI() | 604 | void KABCore::setWhoAmI() |
605 | { | 605 | { |
606 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 606 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
607 | 607 | ||
608 | if ( addrList.count() > 1 ) { | 608 | if ( addrList.count() > 1 ) { |
609 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 609 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
610 | return; | 610 | return; |
611 | } | 611 | } |
612 | 612 | ||
613 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 613 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
614 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 614 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
615 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 615 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
616 | } | 616 | } |
617 | 617 | ||
618 | void KABCore::setCategories() | 618 | void KABCore::setCategories() |
619 | { | 619 | { |
620 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 620 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
621 | if ( !dlg.exec() ) | 621 | if ( !dlg.exec() ) |
622 | return; | 622 | return; |
623 | 623 | ||
624 | bool merge = false; | 624 | bool merge = false; |
625 | QString msg = i18n( "Merge with existing categories?" ); | 625 | QString msg = i18n( "Merge with existing categories?" ); |
626 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 626 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
627 | merge = true; | 627 | merge = true; |
628 | 628 | ||
629 | QStringList categories = dlg.selectedCategories(); | 629 | QStringList categories = dlg.selectedCategories(); |
630 | 630 | ||
631 | QStringList uids = mViewManager->selectedUids(); | 631 | QStringList uids = mViewManager->selectedUids(); |
632 | QStringList::Iterator it; | 632 | QStringList::Iterator it; |
633 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 633 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
634 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 634 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
635 | if ( !addr.isEmpty() ) { | 635 | if ( !addr.isEmpty() ) { |
636 | if ( !merge ) | 636 | if ( !merge ) |
637 | addr.setCategories( categories ); | 637 | addr.setCategories( categories ); |
638 | else { | 638 | else { |
639 | QStringList addrCategories = addr.categories(); | 639 | QStringList addrCategories = addr.categories(); |
640 | QStringList::Iterator catIt; | 640 | QStringList::Iterator catIt; |
641 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 641 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
642 | if ( !addrCategories.contains( *catIt ) ) | 642 | if ( !addrCategories.contains( *catIt ) ) |
643 | addrCategories.append( *catIt ); | 643 | addrCategories.append( *catIt ); |
644 | } | 644 | } |
645 | addr.setCategories( addrCategories ); | 645 | addr.setCategories( addrCategories ); |
646 | } | 646 | } |
647 | 647 | ||
648 | mAddressBook->insertAddressee( addr ); | 648 | mAddressBook->insertAddressee( addr ); |
649 | } | 649 | } |
650 | } | 650 | } |
651 | 651 | ||
652 | if ( uids.count() > 0 ) | 652 | if ( uids.count() > 0 ) |
653 | setModified( true ); | 653 | setModified( true ); |
654 | } | 654 | } |
655 | 655 | ||
656 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 656 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
657 | { | 657 | { |
658 | mIncSearchWidget->setFields( fields ); | 658 | mIncSearchWidget->setFields( fields ); |
659 | } | 659 | } |
660 | 660 | ||
661 | void KABCore::incrementalSearch( const QString& text ) | 661 | void KABCore::incrementalSearch( const QString& text ) |
662 | { | 662 | { |
663 | mViewManager->setSelected( QString::null, false ); | 663 | mViewManager->setSelected( QString::null, false ); |
664 | 664 | ||
665 | if ( !text.isEmpty() ) { | 665 | if ( !text.isEmpty() ) { |
666 | KABC::Field *field = mIncSearchWidget->currentField(); | 666 | KABC::Field *field = mIncSearchWidget->currentField(); |
667 | 667 | ||
668 | QString pattern = text.lower(); | 668 | QString pattern = text.lower(); |
669 | 669 | ||
670 | #if 1 //KDE_VERSION >= 319 | 670 | #if 1 //KDE_VERSION >= 319 |
671 | KABC::AddresseeList list( mAddressBook->allAddressees() ); | 671 | KABC::AddresseeList list( mAddressBook->allAddressees() ); |
672 | if ( field ) { | 672 | if ( field ) { |
673 | list.sortByField( field ); | 673 | list.sortByField( field ); |
674 | KABC::AddresseeList::Iterator it; | 674 | KABC::AddresseeList::Iterator it; |
675 | for ( it = list.begin(); it != list.end(); ++it ) { | 675 | for ( it = list.begin(); it != list.end(); ++it ) { |
676 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | 676 | if ( field->value( *it ).lower().startsWith( pattern ) ) { |
677 | mViewManager->setSelected( (*it).uid(), true ); | 677 | mViewManager->setSelected( (*it).uid(), true ); |
678 | return; | 678 | return; |
679 | } | 679 | } |
680 | } | 680 | } |
681 | } else { | 681 | } else { |
682 | KABC::AddresseeList::Iterator it; | 682 | KABC::AddresseeList::Iterator it; |
683 | for ( it = list.begin(); it != list.end(); ++it ) { | 683 | for ( it = list.begin(); it != list.end(); ++it ) { |
684 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | 684 | KABC::Field::List fieldList = mIncSearchWidget->fields(); |
685 | KABC::Field::List::ConstIterator fieldIt; | 685 | KABC::Field::List::ConstIterator fieldIt; |
686 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 686 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
687 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | 687 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { |
688 | mViewManager->setSelected( (*it).uid(), true ); | 688 | mViewManager->setSelected( (*it).uid(), true ); |
689 | return; | 689 | return; |
690 | } | 690 | } |
691 | } | 691 | } |
692 | } | 692 | } |
693 | } | 693 | } |
694 | #else | 694 | #else |
695 | KABC::AddressBook::Iterator it; | 695 | KABC::AddressBook::Iterator it; |
696 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 696 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
697 | if ( field ) { | 697 | if ( field ) { |
698 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | 698 | if ( field->value( *it ).lower().startsWith( pattern ) ) { |
699 | mViewManager->setSelected( (*it).uid(), true ); | 699 | mViewManager->setSelected( (*it).uid(), true ); |
700 | return; | 700 | return; |
701 | } | 701 | } |
702 | } else { | 702 | } else { |
703 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | 703 | KABC::Field::List fieldList = mIncSearchWidget->fields(); |
704 | KABC::Field::List::ConstIterator fieldIt; | 704 | KABC::Field::List::ConstIterator fieldIt; |
705 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 705 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
706 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | 706 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { |
707 | mViewManager->setSelected( (*it).uid(), true ); | 707 | mViewManager->setSelected( (*it).uid(), true ); |
708 | return; | 708 | return; |
709 | } | 709 | } |
710 | } | 710 | } |
711 | } | 711 | } |
712 | } | 712 | } |
713 | #endif | 713 | #endif |
714 | } | 714 | } |
715 | } | 715 | } |
716 | 716 | ||
717 | void KABCore::setModified() | 717 | void KABCore::setModified() |
718 | { | 718 | { |
719 | setModified( true ); | 719 | setModified( true ); |
720 | } | 720 | } |
721 | 721 | ||
722 | void KABCore::setModifiedWOrefresh() | 722 | void KABCore::setModifiedWOrefresh() |
723 | { | 723 | { |
724 | // qDebug("KABCore::setModifiedWOrefresh() "); | 724 | // qDebug("KABCore::setModifiedWOrefresh() "); |
725 | mModified = true; | 725 | mModified = true; |
726 | mActionSave->setEnabled( mModified ); | 726 | mActionSave->setEnabled( mModified ); |
727 | #ifdef DESKTOP_VERSION | 727 | #ifdef DESKTOP_VERSION |
728 | mDetails->refreshView(); | 728 | mDetails->refreshView(); |
729 | #endif | 729 | #endif |
730 | 730 | ||
731 | } | 731 | } |
732 | void KABCore::setModified( bool modified ) | 732 | void KABCore::setModified( bool modified ) |
733 | { | 733 | { |
734 | mModified = modified; | 734 | mModified = modified; |
735 | mActionSave->setEnabled( mModified ); | 735 | mActionSave->setEnabled( mModified ); |
736 | 736 | ||
737 | if ( modified ) | 737 | if ( modified ) |
738 | mJumpButtonBar->recreateButtons(); | 738 | mJumpButtonBar->recreateButtons(); |
739 | 739 | ||
740 | mViewManager->refreshView(); | 740 | mViewManager->refreshView(); |
741 | mDetails->refreshView(); | 741 | mDetails->refreshView(); |
742 | 742 | ||
743 | } | 743 | } |
744 | 744 | ||
745 | bool KABCore::modified() const | 745 | bool KABCore::modified() const |
746 | { | 746 | { |
747 | return mModified; | 747 | return mModified; |
748 | } | 748 | } |
749 | 749 | ||
750 | void KABCore::contactModified( const KABC::Addressee &addr ) | 750 | void KABCore::contactModified( const KABC::Addressee &addr ) |
751 | { | 751 | { |
752 | 752 | ||
753 | Command *command = 0; | 753 | Command *command = 0; |
754 | QString uid; | 754 | QString uid; |
755 | 755 | ||
756 | // check if it exists already | 756 | // check if it exists already |
757 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); | 757 | KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); |
758 | if ( origAddr.isEmpty() ) | 758 | if ( origAddr.isEmpty() ) |
759 | command = new PwNewCommand( mAddressBook, addr ); | 759 | command = new PwNewCommand( mAddressBook, addr ); |
760 | else { | 760 | else { |
761 | command = new PwEditCommand( mAddressBook, origAddr, addr ); | 761 | command = new PwEditCommand( mAddressBook, origAddr, addr ); |
762 | uid = addr.uid(); | 762 | uid = addr.uid(); |
763 | } | 763 | } |
764 | 764 | ||
765 | UndoStack::instance()->push( command ); | 765 | UndoStack::instance()->push( command ); |
766 | RedoStack::instance()->clear(); | 766 | RedoStack::instance()->clear(); |
767 | 767 | ||
768 | setModified( true ); | 768 | setModified( true ); |
769 | } | 769 | } |
770 | 770 | ||
771 | void KABCore::newContact() | 771 | void KABCore::newContact() |
772 | { | 772 | { |
773 | 773 | ||
774 | 774 | ||
775 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); | 775 | QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); |
776 | 776 | ||
777 | QPtrList<KRES::Resource> kresResources; | 777 | QPtrList<KRES::Resource> kresResources; |
778 | QPtrListIterator<KABC::Resource> it( kabcResources ); | 778 | QPtrListIterator<KABC::Resource> it( kabcResources ); |
779 | KABC::Resource *resource; | 779 | KABC::Resource *resource; |
780 | while ( ( resource = it.current() ) != 0 ) { | 780 | while ( ( resource = it.current() ) != 0 ) { |
781 | ++it; | 781 | ++it; |
782 | if ( !resource->readOnly() ) { | 782 | if ( !resource->readOnly() ) { |
783 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 783 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
784 | if ( res ) | 784 | if ( res ) |
785 | kresResources.append( res ); | 785 | kresResources.append( res ); |
786 | } | 786 | } |
787 | } | 787 | } |
788 | 788 | ||
789 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); | 789 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); |
790 | resource = static_cast<KABC::Resource*>( res ); | 790 | resource = static_cast<KABC::Resource*>( res ); |
791 | 791 | ||
792 | if ( resource ) { | 792 | if ( resource ) { |
793 | KABC::Addressee addr; | 793 | KABC::Addressee addr; |
794 | addr.setResource( resource ); | 794 | addr.setResource( resource ); |
795 | mEditorDialog->setAddressee( addr ); | 795 | mEditorDialog->setAddressee( addr ); |
796 | KApplication::execDialog ( mEditorDialog ); | 796 | KApplication::execDialog ( mEditorDialog ); |
797 | 797 | ||
798 | } else | 798 | } else |
799 | return; | 799 | return; |
800 | 800 | ||
801 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); | 801 | // mEditorDict.insert( dialog->addressee().uid(), dialog ); |
802 | 802 | ||
803 | 803 | ||
804 | } | 804 | } |
805 | 805 | ||
806 | void KABCore::addEmail( QString aStr ) | 806 | void KABCore::addEmail( QString aStr ) |
807 | { | 807 | { |
808 | #ifndef KAB_EMBEDDED | 808 | #ifndef KAB_EMBEDDED |
809 | QString fullName, email; | 809 | QString fullName, email; |
810 | 810 | ||
811 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); | 811 | KABC::Addressee::parseEmailAddress( aStr, fullName, email ); |
812 | 812 | ||
813 | // Try to lookup the addressee matching the email address | 813 | // Try to lookup the addressee matching the email address |
814 | bool found = false; | 814 | bool found = false; |
815 | QStringList emailList; | 815 | QStringList emailList; |
816 | KABC::AddressBook::Iterator it; | 816 | KABC::AddressBook::Iterator it; |
817 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { | 817 | for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { |
818 | emailList = (*it).emails(); | 818 | emailList = (*it).emails(); |
819 | if ( emailList.contains( email ) > 0 ) { | 819 | if ( emailList.contains( email ) > 0 ) { |
820 | found = true; | 820 | found = true; |
821 | (*it).setNameFromString( fullName ); | 821 | (*it).setNameFromString( fullName ); |
822 | editContact( (*it).uid() ); | 822 | editContact( (*it).uid() ); |
823 | } | 823 | } |
824 | } | 824 | } |
825 | 825 | ||
826 | if ( !found ) { | 826 | if ( !found ) { |
827 | KABC::Addressee addr; | 827 | KABC::Addressee addr; |
828 | addr.setNameFromString( fullName ); | 828 | addr.setNameFromString( fullName ); |
829 | addr.insertEmail( email, true ); | 829 | addr.insertEmail( email, true ); |
830 | 830 | ||
831 | mAddressBook->insertAddressee( addr ); | 831 | mAddressBook->insertAddressee( addr ); |
832 | mViewManager->refreshView( addr.uid() ); | 832 | mViewManager->refreshView( addr.uid() ); |
833 | editContact( addr.uid() ); | 833 | editContact( addr.uid() ); |
834 | } | 834 | } |
835 | #else //KAB_EMBEDDED | 835 | #else //KAB_EMBEDDED |
836 | qDebug("KABCore::addEmail finsih method"); | 836 | qDebug("KABCore::addEmail finsih method"); |
837 | #endif //KAB_EMBEDDED | 837 | #endif //KAB_EMBEDDED |
838 | } | 838 | } |
839 | 839 | ||
840 | void KABCore::importVCard( const KURL &url, bool showPreview ) | 840 | void KABCore::importVCard( const KURL &url, bool showPreview ) |
841 | { | 841 | { |
842 | mXXPortManager->importVCard( url, showPreview ); | 842 | mXXPortManager->importVCard( url, showPreview ); |
843 | } | 843 | } |
844 | 844 | ||
845 | void KABCore::importVCard( const QString &vCard, bool showPreview ) | 845 | void KABCore::importVCard( const QString &vCard, bool showPreview ) |
846 | { | 846 | { |
847 | mXXPortManager->importVCard( vCard, showPreview ); | 847 | mXXPortManager->importVCard( vCard, showPreview ); |
848 | } | 848 | } |
849 | 849 | ||
850 | //US added a second method without defaultparameter | 850 | //US added a second method without defaultparameter |
851 | void KABCore::editContact2() { | 851 | void KABCore::editContact2() { |
852 | editContact( QString::null ); | 852 | editContact( QString::null ); |
853 | } | 853 | } |
854 | 854 | ||
855 | void KABCore::editContact( const QString &uid ) | 855 | void KABCore::editContact( const QString &uid ) |
856 | { | 856 | { |
857 | 857 | ||
858 | if ( mExtensionManager->isQuickEditVisible() ) | 858 | if ( mExtensionManager->isQuickEditVisible() ) |
859 | return; | 859 | return; |
860 | 860 | ||
861 | // First, locate the contact entry | 861 | // First, locate the contact entry |
862 | QString localUID = uid; | 862 | QString localUID = uid; |
863 | if ( localUID.isNull() ) { | 863 | if ( localUID.isNull() ) { |
864 | QStringList uidList = mViewManager->selectedUids(); | 864 | QStringList uidList = mViewManager->selectedUids(); |
865 | if ( uidList.count() > 0 ) | 865 | if ( uidList.count() > 0 ) |
866 | localUID = *( uidList.at( 0 ) ); | 866 | localUID = *( uidList.at( 0 ) ); |
867 | } | 867 | } |
868 | 868 | ||
869 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); | 869 | KABC::Addressee addr = mAddressBook->findByUid( localUID ); |
870 | if ( !addr.isEmpty() ) { | 870 | if ( !addr.isEmpty() ) { |
871 | mEditorDialog->setAddressee( addr ); | 871 | mEditorDialog->setAddressee( addr ); |
872 | KApplication::execDialog ( mEditorDialog ); | 872 | KApplication::execDialog ( mEditorDialog ); |
873 | } | 873 | } |
874 | } | 874 | } |
875 | 875 | ||
876 | void KABCore::save() | 876 | void KABCore::save() |
877 | { | 877 | { |
878 | if ( !mModified ) | 878 | if ( !mModified ) |
879 | return; | 879 | return; |
880 | QString text = i18n( "There was an error while attempting to save\n the " | 880 | QString text = i18n( "There was an error while attempting to save\n the " |
881 | "address book. Please check that some \nother application is " | 881 | "address book. Please check that some \nother application is " |
882 | "not using it. " ); | 882 | "not using it. " ); |
883 | statusMessage(i18n("Saving addressbook ... ")); | 883 | statusMessage(i18n("Saving addressbook ... ")); |
884 | #ifndef KAB_EMBEDDED | 884 | #ifndef KAB_EMBEDDED |
885 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); | 885 | KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); |
886 | if ( !b || !b->save() ) { | 886 | if ( !b || !b->save() ) { |
887 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); | 887 | KMessageBox::error( this, text, i18n( "Unable to Save" ) ); |
888 | } | 888 | } |
889 | #else //KAB_EMBEDDED | 889 | #else //KAB_EMBEDDED |
890 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); | 890 | KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); |
891 | if ( !b || !b->save() ) { | 891 | if ( !b || !b->save() ) { |
892 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); | 892 | QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); |
893 | } | 893 | } |
894 | #endif //KAB_EMBEDDED | 894 | #endif //KAB_EMBEDDED |
895 | 895 | ||
896 | statusMessage(i18n("Addressbook saved!")); | 896 | statusMessage(i18n("Addressbook saved!")); |
897 | setModified( false ); | 897 | setModified( false ); |
898 | } | 898 | } |
899 | 899 | ||
900 | void KABCore::statusMessage(QString mess , int time ) | 900 | void KABCore::statusMessage(QString mess , int time ) |
901 | { | 901 | { |
902 | //topLevelWidget()->setCaption( mess ); | 902 | //topLevelWidget()->setCaption( mess ); |
903 | // pending setting timer to revome message | 903 | // pending setting timer to revome message |
904 | } | 904 | } |
905 | void KABCore::undo() | 905 | void KABCore::undo() |
906 | { | 906 | { |
907 | UndoStack::instance()->undo(); | 907 | UndoStack::instance()->undo(); |
908 | 908 | ||
909 | // Refresh the view | 909 | // Refresh the view |
910 | mViewManager->refreshView(); | 910 | mViewManager->refreshView(); |
911 | } | 911 | } |
912 | 912 | ||
913 | void KABCore::redo() | 913 | void KABCore::redo() |
914 | { | 914 | { |
915 | RedoStack::instance()->redo(); | 915 | RedoStack::instance()->redo(); |
916 | 916 | ||
917 | // Refresh the view | 917 | // Refresh the view |
918 | mViewManager->refreshView(); | 918 | mViewManager->refreshView(); |
919 | } | 919 | } |
920 | 920 | ||
921 | void KABCore::setJumpButtonBarVisible( bool visible ) | 921 | void KABCore::setJumpButtonBarVisible( bool visible ) |
922 | { | 922 | { |
923 | if ( visible ) | 923 | if ( visible ) |
924 | mJumpButtonBar->show(); | 924 | mJumpButtonBar->show(); |
925 | else | 925 | else |
926 | mJumpButtonBar->hide(); | 926 | mJumpButtonBar->hide(); |
927 | } | 927 | } |
928 | void KABCore::setDetailsToState() | 928 | void KABCore::setDetailsToState() |
929 | { | 929 | { |
930 | setDetailsVisible( mActionDetails->isChecked() ); | 930 | setDetailsVisible( mActionDetails->isChecked() ); |
931 | } | 931 | } |
932 | 932 | ||
933 | void KABCore::setDetailsVisible( bool visible ) | 933 | void KABCore::setDetailsVisible( bool visible ) |
934 | { | 934 | { |
935 | if ( visible ) | 935 | if ( visible ) |
936 | mDetails->show(); | 936 | mDetails->show(); |
937 | else | 937 | else |
938 | mDetails->hide(); | 938 | mDetails->hide(); |
939 | } | 939 | } |
940 | 940 | ||
941 | void KABCore::extensionModified( const KABC::Addressee::List &list ) | 941 | void KABCore::extensionModified( const KABC::Addressee::List &list ) |
942 | { | 942 | { |
943 | 943 | ||
944 | if ( list.count() != 0 ) { | 944 | if ( list.count() != 0 ) { |
945 | KABC::Addressee::List::ConstIterator it; | 945 | KABC::Addressee::List::ConstIterator it; |
946 | for ( it = list.begin(); it != list.end(); ++it ) | 946 | for ( it = list.begin(); it != list.end(); ++it ) |
947 | mAddressBook->insertAddressee( *it ); | 947 | mAddressBook->insertAddressee( *it ); |
948 | if ( list.count() > 1 ) | 948 | if ( list.count() > 1 ) |
949 | setModified(); | 949 | setModified(); |
950 | else | 950 | else |
951 | setModifiedWOrefresh(); | 951 | setModifiedWOrefresh(); |
952 | } | 952 | } |
953 | if ( list.count() == 0 ) | 953 | if ( list.count() == 0 ) |
954 | mViewManager->refreshView(); | 954 | mViewManager->refreshView(); |
955 | else | 955 | else |
956 | mViewManager->refreshView( list[ 0 ].uid() ); | 956 | mViewManager->refreshView( list[ 0 ].uid() ); |
957 | 957 | ||
958 | 958 | ||
959 | 959 | ||
960 | } | 960 | } |
961 | 961 | ||
962 | QString KABCore::getNameByPhone( const QString &phone ) | 962 | QString KABCore::getNameByPhone( const QString &phone ) |
963 | { | 963 | { |
964 | #ifndef KAB_EMBEDDED | 964 | #ifndef KAB_EMBEDDED |
965 | QRegExp r( "[/*/-/ ]" ); | 965 | QRegExp r( "[/*/-/ ]" ); |
966 | QString localPhone( phone ); | 966 | QString localPhone( phone ); |
967 | 967 | ||
968 | bool found = false; | 968 | bool found = false; |
969 | QString ownerName = ""; | 969 | QString ownerName = ""; |
970 | KABC::AddressBook::Iterator iter; | 970 | KABC::AddressBook::Iterator iter; |
971 | KABC::PhoneNumber::List::Iterator phoneIter; | 971 | KABC::PhoneNumber::List::Iterator phoneIter; |
972 | KABC::PhoneNumber::List phoneList; | 972 | KABC::PhoneNumber::List phoneList; |
973 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { | 973 | for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { |
974 | phoneList = (*iter).phoneNumbers(); | 974 | phoneList = (*iter).phoneNumbers(); |
975 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); | 975 | for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); |
976 | ++phoneIter) { | 976 | ++phoneIter) { |
977 | // Get rid of separator chars so just the numbers are compared. | 977 | // Get rid of separator chars so just the numbers are compared. |
978 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { | 978 | if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { |
979 | ownerName = (*iter).formattedName(); | 979 | ownerName = (*iter).formattedName(); |
980 | found = true; | 980 | found = true; |
981 | } | 981 | } |
982 | } | 982 | } |
983 | } | 983 | } |
984 | 984 | ||
985 | return ownerName; | 985 | return ownerName; |
986 | #else //KAB_EMBEDDED | 986 | #else //KAB_EMBEDDED |
987 | qDebug("KABCore::getNameByPhone finsih method"); | 987 | qDebug("KABCore::getNameByPhone finsih method"); |
988 | return ""; | 988 | return ""; |
989 | #endif //KAB_EMBEDDED | 989 | #endif //KAB_EMBEDDED |
990 | 990 | ||
991 | } | 991 | } |
992 | 992 | ||
993 | void KABCore::openConfigDialog() | 993 | void KABCore::openConfigDialog() |
994 | { | 994 | { |
995 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); | 995 | KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); |
996 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); | 996 | KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); |
997 | ConfigureDialog->addModule(kabcfg ); | 997 | ConfigureDialog->addModule(kabcfg ); |
998 | connect( ConfigureDialog, SIGNAL( applyClicked() ), | 998 | connect( ConfigureDialog, SIGNAL( applyClicked() ), |
999 | this, SLOT( configurationChanged() ) ); | 999 | this, SLOT( configurationChanged() ) ); |
1000 | connect( ConfigureDialog, SIGNAL( okClicked() ), | 1000 | connect( ConfigureDialog, SIGNAL( okClicked() ), |
1001 | this, SLOT( configurationChanged() ) ); | 1001 | this, SLOT( configurationChanged() ) ); |
1002 | saveSettings(); | 1002 | saveSettings(); |
1003 | ConfigureDialog->showMaximized(); | 1003 | ConfigureDialog->showMaximized(); |
1004 | if ( ConfigureDialog->exec() ) | 1004 | if ( ConfigureDialog->exec() ) |
1005 | KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") ); | 1005 | KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") ); |
1006 | delete ConfigureDialog; | 1006 | delete ConfigureDialog; |
1007 | } | 1007 | } |
1008 | 1008 | ||
1009 | void KABCore::openLDAPDialog() | 1009 | void KABCore::openLDAPDialog() |
1010 | { | 1010 | { |
1011 | #ifndef KAB_EMBEDDED | 1011 | #ifndef KAB_EMBEDDED |
1012 | if ( !mLdapSearchDialog ) { | 1012 | if ( !mLdapSearchDialog ) { |
1013 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); | 1013 | mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); |
1014 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, | 1014 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, |
1015 | SLOT( refreshView() ) ); | 1015 | SLOT( refreshView() ) ); |
1016 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, | 1016 | connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, |
1017 | SLOT( setModified() ) ); | 1017 | SLOT( setModified() ) ); |
1018 | } else | 1018 | } else |
1019 | mLdapSearchDialog->restoreSettings(); | 1019 | mLdapSearchDialog->restoreSettings(); |
1020 | 1020 | ||
1021 | if ( mLdapSearchDialog->isOK() ) | 1021 | if ( mLdapSearchDialog->isOK() ) |
1022 | mLdapSearchDialog->exec(); | 1022 | mLdapSearchDialog->exec(); |
1023 | #else //KAB_EMBEDDED | 1023 | #else //KAB_EMBEDDED |
1024 | qDebug("KABCore::openLDAPDialog() finsih method"); | 1024 | qDebug("KABCore::openLDAPDialog() finsih method"); |
1025 | #endif //KAB_EMBEDDED | 1025 | #endif //KAB_EMBEDDED |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | void KABCore::print() | 1028 | void KABCore::print() |
1029 | { | 1029 | { |
1030 | #ifndef KAB_EMBEDDED | 1030 | #ifndef KAB_EMBEDDED |
1031 | KPrinter printer; | 1031 | KPrinter printer; |
1032 | if ( !printer.setup( this ) ) | 1032 | if ( !printer.setup( this ) ) |
1033 | return; | 1033 | return; |
1034 | 1034 | ||
1035 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, | 1035 | KABPrinting::PrintingWizard wizard( &printer, mAddressBook, |
1036 | mViewManager->selectedUids(), this ); | 1036 | mViewManager->selectedUids(), this ); |
1037 | 1037 | ||
1038 | wizard.exec(); | 1038 | wizard.exec(); |
1039 | #else //KAB_EMBEDDED | 1039 | #else //KAB_EMBEDDED |
1040 | qDebug("KABCore::print() finsih method"); | 1040 | qDebug("KABCore::print() finsih method"); |
1041 | #endif //KAB_EMBEDDED | 1041 | #endif //KAB_EMBEDDED |
1042 | 1042 | ||
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | 1045 | ||
1046 | void KABCore::addGUIClient( KXMLGUIClient *client ) | 1046 | void KABCore::addGUIClient( KXMLGUIClient *client ) |
1047 | { | 1047 | { |
1048 | if ( mGUIClient ) | 1048 | if ( mGUIClient ) |
1049 | mGUIClient->insertChildClient( client ); | 1049 | mGUIClient->insertChildClient( client ); |
1050 | else | 1050 | else |
1051 | KMessageBox::error( this, "no KXMLGUICLient"); | 1051 | KMessageBox::error( this, "no KXMLGUICLient"); |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | 1054 | ||
1055 | void KABCore::configurationChanged() | 1055 | void KABCore::configurationChanged() |
1056 | { | 1056 | { |
1057 | mExtensionManager->reconfigure(); | 1057 | mExtensionManager->reconfigure(); |
1058 | } | 1058 | } |
1059 | 1059 | ||
1060 | void KABCore::addressBookChanged() | 1060 | void KABCore::addressBookChanged() |
1061 | { | 1061 | { |
1062 | #ifndef KAB_EMBEDDED | 1062 | #ifndef KAB_EMBEDDED |
1063 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); | 1063 | QDictIterator<AddresseeEditorDialog> it( mEditorDict ); |
1064 | while ( it.current() ) { | 1064 | while ( it.current() ) { |
1065 | if ( it.current()->dirty() ) { | 1065 | if ( it.current()->dirty() ) { |
1066 | QString text = i18n( "Data has been changed externally. Unsaved " | 1066 | QString text = i18n( "Data has been changed externally. Unsaved " |
1067 | "changes will be lost." ); | 1067 | "changes will be lost." ); |
1068 | KMessageBox::information( this, text ); | 1068 | KMessageBox::information( this, text ); |
1069 | } | 1069 | } |
1070 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); | 1070 | it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); |
1071 | ++it; | 1071 | ++it; |
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | mViewManager->refreshView(); | 1074 | mViewManager->refreshView(); |
1075 | #else //KAB_EMBEDDED | 1075 | #else //KAB_EMBEDDED |
1076 | qDebug("KABCore::addressBookChanged() finsih method"); | 1076 | qDebug("KABCore::addressBookChanged() finsih method"); |
1077 | #endif //KAB_EMBEDDED | 1077 | #endif //KAB_EMBEDDED |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, | 1080 | AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, |
1081 | const char *name ) | 1081 | const char *name ) |
1082 | { | 1082 | { |
1083 | 1083 | ||
1084 | if ( mEditorDialog == 0 ) { | 1084 | if ( mEditorDialog == 0 ) { |
1085 | mEditorDialog = new AddresseeEditorDialog( this, parent, | 1085 | mEditorDialog = new AddresseeEditorDialog( this, parent, |
1086 | name ? name : "editorDialog" ); | 1086 | name ? name : "editorDialog" ); |
1087 | 1087 | ||
1088 | 1088 | ||
1089 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), | 1089 | connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), |
1090 | SLOT( contactModified( const KABC::Addressee& ) ) ); | 1090 | SLOT( contactModified( const KABC::Addressee& ) ) ); |
1091 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), | 1091 | //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), |
1092 | // SLOT( slotEditorDestroyed( const QString& ) ) ); | 1092 | // SLOT( slotEditorDestroyed( const QString& ) ) ); |
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | return mEditorDialog; | 1095 | return mEditorDialog; |
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | void KABCore::slotEditorDestroyed( const QString &uid ) | 1098 | void KABCore::slotEditorDestroyed( const QString &uid ) |
1099 | { | 1099 | { |
1100 | qDebug("KABCore::slotEditorDestroyed called. maybe a problem! "); | 1100 | qDebug("KABCore::slotEditorDestroyed called. maybe a problem! "); |
1101 | //mEditorDict.remove( uid ); | 1101 | //mEditorDict.remove( uid ); |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | void KABCore::initGUI() | 1104 | void KABCore::initGUI() |
1105 | { | 1105 | { |
1106 | #ifndef KAB_EMBEDDED | 1106 | #ifndef KAB_EMBEDDED |
1107 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1107 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1108 | topLayout->setSpacing( KDialogBase::spacingHint() ); | 1108 | topLayout->setSpacing( KDialogBase::spacingHint() ); |
1109 | 1109 | ||
1110 | mExtensionBarSplitter = new QSplitter( this ); | 1110 | mExtensionBarSplitter = new QSplitter( this ); |
1111 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); | 1111 | mExtensionBarSplitter->setOrientation( Qt::Vertical ); |
1112 | 1112 | ||
1113 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); | 1113 | mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); |
1114 | 1114 | ||
1115 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1115 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1116 | mIncSearchWidget = new IncSearchWidget( viewSpace ); | 1116 | mIncSearchWidget = new IncSearchWidget( viewSpace ); |
1117 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1117 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1118 | SLOT( incrementalSearch( const QString& ) ) ); | 1118 | SLOT( incrementalSearch( const QString& ) ) ); |
1119 | 1119 | ||
1120 | mViewManager = new ViewManager( this, viewSpace ); | 1120 | mViewManager = new ViewManager( this, viewSpace ); |
1121 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1121 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1122 | 1122 | ||
1123 | mDetails = new ViewContainer( mDetailsSplitter ); | 1123 | mDetails = new ViewContainer( mDetailsSplitter ); |
1124 | 1124 | ||
1125 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1125 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1126 | 1126 | ||
1127 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1127 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1128 | 1128 | ||
1129 | topLayout->addWidget( mExtensionBarSplitter ); | 1129 | topLayout->addWidget( mExtensionBarSplitter ); |
1130 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); | 1130 | topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); |
1131 | topLayout->addWidget( mJumpButtonBar ); | 1131 | topLayout->addWidget( mJumpButtonBar ); |
1132 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); | 1132 | topLayout->setStretchFactor( mJumpButtonBar, 1 ); |
1133 | 1133 | ||
1134 | mXXPortManager = new XXPortManager( this, this ); | 1134 | mXXPortManager = new XXPortManager( this, this ); |
1135 | 1135 | ||
1136 | #else //KAB_EMBEDDED | 1136 | #else //KAB_EMBEDDED |
1137 | //US initialize viewMenu before settingup viewmanager. | 1137 | //US initialize viewMenu before settingup viewmanager. |
1138 | // Viewmanager needs this menu to plugin submenues. | 1138 | // Viewmanager needs this menu to plugin submenues. |
1139 | viewMenu = new QPopupMenu( this ); | 1139 | viewMenu = new QPopupMenu( this ); |
1140 | settingsMenu = new QPopupMenu( this ); | 1140 | settingsMenu = new QPopupMenu( this ); |
1141 | //filterMenu = new QPopupMenu( this ); | 1141 | //filterMenu = new QPopupMenu( this ); |
1142 | ImportMenu = new QPopupMenu( this ); | 1142 | ImportMenu = new QPopupMenu( this ); |
1143 | ExportMenu = new QPopupMenu( this ); | 1143 | ExportMenu = new QPopupMenu( this ); |
1144 | 1144 | ||
1145 | 1145 | ||
1146 | //US since we have no splitter for the embedded system, setup | 1146 | //US since we have no splitter for the embedded system, setup |
1147 | // a layout with two frames. One left and one right. | 1147 | // a layout with two frames. One left and one right. |
1148 | 1148 | ||
1149 | QBoxLayout *topLayout; | 1149 | QBoxLayout *topLayout; |
1150 | 1150 | ||
1151 | // = new QHBoxLayout( this ); | 1151 | // = new QHBoxLayout( this ); |
1152 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); | 1152 | // QBoxLayout *topLayout = (QBoxLayout*)layout(); |
1153 | 1153 | ||
1154 | // QWidget *mainBox = new QWidget( this ); | 1154 | // QWidget *mainBox = new QWidget( this ); |
1155 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); | 1155 | // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); |
1156 | 1156 | ||
1157 | #ifdef DESKTOP_VERSION | 1157 | #ifdef DESKTOP_VERSION |
1158 | topLayout = new QHBoxLayout( this ); | 1158 | topLayout = new QHBoxLayout( this ); |
1159 | 1159 | ||
1160 | 1160 | ||
1161 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1161 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1162 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1162 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1163 | 1163 | ||
1164 | topLayout->addWidget(mMiniSplitter ); | 1164 | topLayout->addWidget(mMiniSplitter ); |
1165 | 1165 | ||
1166 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); | 1166 | mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); |
1167 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1167 | mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1168 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); | 1168 | mViewManager = new ViewManager( this, mExtensionBarSplitter ); |
1169 | mDetails = new ViewContainer( mMiniSplitter ); | 1169 | mDetails = new ViewContainer( mMiniSplitter ); |
1170 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); | 1170 | mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); |
1171 | #else | 1171 | #else |
1172 | if ( QApplication::desktop()->width() > 480 ) { | 1172 | if ( QApplication::desktop()->width() > 480 ) { |
1173 | topLayout = new QHBoxLayout( this ); | 1173 | topLayout = new QHBoxLayout( this ); |
1174 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 1174 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
1175 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 1175 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
1176 | } else { | 1176 | } else { |
1177 | 1177 | ||
1178 | topLayout = new QHBoxLayout( this ); | 1178 | topLayout = new QHBoxLayout( this ); |
1179 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 1179 | mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
1180 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); | 1180 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); |
1181 | } | 1181 | } |
1182 | 1182 | ||
1183 | topLayout->addWidget(mMiniSplitter ); | 1183 | topLayout->addWidget(mMiniSplitter ); |
1184 | mViewManager = new ViewManager( this, mMiniSplitter ); | 1184 | mViewManager = new ViewManager( this, mMiniSplitter ); |
1185 | mDetails = new ViewContainer( mMiniSplitter ); | 1185 | mDetails = new ViewContainer( mMiniSplitter ); |
1186 | 1186 | ||
1187 | 1187 | ||
1188 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); | 1188 | mExtensionManager = new ExtensionManager( this, mMiniSplitter ); |
1189 | #endif | 1189 | #endif |
1190 | //eh->hide(); | 1190 | //eh->hide(); |
1191 | // topLayout->addWidget(mExtensionManager ); | 1191 | // topLayout->addWidget(mExtensionManager ); |
1192 | 1192 | ||
1193 | 1193 | ||
1194 | /*US | 1194 | /*US |
1195 | #ifndef KAB_NOSPLITTER | 1195 | #ifndef KAB_NOSPLITTER |
1196 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1196 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1197 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1197 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1198 | topLayout->setSpacing( 10 ); | 1198 | topLayout->setSpacing( 10 ); |
1199 | 1199 | ||
1200 | mDetailsSplitter = new QSplitter( this ); | 1200 | mDetailsSplitter = new QSplitter( this ); |
1201 | 1201 | ||
1202 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); | 1202 | QVBox *viewSpace = new QVBox( mDetailsSplitter ); |
1203 | 1203 | ||
1204 | mViewManager = new ViewManager( this, viewSpace ); | 1204 | mViewManager = new ViewManager( this, viewSpace ); |
1205 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1205 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1206 | 1206 | ||
1207 | mDetails = new ViewContainer( mDetailsSplitter ); | 1207 | mDetails = new ViewContainer( mDetailsSplitter ); |
1208 | 1208 | ||
1209 | topLayout->addWidget( mDetailsSplitter ); | 1209 | topLayout->addWidget( mDetailsSplitter ); |
1210 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1210 | topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1211 | #else //KAB_NOSPLITTER | 1211 | #else //KAB_NOSPLITTER |
1212 | QHBoxLayout *topLayout = new QHBoxLayout( this ); | 1212 | QHBoxLayout *topLayout = new QHBoxLayout( this ); |
1213 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); | 1213 | //US topLayout->setSpacing( KDialogBase::spacingHint() ); |
1214 | topLayout->setSpacing( 10 ); | 1214 | topLayout->setSpacing( 10 ); |
1215 | 1215 | ||
1216 | // mDetailsSplitter = new QSplitter( this ); | 1216 | // mDetailsSplitter = new QSplitter( this ); |
1217 | 1217 | ||
1218 | QVBox *viewSpace = new QVBox( this ); | 1218 | QVBox *viewSpace = new QVBox( this ); |
1219 | 1219 | ||
1220 | mViewManager = new ViewManager( this, viewSpace ); | 1220 | mViewManager = new ViewManager( this, viewSpace ); |
1221 | viewSpace->setStretchFactor( mViewManager, 1 ); | 1221 | viewSpace->setStretchFactor( mViewManager, 1 ); |
1222 | 1222 | ||
1223 | mDetails = new ViewContainer( this ); | 1223 | mDetails = new ViewContainer( this ); |
1224 | 1224 | ||
1225 | topLayout->addWidget( viewSpace ); | 1225 | topLayout->addWidget( viewSpace ); |
1226 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); | 1226 | // topLayout->setStretchFactor( mDetailsSplitter, 100 ); |
1227 | topLayout->addWidget( mDetails ); | 1227 | topLayout->addWidget( mDetails ); |
1228 | #endif //KAB_NOSPLITTER | 1228 | #endif //KAB_NOSPLITTER |
1229 | */ | 1229 | */ |
1230 | 1230 | ||
1231 | 1231 | ||
1232 | #endif //KAB_EMBEDDED | 1232 | #endif //KAB_EMBEDDED |
1233 | initActions(); | 1233 | initActions(); |
1234 | 1234 | ||
1235 | #ifdef KAB_EMBEDDED | 1235 | #ifdef KAB_EMBEDDED |
1236 | addActionsManually(); | 1236 | addActionsManually(); |
1237 | //US make sure the export and import menues are initialized before creating the xxPortManager. | 1237 | //US make sure the export and import menues are initialized before creating the xxPortManager. |
1238 | mXXPortManager = new XXPortManager( this, this ); | 1238 | mXXPortManager = new XXPortManager( this, this ); |
1239 | 1239 | ||
1240 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); | 1240 | // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); |
1241 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); | 1241 | //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); |
1242 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1242 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1243 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); | 1243 | //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); |
1244 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); | 1244 | //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); |
1245 | // mIncSearchWidget->hide(); | 1245 | // mIncSearchWidget->hide(); |
1246 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1246 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1247 | SLOT( incrementalSearch( const QString& ) ) ); | 1247 | SLOT( incrementalSearch( const QString& ) ) ); |
1248 | 1248 | ||
1249 | 1249 | ||
1250 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1250 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1251 | 1251 | ||
1252 | topLayout->addWidget( mJumpButtonBar ); | 1252 | topLayout->addWidget( mJumpButtonBar ); |
1253 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); | 1253 | //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); |
1254 | 1254 | ||
1255 | // mMainWindow->getIconToolBar()->raise(); | 1255 | // mMainWindow->getIconToolBar()->raise(); |
1256 | 1256 | ||
1257 | #endif //KAB_EMBEDDED | 1257 | #endif //KAB_EMBEDDED |
1258 | 1258 | ||
1259 | } | 1259 | } |
1260 | void KABCore::initActions() | 1260 | void KABCore::initActions() |
1261 | { | 1261 | { |
1262 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1262 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1263 | 1263 | ||
1264 | #ifndef KAB_EMBEDDED | 1264 | #ifndef KAB_EMBEDDED |
1265 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), | 1265 | connect( QApplication::clipboard(), SIGNAL( dataChanged() ), |
1266 | SLOT( clipboardDataChanged() ) ); | 1266 | SLOT( clipboardDataChanged() ) ); |
1267 | #endif //KAB_EMBEDDED | 1267 | #endif //KAB_EMBEDDED |
1268 | 1268 | ||
1269 | // file menu | 1269 | // file menu |
1270 | if ( mIsPart ) { | 1270 | if ( mIsPart ) { |
1271 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, | 1271 | mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, |
1272 | SLOT( sendMail() ), actionCollection(), | 1272 | SLOT( sendMail() ), actionCollection(), |
1273 | "kaddressbook_mail" ); | 1273 | "kaddressbook_mail" ); |
1274 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, | 1274 | mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, |
1275 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); | 1275 | SLOT( print() ), actionCollection(), "kaddressbook_print" ); |
1276 | 1276 | ||
1277 | } else { | 1277 | } else { |
1278 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); | 1278 | mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); |
1279 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); | 1279 | mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); |
1280 | } | 1280 | } |
1281 | 1281 | ||
1282 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, | 1282 | mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, |
1283 | SLOT( save() ), actionCollection(), "file_sync" ); | 1283 | SLOT( save() ), actionCollection(), "file_sync" ); |
1284 | 1284 | ||
1285 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, | 1285 | mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, |
1286 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); | 1286 | SLOT( newContact() ), actionCollection(), "file_new_contact" ); |
1287 | 1287 | ||
1288 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, | 1288 | mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, |
1289 | this, SLOT( mailVCard() ), | 1289 | this, SLOT( mailVCard() ), |
1290 | actionCollection(), "file_mail_vcard"); | 1290 | actionCollection(), "file_mail_vcard"); |
1291 | 1291 | ||
1292 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, | 1292 | mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, |
1293 | this, SLOT( editContact2() ), | 1293 | this, SLOT( editContact2() ), |
1294 | actionCollection(), "file_properties" ); | 1294 | actionCollection(), "file_properties" ); |
1295 | 1295 | ||
1296 | #ifdef KAB_EMBEDDED | 1296 | #ifdef KAB_EMBEDDED |
1297 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); | 1297 | // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); |
1298 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, | 1298 | mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, |
1299 | mMainWindow, SLOT( exit() ), | 1299 | mMainWindow, SLOT( exit() ), |
1300 | actionCollection(), "quit" ); | 1300 | actionCollection(), "quit" ); |
1301 | #endif //KAB_EMBEDDED | 1301 | #endif //KAB_EMBEDDED |
1302 | 1302 | ||
1303 | // edit menu | 1303 | // edit menu |
1304 | if ( mIsPart ) { | 1304 | if ( mIsPart ) { |
1305 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, | 1305 | mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, |
1306 | SLOT( copyContacts() ), actionCollection(), | 1306 | SLOT( copyContacts() ), actionCollection(), |
1307 | "kaddressbook_copy" ); | 1307 | "kaddressbook_copy" ); |
1308 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, | 1308 | mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, |
1309 | SLOT( cutContacts() ), actionCollection(), | 1309 | SLOT( cutContacts() ), actionCollection(), |
1310 | "kaddressbook_cut" ); | 1310 | "kaddressbook_cut" ); |
1311 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, | 1311 | mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, |
1312 | SLOT( pasteContacts() ), actionCollection(), | 1312 | SLOT( pasteContacts() ), actionCollection(), |
1313 | "kaddressbook_paste" ); | 1313 | "kaddressbook_paste" ); |
1314 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, | 1314 | mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, |
1315 | SLOT( selectAllContacts() ), actionCollection(), | 1315 | SLOT( selectAllContacts() ), actionCollection(), |
1316 | "kaddressbook_select_all" ); | 1316 | "kaddressbook_select_all" ); |
1317 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, | 1317 | mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, |
1318 | SLOT( undo() ), actionCollection(), | 1318 | SLOT( undo() ), actionCollection(), |
1319 | "kaddressbook_undo" ); | 1319 | "kaddressbook_undo" ); |
1320 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, | 1320 | mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, |
1321 | this, SLOT( redo() ), actionCollection(), | 1321 | this, SLOT( redo() ), actionCollection(), |
1322 | "kaddressbook_redo" ); | 1322 | "kaddressbook_redo" ); |
1323 | } else { | 1323 | } else { |
1324 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); | 1324 | mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); |
1325 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); | 1325 | mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); |
1326 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); | 1326 | mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); |
1327 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); | 1327 | mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); |
1328 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); | 1328 | mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); |
1329 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); | 1329 | mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); |
1330 | } | 1330 | } |
1331 | 1331 | ||
1332 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", | 1332 | mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", |
1333 | Key_Delete, this, SLOT( deleteContacts() ), | 1333 | Key_Delete, this, SLOT( deleteContacts() ), |
1334 | actionCollection(), "edit_delete" ); | 1334 | actionCollection(), "edit_delete" ); |
1335 | 1335 | ||
1336 | mActionUndo->setEnabled( false ); | 1336 | mActionUndo->setEnabled( false ); |
1337 | mActionRedo->setEnabled( false ); | 1337 | mActionRedo->setEnabled( false ); |
1338 | 1338 | ||
1339 | // settings menu | 1339 | // settings menu |
1340 | #ifdef KAB_EMBEDDED | 1340 | #ifdef KAB_EMBEDDED |
1341 | //US special menuentry to configure the addressbook resources. On KDE | 1341 | //US special menuentry to configure the addressbook resources. On KDE |
1342 | // you do that through the control center !!! | 1342 | // you do that through the control center !!! |
1343 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, | 1343 | mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, |
1344 | SLOT( configureResources() ), actionCollection(), | 1344 | SLOT( configureResources() ), actionCollection(), |
1345 | "kaddressbook_configure_resources" ); | 1345 | "kaddressbook_configure_resources" ); |
1346 | #endif //KAB_EMBEDDED | 1346 | #endif //KAB_EMBEDDED |
1347 | 1347 | ||
1348 | if ( mIsPart ) { | 1348 | if ( mIsPart ) { |
1349 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, | 1349 | mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, |
1350 | SLOT( openConfigDialog() ), actionCollection(), | 1350 | SLOT( openConfigDialog() ), actionCollection(), |
1351 | "kaddressbook_configure" ); | 1351 | "kaddressbook_configure" ); |
1352 | 1352 | ||
1353 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, | 1353 | mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, |
1354 | this, SLOT( configureKeyBindings() ), actionCollection(), | 1354 | this, SLOT( configureKeyBindings() ), actionCollection(), |
1355 | "kaddressbook_configure_shortcuts" ); | 1355 | "kaddressbook_configure_shortcuts" ); |
1356 | #ifdef KAB_EMBEDDED | 1356 | #ifdef KAB_EMBEDDED |
1357 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); | 1357 | mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); |
1358 | mActionConfigureToolbars->setEnabled( false ); | 1358 | mActionConfigureToolbars->setEnabled( false ); |
1359 | #endif //KAB_EMBEDDED | 1359 | #endif //KAB_EMBEDDED |
1360 | 1360 | ||
1361 | } else { | 1361 | } else { |
1362 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); | 1362 | mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); |
1363 | 1363 | ||
1364 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); | 1364 | mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); |
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, | 1367 | mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, |
1368 | actionCollection(), "options_show_jump_bar" ); | 1368 | actionCollection(), "options_show_jump_bar" ); |
1369 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); | 1369 | connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); |
1370 | 1370 | ||
1371 | mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0, | 1371 | mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0, |
1372 | actionCollection(), "options_show_details" ); | 1372 | actionCollection(), "options_show_details" ); |
1373 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); | 1373 | connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); |
1374 | 1374 | ||
1375 | // misc | 1375 | // misc |
1376 | // only enable LDAP lookup if we can handle the protocol | 1376 | // only enable LDAP lookup if we can handle the protocol |
1377 | #ifndef KAB_EMBEDDED | 1377 | #ifndef KAB_EMBEDDED |
1378 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { | 1378 | if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { |
1379 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, | 1379 | new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, |
1380 | this, SLOT( openLDAPDialog() ), actionCollection(), | 1380 | this, SLOT( openLDAPDialog() ), actionCollection(), |
1381 | "ldap_lookup" ); | 1381 | "ldap_lookup" ); |
1382 | } | 1382 | } |
1383 | #else //KAB_EMBEDDED | 1383 | #else //KAB_EMBEDDED |
1384 | //qDebug("KABCore::initActions() LDAP has to be implemented"); | 1384 | //qDebug("KABCore::initActions() LDAP has to be implemented"); |
1385 | #endif //KAB_EMBEDDED | 1385 | #endif //KAB_EMBEDDED |
1386 | 1386 | ||
1387 | 1387 | ||
1388 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, | 1388 | mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, |
1389 | SLOT( setWhoAmI() ), actionCollection(), | 1389 | SLOT( setWhoAmI() ), actionCollection(), |
1390 | "set_personal" ); | 1390 | "set_personal" ); |
1391 | 1391 | ||
1392 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, | 1392 | mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, |
1393 | SLOT( setCategories() ), actionCollection(), | 1393 | SLOT( setCategories() ), actionCollection(), |
1394 | "edit_set_categories" ); | 1394 | "edit_set_categories" ); |
1395 | 1395 | ||
1396 | #ifdef KAB_EMBEDDED | 1396 | #ifdef KAB_EMBEDDED |
1397 | 1397 | ||
1398 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, | 1398 | mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, |
1399 | this, SLOT( createAboutData() ), actionCollection(), | 1399 | this, SLOT( createAboutData() ), actionCollection(), |
1400 | "kaddressbook_about_data" ); | 1400 | "kaddressbook_about_data" ); |
1401 | #endif //KAB_EMBEDDED | 1401 | #endif //KAB_EMBEDDED |
1402 | 1402 | ||
1403 | clipboardDataChanged(); | 1403 | clipboardDataChanged(); |
1404 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1404 | connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1405 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); | 1405 | connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); |
1406 | } | 1406 | } |
1407 | 1407 | ||
1408 | //US we need this function, to plug all actions into the correct menues. | 1408 | //US we need this function, to plug all actions into the correct menues. |
1409 | // KDE uses a XML format to plug the actions, but we work her without this overhead. | 1409 | // KDE uses a XML format to plug the actions, but we work her without this overhead. |
1410 | void KABCore::addActionsManually() | 1410 | void KABCore::addActionsManually() |
1411 | { | 1411 | { |
1412 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); | 1412 | //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); |
1413 | 1413 | ||
1414 | #ifdef KAB_EMBEDDED | 1414 | #ifdef KAB_EMBEDDED |
1415 | QPopupMenu *fileMenu = new QPopupMenu( this ); | 1415 | QPopupMenu *fileMenu = new QPopupMenu( this ); |
1416 | QPopupMenu *editMenu = new QPopupMenu( this ); | 1416 | QPopupMenu *editMenu = new QPopupMenu( this ); |
1417 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 1417 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
1418 | 1418 | ||
1419 | KToolBar* tb = mMainWindow->toolBar(); | 1419 | KToolBar* tb = mMainWindow->toolBar(); |
1420 | 1420 | ||
1421 | #ifdef DESKTOP_VERSION | 1421 | #ifdef DESKTOP_VERSION |
1422 | QMenuBar* mb = mMainWindow->menuBar(); | 1422 | QMenuBar* mb = mMainWindow->menuBar(); |
1423 | 1423 | ||
1424 | //US setup menubar. | 1424 | //US setup menubar. |
1425 | //Disable the following block if you do not want to have a menubar. | 1425 | //Disable the following block if you do not want to have a menubar. |
1426 | mb->insertItem( "&File", fileMenu ); | 1426 | mb->insertItem( "&File", fileMenu ); |
1427 | mb->insertItem( "&Edit", editMenu ); | 1427 | mb->insertItem( "&Edit", editMenu ); |
1428 | mb->insertItem( "&View", viewMenu ); | 1428 | mb->insertItem( "&View", viewMenu ); |
1429 | mb->insertItem( "&Settings", settingsMenu ); | 1429 | mb->insertItem( "&Settings", settingsMenu ); |
1430 | mb->insertItem( "&Help", helpMenu ); | 1430 | mb->insertItem( "&Help", helpMenu ); |
1431 | mIncSearchWidget = new IncSearchWidget( tb ); | 1431 | mIncSearchWidget = new IncSearchWidget( tb ); |
1432 | // tb->insertWidget(-1, 0, mIncSearchWidget); | 1432 | // tb->insertWidget(-1, 0, mIncSearchWidget); |
1433 | 1433 | ||
1434 | #else | 1434 | #else |
1435 | //US setup toolbar | 1435 | //US setup toolbar |
1436 | QMenuBar *menuBarTB = new QMenuBar( tb ); | 1436 | QMenuBar *menuBarTB = new QMenuBar( tb ); |
1437 | QPopupMenu *popupBarTB = new QPopupMenu( this ); | 1437 | QPopupMenu *popupBarTB = new QPopupMenu( this ); |
1438 | menuBarTB->insertItem( "ME", popupBarTB); | 1438 | menuBarTB->insertItem( "ME", popupBarTB); |
1439 | tb->insertWidget(-1, 0, menuBarTB); | 1439 | tb->insertWidget(-1, 0, menuBarTB); |
1440 | mIncSearchWidget = new IncSearchWidget( tb ); | 1440 | mIncSearchWidget = new IncSearchWidget( tb ); |
1441 | 1441 | ||
1442 | tb->enableMoving(false); | 1442 | tb->enableMoving(false); |
1443 | popupBarTB->insertItem( "&File", fileMenu ); | 1443 | popupBarTB->insertItem( "&File", fileMenu ); |
1444 | popupBarTB->insertItem( "&Edit", editMenu ); | 1444 | popupBarTB->insertItem( "&Edit", editMenu ); |
1445 | popupBarTB->insertItem( "&View", viewMenu ); | 1445 | popupBarTB->insertItem( "&View", viewMenu ); |
1446 | popupBarTB->insertItem( "&Settings", settingsMenu ); | 1446 | popupBarTB->insertItem( "&Settings", settingsMenu ); |
1447 | mViewManager->getFilterAction()->plug ( popupBarTB); | 1447 | mViewManager->getFilterAction()->plug ( popupBarTB); |
1448 | popupBarTB->insertItem( "&Help", helpMenu ); | 1448 | popupBarTB->insertItem( "&Help", helpMenu ); |
1449 | if (QApplication::desktop()->width() > 320 ) { | 1449 | if (QApplication::desktop()->width() > 320 ) { |
1450 | // mViewManager->getFilterAction()->plug ( tb); | 1450 | // mViewManager->getFilterAction()->plug ( tb); |
1451 | } | 1451 | } |
1452 | #endif | 1452 | #endif |
1453 | // mActionQuit->plug ( mMainWindow->toolBar()); | 1453 | // mActionQuit->plug ( mMainWindow->toolBar()); |
1454 | 1454 | ||
1455 | 1455 | ||
1456 | 1456 | ||
1457 | //US Now connect the actions with the menue entries. | 1457 | //US Now connect the actions with the menue entries. |
1458 | mActionPrint->plug( fileMenu ); | 1458 | mActionPrint->plug( fileMenu ); |
1459 | mActionMail->plug( fileMenu ); | 1459 | mActionMail->plug( fileMenu ); |
1460 | fileMenu->insertSeparator(); | 1460 | fileMenu->insertSeparator(); |
1461 | 1461 | ||
1462 | mActionNewContact->plug( fileMenu ); | 1462 | mActionNewContact->plug( fileMenu ); |
1463 | mActionNewContact->plug( tb ); | 1463 | mActionNewContact->plug( tb ); |
1464 | 1464 | ||
1465 | mActionEditAddressee->plug( fileMenu ); | 1465 | mActionEditAddressee->plug( fileMenu ); |
1466 | fileMenu->insertSeparator(); | 1466 | fileMenu->insertSeparator(); |
1467 | mActionSave->plug( fileMenu ); | 1467 | mActionSave->plug( fileMenu ); |
1468 | fileMenu->insertItem( "&Import", ImportMenu ); | 1468 | fileMenu->insertItem( "&Import", ImportMenu ); |
1469 | fileMenu->insertItem( "&Emport", ExportMenu ); | 1469 | fileMenu->insertItem( "&Emport", ExportMenu ); |
1470 | fileMenu->insertSeparator(); | 1470 | fileMenu->insertSeparator(); |
1471 | mActionMailVCard->plug( fileMenu ); | 1471 | mActionMailVCard->plug( fileMenu ); |
1472 | fileMenu->insertSeparator(); | 1472 | fileMenu->insertSeparator(); |
1473 | mActionQuit->plug( fileMenu ); | 1473 | mActionQuit->plug( fileMenu ); |
1474 | 1474 | ||
1475 | 1475 | ||
1476 | // edit menu | 1476 | // edit menu |
1477 | mActionUndo->plug( editMenu ); | 1477 | mActionUndo->plug( editMenu ); |
1478 | mActionRedo->plug( editMenu ); | 1478 | mActionRedo->plug( editMenu ); |
1479 | editMenu->insertSeparator(); | 1479 | editMenu->insertSeparator(); |
1480 | mActionCut->plug( editMenu ); | 1480 | mActionCut->plug( editMenu ); |
1481 | mActionCopy->plug( editMenu ); | 1481 | mActionCopy->plug( editMenu ); |
1482 | mActionPaste->plug( editMenu ); | 1482 | mActionPaste->plug( editMenu ); |
1483 | mActionDelete->plug( editMenu ); | 1483 | mActionDelete->plug( editMenu ); |
1484 | editMenu->insertSeparator(); | 1484 | editMenu->insertSeparator(); |
1485 | mActionSelectAll->plug( editMenu ); | 1485 | mActionSelectAll->plug( editMenu ); |
1486 | 1486 | ||
1487 | 1487 | ||
1488 | // settings menu | 1488 | // settings menu |
1489 | //US special menuentry to configure the addressbook resources. On KDE | 1489 | //US special menuentry to configure the addressbook resources. On KDE |
1490 | // you do that through the control center !!! | 1490 | // you do that through the control center !!! |
1491 | mActionConfigResources->plug( settingsMenu ); | 1491 | mActionConfigResources->plug( settingsMenu ); |
1492 | settingsMenu->insertSeparator(); | 1492 | settingsMenu->insertSeparator(); |
1493 | 1493 | ||
1494 | mActionConfigKAddressbook->plug( settingsMenu ); | 1494 | mActionConfigKAddressbook->plug( settingsMenu ); |
1495 | 1495 | ||
1496 | if ( mIsPart ) { | 1496 | if ( mIsPart ) { |
1497 | mActionConfigShortcuts->plug( settingsMenu ); | 1497 | mActionConfigShortcuts->plug( settingsMenu ); |
1498 | mActionConfigureToolbars->plug( settingsMenu ); | 1498 | mActionConfigureToolbars->plug( settingsMenu ); |
1499 | 1499 | ||
1500 | } else { | 1500 | } else { |
1501 | mActionKeyBindings->plug( settingsMenu ); | 1501 | mActionKeyBindings->plug( settingsMenu ); |
1502 | } | 1502 | } |
1503 | 1503 | ||
1504 | settingsMenu->insertSeparator(); | 1504 | settingsMenu->insertSeparator(); |
1505 | 1505 | ||
1506 | mActionJumpBar->plug( settingsMenu ); | 1506 | mActionJumpBar->plug( settingsMenu ); |
1507 | mActionDetails->plug( settingsMenu ); | 1507 | mActionDetails->plug( settingsMenu ); |
1508 | settingsMenu->insertSeparator(); | 1508 | settingsMenu->insertSeparator(); |
1509 | 1509 | ||
1510 | mActionWhoAmI->plug( settingsMenu ); | 1510 | mActionWhoAmI->plug( settingsMenu ); |
1511 | mActionCategories->plug( settingsMenu ); | 1511 | mActionCategories->plug( settingsMenu ); |
1512 | 1512 | ||
1513 | mActionAboutKAddressbook->plug( helpMenu ); | 1513 | mActionAboutKAddressbook->plug( helpMenu ); |
1514 | 1514 | ||
1515 | 1515 | ||
1516 | if (QApplication::desktop()->width() > 320 ) { | 1516 | if (QApplication::desktop()->width() > 320 ) { |
1517 | 1517 | ||
1518 | mActionEditAddressee->plug( tb ); | 1518 | mActionEditAddressee->plug( tb ); |
1519 | mActionSave->plug( tb ); | 1519 | mActionSave->plug( tb ); |
1520 | mViewManager->getFilterAction()->plug ( tb); | 1520 | mViewManager->getFilterAction()->plug ( tb); |
1521 | if (QApplication::desktop()->width() > 480 ) { | 1521 | if (QApplication::desktop()->width() > 480 ) { |
1522 | mActionUndo->plug( tb ); | 1522 | mActionUndo->plug( tb ); |
1523 | mActionDelete->plug( tb ); | 1523 | mActionDelete->plug( tb ); |
1524 | mActionRedo->plug( tb ); | 1524 | mActionRedo->plug( tb ); |
1525 | } | 1525 | } |
1526 | } | 1526 | } |
1527 | //mActionQuit->plug ( tb ); | 1527 | //mActionQuit->plug ( tb ); |
1528 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); | 1528 | // tb->insertWidget(-1, 0, mIncSearchWidget, 6); |
1529 | 1529 | ||
1530 | //US link the searchwidget first to this. | 1530 | //US link the searchwidget first to this. |
1531 | // The real linkage to the toolbar happens later. | 1531 | // The real linkage to the toolbar happens later. |
1532 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); | 1532 | //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); |
1533 | //US tb->insertItem( mIncSearchWidget ); | 1533 | //US tb->insertItem( mIncSearchWidget ); |
1534 | /*US | 1534 | /*US |
1535 | mIncSearchWidget = new IncSearchWidget( tb ); | 1535 | mIncSearchWidget = new IncSearchWidget( tb ); |
1536 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), | 1536 | connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), |
1537 | SLOT( incrementalSearch( const QString& ) ) ); | 1537 | SLOT( incrementalSearch( const QString& ) ) ); |
1538 | 1538 | ||
1539 | mJumpButtonBar = new JumpButtonBar( this, this ); | 1539 | mJumpButtonBar = new JumpButtonBar( this, this ); |
1540 | 1540 | ||
1541 | //US topLayout->addWidget( mJumpButtonBar ); | 1541 | //US topLayout->addWidget( mJumpButtonBar ); |
1542 | this->layout()->add( mJumpButtonBar ); | 1542 | this->layout()->add( mJumpButtonBar ); |
1543 | */ | 1543 | */ |
1544 | 1544 | ||
1545 | #endif //KAB_EMBEDDED | 1545 | #endif //KAB_EMBEDDED |
1546 | } | 1546 | } |
1547 | 1547 | ||
1548 | 1548 | ||
1549 | 1549 | ||
1550 | void KABCore::clipboardDataChanged() | 1550 | void KABCore::clipboardDataChanged() |
1551 | { | 1551 | { |
1552 | 1552 | ||
1553 | if ( mReadWrite ) | 1553 | if ( mReadWrite ) |
1554 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); | 1554 | mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); |
1555 | 1555 | ||
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | void KABCore::updateActionMenu() | 1558 | void KABCore::updateActionMenu() |
1559 | { | 1559 | { |
1560 | UndoStack *undo = UndoStack::instance(); | 1560 | UndoStack *undo = UndoStack::instance(); |
1561 | RedoStack *redo = RedoStack::instance(); | 1561 | RedoStack *redo = RedoStack::instance(); |
1562 | 1562 | ||
1563 | if ( undo->isEmpty() ) | 1563 | if ( undo->isEmpty() ) |
1564 | mActionUndo->setText( i18n( "Undo" ) ); | 1564 | mActionUndo->setText( i18n( "Undo" ) ); |
1565 | else | 1565 | else |
1566 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); | 1566 | mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); |
1567 | 1567 | ||
1568 | mActionUndo->setEnabled( !undo->isEmpty() ); | 1568 | mActionUndo->setEnabled( !undo->isEmpty() ); |
1569 | 1569 | ||
1570 | if ( !redo->top() ) | 1570 | if ( !redo->top() ) |
1571 | mActionRedo->setText( i18n( "Redo" ) ); | 1571 | mActionRedo->setText( i18n( "Redo" ) ); |
1572 | else | 1572 | else |
1573 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); | 1573 | mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); |
1574 | 1574 | ||
1575 | mActionRedo->setEnabled( !redo->isEmpty() ); | 1575 | mActionRedo->setEnabled( !redo->isEmpty() ); |
1576 | } | 1576 | } |
1577 | 1577 | ||
1578 | void KABCore::configureKeyBindings() | 1578 | void KABCore::configureKeyBindings() |
1579 | { | 1579 | { |
1580 | #ifndef KAB_EMBEDDED | 1580 | #ifndef KAB_EMBEDDED |
1581 | KKeyDialog::configure( actionCollection(), true ); | 1581 | KKeyDialog::configure( actionCollection(), true ); |
1582 | #else //KAB_EMBEDDED | 1582 | #else //KAB_EMBEDDED |
1583 | qDebug("KABCore::configureKeyBindings() not implemented"); | 1583 | qDebug("KABCore::configureKeyBindings() not implemented"); |
1584 | #endif //KAB_EMBEDDED | 1584 | #endif //KAB_EMBEDDED |
1585 | } | 1585 | } |
1586 | 1586 | ||
1587 | #ifdef KAB_EMBEDDED | 1587 | #ifdef KAB_EMBEDDED |
1588 | void KABCore::configureResources() | 1588 | void KABCore::configureResources() |
1589 | { | 1589 | { |
1590 | KRES::KCMKResources dlg( this, "" , 0 ); | 1590 | KRES::KCMKResources dlg( this, "" , 0 ); |
1591 | 1591 | ||
1592 | if ( !dlg.exec() ) | 1592 | if ( !dlg.exec() ) |
1593 | return; | 1593 | return; |
1594 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); | 1594 | KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); |
1595 | } | 1595 | } |
1596 | #endif //KAB_EMBEDDED | 1596 | #endif //KAB_EMBEDDED |
1597 | 1597 | ||
1598 | 1598 | ||
1599 | 1599 | ||
1600 | #ifndef KAB_EMBEDDED | 1600 | #ifndef KAB_EMBEDDED |
1601 | #include "kabcore.moc" | 1601 | #include "kabcore.moc" |
1602 | #endif //KAB_EMBEDDED | 1602 | #endif //KAB_EMBEDDED |
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp index 56b0ef3..827ec38 100644 --- a/microkde/kresources/factory.cpp +++ b/microkde/kresources/factory.cpp | |||
@@ -1,242 +1,242 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkresources. | 2 | This file is part of libkresources. |
3 | 3 | ||
4 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 4 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> | 5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> |
6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
7 | 7 | ||
8 | This library is free software; you can redistribute it and/or | 8 | This library 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 | This library is distributed in the hope that it will be useful, | 13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Library General Public License for more details. | 16 | Library General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU Library General Public License | 18 | You should have received a copy of the GNU Library General Public License |
19 | along with this library; see the file COPYING.LIB. If not, write to | 19 | along with this library; see the file COPYING.LIB. If not, write to |
20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
21 | Boston, MA 02111-1307, USA. | 21 | Boston, MA 02111-1307, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <kdebug.h> | 24 | #include <kdebug.h> |
25 | #include <klocale.h> | 25 | #include <klocale.h> |
26 | #include <ksimpleconfig.h> | 26 | #include <ksimpleconfig.h> |
27 | #include <kstandarddirs.h> | 27 | #include <kstandarddirs.h> |
28 | #include <kstaticdeleter.h> | 28 | #include <kstaticdeleter.h> |
29 | #include <klibloader.h> | 29 | #include <klibloader.h> |
30 | 30 | ||
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | 32 | ||
33 | #include "resource.h" | 33 | #include "resource.h" |
34 | #include "factory.h" | 34 | #include "factory.h" |
35 | 35 | ||
36 | using namespace KRES; | 36 | using namespace KRES; |
37 | 37 | ||
38 | QDict<Factory> *Factory::mSelves = 0; | 38 | QDict<Factory> *Factory::mSelves = 0; |
39 | static KStaticDeleter< QDict<Factory> > staticDeleter; | 39 | static KStaticDeleter< QDict<Factory> > staticDeleter; |
40 | 40 | ||
41 | Factory *Factory::self( const QString& resourceFamily ) | 41 | Factory *Factory::self( const QString& resourceFamily ) |
42 | { | 42 | { |
43 | kdDebug(5650) << "Factory::self()" << endl; | 43 | |
44 | 44 | ||
45 | Factory *factory = 0; | 45 | Factory *factory = 0; |
46 | if ( !mSelves ) | 46 | if ( !mSelves ) |
47 | { | 47 | { |
48 | mSelves = staticDeleter.setObject( new QDict<Factory> ); | 48 | mSelves = staticDeleter.setObject( new QDict<Factory> ); |
49 | } | 49 | } |
50 | 50 | ||
51 | factory = mSelves->find( resourceFamily ); | 51 | factory = mSelves->find( resourceFamily ); |
52 | 52 | ||
53 | if ( !factory ) { | 53 | if ( !factory ) { |
54 | factory = new Factory( resourceFamily ); | 54 | factory = new Factory( resourceFamily ); |
55 | mSelves->insert( resourceFamily, factory ); | 55 | mSelves->insert( resourceFamily, factory ); |
56 | } | 56 | } |
57 | 57 | ||
58 | return factory; | 58 | return factory; |
59 | } | 59 | } |
60 | 60 | ||
61 | Factory::Factory( const QString& resourceFamily ) : | 61 | Factory::Factory( const QString& resourceFamily ) : |
62 | mResourceFamily( resourceFamily ) | 62 | mResourceFamily( resourceFamily ) |
63 | { | 63 | { |
64 | //US so far we have three types available for resourceFamily "contact" | 64 | //US so far we have three types available for resourceFamily "contact" |
65 | // and that are "file", "dir", "ldap" | 65 | // and that are "file", "dir", "ldap" |
66 | /*US | 66 | /*US |
67 | 67 | ||
68 | KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" ) | 68 | KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" ) |
69 | .arg( resourceFamily ) ); | 69 | .arg( resourceFamily ) ); |
70 | KTrader::OfferList::ConstIterator it; | 70 | KTrader::OfferList::ConstIterator it; |
71 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | 71 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { |
72 | QVariant type = (*it)->property( "X-KDE-ResourceType" ); | 72 | QVariant type = (*it)->property( "X-KDE-ResourceType" ); |
73 | if ( !type.toString().isEmpty() ) | 73 | if ( !type.toString().isEmpty() ) |
74 | mTypeMap.insert( type.toString(), *it ); | 74 | mTypeMap.insert( type.toString(), *it ); |
75 | } | 75 | } |
76 | */ | 76 | */ |
77 | 77 | ||
78 | //US new | 78 | //US new |
79 | PluginInfo* info = new PluginInfo; | 79 | PluginInfo* info = new PluginInfo; |
80 | info->library = "microkabc_file"; | 80 | info->library = "microkabc_file"; |
81 | info->nameLabel = i18n( "file" ); | 81 | info->nameLabel = i18n( "file" ); |
82 | info->descriptionLabel = i18n( "No description available." ); | 82 | info->descriptionLabel = i18n( "Choose one file" ); |
83 | mTypeMap.insert( "file", info ); | 83 | mTypeMap.insert( "file", info ); |
84 | 84 | ||
85 | info = new PluginInfo; | 85 | info = new PluginInfo; |
86 | info->library = "microkabc_dir"; | 86 | info->library = "microkabc_dir"; |
87 | info->nameLabel = i18n( "dir" ); | 87 | info->nameLabel = i18n( "dir" ); |
88 | info->descriptionLabel = i18n( "No description available." ); | 88 | info->descriptionLabel = i18n( "Choose a directory with may files" ); |
89 | mTypeMap.insert( "dir", info ); | 89 | mTypeMap.insert( "dir", info ); |
90 | 90 | ||
91 | info = new PluginInfo; | 91 | info = new PluginInfo; |
92 | info->library = "microkabc_ldap"; | 92 | info->library = "microkabc_ldap"; |
93 | info->nameLabel = i18n( "ldap" ); | 93 | info->nameLabel = i18n( "ldap" ); |
94 | info->descriptionLabel = i18n( "No description available." ); | 94 | info->descriptionLabel = i18n( "No description available" ); |
95 | mTypeMap.insert( "ldap", info ); | 95 | mTypeMap.insert( "ldap", info ); |
96 | 96 | ||
97 | //US add opie plugin only, if the library exists | 97 | //US add opie plugin only, if the library exists |
98 | QString libname = "microkabc_opie"; | 98 | QString libname = "microkabc_opie"; |
99 | QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); | 99 | QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); |
100 | if ( !path.isEmpty() ) | 100 | if ( !path.isEmpty() ) |
101 | { | 101 | { |
102 | info = new PluginInfo; | 102 | info = new PluginInfo; |
103 | info->library = libname; | 103 | info->library = libname; |
104 | info->nameLabel = i18n( "opie" ); | 104 | info->nameLabel = i18n( "opie" ); |
105 | info->descriptionLabel = i18n( "Opie PIM Addressbook." ); | 105 | info->descriptionLabel = i18n( "Opie PIM Addressbook." ); |
106 | mTypeMap.insert( "opie", info ); | 106 | mTypeMap.insert( "opie", info ); |
107 | } | 107 | } |
108 | 108 | ||
109 | //US add qtopia plugin only, if the library exists | 109 | //US add qtopia plugin only, if the library exists |
110 | libname = "microkabc_qtopia"; | 110 | libname = "microkabc_qtopia"; |
111 | path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); | 111 | path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); |
112 | if ( !path.isEmpty() ) | 112 | if ( !path.isEmpty() ) |
113 | { | 113 | { |
114 | info = new PluginInfo; | 114 | info = new PluginInfo; |
115 | info->library = libname; | 115 | info->library = libname; |
116 | info->nameLabel = i18n( "qtopia" ); | 116 | info->nameLabel = i18n( "qtopia" ); |
117 | info->descriptionLabel = i18n( "Qtopia PIM Addressbook." ); | 117 | info->descriptionLabel = i18n( "Qtopia PIM Addressbook." ); |
118 | mTypeMap.insert( "qtopia", info ); | 118 | mTypeMap.insert( "qtopia", info ); |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | } | 122 | } |
123 | 123 | ||
124 | Factory::~Factory() | 124 | Factory::~Factory() |
125 | { | 125 | { |
126 | } | 126 | } |
127 | 127 | ||
128 | QStringList Factory::typeNames() const | 128 | QStringList Factory::typeNames() const |
129 | { | 129 | { |
130 | //US method QMap::keys() not available yet. SO collect the data manually | 130 | //US method QMap::keys() not available yet. SO collect the data manually |
131 | //US return mTypeMap.keys(); | 131 | //US return mTypeMap.keys(); |
132 | 132 | ||
133 | QStringList result; | 133 | QStringList result; |
134 | 134 | ||
135 | QMap<QString, PluginInfo*>::ConstIterator it; | 135 | QMap<QString, PluginInfo*>::ConstIterator it; |
136 | for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) { | 136 | for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) { |
137 | result << it.key().latin1(); | 137 | result << it.key().latin1(); |
138 | // qDebug("Factory::typeNames() : %s ", it.key().latin1()); | 138 | // qDebug("Factory::typeNames() : %s ", it.key().latin1()); |
139 | 139 | ||
140 | } | 140 | } |
141 | return result; | 141 | return result; |
142 | } | 142 | } |
143 | 143 | ||
144 | ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) | 144 | ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) |
145 | { | 145 | { |
146 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | 146 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) |
147 | return 0; | 147 | return 0; |
148 | 148 | ||
149 | //US KService::Ptr ptr = mTypeMap[ type ]; | 149 | //US KService::Ptr ptr = mTypeMap[ type ]; |
150 | //US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); | 150 | //US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); |
151 | PluginInfo* pi = mTypeMap[ type ]; | 151 | PluginInfo* pi = mTypeMap[ type ]; |
152 | KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); | 152 | KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); |
153 | if ( !factory ) { | 153 | if ( !factory ) { |
154 | qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1()); | 154 | qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1()); |
155 | kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl; | 155 | kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl; |
156 | return 0; | 156 | return 0; |
157 | } | 157 | } |
158 | 158 | ||
159 | PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); | 159 | PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); |
160 | 160 | ||
161 | if ( !pluginFactory ) { | 161 | if ( !pluginFactory ) { |
162 | qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1()); | 162 | qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1()); |
163 | kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl; | 163 | kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl; |
164 | return 0; | 164 | return 0; |
165 | } | 165 | } |
166 | 166 | ||
167 | ConfigWidget *wdg = pluginFactory->configWidget( parent ); | 167 | ConfigWidget *wdg = pluginFactory->configWidget( parent ); |
168 | if ( !wdg ) { | 168 | if ( !wdg ) { |
169 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; | 169 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; |
170 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); | 170 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); |
171 | return 0; | 171 | return 0; |
172 | } | 172 | } |
173 | return wdg; | 173 | return wdg; |
174 | 174 | ||
175 | } | 175 | } |
176 | 176 | ||
177 | QString Factory::typeName( const QString &type ) const | 177 | QString Factory::typeName( const QString &type ) const |
178 | { | 178 | { |
179 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | 179 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) |
180 | return QString(); | 180 | return QString(); |
181 | 181 | ||
182 | 182 | ||
183 | //US KService::Ptr ptr = mTypeMap[ type ]; | 183 | //US KService::Ptr ptr = mTypeMap[ type ]; |
184 | //US return ptr->name(); | 184 | //US return ptr->name(); |
185 | PluginInfo* pi = mTypeMap[ type ]; | 185 | PluginInfo* pi = mTypeMap[ type ]; |
186 | return pi->nameLabel; | 186 | return pi->nameLabel; |
187 | 187 | ||
188 | } | 188 | } |
189 | 189 | ||
190 | QString Factory::typeDescription( const QString &type ) const | 190 | QString Factory::typeDescription( const QString &type ) const |
191 | { | 191 | { |
192 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | 192 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) |
193 | return QString(); | 193 | return QString(); |
194 | 194 | ||
195 | //US KService::Ptr ptr = mTypeMap[ type ]; | 195 | //US KService::Ptr ptr = mTypeMap[ type ]; |
196 | //US return ptr->comment(); | 196 | //US return ptr->comment(); |
197 | PluginInfo* pi = mTypeMap[ type ]; | 197 | PluginInfo* pi = mTypeMap[ type ]; |
198 | return pi->descriptionLabel; | 198 | return pi->descriptionLabel; |
199 | } | 199 | } |
200 | 200 | ||
201 | Resource *Factory::resource( const QString& type, const KConfig *config ) | 201 | Resource *Factory::resource( const QString& type, const KConfig *config ) |
202 | { | 202 | { |
203 | kdDebug() << "Factory::resource( " << type << ", config)" << endl; | 203 | |
204 | 204 | ||
205 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | 205 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) |
206 | return 0; | 206 | return 0; |
207 | 207 | ||
208 | /*US load the lib not dynamicly. !! | 208 | /*US load the lib not dynamicly. !! |
209 | KService::Ptr ptr = mTypeMap[ type ]; | 209 | KService::Ptr ptr = mTypeMap[ type ]; |
210 | KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); | 210 | KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); |
211 | if ( !factory ) { | 211 | if ( !factory ) { |
212 | kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; | 212 | kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; |
213 | return 0; | 213 | return 0; |
214 | } | 214 | } |
215 | */ | 215 | */ |
216 | PluginInfo* pi = mTypeMap[ type ]; | 216 | PluginInfo* pi = mTypeMap[ type ]; |
217 | KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); | 217 | KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); |
218 | if ( !factory ) { | 218 | if ( !factory ) { |
219 | qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1()); | 219 | qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1()); |
220 | kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; | 220 | kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; |
221 | return 0; | 221 | return 0; |
222 | } | 222 | } |
223 | 223 | ||
224 | PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); | 224 | PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); |
225 | 225 | ||
226 | if ( !pluginFactory ) { | 226 | if ( !pluginFactory ) { |
227 | qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1()); | 227 | qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1()); |
228 | kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl; | 228 | kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl; |
229 | return 0; | 229 | return 0; |
230 | } | 230 | } |
231 | 231 | ||
232 | Resource *resource = pluginFactory->resource( config ); | 232 | Resource *resource = pluginFactory->resource( config ); |
233 | if ( !resource ) { | 233 | if ( !resource ) { |
234 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; | 234 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; |
235 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); | 235 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); |
236 | return 0; | 236 | return 0; |
237 | } | 237 | } |
238 | 238 | ||
239 | resource->setType( type ); | 239 | resource->setType( type ); |
240 | 240 | ||
241 | return resource; | 241 | return resource; |
242 | } | 242 | } |
diff --git a/microkde/kresources/resource.cpp b/microkde/kresources/resource.cpp index 169eaa4..7827a67 100644 --- a/microkde/kresources/resource.cpp +++ b/microkde/kresources/resource.cpp | |||
@@ -1,185 +1,186 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkresources. | 2 | This file is part of libkresources. |
3 | 3 | ||
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> | 5 | Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> |
6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 6 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
7 | 7 | ||
8 | This library is free software; you can redistribute it and/or | 8 | This library 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 | This library is distributed in the hope that it will be useful, | 13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Library General Public License for more details. | 16 | Library General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU Library General Public License | 18 | You should have received a copy of the GNU Library General Public License |
19 | along with this library; see the file COPYING.LIB. If not, write to | 19 | along with this library; see the file COPYING.LIB. If not, write to |
20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
21 | Boston, MA 02111-1307, USA. | 21 | Boston, MA 02111-1307, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <kdebug.h> | 24 | #include <kdebug.h> |
25 | #include <kapplication.h> | 25 | #include <kapplication.h> |
26 | #include <kconfig.h> | 26 | #include <kconfig.h> |
27 | 27 | ||
28 | #include "resource.h" | 28 | #include "resource.h" |
29 | 29 | ||
30 | using namespace KRES; | 30 | using namespace KRES; |
31 | 31 | ||
32 | class Resource::ResourcePrivate | 32 | class Resource::ResourcePrivate |
33 | { | 33 | { |
34 | public: | 34 | public: |
35 | #ifdef QT_THREAD_SUPPORT | 35 | #ifdef QT_THREAD_SUPPORT |
36 | QMutex mMutex; | 36 | QMutex mMutex; |
37 | #endif | 37 | #endif |
38 | int mOpenCount; | 38 | int mOpenCount; |
39 | QString mType; | 39 | QString mType; |
40 | QString mIdentifier; | 40 | QString mIdentifier; |
41 | bool mReadOnly; | 41 | bool mReadOnly; |
42 | QString mName; | 42 | QString mName; |
43 | bool mActive; | 43 | bool mActive; |
44 | bool mIsOpen; | 44 | bool mIsOpen; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | Resource::Resource( const KConfig* config ) | 47 | Resource::Resource( const KConfig* config ) |
48 | : QObject( 0, "" ), d( new ResourcePrivate ) | 48 | : QObject( 0, "" ), d( new ResourcePrivate ) |
49 | { | 49 | { |
50 | d->mOpenCount = 0; | 50 | d->mOpenCount = 0; |
51 | d->mIsOpen = false; | 51 | d->mIsOpen = false; |
52 | 52 | ||
53 | //US compiler claimed that const discards qualifier | 53 | //US compiler claimed that const discards qualifier |
54 | KConfig* cfg = (KConfig*)config; | 54 | KConfig* cfg = (KConfig*)config; |
55 | if ( cfg ) { | 55 | if ( cfg ) { |
56 | d->mType = cfg->readEntry( "ResourceType" ); | 56 | d->mType = cfg->readEntry( "ResourceType" ); |
57 | d->mName = cfg->readEntry( "ResourceName" ); | 57 | d->mName = cfg->readEntry( "ResourceName" ); |
58 | d->mReadOnly = cfg->readBoolEntry( "ResourceIsReadOnly", false ); | 58 | d->mReadOnly = cfg->readBoolEntry( "ResourceIsReadOnly", false ); |
59 | d->mActive = cfg->readBoolEntry( "ResourceIsActive", true ); | 59 | d->mActive = cfg->readBoolEntry( "ResourceIsActive", true ); |
60 | d->mIdentifier = cfg->readEntry( "ResourceIdentifier" ); | 60 | d->mIdentifier = cfg->readEntry( "ResourceIdentifier" ); |
61 | } else { | 61 | } else { |
62 | d->mType = "type"; | 62 | d->mType = "type"; |
63 | d->mName = "resource-name"; | 63 | d->mName = "resource-name"; |
64 | d->mReadOnly = false; | 64 | d->mReadOnly = false; |
65 | d->mActive = true; | 65 | d->mActive = true; |
66 | d->mIdentifier = KApplication::randomString( 10 ); | 66 | d->mIdentifier = KApplication::randomString( 10 ); |
67 | } | 67 | } |
68 | } | 68 | } |
69 | 69 | ||
70 | Resource::~Resource() | 70 | Resource::~Resource() |
71 | { | 71 | { |
72 | delete d; | 72 | delete d; |
73 | d = 0; | 73 | d = 0; |
74 | } | 74 | } |
75 | 75 | ||
76 | void Resource::writeConfig( KConfig* config ) | 76 | void Resource::writeConfig( KConfig* config ) |
77 | { | 77 | { |
78 | kdDebug(5650) << "Resource::writeConfig()" << endl; | 78 | |
79 | 79 | ||
80 | config->writeEntry( "ResourceType", d->mType ); | 80 | config->writeEntry( "ResourceType", d->mType ); |
81 | config->writeEntry( "ResourceName", d->mName ); | 81 | config->writeEntry( "ResourceName", d->mName ); |
82 | config->writeEntry( "ResourceIsReadOnly", d->mReadOnly ); | 82 | config->writeEntry( "ResourceIsReadOnly", d->mReadOnly ); |
83 | config->writeEntry( "ResourceIsActive", d->mActive ); | 83 | config->writeEntry( "ResourceIsActive", d->mActive ); |
84 | config->writeEntry( "ResourceIdentifier", d->mIdentifier ); | 84 | config->writeEntry( "ResourceIdentifier", d->mIdentifier ); |
85 | } | 85 | } |
86 | 86 | ||
87 | bool Resource::open() | 87 | bool Resource::open() |
88 | { | 88 | { |
89 | d->mIsOpen = true; | 89 | d->mIsOpen = true; |
90 | #ifdef QT_THREAD_SUPPORT | 90 | #ifdef QT_THREAD_SUPPORT |
91 | QMutexLocker guard( &(d->mMutex) ); | 91 | QMutexLocker guard( &(d->mMutex) ); |
92 | #endif | 92 | #endif |
93 | if ( !d->mOpenCount ) { | 93 | if ( !d->mOpenCount ) { |
94 | kdDebug(5650) << "Opening resource " << resourceName() << endl; | 94 | kdDebug(5650) << "Opening resource " << resourceName() << endl; |
95 | d->mIsOpen = doOpen(); | 95 | d->mIsOpen = doOpen(); |
96 | } | 96 | } |
97 | d->mOpenCount++; | 97 | d->mOpenCount++; |
98 | return d->mIsOpen; | 98 | return d->mIsOpen; |
99 | } | 99 | } |
100 | 100 | ||
101 | void Resource::close() | 101 | void Resource::close() |
102 | { | 102 | { |
103 | #ifdef QT_THREAD_SUPPORT | 103 | #ifdef QT_THREAD_SUPPORT |
104 | QMutexLocker guard( &(d->mMutex) ); | 104 | QMutexLocker guard( &(d->mMutex) ); |
105 | #endif | 105 | #endif |
106 | if ( !d->mOpenCount ) { | 106 | if ( !d->mOpenCount ) { |
107 | kdDebug(5650) << "ERROR: Resource " << resourceName() << " closed more times than previously opened" << endl; | 107 | kdDebug(5650) << "ERROR: Resource " << resourceName() << " closed more times than previously opened" << endl; |
108 | return; | 108 | return; |
109 | } | 109 | } |
110 | d->mOpenCount--; | 110 | d->mOpenCount--; |
111 | if ( !d->mOpenCount ) { | 111 | if ( !d->mOpenCount ) { |
112 | kdDebug(5650) << "Closing resource " << resourceName() << endl; | 112 | kdDebug(5650) << "Closing resource " << resourceName() << endl; |
113 | doClose(); | 113 | doClose(); |
114 | d->mIsOpen = false; | 114 | d->mIsOpen = false; |
115 | } else { | 115 | } else { |
116 | kdDebug(5650) << "Not yet closing resource " << resourceName() << ", open count = " << d->mOpenCount << endl; | 116 | kdDebug(5650) << "Not yet closing resource " << resourceName() << ", open count = " << d->mOpenCount << endl; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | bool Resource::isOpen() const | 120 | bool Resource::isOpen() const |
121 | { | 121 | { |
122 | return d->mIsOpen; | 122 | return d->mIsOpen; |
123 | } | 123 | } |
124 | 124 | ||
125 | void Resource::setIdentifier( const QString& identifier ) | 125 | void Resource::setIdentifier( const QString& identifier ) |
126 | { | 126 | { |
127 | d->mIdentifier = identifier; | 127 | d->mIdentifier = identifier; |
128 | } | 128 | } |
129 | 129 | ||
130 | QString Resource::identifier() const | 130 | QString Resource::identifier() const |
131 | { | 131 | { |
132 | return d->mIdentifier; | 132 | return d->mIdentifier; |
133 | } | 133 | } |
134 | 134 | ||
135 | void Resource::setType( const QString& type ) | 135 | void Resource::setType( const QString& type ) |
136 | { | 136 | { |
137 | d->mType = type; | 137 | d->mType = type; |
138 | } | 138 | } |
139 | 139 | ||
140 | QString Resource::type() const | 140 | QString Resource::type() const |
141 | { | 141 | { |
142 | return d->mType; | 142 | return d->mType; |
143 | } | 143 | } |
144 | 144 | ||
145 | void Resource::setReadOnly( bool value ) | 145 | void Resource::setReadOnly( bool value ) |
146 | { | 146 | { |
147 | d->mReadOnly = value; | 147 | d->mReadOnly = value; |
148 | } | 148 | } |
149 | 149 | ||
150 | bool Resource::readOnly() const | 150 | bool Resource::readOnly() const |
151 | { | 151 | { |
152 | return d->mReadOnly; | 152 | return d->mReadOnly; |
153 | } | 153 | } |
154 | 154 | ||
155 | void Resource::setResourceName( const QString &name ) | 155 | void Resource::setResourceName( const QString &name ) |
156 | { | 156 | { |
157 | d->mName = name; | 157 | d->mName = name; |
158 | } | 158 | } |
159 | 159 | ||
160 | QString Resource::resourceName() const | 160 | QString Resource::resourceName() const |
161 | { | 161 | { |
162 | return d->mName; | 162 | return d->mName; |
163 | } | 163 | } |
164 | 164 | ||
165 | void Resource::setActive( bool value ) | 165 | void Resource::setActive( bool value ) |
166 | { | 166 | { |
167 | d->mActive = value; | 167 | d->mActive = value; |
168 | } | 168 | } |
169 | 169 | ||
170 | bool Resource::isActive() const | 170 | bool Resource::isActive() const |
171 | { | 171 | { |
172 | return d->mActive; | 172 | return d->mActive; |
173 | } | 173 | } |
174 | 174 | ||
175 | void Resource::dump() const | 175 | void Resource::dump() const |
176 | { | 176 | { |
177 | qDebug("Resource::dump() "); | ||
177 | kdDebug(5650) << "Resource:" << endl; | 178 | kdDebug(5650) << "Resource:" << endl; |
178 | kdDebug(5650) << " Name: " << d->mName << endl; | 179 | kdDebug(5650) << " Name: " << d->mName << endl; |
179 | kdDebug(5650) << " Identifier: " << d->mIdentifier << endl; | 180 | kdDebug(5650) << " Identifier: " << d->mIdentifier << endl; |
180 | kdDebug(5650) << " Type: " << d->mType << endl; | 181 | kdDebug(5650) << " Type: " << d->mType << endl; |
181 | kdDebug(5650) << " OpenCount: " << d->mOpenCount << endl; | 182 | kdDebug(5650) << " OpenCount: " << d->mOpenCount << endl; |
182 | kdDebug(5650) << " ReadOnly: " << ( d->mReadOnly ? "yes" : "no" ) << endl; | 183 | kdDebug(5650) << " ReadOnly: " << ( d->mReadOnly ? "yes" : "no" ) << endl; |
183 | kdDebug(5650) << " Active: " << ( d->mActive ? "yes" : "no" ) << endl; | 184 | kdDebug(5650) << " Active: " << ( d->mActive ? "yes" : "no" ) << endl; |
184 | kdDebug(5650) << " IsOpen: " << ( d->mIsOpen ? "yes" : "no" ) << endl; | 185 | kdDebug(5650) << " IsOpen: " << ( d->mIsOpen ? "yes" : "no" ) << endl; |
185 | } | 186 | } |