-rw-r--r-- | kaddressbook/kaddressbookview.cpp | 20 | ||||
-rw-r--r-- | kaddressbook/kaddressbookview.h | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 6 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 6 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 6 |
5 files changed, 23 insertions, 17 deletions
diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp index 424d52a..09859c2 100644 --- a/kaddressbook/kaddressbookview.cpp +++ b/kaddressbook/kaddressbookview.cpp @@ -44,20 +44,36 @@ KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent, : QWidget( parent, name ), mAddressBook( ab ), mFieldList() { initGUI(); } KAddressBookView::~KAddressBookView() { - kdDebug(5720) << "KAddressBookView::~KAddressBookView: destroying - " - << name() << endl; + } +QRegExp KAddressBookView::getRegExp( const QString s ) +{ + QRegExp re; + + if ( s.length() == 3 && s.mid(1,1) == "-" ) { + QString pattern = "^[" + s.lower() +"]"; + re.setCaseSensitive(false); + re.setPattern( pattern ); + } else { + QString pattern = s.lower()+"*"; + re.setWildcard(true); // most people understand these better. + re.setCaseSensitive(false); + re.setPattern( pattern ); + } + return re; +} + void KAddressBookView::readConfig( KConfig *config ) { mFieldList = KABC::Field::restoreFields( config, "KABCFields" ); if ( mFieldList.isEmpty() ) mFieldList = KABC::Field::defaultFields(); mDefaultFilterType = (DefaultFilterType)config->readNumEntry( "DefaultFilterType", 1 ); diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h index 8f31910..6bbb9c2 100644 --- a/kaddressbook/kaddressbookview.h +++ b/kaddressbook/kaddressbookview.h @@ -29,16 +29,17 @@ #endif //KAB_EMBEDDED class KConfig; class QDropEvent; #include <qstringlist.h> #include <kabc/field.h> #include <qwidget.h> +#include <qregexp.h> #include "viewconfigurewidget.h" #include "filter.h" #ifdef DESKTOP_VERSION #include <qpaintdevicemetrics.h> #include <qprinter.h> #include <qpainter.h> @@ -240,16 +241,17 @@ class KAddressBookView : public QWidget /** This method returns the widget that should be used as the parent for all view components. By using this widget as the parent and not 'this', the view subclass has the option of placing other widgets around the view (ie: search fields, etc). Do not delete this widget! */ QWidget *viewWidget(); + QRegExp getRegExp( const QString ); private: void initGUI(); DefaultFilterType mDefaultFilterType; Filter mFilter; QString mDefaultFilterName; KABC::AddressBook *mAddressBook; diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 9d8c5ce..2b40909 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp @@ -295,21 +295,17 @@ void KAddressBookCardView::writeConfig( KConfig *config ) } void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) { mCardView->clear(); if ( s.isEmpty() || s == "*" ) { refresh(); return; } - QString pattern = s.lower()+"*"; - QRegExp re; - re.setWildcard(true); // most people understand these better. - re.setCaseSensitive(false); - re.setPattern( pattern ); + QRegExp re = getRegExp( s ); if (!re.isValid()) return; mCardView->viewport()->setUpdatesEnabled( false ); KABC::Addressee::List addresseeList = addressees(); KABC::Addressee::List::Iterator it; if ( field ) { for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp index fb53215..3bdfd1a 100644 --- a/kaddressbook/views/kaddressbookiconview.cpp +++ b/kaddressbook/views/kaddressbookiconview.cpp @@ -254,21 +254,17 @@ void KAddressBookIconView::readConfig(KConfig *config) void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) { mIconView->clear(); mIconList.clear(); if ( s.isEmpty() || s == "*" ) { refresh(); return; } - QString pattern = s.lower()+"*"; - QRegExp re; - re.setWildcard(true); // most people understand these better. - re.setCaseSensitive(false); - re.setPattern( pattern ); + QRegExp re = getRegExp( s ); if (!re.isValid()) return; KABC::Addressee::List addresseeList = addressees(); KABC::Addressee::List::Iterator it; if ( field ) { for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) continue; diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index b73ceaa..f4b008c 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp @@ -138,21 +138,17 @@ void KAddressBookTableView::reconstructListView() void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) { mListView->clear(); if ( s.isEmpty() || s == "*" ) { refresh(); return; } - QString pattern = s.lower()+"*"; - QRegExp re; - re.setWildcard(true); // most people understand these better. - re.setCaseSensitive(false); - re.setPattern( pattern ); + QRegExp re = getRegExp( s ); if (!re.isValid()) return; KABC::Addressee::List addresseeList = addressees(); KABC::Addressee::List::Iterator it; if ( field ) { for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) continue; |