-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 @@ -40,28 +40,44 @@ #include "kaddressbookview.h" KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name ) : 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 ); mDefaultFilterName = config->readEntry( "DefaultFilterName", QString::null ); } void KAddressBookView::writeConfig( KConfig* ) diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h index 8f31910..6bbb9c2 100644 --- a/kaddressbook/kaddressbookview.h +++ b/kaddressbook/kaddressbookview.h @@ -25,24 +25,25 @@ #define KADDRESSBOOKVIEW_H #ifndef KAB_EMBEDDED #include <klibloader.h> #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> #endif namespace KABC { class AddressBook; } @@ -236,24 +237,25 @@ class KAddressBookView : public QWidget method internally takes many factors into account, including the current filter. */ KABC::Addressee::List addressees(); /** 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; KABC::Field::List mFieldList; QWidget *mViewWidget; }; 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 @@ -291,29 +291,25 @@ void KAddressBookCardView::readConfig(KConfig *config) void KAddressBookCardView::writeConfig( KConfig *config ) { config->writeEntry( "ItemWidth", mCardView->itemWidth() ); KAddressBookView::writeConfig( 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-") ) continue; #if QT_VERSION >= 0x030000 if (re.search(field->value( *it ).lower()) != -1) #else 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 @@ -250,29 +250,25 @@ void KAddressBookIconView::readConfig(KConfig *config) connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), this, SLOT(addresseeExecuted(QIconViewItem *))); } 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; #if QT_VERSION >= 0x030000 if (re.search(field->value( *it ).lower()) != -1) #else if (re.match(field->value( *it ).lower()) != -1) 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 @@ -134,29 +134,25 @@ void KAddressBookTableView::reconstructListView() mainLayout->addWidget( mListView ); mainLayout->activate(); mListView->show(); } 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; #if QT_VERSION >= 0x030000 if (re.search(field->value( *it ).lower()) == 0) #else if (re.match(field->value( *it ).lower()) != -1) |