summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/incsearchwidget.cpp7
-rw-r--r--kaddressbook/kabcore.cpp42
-rw-r--r--kaddressbook/viewmanager.cpp7
-rw-r--r--kaddressbook/viewmanager.h1
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp6
5 files changed, 48 insertions, 15 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp
index 94c37e7..2ffa357 100644
--- a/kaddressbook/incsearchwidget.cpp
+++ b/kaddressbook/incsearchwidget.cpp
@@ -6,134 +6,137 @@
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qtooltip.h> 26#include <qtooltip.h>
27#include <qcombobox.h> 27#include <qcombobox.h>
28 28
29#include <kdialog.h> 29#include <kdialog.h>
30#include <klineedit.h> 30#include <klineedit.h>
31#include <klocale.h> 31#include <klocale.h>
32#include <kglobal.h> 32#include <kglobal.h>
33 33
34#include "incsearchwidget.h" 34#include "incsearchwidget.h"
35 35
36IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) 36IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
37 : QWidget( parent, name ) 37 : QWidget( parent, name )
38{ 38{
39#ifndef KAB_EMBEDDED 39#ifndef KAB_EMBEDDED
40//US setCaption( i18n( "Incremental Search" ) ); 40//US setCaption( i18n( "Incremental Search" ) );
41#endif //KAB_EMBEDDED 41#endif //KAB_EMBEDDED
42 42
43 QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); 43 QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() );
44 44
45#ifdef DESKTOP_VERSION 45#ifdef DESKTOP_VERSION
46 QLabel *label = new QLabel( i18n( "Search:" ), this ); 46 QLabel *label = new QLabel( i18n( "Search:" ), this );
47 label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); 47 label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight );
48 layout->addWidget( label ); 48 layout->addWidget( label );
49#endif //KAB_EMBEDDED 49#endif //KAB_EMBEDDED
50 50
51 mSearchText = new KLineEdit( this ); 51 mSearchText = new KLineEdit( this );
52 layout->addWidget( mSearchText ); 52 layout->addWidget( mSearchText );
53// #ifdef KAB_EMBEDDED 53// #ifdef KAB_EMBEDDED
54// if (KGlobal::getOrientation() == KGlobal::Portrait) 54// if (KGlobal::getOrientation() == KGlobal::Portrait)
55// mSearchText->setMaximumWidth(30); 55// mSearchText->setMaximumWidth(30);
56// #endif //KAB_EMBEDDED 56// #endif //KAB_EMBEDDED
57 57
58 58
59 mFieldCombo = new QComboBox( false, this ); 59 mFieldCombo = new QComboBox( false, this );
60 layout->addWidget( mFieldCombo ); 60 layout->addWidget( mFieldCombo );
61 mFieldCombo->setMaximumHeight( 34 ); 61 mFieldCombo->setMaximumHeight( 34 );
62 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); 62 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) );
63 63
64// #ifndef KAB_EMBEDDED 64// #ifndef KAB_EMBEDDED
65// resize( QSize(420, 50).expandedTo( sizeHint() ) ); 65// resize( QSize(420, 50).expandedTo( sizeHint() ) );
66// #else //KAB_EMBEDDED 66// #else //KAB_EMBEDDED
67// resize( QSize(30, 10).expandedTo( sizeHint() ) ); 67// resize( QSize(30, 10).expandedTo( sizeHint() ) );
68// #endif //KAB_EMBEDDED 68// #endif //KAB_EMBEDDED
69 69
70#ifdef DESKTOP_VERSION
71 // for performance reasons, we do a search on the pda only after return is pressed
70 connect( mSearchText, SIGNAL( textChanged( const QString& ) ), 72 connect( mSearchText, SIGNAL( textChanged( const QString& ) ),
71 SLOT( announceDoSearch() ) ); 73 SLOT( announceDoSearch() ) );
72 connect( mSearchText, SIGNAL( returnPressed() ),
73 SLOT( announceDoSearch() ) );
74 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 74 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
75 SLOT( announceDoSearch() ) ); 75 SLOT( announceDoSearch() ) );
76#endif
77 connect( mSearchText, SIGNAL( returnPressed() ),
78 SLOT( announceDoSearch() ) );
76 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 79 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
77 SLOT( announceFieldChanged() ) ); 80 SLOT( announceFieldChanged() ) );
78 81
79 setFocusProxy( mSearchText ); 82 setFocusProxy( mSearchText );
80} 83}
81 84
82IncSearchWidget::~IncSearchWidget() 85IncSearchWidget::~IncSearchWidget()
83{ 86{
84 87
85} 88}
86 89
87void IncSearchWidget::announceDoSearch() 90void IncSearchWidget::announceDoSearch()
88{ 91{
89 emit doSearch( mSearchText->text() ); 92 emit doSearch( mSearchText->text() );
90} 93}
91 94
92void IncSearchWidget::announceFieldChanged() 95void IncSearchWidget::announceFieldChanged()
93{ 96{
94 emit fieldChanged(); 97 emit fieldChanged();
95} 98}
96 99
97void IncSearchWidget::setFields( const KABC::Field::List &list ) 100void IncSearchWidget::setFields( const KABC::Field::List &list )
98{ 101{
99 102
100 mFieldCombo->clear(); 103 mFieldCombo->clear();
101 mFieldCombo->insertItem( i18n( "All Fields" ) ); 104 mFieldCombo->insertItem( i18n( "All Fields" ) );
102 QFontMetrics fm ( mFieldCombo->font() ); 105 QFontMetrics fm ( mFieldCombo->font() );
103 int wid = fm.width(i18n( "All Fields" ) ); 106 int wid = fm.width(i18n( "All Fields" ) );
104 int max = wid; 107 int max = wid;
105 108
106 KABC::Field::List::ConstIterator it; 109 KABC::Field::List::ConstIterator it;
107 for ( it = list.begin(); it != list.end(); ++it ) { 110 for ( it = list.begin(); it != list.end(); ++it ) {
108 mFieldCombo->insertItem( (*it)->label() ); 111 mFieldCombo->insertItem( (*it)->label() );
109 // wid = fm.width((*it)->label() ); 112 // wid = fm.width((*it)->label() );
110 //if ( wid > max ) 113 //if ( wid > max )
111 // max = wid; 114 // max = wid;
112 } 115 }
113 116
114 mFieldList = list; 117 mFieldList = list;
115 118
116 announceDoSearch(); 119 announceDoSearch();
117 announceFieldChanged(); 120 announceFieldChanged();
118 mFieldCombo->setMaximumWidth( wid+60 ); 121 mFieldCombo->setMaximumWidth( wid+60 );
119} 122}
120 123
121KABC::Field::List IncSearchWidget::fields() const 124KABC::Field::List IncSearchWidget::fields() const
122{ 125{
123 return mFieldList; 126 return mFieldList;
124} 127}
125 128
126KABC::Field *IncSearchWidget::currentField()const 129KABC::Field *IncSearchWidget::currentField()const
127{ 130{
128 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) 131 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 )
129 return 0; // for error or 'use all fields' 132 return 0; // for error or 'use all fields'
130 else 133 else
131 return mFieldList[ mFieldCombo->currentItem() - 1 ]; 134 return mFieldList[ mFieldCombo->currentItem() - 1 ];
132} 135}
133 136
134void IncSearchWidget::setCurrentItem( int pos ) 137void IncSearchWidget::setCurrentItem( int pos )
135{ 138{
136 mFieldCombo->setCurrentItem( pos ); 139 mFieldCombo->setCurrentItem( pos );
137 announceFieldChanged(); 140 announceFieldChanged();
138} 141}
139 142
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index f0f08f4..4299ebd 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -772,155 +772,177 @@ void KABCore::pasteContacts( KABC::Addressee::List &list )
772 772
773void KABCore::setWhoAmI() 773void KABCore::setWhoAmI()
774{ 774{
775 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 775 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
776 776
777 if ( addrList.count() > 1 ) { 777 if ( addrList.count() > 1 ) {
778 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 778 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
779 return; 779 return;
780 } 780 }
781 781
782 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 782 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
783 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 783 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
784 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 784 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
785} 785}
786 786
787void KABCore::setCategories() 787void KABCore::setCategories()
788{ 788{
789 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 789 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
790 if ( !dlg.exec() ) 790 if ( !dlg.exec() )
791 return; 791 return;
792 792
793 bool merge = false; 793 bool merge = false;
794 QString msg = i18n( "Merge with existing categories?" ); 794 QString msg = i18n( "Merge with existing categories?" );
795 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 795 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
796 merge = true; 796 merge = true;
797 797
798 QStringList categories = dlg.selectedCategories(); 798 QStringList categories = dlg.selectedCategories();
799 799
800 QStringList uids = mViewManager->selectedUids(); 800 QStringList uids = mViewManager->selectedUids();
801 QStringList::Iterator it; 801 QStringList::Iterator it;
802 for ( it = uids.begin(); it != uids.end(); ++it ) { 802 for ( it = uids.begin(); it != uids.end(); ++it ) {
803 KABC::Addressee addr = mAddressBook->findByUid( *it ); 803 KABC::Addressee addr = mAddressBook->findByUid( *it );
804 if ( !addr.isEmpty() ) { 804 if ( !addr.isEmpty() ) {
805 if ( !merge ) 805 if ( !merge )
806 addr.setCategories( categories ); 806 addr.setCategories( categories );
807 else { 807 else {
808 QStringList addrCategories = addr.categories(); 808 QStringList addrCategories = addr.categories();
809 QStringList::Iterator catIt; 809 QStringList::Iterator catIt;
810 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 810 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
811 if ( !addrCategories.contains( *catIt ) ) 811 if ( !addrCategories.contains( *catIt ) )
812 addrCategories.append( *catIt ); 812 addrCategories.append( *catIt );
813 } 813 }
814 addr.setCategories( addrCategories ); 814 addr.setCategories( addrCategories );
815 } 815 }
816 816
817 mAddressBook->insertAddressee( addr ); 817 mAddressBook->insertAddressee( addr );
818 } 818 }
819 } 819 }
820 820
821 if ( uids.count() > 0 ) 821 if ( uids.count() > 0 )
822 setModified( true ); 822 setModified( true );
823} 823}
824 824
825void KABCore::setSearchFields( const KABC::Field::List &fields ) 825void KABCore::setSearchFields( const KABC::Field::List &fields )
826{ 826{
827 mIncSearchWidget->setFields( fields ); 827 mIncSearchWidget->setFields( fields );
828} 828}
829 829
830void KABCore::incrementalSearch( const QString& text ) 830void KABCore::incrementalSearch( const QString& text )
831{ 831{
832 mViewManager->setSelected( QString::null, false ); 832 mViewManager->setSelected( QString::null, false );
833 833
834 if ( !text.isEmpty() ) { 834 if ( !text.isEmpty() ) {
835 KABC::Field *field = mIncSearchWidget->currentField(); 835 KABC::Field *field = mIncSearchWidget->currentField();
836 836 QString pattern = text.lower()+"*";
837 QString pattern = text.lower(); 837 QRegExp re;
838 838 re.setWildcard(true); // most people understand these better.
839 re.setCaseSensitive(false);
840 re.setPattern( pattern );
841 QStringList foundUids;
842 if (!re.isValid())
843 return;
839#if 1 //KDE_VERSION >= 319 844#if 1 //KDE_VERSION >= 319
840 KABC::AddresseeList list( mAddressBook->allAddressees() ); 845 KABC::AddresseeList list( mAddressBook->allAddressees() );
841 if ( field ) { 846 if ( field ) {
842 list.sortByField( field ); 847 list.sortByField( field );
843 KABC::AddresseeList::Iterator it; 848 KABC::AddresseeList::Iterator it;
844 for ( it = list.begin(); it != list.end(); ++it ) { 849 for ( it = list.begin(); it != list.end(); ++it ) {
845 if ( field->value( *it ).lower().startsWith( pattern ) ) { 850
846 mViewManager->setSelected( (*it).uid(), true ); 851#if QT_VERSION >= 300
847 return; 852 if (re.search(field->value( *it ).lower()) != -1)
848 } 853#else
854 if (re.match(field->value( *it ).lower()) != -1)
855#endif
856 {
857 // if ( field->value( *it ).lower().startsWith( pattern ) ) {
858 //mViewManager->setSelected( (*it).uid(), true );
859 foundUids.append( (*it).uid() );
860 //return;
861 }
849 } 862 }
850 } else { 863 } else {
851 KABC::AddresseeList::Iterator it; 864 KABC::AddresseeList::Iterator it;
852 for ( it = list.begin(); it != list.end(); ++it ) { 865 for ( it = list.begin(); it != list.end(); ++it ) {
853 KABC::Field::List fieldList = mIncSearchWidget->fields(); 866 KABC::Field::List fieldList = mIncSearchWidget->fields();
854 KABC::Field::List::ConstIterator fieldIt; 867 KABC::Field::List::ConstIterator fieldIt;
855 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 868 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
856 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 869#if QT_VERSION >= 300
857 mViewManager->setSelected( (*it).uid(), true ); 870 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
858 return; 871#else
872 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
873#endif
874 {
875 // if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
876 //mViewManager->setSelected( (*it).uid(), true );
877 foundUids.append( (*it).uid() );
878 //return;
859 } 879 }
860 } 880 }
861 } 881 }
862 } 882 }
883 if ( foundUids.count() > 0 )
884 mViewManager->setListSelected( foundUids );
863#else 885#else
864 KABC::AddressBook::Iterator it; 886 KABC::AddressBook::Iterator it;
865 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 887 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
866 if ( field ) { 888 if ( field ) {
867 if ( field->value( *it ).lower().startsWith( pattern ) ) { 889 if ( field->value( *it ).lower().startsWith( pattern ) ) {
868 mViewManager->setSelected( (*it).uid(), true ); 890 mViewManager->setSelected( (*it).uid(), true );
869 return; 891 return;
870 } 892 }
871 } else { 893 } else {
872 KABC::Field::List fieldList = mIncSearchWidget->fields(); 894 KABC::Field::List fieldList = mIncSearchWidget->fields();
873 KABC::Field::List::ConstIterator fieldIt; 895 KABC::Field::List::ConstIterator fieldIt;
874 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 896 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
875 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 897 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
876 mViewManager->setSelected( (*it).uid(), true ); 898 mViewManager->setSelected( (*it).uid(), true );
877 return; 899 return;
878 } 900 }
879 } 901 }
880 } 902 }
881 } 903 }
882#endif 904#endif
883 } 905 }
884} 906}
885 907
886void KABCore::setModified() 908void KABCore::setModified()
887{ 909{
888 setModified( true ); 910 setModified( true );
889} 911}
890 912
891void KABCore::setModifiedWOrefresh() 913void KABCore::setModifiedWOrefresh()
892{ 914{
893 // qDebug("KABCore::setModifiedWOrefresh() "); 915 // qDebug("KABCore::setModifiedWOrefresh() ");
894 mModified = true; 916 mModified = true;
895 mActionSave->setEnabled( mModified ); 917 mActionSave->setEnabled( mModified );
896#ifdef DESKTOP_VERSION 918#ifdef DESKTOP_VERSION
897 mDetails->refreshView(); 919 mDetails->refreshView();
898#endif 920#endif
899 921
900} 922}
901void KABCore::setModified( bool modified ) 923void KABCore::setModified( bool modified )
902{ 924{
903 mModified = modified; 925 mModified = modified;
904 mActionSave->setEnabled( mModified ); 926 mActionSave->setEnabled( mModified );
905 927
906 if ( modified ) 928 if ( modified )
907 mJumpButtonBar->recreateButtons(); 929 mJumpButtonBar->recreateButtons();
908 930
909 mViewManager->refreshView(); 931 mViewManager->refreshView();
910 mDetails->refreshView(); 932 mDetails->refreshView();
911 933
912} 934}
913 935
914bool KABCore::modified() const 936bool KABCore::modified() const
915{ 937{
916 return mModified; 938 return mModified;
917} 939}
918 940
919void KABCore::contactModified( const KABC::Addressee &addr ) 941void KABCore::contactModified( const KABC::Addressee &addr )
920{ 942{
921 943
922 Command *command = 0; 944 Command *command = 0;
923 QString uid; 945 QString uid;
924 946
925 // check if it exists already 947 // check if it exists already
926 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 948 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 45c7b55..c93d51a 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -117,128 +117,135 @@ void ViewManager::saveSettings()
117 QString _oldgroup = mCore->config()->group(); 117 QString _oldgroup = mCore->config()->group();
118 118
119 QDictIterator<KAddressBookView> it( mViewDict ); 119 QDictIterator<KAddressBookView> it( mViewDict );
120 for ( it.toFirst(); it.current(); ++it ) { 120 for ( it.toFirst(); it.current(); ++it ) {
121 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 121 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
122#ifdef DESKTOP_VERSION 122#ifdef DESKTOP_VERSION
123 (*it)->writeConfig( mCore->config() ); 123 (*it)->writeConfig( mCore->config() );
124#else 124#else
125 (*it).writeConfig( mCore->config() ); 125 (*it).writeConfig( mCore->config() );
126#endif 126#endif
127 } 127 }
128 128
129 Filter::save( mCore->config(), "Filter", mFilterList ); 129 Filter::save( mCore->config(), "Filter", mFilterList );
130 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); 130 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem();
131 131
132 // write the view name list 132 // write the view name list
133 KABPrefs::instance()->mViewNames = mViewNameList; 133 KABPrefs::instance()->mViewNames = mViewNameList;
134 KABPrefs::instance()->mCurrentView = mActiveView->caption(); 134 KABPrefs::instance()->mCurrentView = mActiveView->caption();
135 135
136} 136}
137 137
138QStringList ViewManager::selectedUids() const 138QStringList ViewManager::selectedUids() const
139{ 139{
140 if ( mActiveView ) 140 if ( mActiveView )
141 return mActiveView->selectedUids(); 141 return mActiveView->selectedUids();
142 else 142 else
143 return QStringList(); 143 return QStringList();
144} 144}
145 145
146QStringList ViewManager::selectedEmails() const 146QStringList ViewManager::selectedEmails() const
147{ 147{
148 if ( mActiveView ) 148 if ( mActiveView )
149 return mActiveView->selectedEmails(); 149 return mActiveView->selectedEmails();
150 else 150 else
151 return QStringList(); 151 return QStringList();
152} 152}
153 153
154KABC::Addressee::List ViewManager::selectedAddressees() const 154KABC::Addressee::List ViewManager::selectedAddressees() const
155{ 155{
156 KABC::Addressee::List list; 156 KABC::Addressee::List list;
157 if ( mActiveView ) { 157 if ( mActiveView ) {
158 QStringList uids = mActiveView->selectedUids(); 158 QStringList uids = mActiveView->selectedUids();
159 QStringList::Iterator it; 159 QStringList::Iterator it;
160 for ( it = uids.begin(); it != uids.end(); ++it ) { 160 for ( it = uids.begin(); it != uids.end(); ++it ) {
161 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 161 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
162 if ( !addr.isEmpty() ) 162 if ( !addr.isEmpty() )
163 list.append( addr ); 163 list.append( addr );
164 } 164 }
165 } 165 }
166 166
167 return list; 167 return list;
168} 168}
169//US added another method with no parameter, since my moc compiler does not support default parameters. 169//US added another method with no parameter, since my moc compiler does not support default parameters.
170void ViewManager::setSelected() 170void ViewManager::setSelected()
171{ 171{
172 setSelected( QString::null, true ); 172 setSelected( QString::null, true );
173} 173}
174 174
175void ViewManager::setSelected( const QString &uid, bool selected ) 175void ViewManager::setSelected( const QString &uid, bool selected )
176{ 176{
177 if ( mActiveView ) 177 if ( mActiveView )
178 mActiveView->setSelected( uid, selected ); 178 mActiveView->setSelected( uid, selected );
179} 179}
180 180
181void ViewManager::setListSelected(QStringList list)
182{
183 int i, count = list.count();
184 for ( i = 0; i < count;++i )
185 setSelected( list[i], true );
186
187}
181void ViewManager::unloadViews() 188void ViewManager::unloadViews()
182{ 189{
183 mViewDict.clear(); 190 mViewDict.clear();
184 mActiveView = 0; 191 mActiveView = 0;
185} 192}
186 193
187void ViewManager::setActiveView( const QString &name ) 194void ViewManager::setActiveView( const QString &name )
188{ 195{
189 KAddressBookView *view = 0; 196 KAddressBookView *view = 0;
190 197
191 // Check that this isn't the same as the current active view 198 // Check that this isn't the same as the current active view
192 if ( mActiveView && ( mActiveView->caption() == name ) ) 199 if ( mActiveView && ( mActiveView->caption() == name ) )
193 return; 200 return;
194 201
195 // At this point we know the view that should be active is not 202 // At this point we know the view that should be active is not
196 // currently active. We will try to find the new on in the list. If 203 // currently active. We will try to find the new on in the list. If
197 // we can't find it, it means it hasn't been instantiated, so we will 204 // we can't find it, it means it hasn't been instantiated, so we will
198 // create it on demand. 205 // create it on demand.
199 206
200 view = mViewDict.find( name ); 207 view = mViewDict.find( name );
201 208
202 // Check if we found the view. If we didn't, then we need to create it 209 // Check if we found the view. If we didn't, then we need to create it
203 if ( view == 0 ) { 210 if ( view == 0 ) {
204 KConfig *config = mCore->config(); 211 KConfig *config = mCore->config();
205 212
206 KConfigGroupSaver saver( config, name ); 213 KConfigGroupSaver saver( config, name );
207 214
208 QString type = config->readEntry( "Type", "Table" ); 215 QString type = config->readEntry( "Type", "Table" );
209 216
210 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl; 217 kdDebug(5720) << "ViewManager::setActiveView: creating view - " << name << endl;
211 218
212 ViewFactory *factory = mViewFactoryDict.find( type ); 219 ViewFactory *factory = mViewFactoryDict.find( type );
213 if ( factory ) 220 if ( factory )
214 view = factory->view( mCore->addressBook(), mViewWidgetStack ); 221 view = factory->view( mCore->addressBook(), mViewWidgetStack );
215 222
216 if ( view ) { 223 if ( view ) {
217 view->setCaption( name ); 224 view->setCaption( name );
218 mViewDict.insert( name, view ); 225 mViewDict.insert( name, view );
219//US my version needs an int as second parameter to addWidget 226//US my version needs an int as second parameter to addWidget
220 mViewWidgetStack->addWidget( view, -1 ); 227 mViewWidgetStack->addWidget( view, -1 );
221 view->readConfig( config ); 228 view->readConfig( config );
222 229
223 // The manager just relays the signals 230 // The manager just relays the signals
224 connect( view, SIGNAL( selected( const QString& ) ), 231 connect( view, SIGNAL( selected( const QString& ) ),
225 SIGNAL( selected( const QString & ) ) ); 232 SIGNAL( selected( const QString & ) ) );
226 connect( view, SIGNAL( executed( const QString& ) ), 233 connect( view, SIGNAL( executed( const QString& ) ),
227 SIGNAL( executed( const QString& ) ) ); 234 SIGNAL( executed( const QString& ) ) );
228 235
229 connect( view, SIGNAL( deleteRequest( ) ), 236 connect( view, SIGNAL( deleteRequest( ) ),
230 SIGNAL( deleteRequest( ) ) ); 237 SIGNAL( deleteRequest( ) ) );
231 238
232 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) ); 239 connect( view, SIGNAL( modified() ), SIGNAL( modified() ) );
233 connect( view, SIGNAL( dropped( QDropEvent* ) ), 240 connect( view, SIGNAL( dropped( QDropEvent* ) ),
234 SLOT( dropped( QDropEvent* ) ) ); 241 SLOT( dropped( QDropEvent* ) ) );
235 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) ); 242 connect( view, SIGNAL( startDrag() ), SLOT( startDrag() ) );
236 } 243 }
237 } 244 }
238 245
239 // If we found or created the view, raise it and refresh it 246 // If we found or created the view, raise it and refresh it
240 if ( view ) { 247 if ( view ) {
241 mActiveView = view; 248 mActiveView = view;
242 mViewWidgetStack->raiseWidget( view ); 249 mViewWidgetStack->raiseWidget( view );
243 // Set the proper filter in the view. By setting the combo 250 // Set the proper filter in the view. By setting the combo
244 // box, the activated slot will be called, which will push 251 // box, the activated slot will be called, which will push
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h
index a18e87d..97c2275 100644
--- a/kaddressbook/viewmanager.h
+++ b/kaddressbook/viewmanager.h
@@ -1,128 +1,129 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef VIEWMANAGER_H 24#ifndef VIEWMANAGER_H
25#define VIEWMANAGER_H 25#define VIEWMANAGER_H
26 26
27#include <qwidget.h> 27#include <qwidget.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <kaddressbookview.h> 29#include <kaddressbookview.h>
30#include <qdict.h> 30#include <qdict.h>
31 31
32class KAction; 32class KAction;
33class KSelectAction; 33class KSelectAction;
34 34
35class KABCore; 35class KABCore;
36class QWidgetStack; 36class QWidgetStack;
37class QDropEvent; 37class QDropEvent;
38 38
39namespace KABC { class AddressBook; } 39namespace KABC { class AddressBook; }
40 40
41/** 41/**
42 The view manager manages the views and everything related to them. The 42 The view manager manages the views and everything related to them. The
43 manager will load the views at startup and display a view when told to 43 manager will load the views at startup and display a view when told to
44 make one active. 44 make one active.
45 45
46 The view manager will also create and manage all dialogs directly related to 46 The view manager will also create and manage all dialogs directly related to
47 views (ie: AddView, ConfigureView, DeleteView, etc). 47 views (ie: AddView, ConfigureView, DeleteView, etc).
48 */ 48 */
49class ViewManager : public QWidget 49class ViewManager : public QWidget
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 ViewManager( KABCore *core, QWidget *parent, const char *name = 0 ); 53 ViewManager( KABCore *core, QWidget *parent, const char *name = 0 );
54 ~ViewManager(); 54 ~ViewManager();
55 55
56 void restoreSettings(); 56 void restoreSettings();
57 void saveSettings(); 57 void saveSettings();
58 58
59 void unloadViews(); 59 void unloadViews();
60 KSelectAction * getFilterAction() { return mActionSelectFilter; } 60 KSelectAction * getFilterAction() { return mActionSelectFilter; }
61 61
62 QStringList selectedUids() const; 62 QStringList selectedUids() const;
63 QStringList selectedEmails() const; 63 QStringList selectedEmails() const;
64 KABC::Addressee::List selectedAddressees() const; 64 KABC::Addressee::List selectedAddressees() const;
65 void setListSelected(QStringList);
65 66
66 public slots: 67 public slots:
67 68
68//US void setSelected( const QString &uid = QString::null, bool selected = true ); 69//US void setSelected( const QString &uid = QString::null, bool selected = true );
69 void setSelected( const QString &uid, bool); 70 void setSelected( const QString &uid, bool);
70//US added another method with no parameter, since my moc compiler does not support default parameters. 71//US added another method with no parameter, since my moc compiler does not support default parameters.
71 void setSelected(); 72 void setSelected();
72 73
73 74
74 75
75//US added another method with no parameter, since my moc compiler does not support default parameters. 76//US added another method with no parameter, since my moc compiler does not support default parameters.
76 void refreshView(); 77 void refreshView();
77 void refreshView( const QString &uid); 78 void refreshView( const QString &uid);
78 79
79 void editView(); 80 void editView();
80 void deleteView(); 81 void deleteView();
81 void addView(); 82 void addView();
82 83
83 protected slots: 84 protected slots:
84 /** 85 /**
85 Called whenever the user drops something in the active view. 86 Called whenever the user drops something in the active view.
86 This method will try to decode what was dropped, and if it was 87 This method will try to decode what was dropped, and if it was
87 a valid addressee, add it to the addressbook. 88 a valid addressee, add it to the addressbook.
88 */ 89 */
89 void dropped( QDropEvent* ); 90 void dropped( QDropEvent* );
90 91
91 /** 92 /**
92 Called whenever the user attempts to start a drag in the view. 93 Called whenever the user attempts to start a drag in the view.
93 This method will convert all the selected addressees into text (vcard) 94 This method will convert all the selected addressees into text (vcard)
94 and create a drag object. 95 and create a drag object.
95 */ 96 */
96 void startDrag(); 97 void startDrag();
97 98
98 signals: 99 signals:
99 /** 100 /**
100 Emitted whenever the user selects an entry in the view. 101 Emitted whenever the user selects an entry in the view.
101 */ 102 */
102 void selected( const QString &uid ); 103 void selected( const QString &uid );
103 void deleteRequest( ); 104 void deleteRequest( );
104 105
105 /** 106 /**
106 Emitted whenever the user activates an entry in the view. 107 Emitted whenever the user activates an entry in the view.
107 */ 108 */
108 void executed( const QString &uid ); 109 void executed( const QString &uid );
109 110
110 /** 111 /**
111 Emitted whenever the address book is modified in some way. 112 Emitted whenever the address book is modified in some way.
112 */ 113 */
113 void modified(); 114 void modified();
114 115
115 /** 116 /**
116 Emitted whenever a url is dragged on a view. 117 Emitted whenever a url is dragged on a view.
117 */ 118 */
118 void urlDropped( const KURL& ); 119 void urlDropped( const KURL& );
119 120
120 private slots: 121 private slots:
121 void setActiveView( const QString &name ); 122 void setActiveView( const QString &name );
122 void setActiveFilter( int index ); 123 void setActiveFilter( int index );
123 void configureFilters(); 124 void configureFilters();
124 125
125 private: 126 private:
126 void createViewFactories(); 127 void createViewFactories();
127 QStringList filterNames() const; 128 QStringList filterNames() const;
128 int filterPosition( const QString &name ) const; 129 int filterPosition( const QString &name ) const;
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 66a3f0b..0847b64 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -61,176 +61,176 @@ void KAddressBookTableView::reconstructListView()
61 this, SLOT(addresseeExecuted(QListViewItem*))); 61 this, SLOT(addresseeExecuted(QListViewItem*)));
62 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 62 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
63 this, SLOT(addresseeExecuted(QListViewItem*))); 63 this, SLOT(addresseeExecuted(QListViewItem*)));
64 disconnect(mListView, SIGNAL(startAddresseeDrag()), this, 64 disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
65 SIGNAL(startDrag())); 65 SIGNAL(startDrag()));
66 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), 66 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)),
67 this, SLOT(addresseeExecuted(QListViewItem*))); 67 this, SLOT(addresseeExecuted(QListViewItem*)));
68 68
69 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 69 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
70 SIGNAL(dropped(QDropEvent*))); 70 SIGNAL(dropped(QDropEvent*)));
71 delete mListView; 71 delete mListView;
72 } 72 }
73 73
74 mListView = new ContactListView( this, addressBook(), viewWidget() ); 74 mListView = new ContactListView( this, addressBook(), viewWidget() );
75 75
76 // Add the columns 76 // Add the columns
77 KABC::Field::List fieldList = fields(); 77 KABC::Field::List fieldList = fields();
78 KABC::Field::List::ConstIterator it; 78 KABC::Field::List::ConstIterator it;
79 79
80 int c = 0; 80 int c = 0;
81 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 81 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
82 mListView->addColumn( (*it)->label() ); 82 mListView->addColumn( (*it)->label() );
83 mListView->setColumnWidthMode(c++, QListView::Manual); 83 mListView->setColumnWidthMode(c++, QListView::Manual);
84//US 84//US
85 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 85 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
86 } 86 }
87 87
88 connect(mListView, SIGNAL(selectionChanged()), 88 connect(mListView, SIGNAL(selectionChanged()),
89 this, SLOT(addresseeSelected())); 89 this, SLOT(addresseeSelected()));
90 connect(mListView, SIGNAL(startAddresseeDrag()), this, 90 connect(mListView, SIGNAL(startAddresseeDrag()), this,
91 SIGNAL(startDrag())); 91 SIGNAL(startDrag()));
92 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 92 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
93 SIGNAL(dropped(QDropEvent*))); 93 SIGNAL(dropped(QDropEvent*)));
94 94
95 if (KABPrefs::instance()->mHonorSingleClick) 95 if (KABPrefs::instance()->mHonorSingleClick)
96 connect(mListView, SIGNAL(executed(QListViewItem*)), 96 connect(mListView, SIGNAL(executed(QListViewItem*)),
97 this, SLOT(addresseeExecuted(QListViewItem*))); 97 this, SLOT(addresseeExecuted(QListViewItem*)));
98 else 98 else
99 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 99 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
100 this, SLOT(addresseeExecuted(QListViewItem*))); 100 this, SLOT(addresseeExecuted(QListViewItem*)));
101 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 101 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
102 this, SLOT(addresseeExecuted(QListViewItem*))); 102 this, SLOT(addresseeExecuted(QListViewItem*)));
103 connect(mListView, SIGNAL(signalDelete()), 103 connect(mListView, SIGNAL(signalDelete()),
104 this, SLOT(addresseeDeleted())); 104 this, SLOT(addresseeDeleted()));
105 105
106//US performceimprovement. Refresh is done from the outside 106//US performceimprovement. Refresh is done from the outside
107//US refresh(); 107//US refresh();
108 108
109 mListView->setSorting( 0, true ); 109 mListView->setSorting( 0, true );
110 mainLayout->addWidget( mListView ); 110 mainLayout->addWidget( mListView );
111 mainLayout->activate(); 111 mainLayout->activate();
112 mListView->show(); 112 mListView->show();
113} 113}
114 114
115void KAddressBookTableView::writeConfig(KConfig *config) 115void KAddressBookTableView::writeConfig(KConfig *config)
116{ 116{
117 KAddressBookView::writeConfig(config); 117 KAddressBookView::writeConfig(config);
118 118
119 mListView->saveLayout(config, config->group()); 119 mListView->saveLayout(config, config->group());
120} 120}
121 121
122void KAddressBookTableView::readConfig(KConfig *config) 122void KAddressBookTableView::readConfig(KConfig *config)
123{ 123{
124 KAddressBookView::readConfig( config ); 124 KAddressBookView::readConfig( config );
125 // The config could have changed the fields, so we need to reconstruct
126 // the listview.
127 reconstructListView();
125 128
126 // costum colors? 129 // costum colors?
127 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 130 if ( config->readBoolEntry( "EnableCustomColors", false ) )
128 { 131 {
129 QPalette p( mListView->palette() ); 132 QPalette p( mListView->palette() );
130 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 133 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
131 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 134 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
132 c = p.color(QPalette::Normal, QColorGroup::Text ); 135 c = p.color(QPalette::Normal, QColorGroup::Text );
133 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 136 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
134 c = p.color(QPalette::Normal, QColorGroup::Button ); 137 c = p.color(QPalette::Normal, QColorGroup::Button );
135 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 138 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
136 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 139 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
137 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 140 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
138 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 141 c = p.color(QPalette::Normal, QColorGroup::Highlight );
139 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 142 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
140 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 143 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
141 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 144 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
142 c = p.color(QPalette::Normal, QColorGroup::Base ); 145 c = p.color(QPalette::Normal, QColorGroup::Base );
143 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "AlternatingBackgroundColor", &c ) ); 146 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "AlternatingBackgroundColor", &c ) );
144 mListView->viewport()->setPalette( p ); 147 mListView->viewport()->setPalette( p );
145 } 148 }
146 else 149 else
147 { 150 {
148 // needed if turned off during a session. 151 // needed if turned off during a session.
149 mListView->viewport()->setPalette( mListView->palette() ); 152 mListView->viewport()->setPalette( mListView->palette() );
150 } 153 }
151 154
152 //custom fonts? 155 //custom fonts?
153 QFont f( font() ); 156 QFont f( font() );
154 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 157 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
155 { 158 {
156 // mListView->setFont( config->readFontEntry( "TextFont", &f) ); 159 // mListView->setFont( config->readFontEntry( "TextFont", &f) );
157 f.setBold( true ); 160 f.setBold( true );
158 // mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 161 // mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
159 } 162 }
160 else 163 else
161 { 164 {
162 // mListView->setFont( f ); 165 // mListView->setFont( f );
163 f.setBold( true ); 166 f.setBold( true );
164 // mListView->setHeaderFont( f ); 167 // mListView->setHeaderFont( f );
165 } 168 }
166 169
167 170
168 171
169 172
170 // The config could have changed the fields, so we need to reconstruct
171 // the listview.
172 reconstructListView();
173 173
174 // Set the list view options 174 // Set the list view options
175 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", 175 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",
176 true)); 176 true));
177 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); 177 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
178 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); 178 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));
179 179
180 if (config->readBoolEntry("Background", false)) 180 if (config->readBoolEntry("Background", false))
181 mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); 181 mListView->setBackgroundPixmap(config->readEntry("BackgroundName"));
182 182
183 // Restore the layout of the listview 183 // Restore the layout of the listview
184 mListView->restoreLayout(config, config->group()); 184 mListView->restoreLayout(config, config->group());
185} 185}
186 186
187void KAddressBookTableView::refresh(QString uid) 187void KAddressBookTableView::refresh(QString uid)
188{ 188{
189 // For now just repopulate. In reality this method should 189 // For now just repopulate. In reality this method should
190 // check the value of uid, and if valid iterate through 190 // check the value of uid, and if valid iterate through
191 // the listview to find the entry, then tell it to refresh. 191 // the listview to find the entry, then tell it to refresh.
192 192
193 if (uid.isNull()) { 193 if (uid.isNull()) {
194 // Clear the list view 194 // Clear the list view
195 QString currentUID, nextUID; 195 QString currentUID, nextUID;
196#ifndef KAB_EMBEDDED 196#ifndef KAB_EMBEDDED
197 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() ); 197 ContactListViewItem *currentItem = dynamic_cast<ContactListViewItem*>( mListView->currentItem() );
198#else //KAB_EMBEDDED 198#else //KAB_EMBEDDED
199 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() ); 199 ContactListViewItem *currentItem = (ContactListViewItem*)( mListView->currentItem() );
200#endif //KAB_EMBEDDED 200#endif //KAB_EMBEDDED
201 201
202 if ( currentItem ) { 202 if ( currentItem ) {
203#ifndef KAB_EMBEDDED 203#ifndef KAB_EMBEDDED
204 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() ); 204 ContactListViewItem *nextItem = dynamic_cast<ContactListViewItem*>( currentItem->itemBelow() );
205#else //KAB_EMBEDDED 205#else //KAB_EMBEDDED
206 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() ); 206 ContactListViewItem *nextItem = (ContactListViewItem*)( currentItem->itemBelow() );
207#endif //KAB_EMBEDDED 207#endif //KAB_EMBEDDED
208 if ( nextItem ) 208 if ( nextItem )
209 nextUID = nextItem->addressee().uid(); 209 nextUID = nextItem->addressee().uid();
210 currentUID = currentItem->addressee().uid(); 210 currentUID = currentItem->addressee().uid();
211 } 211 }
212 212
213 mListView->clear(); 213 mListView->clear();
214 214
215 currentItem = 0; 215 currentItem = 0;
216 KABC::Addressee::List addresseeList = addressees(); 216 KABC::Addressee::List addresseeList = addressees();
217 KABC::Addressee::List::Iterator it; 217 KABC::Addressee::List::Iterator it;
218 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 218 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
219 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 219 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
220 if ( (*it).uid() == currentUID ) 220 if ( (*it).uid() == currentUID )
221 currentItem = item; 221 currentItem = item;
222 else if ( (*it).uid() == nextUID && !currentItem ) 222 else if ( (*it).uid() == nextUID && !currentItem )
223 currentItem = item; 223 currentItem = item;
224 } 224 }
225 225
226 // Sometimes the background pixmap gets messed up when we add lots 226 // Sometimes the background pixmap gets messed up when we add lots
227 // of items. 227 // of items.
228 mListView->repaint(); 228 mListView->repaint();
229 229
230 if ( currentItem ) { 230 if ( currentItem ) {
231 mListView->setCurrentItem( currentItem ); 231 mListView->setCurrentItem( currentItem );
232 mListView->ensureItemVisible( currentItem ); 232 mListView->ensureItemVisible( currentItem );
233 } 233 }
234 } else { 234 } else {
235 // Only need to update on entry. Iterate through and try to find it 235 // Only need to update on entry. Iterate through and try to find it
236 ContactListViewItem *ceItem; 236 ContactListViewItem *ceItem;