Diffstat (limited to 'kaddressbook/views/kaddressbooktableview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index 348f491..02fc40a 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -149,60 +149,76 @@ void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | |||
149 | } | 149 | } |
150 | QRegExp re = getRegExp( s ); | 150 | QRegExp re = getRegExp( s ); |
151 | if (!re.isValid()) | 151 | if (!re.isValid()) |
152 | return; | 152 | return; |
153 | KABC::Addressee::List addresseeList = addressees(); | 153 | KABC::Addressee::List addresseeList = addressees(); |
154 | KABC::Addressee::List::Iterator it; | 154 | KABC::Addressee::List::Iterator it; |
155 | if ( field ) { | 155 | if ( field ) { |
156 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 156 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
157 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 157 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
158 | continue; | 158 | continue; |
159 | #if QT_VERSION >= 0x030000 | 159 | #if QT_VERSION >= 0x030000 |
160 | if (re.search(field->value( *it ).lower()) == 0) | 160 | if (re.search(field->value( *it ).lower()) == 0) |
161 | #else | 161 | #else |
162 | if (re.match(field->value( *it ).lower()) == 0) | 162 | if (re.match(field->value( *it ).lower()) == 0) |
163 | #endif | 163 | #endif |
164 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 164 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
165 | 165 | ||
166 | } | 166 | } |
167 | } else { | 167 | } else { |
168 | KABC::Field::List fieldList = allFields(); | 168 | KABC::Field::List fieldList = allFields(); |
169 | KABC::Field::List::ConstIterator fieldIt; | 169 | KABC::Field::List::ConstIterator fieldIt; |
170 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { | 170 | for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { |
171 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 171 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
172 | continue; | 172 | continue; |
173 | bool match = false; | ||
173 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 174 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
174 | #if QT_VERSION >= 0x030000 | 175 | #if QT_VERSION >= 0x030000 |
175 | if (re.search((*fieldIt)->value( *it ).lower()) == 0) | 176 | if (re.search((*fieldIt)->value( *it ).lower()) == 0) |
176 | #else | 177 | #else |
177 | if (re.match((*fieldIt)->value( *it ).lower()) == 0) | 178 | if (re.match((*fieldIt)->value( *it ).lower()) == 0) |
178 | #endif | 179 | #endif |
179 | { | 180 | { |
180 | //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() ); | 181 | //qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() ); |
181 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 182 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
183 | match = true; | ||
182 | break; | 184 | break; |
183 | } | 185 | } |
184 | } | 186 | } |
187 | if ( ! match ) { | ||
188 | if ( (*it).matchPhoneNumber( &re ) ) { | ||
189 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | ||
190 | match = true; | ||
191 | break; | ||
192 | } | ||
193 | } | ||
194 | if ( ! match ) { | ||
195 | if ( (*it).matchAddress( &re ) ) { | ||
196 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | ||
197 | match = true; | ||
198 | break; | ||
199 | } | ||
200 | } | ||
185 | } | 201 | } |
186 | } | 202 | } |
187 | // Sometimes the background pixmap gets messed up when we add lots | 203 | // Sometimes the background pixmap gets messed up when we add lots |
188 | // of items. | 204 | // of items. |
189 | //mListView->repaint(); | 205 | //mListView->repaint(); |
190 | if ( mListView->firstChild() ) { | 206 | if ( mListView->firstChild() ) { |
191 | mListView->setCurrentItem ( mListView->firstChild() ); | 207 | mListView->setCurrentItem ( mListView->firstChild() ); |
192 | mListView->setSelected ( mListView->firstChild(), true ); | 208 | mListView->setSelected ( mListView->firstChild(), true ); |
193 | } | 209 | } |
194 | else | 210 | else |
195 | emit selected(QString::null); | 211 | emit selected(QString::null); |
196 | 212 | ||
197 | } | 213 | } |
198 | void KAddressBookTableView::writeConfig(KConfig *config) | 214 | void KAddressBookTableView::writeConfig(KConfig *config) |
199 | { | 215 | { |
200 | KAddressBookView::writeConfig(config); | 216 | KAddressBookView::writeConfig(config); |
201 | 217 | ||
202 | mListView->saveLayout(config, config->group()); | 218 | mListView->saveLayout(config, config->group()); |
203 | } | 219 | } |
204 | 220 | ||
205 | void KAddressBookTableView::readConfig(KConfig *config) | 221 | void KAddressBookTableView::readConfig(KConfig *config) |
206 | { | 222 | { |
207 | KAddressBookView::readConfig( config ); | 223 | KAddressBookView::readConfig( config ); |
208 | // The config could have changed the fields, so we need to reconstruct | 224 | // The config could have changed the fields, so we need to reconstruct |