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 @@ -114,25 +114,26 @@ void AbPickItem::setContentFromEditor( QWidget *w ) /*! \class AbTable abtable.h \brief QTable based class for showing a list of entries */ 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 ); connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), this, SLOT(itemClicked(int,int)) ); contactList.clear(); qWarning("C'tor end"); } @@ -153,72 +154,75 @@ void AbTable::init() verticalHeader()->hide(); columnVisible = true; } 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 ); found = true; break; } } 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 ); AbTableItem *ati; ati = new AbTableItem( this, QTableItem::Never, strName, strContact); contactList.insert( ati, cnt ); setItem( row, 0, ati ); ati = new AbTableItem( this, QTableItem::Never, strContact, strName); setItem( row, 1, ati ); @@ -242,79 +246,86 @@ void AbTable::columnClicked( int col ) asc = !asc; } else { lastSortCol = col; asc = TRUE; } //QMessageBox::information( this, "resort", "columnClicked" ); 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; AbTableItem *abItem; abItem = static_cast<AbTableItem*>(item( currentRow(), 0 )); if ( abItem ) { cnt = contactList[abItem]; //cnt = contactList[currentRow()]; } return cnt; } int AbTable::currentEntry_UID() { return ( 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() ); if ( key >= 'A' && key <= 'Z' ) moveTo( key ); qWarning("Received key .."); switch( e->key() ) { case Qt::Key_Space: @@ -446,35 +457,39 @@ void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) // return QMIN( pos/18, numRows()-1 ); // } 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(); QTable::show(); } void AbTable::setChoiceNames( const QStringList& list) { choicenames = list; @@ -524,35 +539,37 @@ QStringList AbTable::choiceSelection(int /*index*/) const } } */ return r; } 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 ) ) selectedRow = row; } visible++; } if ( selectedRow ) @@ -560,35 +577,51 @@ void AbTable::updateVisible() if ( !visible ) setCurrentCell( -1, 0 ); setPaintingEnabled( TRUE ); } 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 */ ) { QString value; value = ""; for ( QValueList<int>::ConstIterator it = intFields.begin(); it != intFields.end(); ++it ) { switch ( *it ) { |