author | eilers <eilers> | 2002-11-27 15:21:06 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-11-27 15:21:06 (UTC) |
commit | 4b20972da142bbdea42c682025ab5303c35a5a92 (patch) (unidiff) | |
tree | 934acaec747a495188a7d3c1e125ecc0776b68c6 | |
parent | 4d7272423782dc2f9f7dbde36b848f55eb323c79 (diff) | |
download | opie-4b20972da142bbdea42c682025ab5303c35a5a92.zip opie-4b20972da142bbdea42c682025ab5303c35a5a92.tar.gz opie-4b20972da142bbdea42c682025ab5303c35a5a92.tar.bz2 |
Extremely improved table update
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 55 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.h | 3 | ||||
-rw-r--r-- | core/pim/addressbook/abview.cpp | 72 | ||||
-rw-r--r-- | core/pim/addressbook/abview.h | 3 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 46 |
5 files changed, 109 insertions, 70 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index e333b17..00335ae 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp | |||
@@ -120,13 +120,14 @@ void AbPickItem::setContentFromEditor( QWidget *w ) | |||
120 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) | 120 | AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) |
121 | : QTable( parent, name ), | 121 | : QTable( parent, name ), |
122 | lastSortCol( -1 ), | 122 | lastSortCol( -1 ), |
123 | asc( TRUE ), | 123 | asc( TRUE ), |
124 | intFields( order ), | 124 | intFields( order ), |
125 | enablePainting( true ), | 125 | enablePainting( true ), |
126 | columnVisible( true ) | 126 | columnVisible( true ), |
127 | countNested( 0 ) | ||
127 | { | 128 | { |
128 | qWarning("C'tor start"); | 129 | qWarning("C'tor start"); |
129 | 130 | ||
130 | setSelectionMode( NoSelection ); | 131 | setSelectionMode( NoSelection ); |
131 | init(); | 132 | init(); |
132 | setSorting( TRUE ); | 133 | setSorting( TRUE ); |
@@ -159,38 +160,39 @@ void AbTable::setContacts( const OContactAccess::List& viewList ) | |||
159 | qWarning("AbTable::setContacts()"); | 160 | qWarning("AbTable::setContacts()"); |
160 | 161 | ||
161 | clear(); | 162 | clear(); |
162 | m_viewList = viewList; | 163 | m_viewList = viewList; |
163 | 164 | ||
164 | setSorting( false ); | 165 | setSorting( false ); |
165 | setUpdatesEnabled( FALSE ); | 166 | setPaintingEnabled( FALSE ); |
166 | 167 | ||
167 | OContactAccess::List::Iterator it; | 168 | OContactAccess::List::Iterator it; |
168 | setNumRows( m_viewList.count() ); | 169 | setNumRows( m_viewList.count() ); |
169 | int row = 0; | 170 | int row = 0; |
170 | for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) | 171 | for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) |
171 | insertIntoTable( *it, row++ ); | 172 | insertIntoTable( *it, row++ ); |
172 | 173 | ||
173 | setUpdatesEnabled( TRUE ); | ||
174 | |||
175 | setSorting( true ); | 174 | setSorting( true ); |
176 | 175 | ||
177 | resort(); | 176 | resort(); |
178 | 177 | ||
179 | updateVisible(); | 178 | updateVisible(); |
180 | 179 | ||
180 | setPaintingEnabled( TRUE ); | ||
181 | |||
181 | } | 182 | } |
182 | 183 | ||
183 | bool AbTable::selectContact( int UID ) | 184 | bool AbTable::selectContact( int UID ) |
184 | { | 185 | { |
185 | qWarning( "AbTable::selectContact( %d )", UID ); | 186 | qWarning( "AbTable::selectContact( %d )", UID ); |
186 | int rows = numRows(); | 187 | int rows = numRows(); |
187 | AbTableItem *abi; | 188 | AbTableItem *abi; |
188 | OContact* foundContact = 0l; | 189 | OContact* foundContact = 0l; |
189 | bool found = false; | 190 | bool found = false; |
190 | 191 | ||
192 | setPaintingEnabled( FALSE ); | ||
191 | for ( int r = 0; r < rows; ++r ) { | 193 | for ( int r = 0; r < rows; ++r ) { |
192 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 194 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
193 | foundContact = &contactList[abi]; | 195 | foundContact = &contactList[abi]; |
194 | if ( foundContact -> uid() == UID ){ | 196 | if ( foundContact -> uid() == UID ){ |
195 | ensureCellVisible( r, 0 ); | 197 | ensureCellVisible( r, 0 ); |
196 | setCurrentCell( r, 0 ); | 198 | setCurrentCell( r, 0 ); |
@@ -201,18 +203,20 @@ bool AbTable::selectContact( int UID ) | |||
201 | 203 | ||
202 | if ( !found ){ | 204 | if ( !found ){ |
203 | ensureCellVisible( 0,0 ); | 205 | ensureCellVisible( 0,0 ); |
204 | setCurrentCell( 0, 0 ); | 206 | setCurrentCell( 0, 0 ); |
205 | } | 207 | } |
206 | 208 | ||
209 | setPaintingEnabled( TRUE ); | ||
210 | |||
207 | return true; | 211 | return true; |
208 | } | 212 | } |
209 | 213 | ||
210 | void AbTable::insertIntoTable( const OContact& cnt, int row ) | 214 | void AbTable::insertIntoTable( const OContact& cnt, int row ) |
211 | { | 215 | { |
212 | // qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); | 216 | qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); |
213 | QString strName, | 217 | QString strName, |
214 | strContact; | 218 | strContact; |
215 | 219 | ||
216 | strName = findContactName( cnt ); | 220 | strName = findContactName( cnt ); |
217 | strContact = findContactContact( cnt, row ); | 221 | strContact = findContactContact( cnt, row ); |
218 | 222 | ||
@@ -248,19 +252,21 @@ void AbTable::columnClicked( int col ) | |||
248 | resort(); | 252 | resort(); |
249 | } | 253 | } |
250 | 254 | ||
251 | void AbTable::resort() | 255 | void AbTable::resort() |
252 | { | 256 | { |
253 | qWarning( "void AbTable::resort()" ); | 257 | qWarning( "void AbTable::resort()" ); |
258 | setPaintingEnabled( FALSE ); | ||
254 | if ( sorting() ) { | 259 | if ( sorting() ) { |
255 | if ( lastSortCol == -1 ) | 260 | if ( lastSortCol == -1 ) |
256 | lastSortCol = 0; | 261 | lastSortCol = 0; |
257 | sortColumn( lastSortCol, asc, TRUE ); | 262 | sortColumn( lastSortCol, asc, TRUE ); |
258 | //QMessageBox::information( this, "resort", "resort" ); | 263 | //QMessageBox::information( this, "resort", "resort" ); |
259 | updateVisible(); | 264 | updateVisible(); |
260 | } | 265 | } |
266 | setPaintingEnabled( TRUE ); | ||
261 | } | 267 | } |
262 | 268 | ||
263 | OContact AbTable::currentEntry() | 269 | OContact AbTable::currentEntry() |
264 | { | 270 | { |
265 | qWarning( "OContact AbTable::currentEntry()" ); | 271 | qWarning( "OContact AbTable::currentEntry()" ); |
266 | OContact cnt; | 272 | OContact cnt; |
@@ -279,36 +285,41 @@ int AbTable::currentEntry_UID() | |||
279 | } | 285 | } |
280 | 286 | ||
281 | void AbTable::clear() | 287 | void AbTable::clear() |
282 | { | 288 | { |
283 | qWarning( "void AbTable::clear()" ); | 289 | qWarning( "void AbTable::clear()" ); |
284 | contactList.clear(); | 290 | contactList.clear(); |
291 | |||
292 | setPaintingEnabled( FALSE ); | ||
285 | for ( int r = 0; r < numRows(); ++r ) { | 293 | for ( int r = 0; r < numRows(); ++r ) { |
286 | for ( int c = 0; c < numCols(); ++c ) { | 294 | for ( int c = 0; c < numCols(); ++c ) { |
287 | if ( cellWidget( r, c ) ) | 295 | if ( cellWidget( r, c ) ) |
288 | clearCellWidget( r, c ); | 296 | clearCellWidget( r, c ); |
289 | clearCell( r, c ); | 297 | clearCell( r, c ); |
290 | } | 298 | } |
291 | } | 299 | } |
292 | setNumRows( 0 ); | 300 | setNumRows( 0 ); |
301 | setPaintingEnabled( TRUE ); | ||
293 | } | 302 | } |
294 | 303 | ||
295 | // Refresh updates column 2 if the contactsettings changed | 304 | // Refresh updates column 2 if the contactsettings changed |
296 | void AbTable::refresh() | 305 | void AbTable::refresh() |
297 | { | 306 | { |
298 | qWarning( "void AbTable::refresh()" ); | 307 | qWarning( "void AbTable::refresh()" ); |
299 | int rows = numRows(); | 308 | int rows = numRows(); |
300 | QString value; | 309 | QString value; |
301 | AbTableItem *abi; | 310 | AbTableItem *abi; |
302 | 311 | ||
312 | setPaintingEnabled( FALSE ); | ||
303 | for ( int r = 0; r < rows; ++r ) { | 313 | for ( int r = 0; r < rows; ++r ) { |
304 | abi = static_cast<AbTableItem*>( item(r, 0) ); | 314 | abi = static_cast<AbTableItem*>( item(r, 0) ); |
305 | value = findContactContact( contactList[abi], r ); | 315 | value = findContactContact( contactList[abi], r ); |
306 | static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); | 316 | static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); |
307 | } | 317 | } |
308 | resort(); | 318 | resort(); |
319 | setPaintingEnabled( TRUE ); | ||
309 | } | 320 | } |
310 | 321 | ||
311 | void AbTable::keyPressEvent( QKeyEvent *e ) | 322 | void AbTable::keyPressEvent( QKeyEvent *e ) |
312 | { | 323 | { |
313 | char key = toupper( e->ascii() ); | 324 | char key = toupper( e->ascii() ); |
314 | 325 | ||
@@ -451,24 +462,28 @@ void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) | |||
451 | void AbTable::fitColumns() | 462 | void AbTable::fitColumns() |
452 | { | 463 | { |
453 | qWarning( "void AbTable::fitColumns()" ); | 464 | qWarning( "void AbTable::fitColumns()" ); |
454 | int contentsWidth = visibleWidth() / 2; // :SX Why too low | 465 | int contentsWidth = visibleWidth() / 2; // :SX Why too low |
455 | // Fix to better value | 466 | // Fix to better value |
456 | // contentsWidth = 130; | 467 | // contentsWidth = 130; |
468 | |||
469 | setPaintingEnabled( FALSE ); | ||
457 | 470 | ||
458 | if ( columnVisible == false ){ | 471 | if ( columnVisible == false ){ |
459 | showColumn(0); | 472 | showColumn(0); |
460 | columnVisible = true; | 473 | columnVisible = true; |
461 | } | 474 | } |
462 | 475 | ||
463 | qWarning("Width: %d", contentsWidth); | 476 | qWarning("Width: %d", contentsWidth); |
464 | 477 | ||
465 | setColumnWidth( 0, contentsWidth ); | 478 | setColumnWidth( 0, contentsWidth ); |
466 | adjustColumn(1); | 479 | adjustColumn(1); |
467 | if ( columnWidth(1) < contentsWidth ) | 480 | if ( columnWidth(1) < contentsWidth ) |
468 | setColumnWidth( 1, contentsWidth ); | 481 | setColumnWidth( 1, contentsWidth ); |
482 | |||
483 | setPaintingEnabled( TRUE ); | ||
469 | } | 484 | } |
470 | 485 | ||
471 | void AbTable::show() | 486 | void AbTable::show() |
472 | { | 487 | { |
473 | qWarning( "void AbTable::show()" ); | 488 | qWarning( "void AbTable::show()" ); |
474 | realignTable(); | 489 | realignTable(); |
@@ -530,23 +545,25 @@ QStringList AbTable::choiceSelection(int /*index*/) const | |||
530 | 545 | ||
531 | 546 | ||
532 | 547 | ||
533 | 548 | ||
534 | void AbTable::updateVisible() | 549 | void AbTable::updateVisible() |
535 | { | 550 | { |
551 | qWarning("void AbTable::updateVisible()"); | ||
552 | |||
536 | int visible, | 553 | int visible, |
537 | totalRows, | 554 | totalRows, |
538 | row, | 555 | row, |
539 | selectedRow = 0; | 556 | selectedRow = 0; |
540 | 557 | ||
541 | visible = 0; | 558 | visible = 0; |
542 | 559 | ||
543 | realignTable(); | ||
544 | |||
545 | setPaintingEnabled( FALSE ); | 560 | setPaintingEnabled( FALSE ); |
546 | 561 | ||
562 | realignTable(); | ||
563 | |||
547 | totalRows = numRows(); | 564 | totalRows = numRows(); |
548 | for ( row = 0; row < totalRows; row++ ) { | 565 | for ( row = 0; row < totalRows; row++ ) { |
549 | if ( rowHeight(row) == 0 ) { | 566 | if ( rowHeight(row) == 0 ) { |
550 | showRow( row ); | 567 | showRow( row ); |
551 | adjustRow( row ); | 568 | adjustRow( row ); |
552 | if ( isSelected( row,0 ) || isSelected( row,1 ) ) | 569 | if ( isSelected( row,0 ) || isSelected( row,1 ) ) |
@@ -566,23 +583,39 @@ void AbTable::updateVisible() | |||
566 | 583 | ||
567 | } | 584 | } |
568 | 585 | ||
569 | 586 | ||
570 | void AbTable::setPaintingEnabled( bool e ) | 587 | void AbTable::setPaintingEnabled( bool e ) |
571 | { | 588 | { |
572 | if ( e != enablePainting ) { | 589 | qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); |
573 | if ( !enablePainting ) { | 590 | |
591 | if ( e ) { | ||
592 | if ( countNested > 0 ) | ||
593 | --countNested; | ||
594 | if ( ! countNested ){ | ||
595 | setUpdatesEnabled( true ); | ||
574 | enablePainting = true; | 596 | enablePainting = true; |
575 | rowHeightChanged( 0 ); | 597 | rowHeightChanged( 0 ); |
576 | viewport()->update(); | 598 | viewport()->update(); |
577 | } else { | ||
578 | enablePainting = false; | ||
579 | } | 599 | } |
600 | } else { | ||
601 | ++countNested; | ||
602 | enablePainting = false; | ||
603 | setUpdatesEnabled( false ); | ||
580 | } | 604 | } |
605 | qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); | ||
581 | } | 606 | } |
582 | 607 | ||
608 | void AbTable::viewportPaintEvent( QPaintEvent* e ) { | ||
609 | qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting); | ||
610 | if ( enablePainting ) | ||
611 | QTable::viewportPaintEvent( e ); | ||
612 | } | ||
613 | |||
614 | |||
615 | |||
583 | void AbTable::rowHeightChanged( int row ) | 616 | void AbTable::rowHeightChanged( int row ) |
584 | { | 617 | { |
585 | if ( enablePainting ) | 618 | if ( enablePainting ) |
586 | QTable::rowHeightChanged( row ); | 619 | QTable::rowHeightChanged( row ); |
587 | } | 620 | } |
588 | QString AbTable::findContactContact( const OContact &entry, int /* row */ ) | 621 | QString AbTable::findContactContact( const OContact &entry, int /* row */ ) |
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h index 83bd5a7..9825665 100644 --- a/core/pim/addressbook/abtable.h +++ b/core/pim/addressbook/abtable.h | |||
@@ -82,12 +82,13 @@ public: | |||
82 | void init(); | 82 | void init(); |
83 | void clear(); | 83 | void clear(); |
84 | void refresh(); | 84 | void refresh(); |
85 | 85 | ||
86 | void show(); | 86 | void show(); |
87 | void setPaintingEnabled( bool e ); | 87 | void setPaintingEnabled( bool e ); |
88 | void viewportPaintEvent( QPaintEvent* e); | ||
88 | 89 | ||
89 | // addresspicker mode (What's that ? se) | 90 | // addresspicker mode (What's that ? se) |
90 | void setChoiceNames( const QStringList& list); | 91 | void setChoiceNames( const QStringList& list); |
91 | QStringList choiceNames() const; | 92 | QStringList choiceNames() const; |
92 | void setChoiceSelection( const QValueList<int>& list ); | 93 | void setChoiceSelection( const QValueList<int>& list ); |
93 | QStringList choiceSelection(int index) const; | 94 | QStringList choiceSelection(int index) const; |
@@ -124,13 +125,13 @@ private: | |||
124 | int lastSortCol; | 125 | int lastSortCol; |
125 | bool asc; | 126 | bool asc; |
126 | QMap<AbTableItem*, OContact> contactList; | 127 | QMap<AbTableItem*, OContact> contactList; |
127 | QValueList<int> intFields; | 128 | QValueList<int> intFields; |
128 | QStringList choicenames; | 129 | QStringList choicenames; |
129 | bool enablePainting; | 130 | bool enablePainting; |
130 | |||
131 | bool columnVisible; | 131 | bool columnVisible; |
132 | int countNested; | ||
132 | 133 | ||
133 | OContactAccess::List m_viewList; | 134 | OContactAccess::List m_viewList; |
134 | 135 | ||
135 | }; | 136 | }; |
136 | #endif // ABTABLE_H | 137 | #endif // ABTABLE_H |
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,6 +1,22 @@ | |||
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 | ||
@@ -134,15 +150,12 @@ void AbView::load() | |||
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 | ||
@@ -156,54 +169,51 @@ void AbView::reload() | |||
156 | 169 | ||
157 | void AbView::clear() | 170 | void AbView::clear() |
158 | { | 171 | { |
159 | // :SX | 172 | // :SX |
160 | } | 173 | } |
161 | 174 | ||
162 | void AbView::setShowByCategory( Views view, const QString& cat ) | 175 | void 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 | |||
199 | void 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 | |||
204 | void AbView::setShowByLetter( char c ) | 214 | void 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(); |
@@ -398,12 +408,15 @@ void AbView::updateListinViews() | |||
398 | } | 408 | } |
399 | 409 | ||
400 | void AbView::updateView() | 410 | void 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() ){ |
@@ -412,29 +425,30 @@ void AbView::updateView() | |||
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 | ||
diff --git a/core/pim/addressbook/abview.h b/core/pim/addressbook/abview.h index 201b521..2c10cfa 100644 --- a/core/pim/addressbook/abview.h +++ b/core/pim/addressbook/abview.h | |||
@@ -26,13 +26,14 @@ public: | |||
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 setShowByCategory( Views view, const QString& cat ); | 32 | void setShowByCategory( const QString& cat ); |
33 | void setShowToView( Views view ); | ||
33 | void setShowByLetter( char c ); | 34 | void setShowByLetter( char c ); |
34 | void setListOrder( const QValueList<int>& ordered ); | 35 | void setListOrder( const QValueList<int>& ordered ); |
35 | 36 | ||
36 | // Add Entry and put to current | 37 | // Add Entry and put to current |
37 | void addEntry( const OContact &newContact ); | 38 | void addEntry( const OContact &newContact ); |
38 | void removeEntry( const int UID ); | 39 | void removeEntry( const int UID ); |
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 3b2e4b8..5d588da 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -818,21 +818,24 @@ void AddressbookWindow::slotSetCategory( int c ) | |||
818 | QString cat, book; | 818 | QString cat, book; |
819 | AbView::Views view = AbView::TableView; | 819 | AbView::Views view = AbView::TableView; |
820 | 820 | ||
821 | if ( c <= 0 ) | 821 | if ( c <= 0 ) |
822 | return; | 822 | return; |
823 | 823 | ||
824 | // Checkmark Book Menu Item Selected | 824 | // Switch view |
825 | if ( c < 3 ) | 825 | if ( c < 3 ) |
826 | for ( unsigned int i = 1; i < 3; i++ ) | 826 | for ( unsigned int i = 1; i < 3; i++ ){ |
827 | catMenu->setItemChecked( i, c == (int)i ); | 827 | if ( catMenu ) |
828 | // Checkmark Category Menu Item Selected | 828 | catMenu->setItemChecked( i, c == (int)i ); |
829 | } | ||
829 | else | 830 | else |
831 | // Checkmark Category Menu Item Selected | ||
830 | for ( unsigned int i = 3; i < catMenu->count(); i++ ) | 832 | for ( unsigned int i = 3; i < catMenu->count(); i++ ) |
831 | catMenu->setItemChecked( i, c == (int)i ); | 833 | catMenu->setItemChecked( i, c == (int)i ); |
832 | 834 | ||
835 | // Now switch to the selected category | ||
833 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { | 836 | for ( unsigned int i = 1; i < catMenu->count(); i++ ) { |
834 | if (catMenu->isItemChecked( i )) { | 837 | if (catMenu->isItemChecked( i )) { |
835 | if ( i == 1 ){ // default List view | 838 | if ( i == 1 ){ // default List view |
836 | book = QString::null; | 839 | book = QString::null; |
837 | view = AbView::TableView; | 840 | view = AbView::TableView; |
838 | }else if ( i == 2 ){ | 841 | }else if ( i == 2 ){ |
@@ -849,15 +852,17 @@ void AddressbookWindow::slotSetCategory( int c ) | |||
849 | }else{ | 852 | }else{ |
850 | cat = m_abView->categories()[i - 4]; | 853 | cat = m_abView->categories()[i - 4]; |
851 | } | 854 | } |
852 | } | 855 | } |
853 | } | 856 | } |
854 | 857 | ||
858 | // Switch to the selected View | ||
855 | slotViewSwitched( view ); | 859 | slotViewSwitched( view ); |
856 | 860 | ||
857 | m_abView -> setShowByCategory( view, cat ); | 861 | // Tell the view about the selected category |
862 | m_abView -> setShowByCategory( cat ); | ||
858 | 863 | ||
859 | if ( book.isEmpty() ) | 864 | if ( book.isEmpty() ) |
860 | book = "List"; | 865 | book = "List"; |
861 | if ( cat.isEmpty() ) | 866 | if ( cat.isEmpty() ) |
862 | cat = "All"; | 867 | cat = "All"; |
863 | 868 | ||
@@ -865,48 +870,45 @@ void AddressbookWindow::slotSetCategory( int c ) | |||
865 | } | 870 | } |
866 | 871 | ||
867 | void AddressbookWindow::slotViewSwitched( int view ) | 872 | void AddressbookWindow::slotViewSwitched( int view ) |
868 | { | 873 | { |
869 | qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); | 874 | qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view ); |
870 | int menu = 0; | 875 | int menu = 0; |
876 | |||
877 | // Switch to selected view | ||
871 | switch ( view ){ | 878 | switch ( view ){ |
872 | case AbView::TableView: | 879 | case AbView::TableView: |
873 | menu = 1; | 880 | menu = 1; |
874 | m_tableViewButton->setOn(true); | 881 | m_tableViewButton->setOn(true); |
875 | m_cardViewButton->setOn(false); | 882 | m_cardViewButton->setOn(false); |
876 | break; | 883 | break; |
877 | case AbView::CardView: | 884 | case AbView::CardView: |
878 | menu = 2; | 885 | menu = 2; |
879 | m_tableViewButton->setOn(false); | 886 | m_tableViewButton->setOn(false); |
880 | m_cardViewButton->setOn(true); | 887 | m_cardViewButton->setOn(true); |
881 | break; | 888 | break; |
882 | // case AbView::PersonalView: | ||
883 | // menu = 3; | ||
884 | // break; | ||
885 | // case AbView::CompanyBook: | ||
886 | // menu = 3; | ||
887 | // break; | ||
888 | // case AbView::EmailBook: | ||
889 | // menu = 4; | ||
890 | // break; | ||
891 | } | 889 | } |
892 | for ( unsigned int i = 1; i < 3; i++ ){ | 890 | for ( unsigned int i = 1; i < 3; i++ ){ |
893 | if ( catMenu ) | 891 | if ( catMenu ) |
894 | catMenu->setItemChecked( i, menu == (int)i ); | 892 | catMenu->setItemChecked( i, menu == (int)i ); |
895 | } | 893 | } |
894 | |||
895 | // Tell the view about the selected view | ||
896 | m_abView -> setShowToView ( (AbView::Views) view ); | ||
897 | |||
896 | } | 898 | } |
897 | 899 | ||
898 | 900 | ||
899 | void AddressbookWindow::slotListView() | 901 | void AddressbookWindow::slotListView() |
900 | { | 902 | { |
901 | emit slotSetCategory( AbView::TableView +1 ); | 903 | slotViewSwitched( AbView::TableView ); |
902 | } | 904 | } |
903 | 905 | ||
904 | void AddressbookWindow::slotCardView() | 906 | void AddressbookWindow::slotCardView() |
905 | { | 907 | { |
906 | emit slotSetCategory( AbView::CardView +1 ); | 908 | slotViewSwitched( AbView::CardView ); |
907 | } | 909 | } |
908 | 910 | ||
909 | void AddressbookWindow::slotSetLetter( char c ) { | 911 | void AddressbookWindow::slotSetLetter( char c ) { |
910 | 912 | ||
911 | m_abView->setShowByLetter( c ); | 913 | m_abView->setShowByLetter( c ); |
912 | 914 | ||
@@ -934,24 +936,12 @@ void AddressbookWindow::populateCategories() | |||
934 | catMenu->insertItem( *it, id ); | 936 | catMenu->insertItem( *it, id ); |
935 | if ( *it == m_abView -> showCategory() ) | 937 | if ( *it == m_abView -> showCategory() ) |
936 | rememberId = id; | 938 | rememberId = id; |
937 | ++id; | 939 | ++id; |
938 | } | 940 | } |
939 | 941 | ||
940 | // :SX | ||
941 | // if ( abList->showBook().isEmpty() ) { | ||
942 | // catMenu->setItemChecked( 1, true ); | ||
943 | // } else if ( abList->showBook() == "Phone" ) { | ||
944 | // catMenu->setItemChecked( 2, true ); | ||
945 | // } else if ( abList->showBook() == "Company" ) { | ||
946 | // catMenu->setItemChecked( 3, true ); | ||
947 | // } else if ( abList->showBook() == "Email" ) { | ||
948 | // catMenu->setItemChecked( 4, true ); | ||
949 | // } else if ( abList->showBook() == "Cards" ) { | ||
950 | // catMenu->setItemChecked( 5, true ); | ||
951 | // } | ||
952 | 942 | ||
953 | if ( m_abView -> showCategory().isEmpty() ) { | 943 | if ( m_abView -> showCategory().isEmpty() ) { |
954 | slotSetCategory( 3 ); | 944 | slotSetCategory( 3 ); |
955 | } | 945 | } |
956 | else { | 946 | else { |
957 | slotSetCategory( rememberId ); | 947 | slotSetCategory( rememberId ); |