Diffstat (limited to 'core/pim/addressbook/abview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/addressbook/abview.cpp | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp index 6be19f8..34035fd 100644 --- a/core/pim/addressbook/abview.cpp +++ b/core/pim/addressbook/abview.cpp | |||
@@ -39,13 +39,13 @@ QString addressbookPersonalVCardName() | |||
39 | 39 | ||
40 | AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): | 40 | AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ): |
41 | QWidget(parent), | 41 | QWidget(parent), |
42 | mCat(0), | 42 | mCat(0), |
43 | m_inSearch( false ), | 43 | m_inSearch( false ), |
44 | m_inPersonal( false ), | 44 | m_inPersonal( false ), |
45 | m_curr_category( -1 ), | 45 | m_curr_category( 0 ), |
46 | m_curr_View( TableView ), | 46 | m_curr_View( TableView ), |
47 | m_prev_View( TableView ), | 47 | m_prev_View( TableView ), |
48 | m_curr_Contact ( 0 ), | 48 | m_curr_Contact ( 0 ), |
49 | m_contactdb ( 0l ), | 49 | m_contactdb ( 0l ), |
50 | m_storedDB ( 0l ), | 50 | m_storedDB ( 0l ), |
51 | m_viewStack( 0l ), | 51 | m_viewStack( 0l ), |
@@ -154,25 +154,14 @@ void AbView::load() | |||
154 | { | 154 | { |
155 | odebug << "AbView::Load data" << oendl; | 155 | odebug << "AbView::Load data" << oendl; |
156 | 156 | ||
157 | // Letter Search is stopped at this place | 157 | // Letter Search is stopped at this place |
158 | emit signalClearLetterPicker(); | 158 | emit signalClearLetterPicker(); |
159 | 159 | ||
160 | if ( m_curr_category == 0 ) { | ||
161 | // Show unfiled | ||
162 | m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, | 160 | m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, |
163 | Opie::OPimContactAccess::DoNotShowWithCategory, 0 ); | 161 | Opie::OPimContactAccess::FilterCategory, m_curr_category ); |
164 | } elseif ( m_curr_category != -1 ){ | ||
165 | // Just show selected category | ||
166 | m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, | ||
167 | Opie::OPimBase::FilterCategory, m_curr_category ); | ||
168 | } else { | ||
169 | // Show all categories | ||
170 | m_list = m_contactdb->sorted( true, Opie::OPimContactAccess::SortFileAsName, | ||
171 | Opie::OPimBase::FilterOff, 0 ); | ||
172 | } | ||
173 | 162 | ||
174 | // if ( m_curr_category != -1 ) | 163 | // if ( m_curr_category != -1 ) |
175 | // clearForCategory(); | 164 | // clearForCategory(); |
176 | 165 | ||
177 | odebug << "Number of contacts: " << m_list.count() << oendl; | 166 | odebug << "Number of contacts: " << m_list.count() << oendl; |
178 | 167 | ||
@@ -196,28 +185,30 @@ void AbView::clear() | |||
196 | void AbView::setShowByCategory( const QString& cat ) | 185 | void AbView::setShowByCategory( const QString& cat ) |
197 | { | 186 | { |
198 | odebug << "AbView::setShowCategory( const QString& cat )" << oendl; | 187 | odebug << "AbView::setShowCategory( const QString& cat )" << oendl; |
199 | 188 | ||
200 | int intCat = 0; | 189 | int intCat = 0; |
201 | 190 | ||
202 | // All (cat == NULL) will be stored as -1 | 191 | // Unfiled will be stored as -1 |
203 | if ( cat.isNull() ) | 192 | if ( cat == tr( "Unfiled" ) ) |
204 | intCat = -1; | 193 | intCat = -1; |
194 | else if ( cat.isNull() ) | ||
195 | intCat = 0; | ||
205 | else | 196 | else |
206 | intCat = mCat.id("Contacts", cat ); | 197 | intCat = mCat.id("Contacts", cat ); |
207 | 198 | ||
208 | // Just do anything if we really change the category | 199 | // Just do anything if we really change the category |
209 | if ( intCat != m_curr_category ){ | 200 | if ( intCat != m_curr_category ){ |
210 | // odebug << "Categories: Selected " << cat << ".. Number: " | 201 | // odebug << "Categories: Selected " << cat << ".. Number: " |
211 | // << m_curr_category << oendl; | 202 | // << m_curr_category << oendl; |
212 | 203 | ||
213 | m_curr_category = intCat; | 204 | m_curr_category = intCat; |
214 | emit signalClearLetterPicker(); | 205 | emit signalClearLetterPicker(); |
215 | |||
216 | load(); | 206 | load(); |
217 | } | 207 | } |
208 | m_curr_category = intCat; | ||
218 | 209 | ||
219 | } | 210 | } |
220 | 211 | ||
221 | void AbView::setShowToView( Views view ) | 212 | void AbView::setShowToView( Views view ) |
222 | { | 213 | { |
223 | odebug << "void AbView::setShowToView( View " << view << " )" << oendl; | 214 | odebug << "void AbView::setShowToView( View " << view << " )" << oendl; |
@@ -262,14 +253,19 @@ void AbView::setShowByLetter( char c, AbConfig::LPSearchMode mode ) | |||
262 | default: | 253 | default: |
263 | owarn << "Unknown Searchmode for AbView::setShowByLetter ! -> " << mode << oendl | 254 | owarn << "Unknown Searchmode for AbView::setShowByLetter ! -> " << mode << oendl |
264 | << "I will ignore it.." << oendl; | 255 | << "I will ignore it.." << oendl; |
265 | return; | 256 | return; |
266 | } | 257 | } |
267 | m_list = m_contactdb->queryByExample( query, Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ); | 258 | m_list = m_contactdb->queryByExample( query, Opie::OPimContactAccess::WildCards | Opie::OPimContactAccess::IgnoreCase ); |
268 | if ( m_curr_category != -1 ) | 259 | |
260 | if ( m_curr_category != 0 ) | ||
269 | clearForCategory(); | 261 | clearForCategory(); |
262 | |||
263 | // Sort filtered results | ||
264 | m_list = m_contactdb->sorted( m_list, true, Opie::OPimContactAccess::SortFileAsName, | ||
265 | Opie::OPimContactAccess::FilterCategory, m_curr_category ); | ||
270 | m_curr_Contact = 0; | 266 | m_curr_Contact = 0; |
271 | } | 267 | } |
272 | updateView( true ); | 268 | updateView( true ); |
273 | } | 269 | } |
274 | 270 | ||
275 | void AbView::setListOrder( const QValueList<int>& ordered ) | 271 | void AbView::setListOrder( const QValueList<int>& ordered ) |
@@ -375,13 +371,13 @@ void AbView::slotDoFind( const QString &str, bool caseSensitive, bool useRegExp, | |||
375 | return; | 371 | return; |
376 | } | 372 | } |
377 | 373 | ||
378 | // Now remove all contacts with wrong category (if any selected) | 374 | // Now remove all contacts with wrong category (if any selected) |
379 | // This algorithm is a litte bit ineffective, but | 375 | // This algorithm is a litte bit ineffective, but |
380 | // we will not have a lot of matching entries.. | 376 | // we will not have a lot of matching entries.. |
381 | if ( m_curr_category != -1 ) | 377 | if ( m_curr_category != 0 ) |
382 | clearForCategory(); | 378 | clearForCategory(); |
383 | 379 | ||
384 | // Now show all found entries | 380 | // Now show all found entries |
385 | updateView( true ); | 381 | updateView( true ); |
386 | } | 382 | } |
387 | 383 | ||
@@ -415,13 +411,13 @@ void AbView::slotSwitch(){ | |||
415 | void AbView::clearForCategory() | 411 | void AbView::clearForCategory() |
416 | { | 412 | { |
417 | Opie::OPimContactAccess::List::Iterator it; | 413 | Opie::OPimContactAccess::List::Iterator it; |
418 | // Now remove all contacts with wrong category if any category selected | 414 | // Now remove all contacts with wrong category if any category selected |
419 | 415 | ||
420 | Opie::OPimContactAccess::List allList = m_list; | 416 | Opie::OPimContactAccess::List allList = m_list; |
421 | if ( m_curr_category != -1 ){ | 417 | if ( m_curr_category != 0 ){ |
422 | for ( it = allList.begin(); it != allList.end(); ++it ){ | 418 | for ( it = allList.begin(); it != allList.end(); ++it ){ |
423 | if ( !contactCompare( *it, m_curr_category ) ){ | 419 | if ( !contactCompare( *it, m_curr_category ) ){ |
424 | //odebug << "Removing " << (*it).uid() << oendl; | 420 | //odebug << "Removing " << (*it).uid() << oendl; |
425 | m_list.remove( (*it).uid() ); | 421 | m_list.remove( (*it).uid() ); |
426 | } | 422 | } |
427 | } | 423 | } |
@@ -438,13 +434,13 @@ bool AbView::contactCompare( const Opie::OPimContact &cnt, int category ) | |||
438 | QArray<int> cats; | 434 | QArray<int> cats; |
439 | cats = cnt.categories(); | 435 | cats = cnt.categories(); |
440 | 436 | ||
441 | //odebug << "Number of categories: " << cats.count() << oendl; | 437 | //odebug << "Number of categories: " << cats.count() << oendl; |
442 | 438 | ||
443 | returnMe = false; | 439 | returnMe = false; |
444 | if ( cats.count() == 0 && category == 0 ) | 440 | if ( cats.count() == 0 && category == -1 ) |
445 | // Contacts with no category will just shown on "All" and "Unfiled" | 441 | // Contacts with no category will just shown on "All" and "Unfiled" |
446 | returnMe = true; | 442 | returnMe = true; |
447 | else { | 443 | else { |
448 | int i; | 444 | int i; |
449 | for ( i = 0; i < int(cats.count()); i++ ) { | 445 | for ( i = 0; i < int(cats.count()); i++ ) { |
450 | //odebug << "Comparing " << cats[i] << " with " << category << oendl; | 446 | //odebug << "Comparing " << cats[i] << " with " << category << oendl; |