summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views/kaddressbooktableview.cpp
Side-by-side diff
Diffstat (limited to 'kaddressbook/views/kaddressbooktableview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 1dc9198..fbfddba 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -184,192 +184,194 @@ void KAddressBookTableView::readConfig(KConfig *config)
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 ) );
#ifndef KAB_EMBEDDED
c = KGlobalSettings::alternateBackgroundColor();
#else //KAB_EMBEDDED
c = QColor(240, 240, 240);
#endif //KAB_EMBEDDED
c = config->readColorEntry ("AlternatingBackgroundColor", &c);
mListView->setAlternateColor(c);
//US mListView->viewport()->setPalette( p );
mListView->setPalette( p );
}
else
{
// needed if turned off during a session.
//US mListView->viewport()->setPalette( mListView->palette() );
mListView->setPalette( mListView->palette() );
}
//custom fonts?
QFont f( font() );
if ( config->readBoolEntry( "EnableCustomFonts", false ) )
{
mListView->setFont( config->readFontEntry( "TextFont", &f) );
f.setBold( true );
//US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) );
}
else
{
mListView->setFont( f );
f.setBold( true );
//US mListView->setHeaderFont( f );
mListView->header()->setFont( f );
}
// 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;
for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
+ if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
+ continue;
ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
if ( (*it).uid() == currentUID )
currentItem = item;
else if ( (*it).uid() == nextUID && !currentItem )
currentItem = item;
}
// Sometimes the background pixmap gets messed up when we add lots
// of items.
mListView->repaint();
if ( currentItem ) {
mListView->setCurrentItem( currentItem );
mListView->ensureItemVisible( currentItem );
}
} else {
// Only need to update on entry. Iterate through and try to find it
ContactListViewItem *ceItem;
QListViewItemIterator it( mListView );
while ( it.current() ) {
#ifndef KAB_EMBEDDED
ceItem = dynamic_cast<ContactListViewItem*>( it.current() );
#else //KAB_EMBEDDED
ceItem = (ContactListViewItem*)( it.current() );
#endif //KAB_EMBEDDED
if ( ceItem && ceItem->addressee().uid() == uid ) {
ceItem->refresh();
return;
}
++it;
}
refresh( QString::null );
}
}
QStringList KAddressBookTableView::selectedUids()
{
QStringList uidList;
QListViewItem *item;
ContactListViewItem *ceItem;
for(item = mListView->firstChild(); item; item = item->itemBelow())
{
if (mListView->isSelected( item ))
{
#ifndef KAB_EMBEDDED
ceItem = dynamic_cast<ContactListViewItem*>(item);
#else //KAB_EMBEDDED
ceItem = (ContactListViewItem*)(item);
#endif //KAB_EMBEDDED
if (ceItem != 0L)
uidList << ceItem->addressee().uid();
}
}
if ( uidList.count() == 0 )
if ( mListView->currentItem() ) {
ceItem = (ContactListViewItem*)(mListView->currentItem()) ;
uidList << ceItem->addressee().uid();
}
return uidList;
}
void KAddressBookTableView::setSelected(QString uid, bool selected)
{
QListViewItem *item;
ContactListViewItem *ceItem;
if (uid.isNull())
{
mListView->selectAll(selected);
}
else
{
for(item = mListView->firstChild(); item; item = item->itemBelow())
{
#ifndef KAB_EMBEDDED
ceItem = dynamic_cast<ContactListViewItem*>(item);
#else //KAB_EMBEDDED
ceItem = (ContactListViewItem*)(item);
#endif //KAB_EMBEDDED
if ((ceItem != 0L) && (ceItem->addressee().uid() == uid))
{
mListView->setSelected(item, selected);
if (selected)
mListView->ensureItemVisible(item);
}
}
}
}