author | eilers <eilers> | 2002-11-27 15:21:06 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-11-27 15:21:06 (UTC) |
commit | 4b20972da142bbdea42c682025ab5303c35a5a92 (patch) (side-by-side diff) | |
tree | 934acaec747a495188a7d3c1e125ecc0776b68c6 /core/pim/addressbook/abtable.cpp | |
parent | 4d7272423782dc2f9f7dbde36b848f55eb323c79 (diff) | |
download | opie-4b20972da142bbdea42c682025ab5303c35a5a92.zip opie-4b20972da142bbdea42c682025ab5303c35a5a92.tar.gz opie-4b20972da142bbdea42c682025ab5303c35a5a92.tar.bz2 |
Extremely improved table update
Diffstat (limited to 'core/pim/addressbook/abtable.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 51 |
1 files changed, 42 insertions, 9 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 ) AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name ) : QTable( parent, name ), lastSortCol( -1 ), asc( TRUE ), intFields( order ), enablePainting( true ), - columnVisible( true ) + columnVisible( true ), + countNested( 0 ) { qWarning("C'tor start"); setSelectionMode( NoSelection ); init(); setSorting( TRUE ); @@ -159,38 +160,39 @@ void AbTable::setContacts( const OContactAccess::List& viewList ) qWarning("AbTable::setContacts()"); clear(); m_viewList = viewList; setSorting( false ); - setUpdatesEnabled( FALSE ); + setPaintingEnabled( FALSE ); OContactAccess::List::Iterator it; setNumRows( m_viewList.count() ); int row = 0; for ( it = m_viewList.begin(); it != m_viewList.end(); ++it ) insertIntoTable( *it, row++ ); - setUpdatesEnabled( TRUE ); - setSorting( true ); resort(); updateVisible(); + setPaintingEnabled( TRUE ); + } bool AbTable::selectContact( int UID ) { qWarning( "AbTable::selectContact( %d )", UID ); int rows = numRows(); AbTableItem *abi; OContact* foundContact = 0l; bool found = false; + setPaintingEnabled( FALSE ); for ( int r = 0; r < rows; ++r ) { abi = static_cast<AbTableItem*>( item(r, 0) ); foundContact = &contactList[abi]; if ( foundContact -> uid() == UID ){ ensureCellVisible( r, 0 ); setCurrentCell( r, 0 ); @@ -201,18 +203,20 @@ bool AbTable::selectContact( int UID ) if ( !found ){ ensureCellVisible( 0,0 ); setCurrentCell( 0, 0 ); } + setPaintingEnabled( TRUE ); + return true; } void AbTable::insertIntoTable( const OContact& cnt, int row ) { - // qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); + qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row ); QString strName, strContact; strName = findContactName( cnt ); strContact = findContactContact( cnt, row ); @@ -248,19 +252,21 @@ void AbTable::columnClicked( int col ) resort(); } void AbTable::resort() { qWarning( "void AbTable::resort()" ); + setPaintingEnabled( FALSE ); if ( sorting() ) { if ( lastSortCol == -1 ) lastSortCol = 0; sortColumn( lastSortCol, asc, TRUE ); //QMessageBox::information( this, "resort", "resort" ); updateVisible(); } + setPaintingEnabled( TRUE ); } OContact AbTable::currentEntry() { qWarning( "OContact AbTable::currentEntry()" ); OContact cnt; @@ -279,36 +285,41 @@ int AbTable::currentEntry_UID() } void AbTable::clear() { qWarning( "void AbTable::clear()" ); contactList.clear(); + + setPaintingEnabled( FALSE ); for ( int r = 0; r < numRows(); ++r ) { for ( int c = 0; c < numCols(); ++c ) { if ( cellWidget( r, c ) ) clearCellWidget( r, c ); clearCell( r, c ); } } setNumRows( 0 ); + setPaintingEnabled( TRUE ); } // Refresh updates column 2 if the contactsettings changed void AbTable::refresh() { qWarning( "void AbTable::refresh()" ); int rows = numRows(); QString value; AbTableItem *abi; + setPaintingEnabled( FALSE ); for ( int r = 0; r < rows; ++r ) { abi = static_cast<AbTableItem*>( item(r, 0) ); value = findContactContact( contactList[abi], r ); static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() ); } resort(); + setPaintingEnabled( TRUE ); } void AbTable::keyPressEvent( QKeyEvent *e ) { char key = toupper( e->ascii() ); @@ -452,23 +463,27 @@ void AbTable::fitColumns() { qWarning( "void AbTable::fitColumns()" ); int contentsWidth = visibleWidth() / 2; // :SX Why too low // Fix to better value // contentsWidth = 130; + setPaintingEnabled( FALSE ); + if ( columnVisible == false ){ showColumn(0); columnVisible = true; } qWarning("Width: %d", contentsWidth); setColumnWidth( 0, contentsWidth ); adjustColumn(1); if ( columnWidth(1) < contentsWidth ) setColumnWidth( 1, contentsWidth ); + + setPaintingEnabled( TRUE ); } void AbTable::show() { qWarning( "void AbTable::show()" ); realignTable(); @@ -530,23 +545,25 @@ QStringList AbTable::choiceSelection(int /*index*/) const void AbTable::updateVisible() { + qWarning("void AbTable::updateVisible()"); + int visible, totalRows, row, selectedRow = 0; visible = 0; - realignTable(); - setPaintingEnabled( FALSE ); + realignTable(); + totalRows = numRows(); for ( row = 0; row < totalRows; row++ ) { if ( rowHeight(row) == 0 ) { showRow( row ); adjustRow( row ); if ( isSelected( row,0 ) || isSelected( row,1 ) ) @@ -566,23 +583,39 @@ void AbTable::updateVisible() } void AbTable::setPaintingEnabled( bool e ) { - if ( e != enablePainting ) { - if ( !enablePainting ) { + qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); + + if ( e ) { + if ( countNested > 0 ) + --countNested; + if ( ! countNested ){ + setUpdatesEnabled( true ); enablePainting = true; rowHeightChanged( 0 ); viewport()->update(); + } } else { + ++countNested; enablePainting = false; + setUpdatesEnabled( false ); } + qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested ); } + +void AbTable::viewportPaintEvent( QPaintEvent* e ) { + qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting); + if ( enablePainting ) + QTable::viewportPaintEvent( e ); } + + void AbTable::rowHeightChanged( int row ) { if ( enablePainting ) QTable::rowHeightChanged( row ); } QString AbTable::findContactContact( const OContact &entry, int /* row */ ) |