-rw-r--r-- | kaddressbook/kabcore.cpp | 75 | ||||
-rw-r--r-- | kaddressbook/kaddressbookview.h | 1 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 5 | ||||
-rw-r--r-- | kaddressbook/viewmanager.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 53 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.h | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 47 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 49 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.h | 1 |
10 files changed, 159 insertions, 76 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 1a1bcff..2a2f904 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -851,76 +851,3 @@ void KABCore::incrementalSearch( const QString& text ) | |||
851 | { | 851 | { |
852 | mViewManager->setSelected( QString::null, false ); | 852 | mViewManager->doSearch( text, mIncSearchWidget->currentField() ); |
853 | |||
854 | if ( !text.isEmpty() ) { | ||
855 | KABC::Field *field = mIncSearchWidget->currentField(); | ||
856 | QString pattern = text.lower()+"*"; | ||
857 | QRegExp re; | ||
858 | re.setWildcard(true); // most people understand these better. | ||
859 | re.setCaseSensitive(false); | ||
860 | re.setPattern( pattern ); | ||
861 | QStringList foundUids; | ||
862 | if (!re.isValid()) | ||
863 | return; | ||
864 | #if 1 //KDE_VERSION >= 319 | ||
865 | KABC::AddresseeList list( mAddressBook->allAddressees() ); | ||
866 | if ( field ) { | ||
867 | list.sortByField( field ); | ||
868 | KABC::AddresseeList::Iterator it; | ||
869 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
870 | |||
871 | #if QT_VERSION >= 300 | ||
872 | if (re.search(field->value( *it ).lower()) != -1) | ||
873 | #else | ||
874 | if (re.match(field->value( *it ).lower()) != -1) | ||
875 | #endif | ||
876 | { | ||
877 | // if ( field->value( *it ).lower().startsWith( pattern ) ) { | ||
878 | //mViewManager->setSelected( (*it).uid(), true ); | ||
879 | foundUids.append( (*it).uid() ); | ||
880 | //return; | ||
881 | } | ||
882 | } | ||
883 | } else { | ||
884 | KABC::AddresseeList::Iterator it; | ||
885 | for ( it = list.begin(); it != list.end(); ++it ) { | ||
886 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | ||
887 | KABC::Field::List::ConstIterator fieldIt; | ||
888 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
889 | #if QT_VERSION >= 300 | ||
890 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | ||
891 | #else | ||
892 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | ||
893 | #endif | ||
894 | { | ||
895 | // if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | ||
896 | //mViewManager->setSelected( (*it).uid(), true ); | ||
897 | foundUids.append( (*it).uid() ); | ||
898 | //return; | ||
899 | } | ||
900 | } | ||
901 | } | ||
902 | } | ||
903 | if ( foundUids.count() > 0 ) | ||
904 | mViewManager->setListSelected( foundUids ); | ||
905 | #else | ||
906 | KABC::AddressBook::Iterator it; | ||
907 | for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | ||
908 | if ( field ) { | ||
909 | if ( field->value( *it ).lower().startsWith( pattern ) ) { | ||
910 | mViewManager->setSelected( (*it).uid(), true ); | ||
911 | return; | ||
912 | } | ||
913 | } else { | ||
914 | KABC::Field::List fieldList = mIncSearchWidget->fields(); | ||
915 | KABC::Field::List::ConstIterator fieldIt; | ||
916 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
917 | if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { | ||
918 | mViewManager->setSelected( (*it).uid(), true ); | ||
919 | return; | ||
920 | } | ||
921 | } | ||
922 | } | ||
923 | } | ||
924 | #endif | ||
925 | } | ||
926 | } | 853 | } |
diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h index 7457080..17106e8 100644 --- a/kaddressbook/kaddressbookview.h +++ b/kaddressbook/kaddressbookview.h | |||
@@ -66,2 +66,3 @@ class KAddressBookView : public QWidget | |||
66 | virtual QStringList selectedUids() = 0; | 66 | virtual QStringList selectedUids() = 0; |
67 | virtual void doSearch( const QString& s ,KABC::Field *field ) = 0; | ||
67 | 68 | ||
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index c93d51a..c6baeac 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp | |||
@@ -548,3 +548,8 @@ qDebug("ViewManager::startDrag() has to be changed!!" ); | |||
548 | } | 548 | } |
549 | void ViewManager::doSearch( const QString& s,KABC::Field *field ) | ||
550 | { | ||
551 | if ( mActiveView ) | ||
552 | mActiveView->doSearch( s, field ); | ||
549 | 553 | ||
554 | } | ||
550 | void ViewManager::setActiveFilter( int index ) | 555 | void ViewManager::setActiveFilter( int index ) |
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h index 97c2275..6def6b6 100644 --- a/kaddressbook/viewmanager.h +++ b/kaddressbook/viewmanager.h | |||
@@ -57,2 +57,3 @@ class ViewManager : public QWidget | |||
57 | void saveSettings(); | 57 | void saveSettings(); |
58 | void doSearch( const QString& s ,KABC::Field *field ); | ||
58 | 59 | ||
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 239429f..49c0691 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp | |||
@@ -117,2 +117,3 @@ AddresseeCardView::~AddresseeCardView() | |||
117 | 117 | ||
118 | |||
118 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) | 119 | void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e) |
@@ -242,3 +243,53 @@ void KAddressBookCardView::writeConfig( KConfig *config ) | |||
242 | } | 243 | } |
243 | 244 | void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) | |
245 | { | ||
246 | mCardView->clear(); | ||
247 | if ( s.isEmpty() || s == "*" ) { | ||
248 | refresh(); | ||
249 | return; | ||
250 | } | ||
251 | QString pattern = s.lower()+"*"; | ||
252 | QRegExp re; | ||
253 | re.setWildcard(true); // most people understand these better. | ||
254 | re.setCaseSensitive(false); | ||
255 | re.setPattern( pattern ); | ||
256 | if (!re.isValid()) | ||
257 | return; | ||
258 | mCardView->viewport()->setUpdatesEnabled( false ); | ||
259 | KABC::Addressee::List addresseeList = addressees(); | ||
260 | KABC::Addressee::List::Iterator it; | ||
261 | if ( field ) { | ||
262 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
263 | #if QT_VERSION >= 300 | ||
264 | if (re.search(field->value( *it ).lower()) != -1) | ||
265 | #else | ||
266 | if (re.match(field->value( *it ).lower()) != -1) | ||
267 | #endif | ||
268 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | ||
269 | addressBook(), *it, mCardView); | ||
270 | |||
271 | } | ||
272 | } else { | ||
273 | KABC::Field::List fieldList = fields(); | ||
274 | KABC::Field::List::ConstIterator fieldIt; | ||
275 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
276 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
277 | #if QT_VERSION >= 300 | ||
278 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | ||
279 | #else | ||
280 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | ||
281 | #endif | ||
282 | { | ||
283 | new AddresseeCardViewItem(fields(), mShowEmptyFields, | ||
284 | addressBook(), *it, mCardView); | ||
285 | continue; | ||
286 | } | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | mCardView->viewport()->setUpdatesEnabled( true ); | ||
291 | mCardView->viewport()->update(); | ||
292 | // by default nothing is selected | ||
293 | emit selected(QString::null); | ||
294 | } | ||
244 | QStringList KAddressBookCardView::selectedUids() | 295 | QStringList KAddressBookCardView::selectedUids() |
diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h index cd70371..b8efb01 100644 --- a/kaddressbook/views/kaddressbookcardview.h +++ b/kaddressbook/views/kaddressbookcardview.h | |||
@@ -56,3 +56,3 @@ class KAddressBookCardView : public KAddressBookView | |||
56 | virtual ~KAddressBookCardView(); | 56 | virtual ~KAddressBookCardView(); |
57 | 57 | void doSearch( const QString& s,KABC::Field *field ); | |
58 | virtual QStringList selectedUids(); | 58 | virtual QStringList selectedUids(); |
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp index 50ff285..78d63b0 100644 --- a/kaddressbook/views/kaddressbookiconview.cpp +++ b/kaddressbook/views/kaddressbookiconview.cpp | |||
@@ -98,2 +98,3 @@ AddresseeIconView::~AddresseeIconView() | |||
98 | 98 | ||
99 | |||
99 | void AddresseeIconView::itemDropped(QDropEvent *e, | 100 | void AddresseeIconView::itemDropped(QDropEvent *e, |
@@ -234,3 +235,49 @@ void KAddressBookIconView::readConfig(KConfig *config) | |||
234 | } | 235 | } |
236 | void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) | ||
237 | { | ||
238 | mIconView->clear(); | ||
239 | mIconList.clear(); | ||
240 | if ( s.isEmpty() || s == "*" ) { | ||
241 | refresh(); | ||
242 | return; | ||
243 | } | ||
244 | QString pattern = s.lower()+"*"; | ||
245 | QRegExp re; | ||
246 | re.setWildcard(true); // most people understand these better. | ||
247 | re.setCaseSensitive(false); | ||
248 | re.setPattern( pattern ); | ||
249 | if (!re.isValid()) | ||
250 | return; | ||
251 | KABC::Addressee::List addresseeList = addressees(); | ||
252 | KABC::Addressee::List::Iterator it; | ||
253 | if ( field ) { | ||
254 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
255 | #if QT_VERSION >= 300 | ||
256 | if (re.search(field->value( *it ).lower()) != -1) | ||
257 | #else | ||
258 | if (re.match(field->value( *it ).lower()) != -1) | ||
259 | #endif | ||
260 | mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | ||
261 | |||
235 | 262 | ||
263 | } | ||
264 | } else { | ||
265 | KABC::Field::List fieldList = fields(); | ||
266 | KABC::Field::List::ConstIterator fieldIt; | ||
267 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
268 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
269 | #if QT_VERSION >= 300 | ||
270 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | ||
271 | #else | ||
272 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | ||
273 | #endif | ||
274 | { | ||
275 | mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); | ||
276 | continue; | ||
277 | } | ||
278 | } | ||
279 | } | ||
280 | } | ||
281 | mIconView->arrangeItemsInGrid( true ); | ||
282 | } | ||
236 | QStringList KAddressBookIconView::selectedUids() | 283 | QStringList KAddressBookIconView::selectedUids() |
diff --git a/kaddressbook/views/kaddressbookiconview.h b/kaddressbook/views/kaddressbookiconview.h index 3afada3..963ee7c 100644 --- a/kaddressbook/views/kaddressbookiconview.h +++ b/kaddressbook/views/kaddressbookiconview.h | |||
@@ -60,2 +60,3 @@ class KAddressBookIconView : public KAddressBookView | |||
60 | virtual QString type() const { return "Icon"; } | 60 | virtual QString type() const { return "Icon"; } |
61 | void doSearch( const QString& s ,KABC::Field *field ); | ||
61 | 62 | ||
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index ab11e2a..12f7c27 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -114,2 +114,51 @@ void KAddressBookTableView::reconstructListView() | |||
114 | 114 | ||
115 | void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | ||
116 | { | ||
117 | mListView->clear(); | ||
118 | if ( s.isEmpty() || s == "*" ) { | ||
119 | refresh(); | ||
120 | return; | ||
121 | } | ||
122 | QString pattern = s.lower()+"*"; | ||
123 | QRegExp re; | ||
124 | re.setWildcard(true); // most people understand these better. | ||
125 | re.setCaseSensitive(false); | ||
126 | re.setPattern( pattern ); | ||
127 | if (!re.isValid()) | ||
128 | return; | ||
129 | KABC::Addressee::List addresseeList = addressees(); | ||
130 | KABC::Addressee::List::Iterator it; | ||
131 | if ( field ) { | ||
132 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
133 | #if QT_VERSION >= 300 | ||
134 | if (re.search(field->value( *it ).lower()) != -1) | ||
135 | #else | ||
136 | if (re.match(field->value( *it ).lower()) != -1) | ||
137 | #endif | ||
138 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | ||
139 | |||
140 | } | ||
141 | } else { | ||
142 | KABC::Field::List fieldList = fields(); | ||
143 | KABC::Field::List::ConstIterator fieldIt; | ||
144 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | ||
145 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | ||
146 | #if QT_VERSION >= 300 | ||
147 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | ||
148 | #else | ||
149 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | ||
150 | #endif | ||
151 | { | ||
152 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | ||
153 | continue; | ||
154 | } | ||
155 | } | ||
156 | } | ||
157 | } | ||
158 | // Sometimes the background pixmap gets messed up when we add lots | ||
159 | // of items. | ||
160 | mListView->repaint(); | ||
161 | emit selected(QString::null); | ||
162 | |||
163 | } | ||
115 | void KAddressBookTableView::writeConfig(KConfig *config) | 164 | void KAddressBookTableView::writeConfig(KConfig *config) |
diff --git a/kaddressbook/views/kaddressbooktableview.h b/kaddressbook/views/kaddressbooktableview.h index bb991bc..ecfe7a1 100644 --- a/kaddressbook/views/kaddressbooktableview.h +++ b/kaddressbook/views/kaddressbooktableview.h | |||
@@ -64,2 +64,3 @@ friend class ContactListView; | |||
64 | virtual QString type() const { return "Table"; } | 64 | virtual QString type() const { return "Table"; } |
65 | void doSearch( const QString& s ,KABC::Field *field ); | ||
65 | 66 | ||