summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views
Side-by-side diff
Diffstat (limited to 'kaddressbook/views') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp53
-rw-r--r--kaddressbook/views/kaddressbookcardview.h2
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp47
-rw-r--r--kaddressbook/views/kaddressbookiconview.h1
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp49
-rw-r--r--kaddressbook/views/kaddressbooktableview.h1
6 files changed, 151 insertions, 2 deletions
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
@@ -116,4 +116,5 @@ AddresseeCardView::~AddresseeCardView()
}
+
void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e)
{
@@ -241,5 +242,55 @@ void KAddressBookCardView::writeConfig( KConfig *config )
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 );
+ 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 QT_VERSION >= 300
+ if (re.search(field->value( *it ).lower()) != -1)
+#else
+ if (re.match(field->value( *it ).lower()) != -1)
+#endif
+ new AddresseeCardViewItem(fields(), mShowEmptyFields,
+ addressBook(), *it, mCardView);
+
+ }
+ } else {
+ KABC::Field::List fieldList = fields();
+ KABC::Field::List::ConstIterator fieldIt;
+ for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
+ for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
+#if QT_VERSION >= 300
+ if (re.search((*fieldIt)->value( *it ).lower()) != -1)
+#else
+ if (re.match((*fieldIt)->value( *it ).lower()) != -1)
+#endif
+ {
+ new AddresseeCardViewItem(fields(), mShowEmptyFields,
+ addressBook(), *it, mCardView);
+ continue;
+ }
+ }
+ }
+ }
+ mCardView->viewport()->setUpdatesEnabled( true );
+ mCardView->viewport()->update();
+ // by default nothing is selected
+ emit selected(QString::null);
+}
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
@@ -55,5 +55,5 @@ class KAddressBookCardView : public KAddressBookView
const char *name = 0 );
virtual ~KAddressBookCardView();
-
+ void doSearch( const QString& s,KABC::Field *field );
virtual QStringList selectedUids();
virtual QString type() const { return "Card"; }
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
@@ -97,4 +97,5 @@ AddresseeIconView::~AddresseeIconView()
}
+
void AddresseeIconView::itemDropped(QDropEvent *e,
const QValueList<QIconDragItem> &)
@@ -233,5 +234,51 @@ 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 );
+ 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 QT_VERSION >= 300
+ if (re.search(field->value( *it ).lower()) != -1)
+#else
+ if (re.match(field->value( *it ).lower()) != -1)
+#endif
+ mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
+
+ }
+ } else {
+ KABC::Field::List fieldList = fields();
+ KABC::Field::List::ConstIterator fieldIt;
+ for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
+ for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
+#if QT_VERSION >= 300
+ if (re.search((*fieldIt)->value( *it ).lower()) != -1)
+#else
+ if (re.match((*fieldIt)->value( *it ).lower()) != -1)
+#endif
+ {
+ mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
+ continue;
+ }
+ }
+ }
+ }
+ mIconView->arrangeItemsInGrid( true );
+}
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
@@ -59,4 +59,5 @@ class KAddressBookIconView : public KAddressBookView
virtual QStringList selectedUids();
virtual QString type() const { return "Icon"; }
+ void doSearch( const QString& s ,KABC::Field *field );
virtual void readConfig(KConfig *config);
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
@@ -113,4 +113,53 @@ 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 );
+ 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 QT_VERSION >= 300
+ if (re.search(field->value( *it ).lower()) != -1)
+#else
+ if (re.match(field->value( *it ).lower()) != -1)
+#endif
+ ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
+
+ }
+ } else {
+ KABC::Field::List fieldList = fields();
+ KABC::Field::List::ConstIterator fieldIt;
+ for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
+ for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
+#if QT_VERSION >= 300
+ if (re.search((*fieldIt)->value( *it ).lower()) != -1)
+#else
+ if (re.match((*fieldIt)->value( *it ).lower()) != -1)
+#endif
+ {
+ ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
+ continue;
+ }
+ }
+ }
+ }
+ // Sometimes the background pixmap gets messed up when we add lots
+ // of items.
+ mListView->repaint();
+ emit selected(QString::null);
+
+}
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
@@ -63,4 +63,5 @@ friend class ContactListView;
virtual void writeConfig(KConfig *config);
virtual QString type() const { return "Table"; }
+ void doSearch( const QString& s ,KABC::Field *field );
public slots: