-rw-r--r-- | core/pim/addressbook/abview.cpp | 7 | ||||
-rw-r--r-- | core/pim/addressbook/abview.h | 1 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 52 |
3 files changed, 35 insertions, 25 deletions
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp index b89b794..d3ca783 100644 --- a/core/pim/addressbook/abview.cpp +++ b/core/pim/addressbook/abview.cpp | |||
@@ -107,373 +107,380 @@ void AbView::addEntry( const OContact &newContact ) | |||
107 | load(); | 107 | load(); |
108 | 108 | ||
109 | } | 109 | } |
110 | void AbView::removeEntry( const int UID ) | 110 | void AbView::removeEntry( const int UID ) |
111 | { | 111 | { |
112 | //qWarning("abview:RemoveContact"); | 112 | //qWarning("abview:RemoveContact"); |
113 | m_contactdb->remove( UID ); | 113 | m_contactdb->remove( UID ); |
114 | load(); | 114 | load(); |
115 | } | 115 | } |
116 | 116 | ||
117 | void AbView::replaceEntry( const OContact &contact ) | 117 | void AbView::replaceEntry( const OContact &contact ) |
118 | { | 118 | { |
119 | //qWarning("abview:ReplaceContact"); | 119 | //qWarning("abview:ReplaceContact"); |
120 | m_contactdb->replace( contact ); | 120 | m_contactdb->replace( contact ); |
121 | load(); | 121 | load(); |
122 | 122 | ||
123 | } | 123 | } |
124 | 124 | ||
125 | OContact AbView::currentEntry() | 125 | OContact AbView::currentEntry() |
126 | { | 126 | { |
127 | OContact currentContact; | 127 | OContact currentContact; |
128 | 128 | ||
129 | switch ( (int) m_curr_View ) { | 129 | switch ( (int) m_curr_View ) { |
130 | case TableView: | 130 | case TableView: |
131 | currentContact = m_abTable -> currentEntry(); | 131 | currentContact = m_abTable -> currentEntry(); |
132 | break; | 132 | break; |
133 | case CardView: | 133 | case CardView: |
134 | currentContact = m_ablabel -> currentEntry(); | 134 | currentContact = m_ablabel -> currentEntry(); |
135 | break; | 135 | break; |
136 | } | 136 | } |
137 | m_curr_Contact = currentContact.uid(); | 137 | m_curr_Contact = currentContact.uid(); |
138 | return currentContact; | 138 | return currentContact; |
139 | } | 139 | } |
140 | 140 | ||
141 | bool AbView::save() | 141 | bool AbView::save() |
142 | { | 142 | { |
143 | //qWarning("abView:Save data"); | 143 | //qWarning("abView:Save data"); |
144 | 144 | ||
145 | return m_contactdb->save(); | 145 | return m_contactdb->save(); |
146 | } | 146 | } |
147 | 147 | ||
148 | void AbView::load() | 148 | void AbView::load() |
149 | { | 149 | { |
150 | //qWarning("abView:Load data"); | 150 | //qWarning("abView:Load data"); |
151 | 151 | ||
152 | // Letter Search is stopped at this place | 152 | // Letter Search is stopped at this place |
153 | emit signalClearLetterPicker(); | 153 | emit signalClearLetterPicker(); |
154 | 154 | ||
155 | if ( m_inPersonal ) | 155 | if ( m_inPersonal ) |
156 | // VCard Backend does not sort.. | 156 | // VCard Backend does not sort.. |
157 | m_list = m_contactdb->allRecords(); | 157 | m_list = m_contactdb->allRecords(); |
158 | else{ | 158 | else{ |
159 | m_list = m_contactdb->sorted( true, 0, 0, 0 ); | 159 | m_list = m_contactdb->sorted( true, 0, 0, 0 ); |
160 | clearForCategory(); | 160 | clearForCategory(); |
161 | } | 161 | } |
162 | 162 | ||
163 | //qWarning ("Number of contacts: %d", m_list.count()); | 163 | //qWarning ("Number of contacts: %d", m_list.count()); |
164 | 164 | ||
165 | updateView( true ); | 165 | updateView( true ); |
166 | 166 | ||
167 | } | 167 | } |
168 | 168 | ||
169 | void AbView::reload() | 169 | void AbView::reload() |
170 | { | 170 | { |
171 | //qWarning( "void AbView::reload()" ); | 171 | //qWarning( "void AbView::reload()" ); |
172 | 172 | ||
173 | m_contactdb->reload(); | 173 | m_contactdb->reload(); |
174 | load(); | 174 | load(); |
175 | } | 175 | } |
176 | 176 | ||
177 | void AbView::clear() | 177 | void AbView::clear() |
178 | { | 178 | { |
179 | // :SX | 179 | // :SX |
180 | } | 180 | } |
181 | 181 | ||
182 | void AbView::setShowByCategory( const QString& cat ) | 182 | void AbView::setShowByCategory( const QString& cat ) |
183 | { | 183 | { |
184 | //qWarning("AbView::setShowCategory( const QString& cat )"); | 184 | //qWarning("AbView::setShowCategory( const QString& cat )"); |
185 | 185 | ||
186 | int intCat = 0; | 186 | int intCat = 0; |
187 | 187 | ||
188 | // All (cat == NULL) will be stored as -1 | 188 | // All (cat == NULL) will be stored as -1 |
189 | if ( cat.isNull() ) | 189 | if ( cat.isNull() ) |
190 | intCat = -1; | 190 | intCat = -1; |
191 | else | 191 | else |
192 | intCat = mCat.id("Contacts", cat ); | 192 | intCat = mCat.id("Contacts", cat ); |
193 | 193 | ||
194 | // Just do anything if we really change the category | 194 | // Just do anything if we really change the category |
195 | if ( intCat != m_curr_category ){ | 195 | if ( intCat != m_curr_category ){ |
196 | // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); | 196 | // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); |
197 | 197 | ||
198 | m_curr_category = intCat; | 198 | m_curr_category = intCat; |
199 | emit signalClearLetterPicker(); | 199 | emit signalClearLetterPicker(); |
200 | 200 | ||
201 | load(); | 201 | load(); |
202 | } | 202 | } |
203 | 203 | ||
204 | } | 204 | } |
205 | 205 | ||
206 | void AbView::setShowToView( Views view ) | 206 | void AbView::setShowToView( Views view ) |
207 | { | 207 | { |
208 | //qWarning("void AbView::setShowToView( View %d )", view); | 208 | //qWarning("void AbView::setShowToView( View %d )", view); |
209 | 209 | ||
210 | //qWarning ("Change the View (Category is: %d)", m_curr_category); | 210 | //qWarning ("Change the View (Category is: %d)", m_curr_category); |
211 | 211 | ||
212 | if ( m_curr_View != view ){ | 212 | if ( m_curr_View != view ){ |
213 | m_prev_View = m_curr_View; | 213 | m_prev_View = m_curr_View; |
214 | m_curr_View = view; | 214 | m_curr_View = view; |
215 | 215 | ||
216 | updateView(); | 216 | updateView(); |
217 | } | 217 | } |
218 | 218 | ||
219 | } | 219 | } |
220 | 220 | ||
221 | void AbView::setShowByLetter( char c ) | 221 | void AbView::setShowByLetter( char c ) |
222 | { | 222 | { |
223 | //qWarning("void AbView::setShowByLetter( %c )", c ); | 223 | //qWarning("void AbView::setShowByLetter( %c )", c ); |
224 | OContact query; | 224 | OContact query; |
225 | if ( c == 0 ){ | 225 | if ( c == 0 ){ |
226 | load(); | 226 | load(); |
227 | return; | 227 | return; |
228 | }else{ | 228 | }else{ |
229 | // If the current Backend is unable to solve the query, we will | 229 | // If the current Backend is unable to solve the query, we will |
230 | // ignore the request .. | 230 | // ignore the request .. |
231 | if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){ | 231 | if ( ! m_contactdb->hasQuerySettings( OContactAccess::WildCards | OContactAccess::IgnoreCase ) ){ |
232 | return; | 232 | return; |
233 | } | 233 | } |
234 | 234 | ||
235 | query.setLastName( QString("%1*").arg(c) ); | 235 | query.setLastName( QString("%1*").arg(c) ); |
236 | m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase ); | 236 | m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards | OContactAccess::IgnoreCase ); |
237 | clearForCategory(); | 237 | clearForCategory(); |
238 | m_curr_Contact = 0; | 238 | m_curr_Contact = 0; |
239 | } | 239 | } |
240 | updateView( true ); | 240 | updateView( true ); |
241 | } | 241 | } |
242 | 242 | ||
243 | void AbView::setListOrder( const QValueList<int>& ordered ) | 243 | void AbView::setListOrder( const QValueList<int>& ordered ) |
244 | { | 244 | { |
245 | m_orderedFields = ordered; | 245 | m_orderedFields = ordered; |
246 | if ( m_abTable ){ | 246 | if ( m_abTable ){ |
247 | m_abTable->setOrderedList( ordered ); | 247 | m_abTable->setOrderedList( ordered ); |
248 | m_abTable->refresh(); | 248 | m_abTable->refresh(); |
249 | } | 249 | } |
250 | updateView(); | 250 | updateView(); |
251 | } | 251 | } |
252 | 252 | ||
253 | 253 | ||
254 | QString AbView::showCategory() const | 254 | QString AbView::showCategory() const |
255 | { | 255 | { |
256 | return mCat.label( "Contacts", m_curr_category ); | 256 | return mCat.label( "Contacts", m_curr_category ); |
257 | } | 257 | } |
258 | 258 | ||
259 | void AbView::showPersonal( bool personal ) | 259 | void AbView::showPersonal( bool personal ) |
260 | { | 260 | { |
261 | //qWarning ("void AbView::showPersonal( %d )", personal); | 261 | //qWarning ("void AbView::showPersonal( %d )", personal); |
262 | 262 | ||
263 | if ( personal ){ | 263 | if ( personal ){ |
264 | 264 | ||
265 | if ( m_inPersonal ) | 265 | if ( m_inPersonal ) |
266 | return; | 266 | return; |
267 | 267 | ||
268 | // Now switch to vCard Backend and load data. | 268 | // Now switch to vCard Backend and load data. |
269 | // The current default backend will be stored | 269 | // The current default backend will be stored |
270 | // to avoid unneeded load/stores. | 270 | // to avoid unneeded load/stores. |
271 | m_storedDB = m_contactdb; | 271 | m_storedDB = m_contactdb; |
272 | 272 | ||
273 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 273 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
274 | addressbookPersonalVCardName() ); | 274 | addressbookPersonalVCardName() ); |
275 | m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 275 | m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
276 | 276 | ||
277 | m_inPersonal = true; | 277 | m_inPersonal = true; |
278 | m_curr_View = CardView; | 278 | m_curr_View = CardView; |
279 | 279 | ||
280 | }else{ | 280 | }else{ |
281 | 281 | ||
282 | if ( !m_inPersonal ) | 282 | if ( !m_inPersonal ) |
283 | return; | 283 | return; |
284 | 284 | ||
285 | // Remove vCard Backend and restore default | 285 | // Remove vCard Backend and restore default |
286 | m_contactdb->save(); | 286 | m_contactdb->save(); |
287 | delete m_contactdb; | 287 | delete m_contactdb; |
288 | 288 | ||
289 | m_contactdb = m_storedDB; | 289 | m_contactdb = m_storedDB; |
290 | m_storedDB = 0l; | 290 | m_storedDB = 0l; |
291 | 291 | ||
292 | m_curr_View = TableView; | 292 | m_curr_View = TableView; |
293 | m_inPersonal = false; | 293 | m_inPersonal = false; |
294 | 294 | ||
295 | } | 295 | } |
296 | load(); | 296 | load(); |
297 | } | 297 | } |
298 | 298 | ||
299 | void AbView::setCurrentUid( int uid ){ | ||
300 | |||
301 | m_curr_Contact = uid; | ||
302 | updateView( true ); //true: Don't modificate the UID ! | ||
303 | } | ||
304 | |||
305 | |||
299 | QStringList AbView::categories() | 306 | QStringList AbView::categories() |
300 | { | 307 | { |
301 | mCat.load( categoryFileName() ); | 308 | mCat.load( categoryFileName() ); |
302 | QStringList categoryList = mCat.labels( "Contacts" ); | 309 | QStringList categoryList = mCat.labels( "Contacts" ); |
303 | return categoryList; | 310 | return categoryList; |
304 | } | 311 | } |
305 | 312 | ||
306 | // BEGIN: Slots | 313 | // BEGIN: Slots |
307 | void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, | 314 | void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, |
308 | bool , QString cat ) | 315 | bool , QString cat ) |
309 | { | 316 | { |
310 | //qWarning( "void AbView::slotDoFind" ); | 317 | //qWarning( "void AbView::slotDoFind" ); |
311 | 318 | ||
312 | // We reloading the data: Deselect Letterpicker | 319 | // We reloading the data: Deselect Letterpicker |
313 | emit signalClearLetterPicker(); | 320 | emit signalClearLetterPicker(); |
314 | 321 | ||
315 | // Use the current Category if nothing else selected | 322 | // Use the current Category if nothing else selected |
316 | int category = 0; | 323 | int category = 0; |
317 | 324 | ||
318 | if ( cat.isEmpty() ) | 325 | if ( cat.isEmpty() ) |
319 | category = m_curr_category; | 326 | category = m_curr_category; |
320 | else{ | 327 | else{ |
321 | category = mCat.id("Contacts", cat ); | 328 | category = mCat.id("Contacts", cat ); |
322 | } | 329 | } |
323 | 330 | ||
324 | //qWarning ("Find in Category %d", category); | 331 | //qWarning ("Find in Category %d", category); |
325 | 332 | ||
326 | QRegExp r( str ); | 333 | QRegExp r( str ); |
327 | r.setCaseSensitive( caseSensitive ); | 334 | r.setCaseSensitive( caseSensitive ); |
328 | r.setWildcard( !useRegExp ); | 335 | r.setWildcard( !useRegExp ); |
329 | 336 | ||
330 | // Get all matching entries out of the database | 337 | // Get all matching entries out of the database |
331 | m_list = m_contactdb->matchRegexp( r ); | 338 | m_list = m_contactdb->matchRegexp( r ); |
332 | 339 | ||
333 | //qWarning( "found: %d", m_list.count() ); | 340 | //qWarning( "found: %d", m_list.count() ); |
334 | if ( m_list.count() == 0 ){ | 341 | if ( m_list.count() == 0 ){ |
335 | emit signalNotFound(); | 342 | emit signalNotFound(); |
336 | return; | 343 | return; |
337 | } | 344 | } |
338 | 345 | ||
339 | // Now remove all contacts with wrong category (if any selected) | 346 | // Now remove all contacts with wrong category (if any selected) |
340 | // This algorithm is a litte bit ineffective, but | 347 | // This algorithm is a litte bit ineffective, but |
341 | // we will not have a lot of matching entries.. | 348 | // we will not have a lot of matching entries.. |
342 | clearForCategory(); | 349 | clearForCategory(); |
343 | 350 | ||
344 | // Now show all found entries | 351 | // Now show all found entries |
345 | updateView( true ); | 352 | updateView( true ); |
346 | } | 353 | } |
347 | 354 | ||
348 | void AbView::offSearch() | 355 | void AbView::offSearch() |
349 | { | 356 | { |
350 | m_inSearch = false; | 357 | m_inSearch = false; |
351 | 358 | ||
352 | load(); | 359 | load(); |
353 | } | 360 | } |
354 | 361 | ||
355 | void AbView::slotSwitch(){ | 362 | void AbView::slotSwitch(){ |
356 | //qWarning("AbView::slotSwitch()"); | 363 | //qWarning("AbView::slotSwitch()"); |
357 | 364 | ||
358 | m_prev_View = m_curr_View; | 365 | m_prev_View = m_curr_View; |
359 | switch ( (int) m_curr_View ){ | 366 | switch ( (int) m_curr_View ){ |
360 | case TableView: | 367 | case TableView: |
361 | qWarning("Switching to CardView"); | 368 | qWarning("Switching to CardView"); |
362 | m_curr_View = CardView; | 369 | m_curr_View = CardView; |
363 | break; | 370 | break; |
364 | case CardView: | 371 | case CardView: |
365 | qWarning("Switching to TableView"); | 372 | qWarning("Switching to TableView"); |
366 | m_curr_View = TableView; | 373 | m_curr_View = TableView; |
367 | break; | 374 | break; |
368 | } | 375 | } |
369 | updateView(); | 376 | updateView(); |
370 | 377 | ||
371 | } | 378 | } |
372 | 379 | ||
373 | // END: Slots | 380 | // END: Slots |
374 | 381 | ||
375 | void AbView::clearForCategory() | 382 | void AbView::clearForCategory() |
376 | { | 383 | { |
377 | OContactAccess::List::Iterator it; | 384 | OContactAccess::List::Iterator it; |
378 | // Now remove all contacts with wrong category if any category selected | 385 | // Now remove all contacts with wrong category if any category selected |
379 | 386 | ||
380 | OContactAccess::List allList = m_list; | 387 | OContactAccess::List allList = m_list; |
381 | if ( m_curr_category != -1 ){ | 388 | if ( m_curr_category != -1 ){ |
382 | for ( it = allList.begin(); it != allList.end(); ++it ){ | 389 | for ( it = allList.begin(); it != allList.end(); ++it ){ |
383 | if ( !contactCompare( *it, m_curr_category ) ){ | 390 | if ( !contactCompare( *it, m_curr_category ) ){ |
384 | // qWarning("Removing %d", (*it).uid()); | 391 | // qWarning("Removing %d", (*it).uid()); |
385 | m_list.remove( (*it).uid() ); | 392 | m_list.remove( (*it).uid() ); |
386 | } | 393 | } |
387 | } | 394 | } |
388 | } | 395 | } |
389 | 396 | ||
390 | } | 397 | } |
391 | 398 | ||
392 | bool AbView::contactCompare( const OContact &cnt, int category ) | 399 | bool AbView::contactCompare( const OContact &cnt, int category ) |
393 | { | 400 | { |
394 | //qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category); | 401 | //qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category); |
395 | 402 | ||
396 | bool returnMe; | 403 | bool returnMe; |
397 | QArray<int> cats; | 404 | QArray<int> cats; |
398 | cats = cnt.categories(); | 405 | cats = cnt.categories(); |
399 | 406 | ||
400 | //qWarning ("Number of categories: %d", cats.count() ); | 407 | //qWarning ("Number of categories: %d", cats.count() ); |
401 | 408 | ||
402 | returnMe = false; | 409 | returnMe = false; |
403 | if ( cats.count() == 0 && category == 0 ) | 410 | if ( cats.count() == 0 && category == 0 ) |
404 | // Contacts with no category will just shown on "All" and "Unfiled" | 411 | // Contacts with no category will just shown on "All" and "Unfiled" |
405 | returnMe = true; | 412 | returnMe = true; |
406 | else { | 413 | else { |
407 | int i; | 414 | int i; |
408 | for ( i = 0; i < int(cats.count()); i++ ) { | 415 | for ( i = 0; i < int(cats.count()); i++ ) { |
409 | // qWarning("Comparing %d with %d",cats[i],category ); | 416 | // qWarning("Comparing %d with %d",cats[i],category ); |
410 | if ( cats[i] == category ) { | 417 | if ( cats[i] == category ) { |
411 | returnMe = true; | 418 | returnMe = true; |
412 | break; | 419 | break; |
413 | } | 420 | } |
414 | } | 421 | } |
415 | } | 422 | } |
416 | //qWarning ("Return: %d", returnMe); | 423 | //qWarning ("Return: %d", returnMe); |
417 | return returnMe; | 424 | return returnMe; |
418 | } | 425 | } |
419 | 426 | ||
420 | // In Some rare cases we have to update all lists.. | 427 | // In Some rare cases we have to update all lists.. |
421 | void AbView::updateListinViews() | 428 | void AbView::updateListinViews() |
422 | { | 429 | { |
423 | m_abTable -> setContacts( m_list ); | 430 | m_abTable -> setContacts( m_list ); |
424 | m_ablabel -> setContacts( m_list ); | 431 | m_ablabel -> setContacts( m_list ); |
425 | } | 432 | } |
426 | 433 | ||
427 | void AbView::updateView( bool newdata ) | 434 | void AbView::updateView( bool newdata ) |
428 | { | 435 | { |
429 | //qWarning("AbView::updateView()"); | 436 | //qWarning("AbView::updateView()"); |
430 | 437 | ||
431 | if ( m_viewStack -> visibleWidget() ){ | 438 | if ( m_viewStack -> visibleWidget() ){ |
432 | m_viewStack -> visibleWidget() -> clearFocus(); | 439 | m_viewStack -> visibleWidget() -> clearFocus(); |
433 | } | 440 | } |
434 | 441 | ||
435 | // If we switching the view, we have to store some information | 442 | // If we switching the view, we have to store some information |
436 | if ( !newdata ){ | 443 | if ( !newdata ){ |
437 | if ( m_list.count() ){ | 444 | if ( m_list.count() ){ |
438 | switch ( (int) m_prev_View ) { | 445 | switch ( (int) m_prev_View ) { |
439 | case TableView: | 446 | case TableView: |
440 | m_curr_Contact = m_abTable -> currentEntry_UID(); | 447 | m_curr_Contact = m_abTable -> currentEntry_UID(); |
441 | break; | 448 | break; |
442 | case CardView: | 449 | case CardView: |
443 | m_curr_Contact = m_ablabel -> currentEntry_UID(); | 450 | m_curr_Contact = m_ablabel -> currentEntry_UID(); |
444 | break; | 451 | break; |
445 | } | 452 | } |
446 | }else | 453 | }else |
447 | m_curr_Contact = 0; | 454 | m_curr_Contact = 0; |
448 | } | 455 | } |
449 | 456 | ||
450 | // Feed all views with new lists | 457 | // Feed all views with new lists |
451 | if ( newdata ) | 458 | if ( newdata ) |
452 | updateListinViews(); | 459 | updateListinViews(); |
453 | 460 | ||
454 | // Tell the world that the view is changed | 461 | // Tell the world that the view is changed |
455 | if ( m_curr_View != m_prev_View ) | 462 | if ( m_curr_View != m_prev_View ) |
456 | emit signalViewSwitched ( (int) m_curr_View ); | 463 | emit signalViewSwitched ( (int) m_curr_View ); |
457 | 464 | ||
458 | m_prev_View = m_curr_View; | 465 | m_prev_View = m_curr_View; |
459 | 466 | ||
460 | // Switch to new View | 467 | // Switch to new View |
461 | switch ( (int) m_curr_View ) { | 468 | switch ( (int) m_curr_View ) { |
462 | case TableView: | 469 | case TableView: |
463 | m_abTable -> setChoiceSelection( m_orderedFields ); | 470 | m_abTable -> setChoiceSelection( m_orderedFields ); |
464 | if ( m_curr_Contact != 0 ) | 471 | if ( m_curr_Contact != 0 ) |
465 | m_abTable -> selectContact ( m_curr_Contact ); | 472 | m_abTable -> selectContact ( m_curr_Contact ); |
466 | m_abTable -> setFocus(); | 473 | m_abTable -> setFocus(); |
467 | break; | 474 | break; |
468 | case CardView: | 475 | case CardView: |
469 | if ( m_curr_Contact != 0 ) | 476 | if ( m_curr_Contact != 0 ) |
470 | m_ablabel -> selectContact( m_curr_Contact ); | 477 | m_ablabel -> selectContact( m_curr_Contact ); |
471 | m_ablabel -> setFocus(); | 478 | m_ablabel -> setFocus(); |
472 | break; | 479 | break; |
473 | } | 480 | } |
474 | 481 | ||
475 | // Raise the current View | 482 | // Raise the current View |
476 | m_viewStack -> raiseWidget( m_curr_View ); | 483 | m_viewStack -> raiseWidget( m_curr_View ); |
477 | } | 484 | } |
478 | 485 | ||
479 | 486 | ||
diff --git a/core/pim/addressbook/abview.h b/core/pim/addressbook/abview.h index 8570fe7..55c63cc 100644 --- a/core/pim/addressbook/abview.h +++ b/core/pim/addressbook/abview.h | |||
@@ -1,87 +1,88 @@ | |||
1 | #ifndef _ABVIEW_H_ | 1 | #ifndef _ABVIEW_H_ |
2 | #define _ABVIEW_H_ | 2 | #define _ABVIEW_H_ |
3 | 3 | ||
4 | #include <qwidget.h> | 4 | #include <qwidget.h> |
5 | #include <qwidgetstack.h> | 5 | #include <qwidgetstack.h> |
6 | 6 | ||
7 | #include <qpe/categories.h> | 7 | #include <qpe/categories.h> |
8 | #include <opie/ocontact.h> | 8 | #include <opie/ocontact.h> |
9 | #include <opie/ocontactaccess.h> | 9 | #include <opie/ocontactaccess.h> |
10 | 10 | ||
11 | #include "contacteditor.h" | 11 | #include "contacteditor.h" |
12 | #include "abtable.h" | 12 | #include "abtable.h" |
13 | #include "ablabel.h" | 13 | #include "ablabel.h" |
14 | 14 | ||
15 | class AbView: public QWidget | 15 | class AbView: public QWidget |
16 | { | 16 | { |
17 | Q_OBJECT | 17 | Q_OBJECT |
18 | 18 | ||
19 | public: | 19 | public: |
20 | enum Views{ TableView=0, CardView, PersonalView }; | 20 | enum Views{ TableView=0, CardView, PersonalView }; |
21 | 21 | ||
22 | AbView( QWidget* parent, const QValueList<int>& ordered ); | 22 | AbView( QWidget* parent, const QValueList<int>& ordered ); |
23 | ~AbView(); | 23 | ~AbView(); |
24 | 24 | ||
25 | bool save(); | 25 | bool save(); |
26 | void load(); | 26 | void load(); |
27 | void reload(); | 27 | void reload(); |
28 | void clear(); | 28 | void clear(); |
29 | 29 | ||
30 | void setView( Views view ); | 30 | void setView( Views view ); |
31 | void showPersonal( bool personal ); | 31 | void showPersonal( bool personal ); |
32 | void setCurrentUid( int uid ); | ||
32 | void setShowByCategory( const QString& cat ); | 33 | void setShowByCategory( const QString& cat ); |
33 | void setShowToView( Views view ); | 34 | void setShowToView( Views view ); |
34 | void setShowByLetter( char c ); | 35 | void setShowByLetter( char c ); |
35 | void setListOrder( const QValueList<int>& ordered ); | 36 | void setListOrder( const QValueList<int>& ordered ); |
36 | 37 | ||
37 | // Add Entry and put to current | 38 | // Add Entry and put to current |
38 | void addEntry( const OContact &newContact ); | 39 | void addEntry( const OContact &newContact ); |
39 | void removeEntry( const int UID ); | 40 | void removeEntry( const int UID ); |
40 | void replaceEntry( const OContact &contact ); | 41 | void replaceEntry( const OContact &contact ); |
41 | OContact currentEntry(); | 42 | OContact currentEntry(); |
42 | 43 | ||
43 | void inSearch() { m_inSearch = true; } | 44 | void inSearch() { m_inSearch = true; } |
44 | void offSearch(); | 45 | void offSearch(); |
45 | 46 | ||
46 | QString showCategory() const; | 47 | QString showCategory() const; |
47 | QStringList categories(); | 48 | QStringList categories(); |
48 | 49 | ||
49 | signals: | 50 | signals: |
50 | void signalNotFound(); | 51 | void signalNotFound(); |
51 | void signalClearLetterPicker(); | 52 | void signalClearLetterPicker(); |
52 | void signalViewSwitched ( int ); | 53 | void signalViewSwitched ( int ); |
53 | 54 | ||
54 | public slots: | 55 | public slots: |
55 | void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, | 56 | void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, |
56 | bool backwards, QString category = QString::null ); | 57 | bool backwards, QString category = QString::null ); |
57 | void slotSwitch(); | 58 | void slotSwitch(); |
58 | 59 | ||
59 | private: | 60 | private: |
60 | void updateListinViews(); | 61 | void updateListinViews(); |
61 | void updateView( bool newdata = false ); | 62 | void updateView( bool newdata = false ); |
62 | void clearForCategory(); | 63 | void clearForCategory(); |
63 | bool contactCompare( const OContact &cnt, int category ); | 64 | bool contactCompare( const OContact &cnt, int category ); |
64 | void parseName( const QString& name, QString *first, QString *middle, | 65 | void parseName( const QString& name, QString *first, QString *middle, |
65 | QString * last ); | 66 | QString * last ); |
66 | 67 | ||
67 | Categories mCat; | 68 | Categories mCat; |
68 | bool m_inSearch; | 69 | bool m_inSearch; |
69 | bool m_inPersonal; | 70 | bool m_inPersonal; |
70 | int m_curr_category; | 71 | int m_curr_category; |
71 | Views m_curr_View; | 72 | Views m_curr_View; |
72 | Views m_prev_View; | 73 | Views m_prev_View; |
73 | int m_curr_Contact; | 74 | int m_curr_Contact; |
74 | 75 | ||
75 | OContactAccess* m_contactdb; | 76 | OContactAccess* m_contactdb; |
76 | OContactAccess* m_storedDB; | 77 | OContactAccess* m_storedDB; |
77 | OContactAccess::List m_list; | 78 | OContactAccess::List m_list; |
78 | 79 | ||
79 | QWidgetStack* m_viewStack; | 80 | QWidgetStack* m_viewStack; |
80 | AbTable* m_abTable; | 81 | AbTable* m_abTable; |
81 | AbLabel* m_ablabel; | 82 | AbLabel* m_ablabel; |
82 | 83 | ||
83 | QValueList<int> m_orderedFields; | 84 | QValueList<int> m_orderedFields; |
84 | }; | 85 | }; |
85 | 86 | ||
86 | 87 | ||
87 | #endif | 88 | #endif |
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 89a3312..e053e94 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -497,414 +497,416 @@ void AddressbookWindow::slotFindOpen() | |||
497 | { | 497 | { |
498 | searchBar->show(); | 498 | searchBar->show(); |
499 | m_abView -> inSearch(); | 499 | m_abView -> inSearch(); |
500 | searchEdit->setFocus(); | 500 | searchEdit->setFocus(); |
501 | } | 501 | } |
502 | void AddressbookWindow::slotFindClose() | 502 | void AddressbookWindow::slotFindClose() |
503 | { | 503 | { |
504 | searchBar->hide(); | 504 | searchBar->hide(); |
505 | m_abView -> offSearch(); | 505 | m_abView -> offSearch(); |
506 | // m_abView->setFocus(); | 506 | // m_abView->setFocus(); |
507 | } | 507 | } |
508 | 508 | ||
509 | 509 | ||
510 | void AddressbookWindow::slotFind() | 510 | void AddressbookWindow::slotFind() |
511 | { | 511 | { |
512 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); | 512 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); |
513 | 513 | ||
514 | searchEdit->clearFocus(); | 514 | searchEdit->clearFocus(); |
515 | // m_abView->setFocus(); | 515 | // m_abView->setFocus(); |
516 | 516 | ||
517 | } | 517 | } |
518 | 518 | ||
519 | void AddressbookWindow::slotViewBack() | 519 | void AddressbookWindow::slotViewBack() |
520 | { | 520 | { |
521 | // :SX showList(); | 521 | // :SX showList(); |
522 | } | 522 | } |
523 | 523 | ||
524 | void AddressbookWindow::slotViewEdit() | 524 | void AddressbookWindow::slotViewEdit() |
525 | { | 525 | { |
526 | if(!syncing) { | 526 | if(!syncing) { |
527 | if (actionPersonal->isOn()) { | 527 | if (actionPersonal->isOn()) { |
528 | editPersonal(); | 528 | editPersonal(); |
529 | } else { | 529 | } else { |
530 | editEntry( EditEntry ); | 530 | editEntry( EditEntry ); |
531 | } | 531 | } |
532 | } else { | 532 | } else { |
533 | QMessageBox::warning( this, tr("Contacts"), | 533 | QMessageBox::warning( this, tr("Contacts"), |
534 | tr("Can not edit data, currently syncing") ); | 534 | tr("Can not edit data, currently syncing") ); |
535 | } | 535 | } |
536 | } | 536 | } |
537 | 537 | ||
538 | 538 | ||
539 | 539 | ||
540 | void AddressbookWindow::writeMail() | 540 | void AddressbookWindow::writeMail() |
541 | { | 541 | { |
542 | OContact c = m_abView -> currentEntry(); | 542 | OContact c = m_abView -> currentEntry(); |
543 | QString name = c.fileAs(); | 543 | QString name = c.fileAs(); |
544 | QString email = c.defaultEmail(); | 544 | QString email = c.defaultEmail(); |
545 | 545 | ||
546 | // I prefer the OPIE-Environment variable before the | 546 | // I prefer the OPIE-Environment variable before the |
547 | // QPE-one.. | 547 | // QPE-one.. |
548 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); | 548 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); |
549 | if ( basepath.isEmpty() ) | 549 | if ( basepath.isEmpty() ) |
550 | basepath = QString::fromLatin1( getenv("QPEDIR") ); | 550 | basepath = QString::fromLatin1( getenv("QPEDIR") ); |
551 | 551 | ||
552 | // Try to access the preferred. If not possible, try to | 552 | // Try to access the preferred. If not possible, try to |
553 | // switch to the other one.. | 553 | // switch to the other one.. |
554 | if ( m_config.useQtMail() ){ | 554 | if ( m_config.useQtMail() ){ |
555 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); | 555 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); |
556 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ | 556 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ |
557 | qWarning ("QCop"); | 557 | qWarning ("QCop"); |
558 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | 558 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); |
559 | e << name << email; | 559 | e << name << email; |
560 | return; | 560 | return; |
561 | } else | 561 | } else |
562 | m_config.setUseOpieMail( true ); | 562 | m_config.setUseOpieMail( true ); |
563 | } | 563 | } |
564 | if ( m_config.useOpieMail() ){ | 564 | if ( m_config.useOpieMail() ){ |
565 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); | 565 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); |
566 | if ( QFile::exists( basepath + "/bin/mail" ) ){ | 566 | if ( QFile::exists( basepath + "/bin/mail" ) ){ |
567 | qWarning ("QCop"); | 567 | qWarning ("QCop"); |
568 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); | 568 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); |
569 | e << name << email; | 569 | e << name << email; |
570 | return; | 570 | return; |
571 | } else | 571 | } else |
572 | m_config.setUseQtMail( true ); | 572 | m_config.setUseQtMail( true ); |
573 | } | 573 | } |
574 | 574 | ||
575 | } | 575 | } |
576 | 576 | ||
577 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 577 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
578 | 578 | ||
579 | void AddressbookWindow::slotBeam() | 579 | void AddressbookWindow::slotBeam() |
580 | { | 580 | { |
581 | QString beamFilename; | 581 | QString beamFilename; |
582 | OContact c; | 582 | OContact c; |
583 | if ( actionPersonal->isOn() ) { | 583 | if ( actionPersonal->isOn() ) { |
584 | beamFilename = addressbookPersonalVCardName(); | 584 | beamFilename = addressbookPersonalVCardName(); |
585 | if ( !QFile::exists( beamFilename ) ) | 585 | if ( !QFile::exists( beamFilename ) ) |
586 | return; // can't beam a non-existent file | 586 | return; // can't beam a non-existent file |
587 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 587 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
588 | beamFilename ); | 588 | beamFilename ); |
589 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 589 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
590 | OContactAccess::List allList = access->allRecords(); | 590 | OContactAccess::List allList = access->allRecords(); |
591 | OContactAccess::List::Iterator it = allList.begin(); // Just take first | 591 | OContactAccess::List::Iterator it = allList.begin(); // Just take first |
592 | c = *it; | 592 | c = *it; |
593 | 593 | ||
594 | delete access; | 594 | delete access; |
595 | } else { | 595 | } else { |
596 | unlink( beamfile ); // delete if exists | 596 | unlink( beamfile ); // delete if exists |
597 | mkdir("/tmp/obex/", 0755); | 597 | mkdir("/tmp/obex/", 0755); |
598 | c = m_abView -> currentEntry(); | 598 | c = m_abView -> currentEntry(); |
599 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 599 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
600 | beamfile ); | 600 | beamfile ); |
601 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 601 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
602 | access->add( c ); | 602 | access->add( c ); |
603 | access->save(); | 603 | access->save(); |
604 | delete access; | 604 | delete access; |
605 | 605 | ||
606 | beamFilename = beamfile; | 606 | beamFilename = beamfile; |
607 | } | 607 | } |
608 | 608 | ||
609 | qWarning("Beaming: %s", beamFilename.latin1() ); | 609 | qWarning("Beaming: %s", beamFilename.latin1() ); |
610 | 610 | ||
611 | Ir *ir = new Ir( this ); | 611 | Ir *ir = new Ir( this ); |
612 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 612 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
613 | QString description = c.fullName(); | 613 | QString description = c.fullName(); |
614 | ir->send( beamFilename, description, "text/x-vCard" ); | 614 | ir->send( beamFilename, description, "text/x-vCard" ); |
615 | } | 615 | } |
616 | 616 | ||
617 | void AddressbookWindow::beamDone( Ir *ir ) | 617 | void AddressbookWindow::beamDone( Ir *ir ) |
618 | { | 618 | { |
619 | 619 | ||
620 | delete ir; | 620 | delete ir; |
621 | unlink( beamfile ); | 621 | unlink( beamfile ); |
622 | } | 622 | } |
623 | 623 | ||
624 | 624 | ||
625 | static void parseName( const QString& name, QString *first, QString *middle, | 625 | static void parseName( const QString& name, QString *first, QString *middle, |
626 | QString * last ) | 626 | QString * last ) |
627 | { | 627 | { |
628 | 628 | ||
629 | int comma = name.find ( "," ); | 629 | int comma = name.find ( "," ); |
630 | QString rest; | 630 | QString rest; |
631 | if ( comma > 0 ) { | 631 | if ( comma > 0 ) { |
632 | *last = name.left( comma ); | 632 | *last = name.left( comma ); |
633 | comma++; | 633 | comma++; |
634 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 634 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
635 | comma++; | 635 | comma++; |
636 | rest = name.mid( comma ); | 636 | rest = name.mid( comma ); |
637 | } else { | 637 | } else { |
638 | int space = name.findRev( ' ' ); | 638 | int space = name.findRev( ' ' ); |
639 | *last = name.mid( space+1 ); | 639 | *last = name.mid( space+1 ); |
640 | rest = name.left( space ); | 640 | rest = name.left( space ); |
641 | } | 641 | } |
642 | int space = rest.find( ' ' ); | 642 | int space = rest.find( ' ' ); |
643 | if ( space <= 0 ) { | 643 | if ( space <= 0 ) { |
644 | *first = rest; | 644 | *first = rest; |
645 | } else { | 645 | } else { |
646 | *first = rest.left( space ); | 646 | *first = rest.left( space ); |
647 | *middle = rest.mid( space+1 ); | 647 | *middle = rest.mid( space+1 ); |
648 | } | 648 | } |
649 | 649 | ||
650 | } | 650 | } |
651 | 651 | ||
652 | 652 | ||
653 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 653 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
654 | { | 654 | { |
655 | if (msg == "editPersonal()") { | 655 | if (msg == "editPersonal()") { |
656 | editPersonal(); | 656 | editPersonal(); |
657 | } else if (msg == "editPersonalAndClose()") { | 657 | } else if (msg == "editPersonalAndClose()") { |
658 | editPersonal(); | 658 | editPersonal(); |
659 | close(); | 659 | close(); |
660 | } else if ( msg == "addContact(QString,QString)" ) { | 660 | } else if ( msg == "addContact(QString,QString)" ) { |
661 | QDataStream stream(data,IO_ReadOnly); | 661 | QDataStream stream(data,IO_ReadOnly); |
662 | QString name, email; | 662 | QString name, email; |
663 | stream >> name >> email; | 663 | stream >> name >> email; |
664 | 664 | ||
665 | OContact cnt; | 665 | OContact cnt; |
666 | QString fn, mn, ln; | 666 | QString fn, mn, ln; |
667 | parseName( name, &fn, &mn, &ln ); | 667 | parseName( name, &fn, &mn, &ln ); |
668 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); | 668 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); |
669 | cnt.setFirstName( fn ); | 669 | cnt.setFirstName( fn ); |
670 | cnt.setMiddleName( mn ); | 670 | cnt.setMiddleName( mn ); |
671 | cnt.setLastName( ln ); | 671 | cnt.setLastName( ln ); |
672 | cnt.insertEmails( email ); | 672 | cnt.insertEmails( email ); |
673 | cnt.setDefaultEmail( email ); | 673 | cnt.setDefaultEmail( email ); |
674 | cnt.setFileAs(); | 674 | cnt.setFileAs(); |
675 | 675 | ||
676 | m_abView -> addEntry( cnt ); | 676 | m_abView -> addEntry( cnt ); |
677 | 677 | ||
678 | // :SXm_abView()->init( cnt ); | 678 | // :SXm_abView()->init( cnt ); |
679 | editEntry( EditEntry ); | 679 | editEntry( EditEntry ); |
680 | } else if ( msg == "beamBusinessCard()" ) { | 680 | } else if ( msg == "beamBusinessCard()" ) { |
681 | QString beamFilename = addressbookPersonalVCardName(); | 681 | QString beamFilename = addressbookPersonalVCardName(); |
682 | if ( !QFile::exists( beamFilename ) ) | 682 | if ( !QFile::exists( beamFilename ) ) |
683 | return; // can't beam a non-existent file | 683 | return; // can't beam a non-existent file |
684 | 684 | ||
685 | Ir *ir = new Ir( this ); | 685 | Ir *ir = new Ir( this ); |
686 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 686 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
687 | QString description = "mycard.vcf"; | 687 | QString description = "mycard.vcf"; |
688 | ir->send( beamFilename, description, "text/x-vCard" ); | 688 | ir->send( beamFilename, description, "text/x-vCard" ); |
689 | } | 689 | } else if ( msg == "showUid(int)" ) { |
690 | #if 0 | ||
691 | else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { | ||
692 | QDataStream stream(data,IO_ReadOnly); | 690 | QDataStream stream(data,IO_ReadOnly); |
693 | QCString ch,m; | 691 | int uid; |
694 | QStringList types; | 692 | stream >> uid; |
695 | stream >> ch >> m >> types; | 693 | |
696 | AddressPicker picker(abList,this,0,TRUE); | 694 | // Deactivate Personal View.. |
697 | picker.showMaximized(); | 695 | if ( actionPersonal->isOn() ){ |
698 | picker.setChoiceNames(types); | 696 | actionPersonal->setOn( false ); |
699 | int i=0; | 697 | slotPersonalView(); |
700 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { | ||
701 | QStringList sel; | ||
702 | stream >> sel; | ||
703 | picker.setSelection(i++,sel); | ||
704 | } | 698 | } |
705 | picker.showMaximized(); | ||
706 | picker.exec(); | ||
707 | 699 | ||
708 | // ###### note: contacts may have been added - save here! | 700 | // Reset category and show as card.. |
701 | m_abView -> setShowByCategory( QString::null ); | ||
702 | m_abView -> setCurrentUid( uid ); | ||
703 | slotViewSwitched ( AbView::CardView ); | ||
704 | |||
705 | } else if ( msg == "editUid(int)" ) { | ||
706 | QDataStream stream(data,IO_ReadOnly); | ||
707 | int uid; | ||
708 | stream >> uid; | ||
709 | 709 | ||
710 | setCentralWidget(abList); | 710 | // Deactivate Personal View.. |
711 | QCopEnvelope e(ch,m); | 711 | if ( actionPersonal->isOn() ){ |
712 | i=0; | 712 | actionPersonal->setOn( false ); |
713 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { | 713 | slotPersonalView(); |
714 | QStringList sel = picker.selection(i++); | ||
715 | e << sel; | ||
716 | } | 714 | } |
717 | } | 715 | |
718 | #endif | 716 | // Reset category and edit.. |
717 | m_abView -> setShowByCategory( QString::null ); | ||
718 | m_abView -> setCurrentUid( uid ); | ||
719 | slotViewEdit(); | ||
720 | } | ||
719 | 721 | ||
720 | } | 722 | } |
721 | 723 | ||
722 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 724 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
723 | { | 725 | { |
724 | OContact entry; | 726 | OContact entry; |
725 | if ( !abEditor ) { | 727 | if ( !abEditor ) { |
726 | abEditor = new ContactEditor( entry, this, "editor" ); | 728 | abEditor = new ContactEditor( entry, this, "editor" ); |
727 | } | 729 | } |
728 | if ( entryMode == EditEntry ) | 730 | if ( entryMode == EditEntry ) |
729 | abEditor->setEntry( m_abView -> currentEntry() ); | 731 | abEditor->setEntry( m_abView -> currentEntry() ); |
730 | else if ( entryMode == NewEntry ) | 732 | else if ( entryMode == NewEntry ) |
731 | abEditor->setEntry( entry ); | 733 | abEditor->setEntry( entry ); |
732 | // other things may change the caption. | 734 | // other things may change the caption. |
733 | abEditor->setCaption( tr("Edit Address") ); | 735 | abEditor->setCaption( tr("Edit Address") ); |
734 | 736 | ||
735 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 737 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
736 | abEditor->showMaximized(); | 738 | abEditor->showMaximized(); |
737 | #endif | 739 | #endif |
738 | // fix the foxus... | 740 | // fix the foxus... |
739 | abEditor->setNameFocus(); | 741 | abEditor->setNameFocus(); |
740 | if ( abEditor->exec() ) { | 742 | if ( abEditor->exec() ) { |
741 | setFocus(); | 743 | setFocus(); |
742 | if ( entryMode == NewEntry ) { | 744 | if ( entryMode == NewEntry ) { |
743 | OContact insertEntry = abEditor->entry(); | 745 | OContact insertEntry = abEditor->entry(); |
744 | insertEntry.assignUid(); | 746 | insertEntry.assignUid(); |
745 | m_abView -> addEntry( insertEntry ); | 747 | m_abView -> addEntry( insertEntry ); |
746 | } else { | 748 | } else { |
747 | OContact replEntry = abEditor->entry(); | 749 | OContact replEntry = abEditor->entry(); |
748 | 750 | ||
749 | if ( !replEntry.isValidUid() ) | 751 | if ( !replEntry.isValidUid() ) |
750 | replEntry.assignUid(); | 752 | replEntry.assignUid(); |
751 | 753 | ||
752 | m_abView -> replaceEntry( replEntry ); | 754 | m_abView -> replaceEntry( replEntry ); |
753 | } | 755 | } |
754 | } | 756 | } |
755 | // populateCategories(); | 757 | // populateCategories(); |
756 | 758 | ||
757 | } | 759 | } |
758 | 760 | ||
759 | void AddressbookWindow::editPersonal() | 761 | void AddressbookWindow::editPersonal() |
760 | { | 762 | { |
761 | OContact entry; | 763 | OContact entry; |
762 | 764 | ||
763 | // Switch to personal view if not selected | 765 | // Switch to personal view if not selected |
764 | // but take care of the menu, too | 766 | // but take care of the menu, too |
765 | if ( ! actionPersonal->isOn() ){ | 767 | if ( ! actionPersonal->isOn() ){ |
766 | qWarning("*** ++++"); | 768 | qWarning("*** ++++"); |
767 | actionPersonal->setOn( true ); | 769 | actionPersonal->setOn( true ); |
768 | slotPersonalView(); | 770 | slotPersonalView(); |
769 | } | 771 | } |
770 | 772 | ||
771 | if ( !abEditor ) { | 773 | if ( !abEditor ) { |
772 | abEditor = new ContactEditor( entry, this, "editor" ); | 774 | abEditor = new ContactEditor( entry, this, "editor" ); |
773 | } | 775 | } |
774 | 776 | ||
775 | abEditor->setCaption(tr("Edit My Personal Details")); | 777 | abEditor->setCaption(tr("Edit My Personal Details")); |
776 | abEditor->setPersonalView( true ); | 778 | abEditor->setPersonalView( true ); |
777 | editEntry( EditEntry ); | 779 | editEntry( EditEntry ); |
778 | abEditor->setPersonalView( false ); | 780 | abEditor->setPersonalView( false ); |
779 | 781 | ||
780 | } | 782 | } |
781 | 783 | ||
782 | 784 | ||
783 | void AddressbookWindow::slotPersonalView() | 785 | void AddressbookWindow::slotPersonalView() |
784 | { | 786 | { |
785 | qWarning("slotPersonalView()"); | 787 | qWarning("slotPersonalView()"); |
786 | if (!actionPersonal->isOn()) { | 788 | if (!actionPersonal->isOn()) { |
787 | // we just turned it off | 789 | // we just turned it off |
788 | qWarning("slotPersonalView()-> OFF"); | 790 | qWarning("slotPersonalView()-> OFF"); |
789 | setCaption( tr("Contacts") ); | 791 | setCaption( tr("Contacts") ); |
790 | actionNew->setEnabled(TRUE); | 792 | actionNew->setEnabled(TRUE); |
791 | actionTrash->setEnabled(TRUE); | 793 | actionTrash->setEnabled(TRUE); |
792 | actionFind->setEnabled(TRUE); | 794 | actionFind->setEnabled(TRUE); |
793 | actionMail->setEnabled(TRUE); | 795 | actionMail->setEnabled(TRUE); |
794 | // slotUpdateToolbar(); | 796 | // slotUpdateToolbar(); |
795 | 797 | ||
796 | m_abView->showPersonal( false ); | 798 | m_abView->showPersonal( false ); |
797 | 799 | ||
798 | return; | 800 | return; |
799 | } | 801 | } |
800 | 802 | ||
801 | qWarning("slotPersonalView()-> ON"); | 803 | qWarning("slotPersonalView()-> ON"); |
802 | // XXX need to disable some QActions. | 804 | // XXX need to disable some QActions. |
803 | actionNew->setEnabled(FALSE); | 805 | actionNew->setEnabled(FALSE); |
804 | actionTrash->setEnabled(FALSE); | 806 | actionTrash->setEnabled(FALSE); |
805 | actionFind->setEnabled(FALSE); | 807 | actionFind->setEnabled(FALSE); |
806 | actionMail->setEnabled(FALSE); | 808 | actionMail->setEnabled(FALSE); |
807 | 809 | ||
808 | setCaption( tr("Contacts - My Personal Details") ); | 810 | setCaption( tr("Contacts - My Personal Details") ); |
809 | 811 | ||
810 | m_abView->showPersonal( true ); | 812 | m_abView->showPersonal( true ); |
811 | 813 | ||
812 | } | 814 | } |
813 | 815 | ||
814 | 816 | ||
815 | void AddressbookWindow::listIsEmpty( bool empty ) | 817 | void AddressbookWindow::listIsEmpty( bool empty ) |
816 | { | 818 | { |
817 | if ( !empty ) { | 819 | if ( !empty ) { |
818 | deleteButton->setEnabled( TRUE ); | 820 | deleteButton->setEnabled( TRUE ); |
819 | } | 821 | } |
820 | } | 822 | } |
821 | 823 | ||
822 | void AddressbookWindow::reload() | 824 | void AddressbookWindow::reload() |
823 | { | 825 | { |
824 | syncing = FALSE; | 826 | syncing = FALSE; |
825 | m_abView->clear(); | 827 | m_abView->clear(); |
826 | m_abView->reload(); | 828 | m_abView->reload(); |
827 | } | 829 | } |
828 | 830 | ||
829 | void AddressbookWindow::flush() | 831 | void AddressbookWindow::flush() |
830 | { | 832 | { |
831 | syncing = TRUE; | 833 | syncing = TRUE; |
832 | m_abView->save(); | 834 | m_abView->save(); |
833 | } | 835 | } |
834 | 836 | ||
835 | 837 | ||
836 | void AddressbookWindow::closeEvent( QCloseEvent *e ) | 838 | void AddressbookWindow::closeEvent( QCloseEvent *e ) |
837 | { | 839 | { |
838 | if(active_view == AbView::CardView){ | 840 | if(active_view == AbView::CardView){ |
839 | slotViewSwitched( AbView::TableView ); | 841 | slotViewSwitched( AbView::TableView ); |
840 | e->ignore(); | 842 | e->ignore(); |
841 | return; | 843 | return; |
842 | } | 844 | } |
843 | if(syncing) { | 845 | if(syncing) { |
844 | /* shouldn't we save, I hear you say? well its already been set | 846 | /* shouldn't we save, I hear you say? well its already been set |
845 | so that an edit can not occur during a sync, and we flushed | 847 | so that an edit can not occur during a sync, and we flushed |
846 | at the start of the sync, so there is no need to save | 848 | at the start of the sync, so there is no need to save |
847 | Saving however itself would cause problems. */ | 849 | Saving however itself would cause problems. */ |
848 | e->accept(); | 850 | e->accept(); |
849 | return; | 851 | return; |
850 | } | 852 | } |
851 | //################## shouldn't always save | 853 | //################## shouldn't always save |
852 | // True, but the database handles this automatically ! (se) | 854 | // True, but the database handles this automatically ! (se) |
853 | if ( save() ) | 855 | if ( save() ) |
854 | e->accept(); | 856 | e->accept(); |
855 | else | 857 | else |
856 | e->ignore(); | 858 | e->ignore(); |
857 | } | 859 | } |
858 | 860 | ||
859 | /* | 861 | /* |
860 | Returns TRUE if it is OK to exit | 862 | Returns TRUE if it is OK to exit |
861 | */ | 863 | */ |
862 | 864 | ||
863 | bool AddressbookWindow::save() | 865 | bool AddressbookWindow::save() |
864 | { | 866 | { |
865 | if ( !m_abView->save() ) { | 867 | if ( !m_abView->save() ) { |
866 | if ( QMessageBox::critical( 0, tr( "Out of space" ), | 868 | if ( QMessageBox::critical( 0, tr( "Out of space" ), |
867 | tr("Unable to save information.\n" | 869 | tr("Unable to save information.\n" |
868 | "Free up some space\n" | 870 | "Free up some space\n" |
869 | "and try again.\n" | 871 | "and try again.\n" |
870 | "\nQuit anyway?"), | 872 | "\nQuit anyway?"), |
871 | QMessageBox::Yes|QMessageBox::Escape, | 873 | QMessageBox::Yes|QMessageBox::Escape, |
872 | QMessageBox::No|QMessageBox::Default ) | 874 | QMessageBox::No|QMessageBox::Default ) |
873 | != QMessageBox::No ) | 875 | != QMessageBox::No ) |
874 | return TRUE; | 876 | return TRUE; |
875 | else | 877 | else |
876 | return FALSE; | 878 | return FALSE; |
877 | } | 879 | } |
878 | return TRUE; | 880 | return TRUE; |
879 | } | 881 | } |
880 | 882 | ||
881 | #ifdef __DEBUG_RELEASE | 883 | #ifdef __DEBUG_RELEASE |
882 | void AddressbookWindow::slotSave() | 884 | void AddressbookWindow::slotSave() |
883 | { | 885 | { |
884 | save(); | 886 | save(); |
885 | } | 887 | } |
886 | #endif | 888 | #endif |
887 | 889 | ||
888 | 890 | ||
889 | void AddressbookWindow::slotNotFound() | 891 | void AddressbookWindow::slotNotFound() |
890 | { | 892 | { |
891 | qWarning("Got notfound signal!"); | 893 | qWarning("Got notfound signal!"); |
892 | QMessageBox::information( this, tr( "Not Found" ), | 894 | QMessageBox::information( this, tr( "Not Found" ), |
893 | tr( "Unable to find a contact for this \n search pattern!" ) ); | 895 | tr( "Unable to find a contact for this \n search pattern!" ) ); |
894 | 896 | ||
895 | 897 | ||
896 | } | 898 | } |
897 | void AddressbookWindow::slotWrapAround() | 899 | void AddressbookWindow::slotWrapAround() |
898 | { | 900 | { |
899 | qWarning("Got wrap signal!"); | 901 | qWarning("Got wrap signal!"); |
900 | // if ( doNotifyWrapAround ) | 902 | // if ( doNotifyWrapAround ) |
901 | // QMessageBox::information( this, tr( "End of list" ), | 903 | // QMessageBox::information( this, tr( "End of list" ), |
902 | // tr( "End of list. Wrap around now...!" ) + "\n" ); | 904 | // tr( "End of list. Wrap around now...!" ) + "\n" ); |
903 | 905 | ||
904 | } | 906 | } |
905 | 907 | ||
906 | void AddressbookWindow::slotSetCategory( int c ) | 908 | void AddressbookWindow::slotSetCategory( int c ) |
907 | { | 909 | { |
908 | qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); | 910 | qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() ); |
909 | 911 | ||
910 | QString cat, book; | 912 | QString cat, book; |