author | ulf69 <ulf69> | 2004-09-03 01:34:57 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-03 01:34:57 (UTC) |
commit | f6b72fd55671131cd81a3357940c9337ea5d7494 (patch) (side-by-side diff) | |
tree | 1075a46b4a7e24696eb7945e5f76bef552d75d88 | |
parent | 7d5e6ab1868753f1f6a3b0831ba2e3c9d6ba411c (diff) | |
download | kdepimpi-f6b72fd55671131cd81a3357940c9337ea5d7494.zip kdepimpi-f6b72fd55671131cd81a3357940c9337ea5d7494.tar.gz kdepimpi-f6b72fd55671131cd81a3357940c9337ea5d7494.tar.bz2 |
sourceforge 1014886: first change to allow customized tableview
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 8d2203e..66a3f0b 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp @@ -78,96 +78,140 @@ void KAddressBookTableView::reconstructListView() KABC::Field::List::ConstIterator it; int c = 0; for( it = fieldList.begin(); it != fieldList.end(); ++it ) { mListView->addColumn( (*it)->label() ); mListView->setColumnWidthMode(c++, QListView::Manual); //US // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); } connect(mListView, SIGNAL(selectionChanged()), this, SLOT(addresseeSelected())); connect(mListView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, SIGNAL(dropped(QDropEvent*))); if (KABPrefs::instance()->mHonorSingleClick) connect(mListView, SIGNAL(executed(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); else connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); connect(mListView, SIGNAL(returnPressed(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); connect(mListView, SIGNAL(signalDelete()), this, SLOT(addresseeDeleted())); //US performceimprovement. Refresh is done from the outside //US refresh(); mListView->setSorting( 0, true ); mainLayout->addWidget( mListView ); mainLayout->activate(); mListView->show(); } void KAddressBookTableView::writeConfig(KConfig *config) { KAddressBookView::writeConfig(config); mListView->saveLayout(config, config->group()); } void KAddressBookTableView::readConfig(KConfig *config) { KAddressBookView::readConfig( config ); + // costum colors? + if ( config->readBoolEntry( "EnableCustomColors", false ) ) + { + QPalette p( mListView->palette() ); + QColor c = p.color(QPalette::Normal, QColorGroup::Base ); + p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); + c = p.color(QPalette::Normal, QColorGroup::Text ); + p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); + c = p.color(QPalette::Normal, QColorGroup::Button ); + p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); + c = p.color(QPalette::Normal, QColorGroup::ButtonText ); + p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); + c = p.color(QPalette::Normal, QColorGroup::Highlight ); + p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); + c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); + p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); + c = p.color(QPalette::Normal, QColorGroup::Base ); + p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "AlternatingBackgroundColor", &c ) ); + mListView->viewport()->setPalette( p ); + } + else + { + // needed if turned off during a session. + mListView->viewport()->setPalette( mListView->palette() ); + } + + //custom fonts? + QFont f( font() ); + if ( config->readBoolEntry( "EnableCustomFonts", false ) ) + { + // mListView->setFont( config->readFontEntry( "TextFont", &f) ); + f.setBold( true ); + // mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); + } + else + { + // mListView->setFont( f ); + f.setBold( true ); + // mListView->setHeaderFont( f ); + } + + + + // The config could have changed the fields, so we need to reconstruct // the listview. reconstructListView(); // Set the list view options mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", true)); mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); if (config->readBoolEntry("Background", false)) mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); // Restore the layout of the listview mListView->restoreLayout(config, config->group()); } void KAddressBookTableView::refresh(QString uid) { // For now just repopulate. In reality this method should // check the value of uid, and if valid iterate through // the listview to find the entry, then tell it to refresh. if (uid.isNull()) { // Clear the list view QString currentUID, nextUID; #ifndef KAB_EMBEDDED ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); #else //KAB_EMBEDDED ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); #endif //KAB_EMBEDDED if ( currentItem ) { #ifndef KAB_EMBEDDED ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); #else //KAB_EMBEDDED ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); #endif //KAB_EMBEDDED if ( nextItem ) nextUID = nextItem->addressee().uid(); currentUID = currentItem->addressee().uid(); } mListView->clear(); currentItem = 0; KABC::Addressee::List addresseeList = addressees(); KABC::Addressee::List::Iterator it; |