-rw-r--r-- | kaddressbook/incsearchwidget.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 42 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/viewmanager.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 6 |
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 | |||
@@ -38,70 +38,73 @@ IncSearchWidget::IncSearchWidget( QWidget *parent, const char *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 | ||
82 | IncSearchWidget::~IncSearchWidget() | 85 | IncSearchWidget::~IncSearchWidget() |
83 | { | 86 | { |
84 | 87 | ||
85 | } | 88 | } |
86 | 89 | ||
87 | void IncSearchWidget::announceDoSearch() | 90 | void IncSearchWidget::announceDoSearch() |
88 | { | 91 | { |
89 | emit doSearch( mSearchText->text() ); | 92 | emit doSearch( mSearchText->text() ); |
90 | } | 93 | } |
91 | 94 | ||
92 | void IncSearchWidget::announceFieldChanged() | 95 | void IncSearchWidget::announceFieldChanged() |
93 | { | 96 | { |
94 | emit fieldChanged(); | 97 | emit fieldChanged(); |
95 | } | 98 | } |
96 | 99 | ||
97 | void IncSearchWidget::setFields( const KABC::Field::List &list ) | 100 | void 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 ) { |
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index f0f08f4..4299ebd 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -804,91 +804,113 @@ void KABCore::setCategories() | |||
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 | ||
825 | void KABCore::setSearchFields( const KABC::Field::List &fields ) | 825 | void KABCore::setSearchFields( const KABC::Field::List &fields ) |
826 | { | 826 | { |
827 | mIncSearchWidget->setFields( fields ); | 827 | mIncSearchWidget->setFields( fields ); |
828 | } | 828 | } |
829 | 829 | ||
830 | void KABCore::incrementalSearch( const QString& text ) | 830 | void 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 | ||
886 | void KABCore::setModified() | 908 | void KABCore::setModified() |
887 | { | 909 | { |
888 | setModified( true ); | 910 | setModified( true ); |
889 | } | 911 | } |
890 | 912 | ||
891 | void KABCore::setModifiedWOrefresh() | 913 | void KABCore::setModifiedWOrefresh() |
892 | { | 914 | { |
893 | // qDebug("KABCore::setModifiedWOrefresh() "); | 915 | // qDebug("KABCore::setModifiedWOrefresh() "); |
894 | mModified = true; | 916 | mModified = true; |
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index 45c7b55..c93d51a 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -149,64 +149,71 @@ QStringList ViewManager::selectedEmails() const | |||
149 | return mActiveView->selectedEmails(); | 149 | return mActiveView->selectedEmails(); |
150 | else | 150 | else |
151 | return QStringList(); | 151 | return QStringList(); |
152 | } | 152 | } |
153 | 153 | ||
154 | KABC::Addressee::List ViewManager::selectedAddressees() const | 154 | KABC::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. |
170 | void ViewManager::setSelected() | 170 | void ViewManager::setSelected() |
171 | { | 171 | { |
172 | setSelected( QString::null, true ); | 172 | setSelected( QString::null, true ); |
173 | } | 173 | } |
174 | 174 | ||
175 | void ViewManager::setSelected( const QString &uid, bool selected ) | 175 | void 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 | ||
181 | void 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 | } | ||
181 | void ViewManager::unloadViews() | 188 | void ViewManager::unloadViews() |
182 | { | 189 | { |
183 | mViewDict.clear(); | 190 | mViewDict.clear(); |
184 | mActiveView = 0; | 191 | mActiveView = 0; |
185 | } | 192 | } |
186 | 193 | ||
187 | void ViewManager::setActiveView( const QString &name ) | 194 | void 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 ); |
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h index a18e87d..97c2275 100644 --- a/kaddressbook/viewmanager.h +++ b/kaddressbook/viewmanager.h | |||
@@ -33,64 +33,65 @@ class KAction; | |||
33 | class KSelectAction; | 33 | class KSelectAction; |
34 | 34 | ||
35 | class KABCore; | 35 | class KABCore; |
36 | class QWidgetStack; | 36 | class QWidgetStack; |
37 | class QDropEvent; | 37 | class QDropEvent; |
38 | 38 | ||
39 | namespace KABC { class AddressBook; } | 39 | namespace 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 | */ |
49 | class ViewManager : public QWidget | 49 | class 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(); |
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 | |||
@@ -93,112 +93,112 @@ void KAddressBookTableView::reconstructListView() | |||
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 | ||
115 | void KAddressBookTableView::writeConfig(KConfig *config) | 115 | void 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 | ||
122 | void KAddressBookTableView::readConfig(KConfig *config) | 122 | void 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 | ||
187 | void KAddressBookTableView::refresh(QString uid) | 187 | void 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() ); |