summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/abview.cpp
Unidiff
Diffstat (limited to 'core/pim/addressbook/abview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abview.cpp72
1 files changed, 43 insertions, 29 deletions
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp
index 8d22129..3af7663 100644
--- a/core/pim/addressbook/abview.cpp
+++ b/core/pim/addressbook/abview.cpp
@@ -1,12 +1,28 @@
1/**********************************************************************
2** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de)
3**
4** This file is part of Qt Palmtop Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14**
15**********************************************************************/
16
1#include "abview.h" 17#include "abview.h"
2 18
3#include <qlayout.h> 19#include <qlayout.h>
4 20
5#include <qpe/global.h> 21#include <qpe/global.h>
6 22
7#include <opie/ocontactaccessbackend_vcard.h> 23#include <opie/ocontactaccessbackend_vcard.h>
8 24
9 25
10// Is defined in LibQPE 26// Is defined in LibQPE
11extern QString categoryFileName(); 27extern QString categoryFileName();
12 28
@@ -128,88 +144,82 @@ bool AbView::save()
128 144
129void AbView::load() 145void AbView::load()
130{ 146{
131 qWarning("abView:Load data"); 147 qWarning("abView:Load data");
132 148
133 if ( m_inPersonal ) 149 if ( m_inPersonal )
134 m_list = m_contactdb->allRecords(); 150 m_list = m_contactdb->allRecords();
135 else 151 else
136 m_list = m_contactdb->sorted( true, 0, 0, 0 ); 152 m_list = m_contactdb->sorted( true, 0, 0, 0 );
137 153
138 clearForCategory(); 154 clearForCategory();
139 155
140 // Feed all views with new lists
141 updateListinViews();
142
143 qWarning ("Number of contacts: %d", m_list.count()); 156 qWarning ("Number of contacts: %d", m_list.count());
144 157
145 updateView(); 158 updateView();
146 159
147} 160}
148 161
149void AbView::reload() 162void AbView::reload()
150{ 163{
151 qWarning( "void AbView::reload()" ); 164 qWarning( "void AbView::reload()" );
152 165
153 m_contactdb->reload(); 166 m_contactdb->reload();
154 load(); 167 load();
155} 168}
156 169
157void AbView::clear() 170void AbView::clear()
158{ 171{
159 // :SX 172 // :SX
160} 173}
161 174
162void AbView::setShowByCategory( Views view, const QString& cat ) 175void AbView::setShowByCategory( const QString& cat )
163{ 176{
164 qWarning("AbView::setShowCategory( Views view, const QString& cat )"); 177 qWarning("AbView::setShowCategory( const QString& cat )");
165
166 // if ( view == PersonalView ){
167 // if ( ! m_inPersonal )
168 // showPersonal( true );
169
170 // }else{
171 // if ( m_inPersonal )
172 // showPersonal( false );
173
174 // m_curr_View = view;
175 // }
176 178
177 int intCat = 0; 179 int intCat = 0;
178 180
179 // All (cat == NULL) will be stored as -1 181 // All (cat == NULL) will be stored as -1
180 if ( cat.isNull() ) 182 if ( cat.isNull() )
181 intCat = -1; 183 intCat = -1;
182 else 184 else
183 intCat = mCat.id("Contacts", cat ); 185 intCat = mCat.id("Contacts", cat );
184 186
185 // If we just change the view, we don't have to reload any data.. 187 // Just do anything if we really change the category
186 // This speeds up a lot of things ! 188 if ( intCat != m_curr_category ){
187 if ( intCat == m_curr_category ){
188 qWarning ("Just change the View (Category is: %d)", m_curr_category);
189 m_prev_View = m_curr_View;
190 m_curr_View = view;
191
192 updateView();
193 }else{
194 qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category); 189 qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category);
195 190
196 m_curr_View = view;
197 m_curr_category = intCat; 191 m_curr_category = intCat;
198 emit signalClearLetterPicker(); 192 emit signalClearLetterPicker();
199 193
200 load(); 194 load();
201 } 195 }
202 196
203} 197}
198
199void AbView::setShowToView( Views view )
200{
201 qWarning("void AbView::setShowToView( View %d )", view);
202
203 qWarning ("Change the View (Category is: %d)", m_curr_category);
204
205 if ( m_curr_View != view ){
206 m_prev_View = m_curr_View;
207 m_curr_View = view;
208
209 updateView();
210 }
211
212}
213
204void AbView::setShowByLetter( char c ) 214void AbView::setShowByLetter( char c )
205{ 215{
206 qWarning("void AbView::setShowByLetter( %c )", c ); 216 qWarning("void AbView::setShowByLetter( %c )", c );
207 OContact query; 217 OContact query;
208 if ( c == 0 ){ 218 if ( c == 0 ){
209 load(); 219 load();
210 return; 220 return;
211 }else{ 221 }else{
212 query.setLastName( QString("%1*").arg(c) ); 222 query.setLastName( QString("%1*").arg(c) );
213 m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards ); 223 m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards );
214 clearForCategory(); 224 clearForCategory();
215 m_curr_Contact = 0; 225 m_curr_Contact = 0;
@@ -392,54 +402,58 @@ bool AbView::contactCompare( const OContact &cnt, int category )
392 402
393// In Some rare cases we have to update all lists.. 403// In Some rare cases we have to update all lists..
394void AbView::updateListinViews() 404void AbView::updateListinViews()
395{ 405{
396 m_abTable -> setContacts( m_list ); 406 m_abTable -> setContacts( m_list );
397 m_ablabel -> setContacts( m_list ); 407 m_ablabel -> setContacts( m_list );
398} 408}
399 409
400void AbView::updateView() 410void AbView::updateView()
401{ 411{
402 qWarning("AbView::updateView()"); 412 qWarning("AbView::updateView()");
403 413
414 // Feed all views with new lists
415 updateListinViews();
416
404 if ( m_viewStack -> visibleWidget() ){ 417 if ( m_viewStack -> visibleWidget() ){
405 m_viewStack -> visibleWidget() -> clearFocus(); 418 m_viewStack -> visibleWidget() -> clearFocus();
406 } 419 }
407 420
408 // If we switching the view, we have to store some information 421 // If we switching the view, we have to store some information
409 if ( m_list.count() ){ 422 if ( m_list.count() ){
410 switch ( (int) m_prev_View ) { 423 switch ( (int) m_prev_View ) {
411 case TableView: 424 case TableView:
412 m_curr_Contact = m_abTable -> currentEntry_UID(); 425 m_curr_Contact = m_abTable -> currentEntry_UID();
413 break; 426 break;
414 case CardView: 427 case CardView:
415 m_curr_Contact = m_ablabel -> currentEntry_UID(); 428 m_curr_Contact = m_ablabel -> currentEntry_UID();
416 break; 429 break;
417 } 430 }
418 emit signalViewSwitched ( (int) m_curr_View );
419 }else 431 }else
420 m_curr_Contact = 0; 432 m_curr_Contact = 0;
421 433
434 // Inform the world that the view is changed
435 if ( m_curr_View != m_prev_View )
436 emit signalViewSwitched ( (int) m_curr_View );
437
422 m_prev_View = m_curr_View; 438 m_prev_View = m_curr_View;
423 439
424 // Switch to new View 440 // Switch to new View
425 switch ( (int) m_curr_View ) { 441 switch ( (int) m_curr_View ) {
426 case TableView: 442 case TableView:
427 m_abTable -> setChoiceSelection( m_orderedFields ); 443 m_abTable -> setChoiceSelection( m_orderedFields );
428 m_abTable -> setContacts( m_list );
429 if ( m_curr_Contact != 0 ) 444 if ( m_curr_Contact != 0 )
430 m_abTable -> selectContact ( m_curr_Contact ); 445 m_abTable -> selectContact ( m_curr_Contact );
431 m_abTable -> setFocus(); 446 m_abTable -> setFocus();
432 break; 447 break;
433 case CardView: 448 case CardView:
434 m_ablabel -> setContacts( m_list );
435 if ( m_curr_Contact != 0 ) 449 if ( m_curr_Contact != 0 )
436 m_ablabel -> selectContact( m_curr_Contact ); 450 m_ablabel -> selectContact( m_curr_Contact );
437 m_ablabel -> setFocus(); 451 m_ablabel -> setFocus();
438 break; 452 break;
439 } 453 }
440 454
441 // Raise the current View 455 // Raise the current View
442 m_viewStack -> raiseWidget( m_curr_View ); 456 m_viewStack -> raiseWidget( m_curr_View );
443} 457}
444 458
445 459