Diffstat (limited to 'core/pim/addressbook/abview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/addressbook/abview.cpp | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp index aa242b7..52e5f59 100644 --- a/core/pim/addressbook/abview.cpp +++ b/core/pim/addressbook/abview.cpp | |||
@@ -14,12 +14,13 @@ | |||
14 | ** | 14 | ** |
15 | **********************************************************************/ | 15 | **********************************************************************/ |
16 | 16 | ||
17 | #include "abview.h" | 17 | #include "abview.h" |
18 | 18 | ||
19 | #include <opie2/ocontactaccessbackend_vcard.h> | 19 | #include <opie2/ocontactaccessbackend_vcard.h> |
20 | #include <opie2/odebug.h> | ||
20 | 21 | ||
21 | #include <qpe/global.h> | 22 | #include <qpe/global.h> |
22 | 23 | ||
23 | #include <qlayout.h> | 24 | #include <qlayout.h> |
24 | 25 | ||
25 | #include <assert.h> | 26 | #include <assert.h> |
@@ -48,13 +49,13 @@ AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): | |||
48 | m_contactdb ( 0l ), | 49 | m_contactdb ( 0l ), |
49 | m_storedDB ( 0l ), | 50 | m_storedDB ( 0l ), |
50 | m_viewStack( 0l ), | 51 | m_viewStack( 0l ), |
51 | m_abTable( 0l ), | 52 | m_abTable( 0l ), |
52 | m_orderedFields( ordered ) | 53 | m_orderedFields( ordered ) |
53 | { | 54 | { |
54 | qWarning("AbView::c'tor"); | 55 | Opie::Core::owarn << "AbView::c'tor" << oendl; |
55 | // Load default database and handle syncing myself.. ! | 56 | // Load default database and handle syncing myself.. ! |
56 | m_contactdb = new Opie::OPimContactAccess ( "addressbook", 0l, 0l, false ); | 57 | m_contactdb = new Opie::OPimContactAccess ( "addressbook", 0l, 0l, false ); |
57 | m_contactdb -> setReadAhead( 16 ); // Use ReadAhead-Cache if available | 58 | m_contactdb -> setReadAhead( 16 ); // Use ReadAhead-Cache if available |
58 | mCat.load( categoryFileName() ); | 59 | mCat.load( categoryFileName() ); |
59 | 60 | ||
60 | // Create Layout and put WidgetStack into it. | 61 | // Create Layout and put WidgetStack into it. |
@@ -96,34 +97,34 @@ AbView::~AbView() | |||
96 | } | 97 | } |
97 | } | 98 | } |
98 | 99 | ||
99 | 100 | ||
100 | void AbView::setView( Views view ) | 101 | void AbView::setView( Views view ) |
101 | { | 102 | { |
102 | qWarning("AbView::setView( Views view )"); | 103 | Opie::Core::owarn << "AbView::setView( Views view )" << oendl; |
103 | m_curr_View = view; | 104 | m_curr_View = view; |
104 | load(); | 105 | load(); |
105 | } | 106 | } |
106 | 107 | ||
107 | void AbView::addEntry( const Opie::OPimContact &newContact ) | 108 | void AbView::addEntry( const Opie::OPimContact &newContact ) |
108 | { | 109 | { |
109 | qWarning("abview:AddContact"); | 110 | Opie::Core::owarn << "AbView::AddContact" << oendl; |
110 | m_contactdb->add ( newContact ); | 111 | m_contactdb->add ( newContact ); |
111 | load(); | 112 | load(); |
112 | 113 | ||
113 | } | 114 | } |
114 | void AbView::removeEntry( const int UID ) | 115 | void AbView::removeEntry( const int UID ) |
115 | { | 116 | { |
116 | qWarning("abview:RemoveContact"); | 117 | Opie::Core::owarn << "AbView;:RemoveContact" << oendl; |
117 | m_contactdb->remove( UID ); | 118 | m_contactdb->remove( UID ); |
118 | load(); | 119 | load(); |
119 | } | 120 | } |
120 | 121 | ||
121 | void AbView::replaceEntry( const Opie::OPimContact &contact ) | 122 | void AbView::replaceEntry( const Opie::OPimContact &contact ) |
122 | { | 123 | { |
123 | qWarning("abview:ReplaceContact"); | 124 | Opie::Core::owarn << "AbView::ReplaceContact" << oendl; |
124 | m_contactdb->replace( contact ); | 125 | m_contactdb->replace( contact ); |
125 | load(); | 126 | load(); |
126 | 127 | ||
127 | } | 128 | } |
128 | 129 | ||
129 | Opie::OPimContact AbView::currentEntry() | 130 | Opie::OPimContact AbView::currentEntry() |
@@ -141,20 +142,20 @@ Opie::OPimContact AbView::currentEntry() | |||
141 | m_curr_Contact = currentContact.uid(); | 142 | m_curr_Contact = currentContact.uid(); |
142 | return currentContact; | 143 | return currentContact; |
143 | } | 144 | } |
144 | 145 | ||
145 | bool AbView::save() | 146 | bool AbView::save() |
146 | { | 147 | { |
147 | //qWarning("abView:Save data"); | 148 | //Opie::Core::owarn << "AbView::Save data" << oendl; |
148 | 149 | ||
149 | return m_contactdb->save(); | 150 | return m_contactdb->save(); |
150 | } | 151 | } |
151 | 152 | ||
152 | void AbView::load() | 153 | void AbView::load() |
153 | { | 154 | { |
154 | qWarning("abView:Load data"); | 155 | Opie::Core::owarn << "AbView::Load data" << oendl; |
155 | 156 | ||
156 | // Letter Search is stopped at this place | 157 | // Letter Search is stopped at this place |
157 | emit signalClearLetterPicker(); | 158 | emit signalClearLetterPicker(); |
158 | 159 | ||
159 | if ( m_inPersonal ) | 160 | if ( m_inPersonal ) |
160 | // VCard Backend does not sort.. | 161 | // VCard Backend does not sort.. |
@@ -162,72 +163,73 @@ void AbView::load() | |||
162 | else{ | 163 | else{ |
163 | m_list = m_contactdb->sorted( true, 0, 0, 0 ); | 164 | m_list = m_contactdb->sorted( true, 0, 0, 0 ); |
164 | if ( m_curr_category != -1 ) | 165 | if ( m_curr_category != -1 ) |
165 | clearForCategory(); | 166 | clearForCategory(); |
166 | } | 167 | } |
167 | 168 | ||
168 | qWarning ("Number of contacts: %d", m_list.count()); | 169 | Opie::Core::owarn << "Number of contacts: " << m_list.count() << oendl; |
169 | 170 | ||
170 | updateView( true ); | 171 | updateView( true ); |
171 | 172 | ||
172 | } | 173 | } |
173 | 174 | ||
174 | void AbView::reload() | 175 | void AbView::reload() |
175 | { | 176 | { |
176 | qWarning( "void AbView::reload()" ); | 177 | Opie::Core::owarn << "AbView::::reload()" << oendl; |
177 | 178 | ||
178 | m_contactdb->reload(); | 179 | m_contactdb->reload(); |
179 | load(); | 180 | load(); |
180 | } | 181 | } |
181 | 182 | ||
182 | void AbView::clear() | 183 | void AbView::clear() |
183 | { | 184 | { |
184 | // :SX | 185 | // :SX |
185 | } | 186 | } |
186 | 187 | ||
187 | void AbView::setShowByCategory( const QString& cat ) | 188 | void AbView::setShowByCategory( const QString& cat ) |
188 | { | 189 | { |
189 | qWarning("AbView::setShowCategory( const QString& cat )"); | 190 | Opie::Core::owarn << "AbView::setShowCategory( const QString& cat )" << oendl; |
190 | 191 | ||
191 | int intCat = 0; | 192 | int intCat = 0; |
192 | 193 | ||
193 | // All (cat == NULL) will be stored as -1 | 194 | // All (cat == NULL) will be stored as -1 |
194 | if ( cat.isNull() ) | 195 | if ( cat.isNull() ) |
195 | intCat = -1; | 196 | intCat = -1; |
196 | else | 197 | else |
197 | intCat = mCat.id("Contacts", cat ); | 198 | intCat = mCat.id("Contacts", cat ); |
198 | 199 | ||
199 | // Just do anything if we really change the category | 200 | // Just do anything if we really change the category |
200 | if ( intCat != m_curr_category ){ | 201 | if ( intCat != m_curr_category ){ |
201 | // qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); | 202 | // Opie::Core::owarn << "Categories: Selected " << cat << ".. Number: " |
203 | // << m_curr_category << oendl; | ||
202 | 204 | ||
203 | m_curr_category = intCat; | 205 | m_curr_category = intCat; |
204 | emit signalClearLetterPicker(); | 206 | emit signalClearLetterPicker(); |
205 | 207 | ||
206 | load(); | 208 | load(); |
207 | } | 209 | } |
208 | 210 | ||
209 | } | 211 | } |
210 | 212 | ||
211 | void AbView::setShowToView( Views view ) | 213 | void AbView::setShowToView( Views view ) |
212 | { | 214 | { |
213 | qWarning("void AbView::setShowToView( View %d )", view); | 215 | Opie::Core::owarn << "void AbView::setShowToView( View " << view << " )" << oendl; |
214 | 216 | ||
215 | if ( m_curr_View != view ){ | 217 | if ( m_curr_View != view ){ |
216 | qWarning ("Change the View (Category is: %d)", m_curr_category); | 218 | Opie::Core::owarn << "Change the View (Category is: " << m_curr_category << ")" << oendl; |
217 | m_prev_View = m_curr_View; | 219 | m_prev_View = m_curr_View; |
218 | m_curr_View = view; | 220 | m_curr_View = view; |
219 | 221 | ||
220 | updateView(); | 222 | updateView(); |
221 | } | 223 | } |
222 | 224 | ||
223 | } | 225 | } |
224 | 226 | ||
225 | void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) | 227 | void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) |
226 | { | 228 | { |
227 | qWarning("void AbView::setShowByLetter( %c, %d )", c, mode ); | 229 | Opie::Core::owarn << "void AbView::setShowByLetter( " << c << ", " << mode << " )" << oendl; |
228 | 230 | ||
229 | assert( mode < AbConfig::LASTELEMENT ); | 231 | assert( mode < AbConfig::LASTELEMENT ); |
230 | 232 | ||
231 | Opie::OPimContact query; | 233 | Opie::OPimContact query; |
232 | if ( c == 0 ){ | 234 | if ( c == 0 ){ |
233 | load(); | 235 | load(); |
@@ -244,14 +246,14 @@ void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) | |||
244 | query.setLastName( QString("%1*").arg(c) ); | 246 | query.setLastName( QString("%1*").arg(c) ); |
245 | break; | 247 | break; |
246 | case AbConfig::FileAs: | 248 | case AbConfig::FileAs: |
247 | query.setFileAs( QString("%1*").arg(c) ); | 249 | query.setFileAs( QString("%1*").arg(c) ); |
248 | break; | 250 | break; |
249 | default: | 251 | default: |
250 | qWarning( "Unknown Searchmode for AbView::setShowByLetter ! -> %d", mode ); | 252 | Opie::Core::owarn << "Unknown Searchmode for AbView::setShowByLetter ! -> " << mode << oendl |
251 | qWarning( "I will ignore it.." ); | 253 | << "I will ignore it.." << oendl; |
252 | return; | 254 | return; |
253 | } | 255 | } |
254 | m_list = m_contactdb->queryByExample( query, Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ); | 256 | m_list = m_contactdb->queryByExample( query, Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ); |
255 | if ( m_curr_category != -1 ) | 257 | if ( m_curr_category != -1 ) |
256 | clearForCategory(); | 258 | clearForCategory(); |
257 | m_curr_Contact = 0; | 259 | m_curr_Contact = 0; |
@@ -274,13 +276,13 @@ QString AbView::showCategory() const | |||
274 | { | 276 | { |
275 | return mCat.label( "Contacts", m_curr_category ); | 277 | return mCat.label( "Contacts", m_curr_category ); |
276 | } | 278 | } |
277 | 279 | ||
278 | void AbView::showPersonal( bool personal ) | 280 | void AbView::showPersonal( bool personal ) |
279 | { | 281 | { |
280 | qWarning ("void AbView::showPersonal( %d )", personal); | 282 | Opie::Core::owarn << "void AbView::showPersonal( " << personal << " )" << oendl; |
281 | 283 | ||
282 | if ( personal ){ | 284 | if ( personal ){ |
283 | 285 | ||
284 | if ( m_inPersonal ) | 286 | if ( m_inPersonal ) |
285 | return; | 287 | return; |
286 | 288 | ||
@@ -330,13 +332,13 @@ QStringList AbView::categories() | |||
330 | } | 332 | } |
331 | 333 | ||
332 | // BEGIN: Slots | 334 | // BEGIN: Slots |
333 | void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, | 335 | void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, |
334 | bool , QString cat ) | 336 | bool , QString cat ) |
335 | { | 337 | { |
336 | //qWarning( "void AbView::slotDoFind" ); | 338 | //Opie::Core::owarn << "void AbView::slotDoFind" << oendl; |
337 | 339 | ||
338 | // We reloading the data: Deselect Letterpicker | 340 | // We reloading the data: Deselect Letterpicker |
339 | emit signalClearLetterPicker(); | 341 | emit signalClearLetterPicker(); |
340 | 342 | ||
341 | // Use the current Category if nothing else selected | 343 | // Use the current Category if nothing else selected |
342 | int category = 0; | 344 | int category = 0; |
@@ -344,22 +346,22 @@ void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, | |||
344 | if ( cat.isEmpty() ) | 346 | if ( cat.isEmpty() ) |
345 | category = m_curr_category; | 347 | category = m_curr_category; |
346 | else{ | 348 | else{ |
347 | category = mCat.id("Contacts", cat ); | 349 | category = mCat.id("Contacts", cat ); |
348 | } | 350 | } |
349 | 351 | ||
350 | //qWarning ("Find in Category %d", category); | 352 | //Opie::Core::owarn << "Find in Category " << category << oendl; |
351 | 353 | ||
352 | QRegExp r( str ); | 354 | QRegExp r( str ); |
353 | r.setCaseSensitive( caseSensitive ); | 355 | r.setCaseSensitive( caseSensitive ); |
354 | r.setWildcard( !useRegExp ); | 356 | r.setWildcard( !useRegExp ); |
355 | 357 | ||
356 | // Get all matching entries out of the database | 358 | // Get all matching entries out of the database |
357 | m_list = m_contactdb->matchRegexp( r ); | 359 | m_list = m_contactdb->matchRegexp( r ); |
358 | 360 | ||
359 | //qWarning( "found: %d", m_list.count() ); | 361 | //Opie::Core::owarn << "Found: " << m_list.count() << oendl; |
360 | if ( m_list.count() == 0 ){ | 362 | if ( m_list.count() == 0 ){ |
361 | emit signalNotFound(); | 363 | emit signalNotFound(); |
362 | return; | 364 | return; |
363 | } | 365 | } |
364 | 366 | ||
365 | // Now remove all contacts with wrong category (if any selected) | 367 | // Now remove all contacts with wrong category (if any selected) |
@@ -377,22 +379,22 @@ void AbView::offSearch() | |||
377 | m_inSearch = false; | 379 | m_inSearch = false; |
378 | 380 | ||
379 | load(); | 381 | load(); |
380 | } | 382 | } |
381 | 383 | ||
382 | void AbView::slotSwitch(){ | 384 | void AbView::slotSwitch(){ |
383 | //qWarning("AbView::slotSwitch()"); | 385 | //Opie::Core::owarn << "AbView::slotSwitch()" << oendl; |
384 | 386 | ||
385 | m_prev_View = m_curr_View; | 387 | m_prev_View = m_curr_View; |
386 | switch ( (int) m_curr_View ){ | 388 | switch ( (int) m_curr_View ){ |
387 | case TableView: | 389 | case TableView: |
388 | qWarning("Switching to CardView"); | 390 | Opie::Core::owarn << "Switching to CardView" << oendl; |
389 | m_curr_View = CardView; | 391 | m_curr_View = CardView; |
390 | break; | 392 | break; |
391 | case CardView: | 393 | case CardView: |
392 | qWarning("Switching to TableView"); | 394 | Opie::Core::owarn << "Switching to TableView" << oendl; |
393 | m_curr_View = TableView; | 395 | m_curr_View = TableView; |
394 | break; | 396 | break; |
395 | } | 397 | } |
396 | updateView(); | 398 | updateView(); |
397 | 399 | ||
398 | } | 400 | } |
@@ -405,58 +407,59 @@ void AbView::clearForCategory() | |||
405 | // Now remove all contacts with wrong category if any category selected | 407 | // Now remove all contacts with wrong category if any category selected |
406 | 408 | ||
407 | Opie::OPimContactAccess::List allList = m_list; | 409 | Opie::OPimContactAccess::List allList = m_list; |
408 | if ( m_curr_category != -1 ){ | 410 | if ( m_curr_category != -1 ){ |
409 | for ( it = allList.begin(); it != allList.end(); ++it ){ | 411 | for ( it = allList.begin(); it != allList.end(); ++it ){ |
410 | if ( !contactCompare( *it, m_curr_category ) ){ | 412 | if ( !contactCompare( *it, m_curr_category ) ){ |
411 | // qWarning("Removing %d", (*it).uid()); | 413 | //Opie::Core::owarn << "Removing " << (*it).uid() << oendl; |
412 | m_list.remove( (*it).uid() ); | 414 | m_list.remove( (*it).uid() ); |
413 | } | 415 | } |
414 | } | 416 | } |
415 | } | 417 | } |
416 | 418 | ||
417 | } | 419 | } |
418 | 420 | ||
419 | bool AbView::contactCompare( const Opie::OPimContact &cnt, int category ) | 421 | bool AbView::contactCompare( const Opie::OPimContact &cnt, int category ) |
420 | { | 422 | { |
421 | //qWarning ("bool AbView::contactCompare( const Opie::OPimContact &cnt, %d )", category); | 423 | //Opie::Core::owarn << "bool AbView::contactCompare( const Opie::OPimContact &cnt, " |
424 | // << category << " )" << oendl; | ||
422 | 425 | ||
423 | bool returnMe; | 426 | bool returnMe; |
424 | QArray<int> cats; | 427 | QArray<int> cats; |
425 | cats = cnt.categories(); | 428 | cats = cnt.categories(); |
426 | 429 | ||
427 | //qWarning ("Number of categories: %d", cats.count() ); | 430 | //Opie::Core::owarn << "Number of categories: " << cats.count() << oendl; |
428 | 431 | ||
429 | returnMe = false; | 432 | returnMe = false; |
430 | if ( cats.count() == 0 && category == 0 ) | 433 | if ( cats.count() == 0 && category == 0 ) |
431 | // Contacts with no category will just shown on "All" and "Unfiled" | 434 | // Contacts with no category will just shown on "All" and "Unfiled" |
432 | returnMe = true; | 435 | returnMe = true; |
433 | else { | 436 | else { |
434 | int i; | 437 | int i; |
435 | for ( i = 0; i < int(cats.count()); i++ ) { | 438 | for ( i = 0; i < int(cats.count()); i++ ) { |
436 | // qWarning("Comparing %d with %d",cats[i],category ); | 439 | //Opie::Core::owarn << "Comparing " << cats[i] << " with " << category << oendl; |
437 | if ( cats[i] == category ) { | 440 | if ( cats[i] == category ) { |
438 | returnMe = true; | 441 | returnMe = true; |
439 | break; | 442 | break; |
440 | } | 443 | } |
441 | } | 444 | } |
442 | } | 445 | } |
443 | //qWarning ("Return: %d", returnMe); | 446 | //Opie::Core::owarn << "Return: " << returnMe << oendl; |
444 | return returnMe; | 447 | return returnMe; |
445 | } | 448 | } |
446 | 449 | ||
447 | // In Some rare cases we have to update all lists.. | 450 | // In Some rare cases we have to update all lists.. |
448 | void AbView::updateListinViews() | 451 | void AbView::updateListinViews() |
449 | { | 452 | { |
450 | m_abTable -> setContacts( m_list ); | 453 | m_abTable -> setContacts( m_list ); |
451 | m_ablabel -> setContacts( m_list ); | 454 | m_ablabel -> setContacts( m_list ); |
452 | } | 455 | } |
453 | 456 | ||
454 | void AbView::updateView( bool newdata ) | 457 | void AbView::updateView( bool newdata ) |
455 | { | 458 | { |
456 | //qWarning("AbView::updateView()"); | 459 | //Opie::Core::owarn << "AbView::updateView()" << oendl; |
457 | 460 | ||
458 | if ( m_viewStack -> visibleWidget() ){ | 461 | if ( m_viewStack -> visibleWidget() ){ |
459 | m_viewStack -> visibleWidget() -> clearFocus(); | 462 | m_viewStack -> visibleWidget() -> clearFocus(); |
460 | } | 463 | } |
461 | 464 | ||
462 | // If we switching the view, we have to store some information | 465 | // If we switching the view, we have to store some information |