author | zautrix <zautrix> | 2004-10-10 23:26:49 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-10 23:26:49 (UTC) |
commit | ea40295e233db219dc2431960e18fb4398ddb75c (patch) (side-by-side diff) | |
tree | 1d654ae51d7f65f4375787105951a8f4f9fc359e /kaddressbook/views | |
parent | 640874bb21ea348edb33a54690ad225e0efdd1e4 (diff) | |
download | kdepimpi-ea40295e233db219dc2431960e18fb4398ddb75c.zip kdepimpi-ea40295e233db219dc2431960e18fb4398ddb75c.tar.gz kdepimpi-ea40295e233db219dc2431960e18fb4398ddb75c.tar.bz2 |
added better searching in kapi
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 20 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.h | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.cpp | 17 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookiconview.h | 2 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 18 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.h | 2 |
6 files changed, 57 insertions, 4 deletions
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp index 4babf67..a7bf6c9 100644 --- a/kaddressbook/views/kaddressbookcardview.cpp +++ b/kaddressbook/views/kaddressbookcardview.cpp @@ -22,16 +22,17 @@ */ #include <qdragobject.h> #include <qevent.h> #include <qiconview.h> #include <qlayout.h> #include <qstringlist.h> #include <qregexp.h> +#include <qapplication.h> #include <kabc/addressbook.h> #include <kabc/addressee.h> #include <kconfig.h> #include <kdebug.h> #include <klocale.h> #include "kabprefs.h" @@ -164,16 +165,27 @@ KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, connect(mCardView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); } KAddressBookCardView::~KAddressBookCardView() { } +void KAddressBookCardView::scrollUP() +{ + QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); + QApplication::postEvent( mCardView, ev ); + +} +void KAddressBookCardView::scrollDOWN() +{ + QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); + QApplication::postEvent( mCardView, ev ); +} void KAddressBookCardView::readConfig(KConfig *config) { KAddressBookView::readConfig(config); // costum colors? if ( config->readBoolEntry( "EnableCustomColors", false ) ) { QPalette p( mCardView->palette() ); @@ -285,18 +297,22 @@ void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) addressBook(), *it, mCardView); continue; } } } } mCardView->viewport()->setUpdatesEnabled( true ); mCardView->viewport()->update(); - // by default nothing is selected - emit selected(QString::null); + if ( mCardView->firstItem() ) { + mCardView->setCurrentItem ( mCardView->firstItem() ); + mCardView->setSelected ( mCardView->firstItem() , true ); + } + else + emit selected(QString::null); } QStringList KAddressBookCardView::selectedUids() { QStringList uidList; CardViewItem *item; AddresseeCardViewItem *aItem; for (item = mCardView->firstItem(); item; item = item->nextItem()) diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h index b8efb01..45a9781 100644 --- a/kaddressbook/views/kaddressbookcardview.h +++ b/kaddressbook/views/kaddressbookcardview.h @@ -55,16 +55,18 @@ 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"; } virtual void readConfig(KConfig *config); virtual void writeConfig(KConfig *); + virtual void scrollUP(); + virtual void scrollDOWN(); public slots: void refresh(QString uid = QString::null); void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/); //US added an additional method without parameter void setSelected(); protected slots: diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp index fdc0db9..f4c68b8 100644 --- a/kaddressbook/views/kaddressbookiconview.cpp +++ b/kaddressbook/views/kaddressbookiconview.cpp @@ -36,16 +36,17 @@ #endif //KAB_EMBEDDED #include <kabc/addressbook.h> #include "kabprefs.h" #include "viewmanager.h" #include "kaddressbookiconview.h" #include <qlayout.h> #include <qregexp.h> +#include <qapplication.h> #include <kglobal.h> /*US transfered to the headerfile class IconViewFactory : public ViewFactory { public: KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name ) { return new KAddressBookIconView( ab, parent, name ); @@ -206,16 +207,26 @@ KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, connect(mIconView, SIGNAL(startAddresseeDrag()), this, SIGNAL(startDrag())); } KAddressBookIconView::~KAddressBookIconView() { } +void KAddressBookIconView::scrollUP() +{ + QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); + QApplication::postEvent( mIconView, ev ); +} +void KAddressBookIconView::scrollDOWN() +{ + QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); + QApplication::postEvent( mIconView, ev ); +} void KAddressBookIconView::readConfig(KConfig *config) { KAddressBookView::readConfig(config); //US method executed is part of KIconView //US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)), //US this, SLOT(addresseeExecuted(QIconViewItem *))); disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)), @@ -275,16 +286,22 @@ void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) { mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView )); continue; } } } } mIconView->arrangeItemsInGrid( true ); + if ( mIconView->firstItem() ) { + mIconView->setCurrentItem ( mIconView->firstItem() ); + mIconView->setSelected ( mIconView->firstItem() , true ); + } + else + emit selected(QString::null); } QStringList KAddressBookIconView::selectedUids() { QStringList uidList; QIconViewItem *item; AddresseeIconViewItem *aItem; for (item = mIconView->firstItem(); item; item = item->nextItem()) diff --git a/kaddressbook/views/kaddressbookiconview.h b/kaddressbook/views/kaddressbookiconview.h index 963ee7c..acfcd71 100644 --- a/kaddressbook/views/kaddressbookiconview.h +++ b/kaddressbook/views/kaddressbookiconview.h @@ -56,16 +56,18 @@ class KAddressBookIconView : public KAddressBookView const char *name = 0 ); virtual ~KAddressBookIconView(); virtual QStringList selectedUids(); virtual QString type() const { return "Icon"; } void doSearch( const QString& s ,KABC::Field *field ); virtual void readConfig(KConfig *config); + virtual void scrollUP(); + virtual void scrollDOWN(); public slots: void refresh(QString uid = QString::null); #ifndef KAB_EMBEDDED //MOC_SKIP_BEGIN void setSelected(QString uid = QString::null, bool selected = true); //MOC_SKIP_END #else //KAB_EMBEDDED diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index fbfddba..2412170 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp @@ -46,17 +46,26 @@ KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, // The list view will be created when the config is read. mListView = 0; } KAddressBookTableView::~KAddressBookTableView() { } - +void KAddressBookTableView::scrollUP() +{ + QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); + QApplication::postEvent( mListView, ev ); +} +void KAddressBookTableView::scrollDOWN() +{ + QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); + QApplication::postEvent( mListView, ev ); +} void KAddressBookTableView::reconstructListView() { if (mListView) { disconnect(mListView, SIGNAL(selectionChanged()), this, SLOT(addresseeSelected())); disconnect(mListView, SIGNAL(executed(QListViewItem*)), this, SLOT(addresseeExecuted(QListViewItem*))); @@ -154,17 +163,22 @@ void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) break; } } } } // Sometimes the background pixmap gets messed up when we add lots // of items. mListView->repaint(); - emit selected(QString::null); + if ( mListView->firstChild() ) { + mListView->setCurrentItem ( mListView->firstChild() ); + mListView->setSelected ( mListView->firstChild(), true ); + } + else + emit selected(QString::null); } void KAddressBookTableView::writeConfig(KConfig *config) { KAddressBookView::writeConfig(config); mListView->saveLayout(config, config->group()); } diff --git a/kaddressbook/views/kaddressbooktableview.h b/kaddressbook/views/kaddressbooktableview.h index ecfe7a1..865f8d5 100644 --- a/kaddressbook/views/kaddressbooktableview.h +++ b/kaddressbook/views/kaddressbooktableview.h @@ -58,16 +58,18 @@ friend class ContactListView; virtual void refresh(QString uid = QString::null); virtual QStringList selectedUids(); virtual void setSelected(QString uid = QString::null, bool selected = false); virtual void readConfig(KConfig *config); virtual void writeConfig(KConfig *config); virtual QString type() const { return "Table"; } void doSearch( const QString& s ,KABC::Field *field ); + virtual void scrollUP(); + virtual void scrollDOWN(); public slots: virtual void reconstructListView(); protected slots: /** Called whenever the user selects an addressee in the list view. */ void addresseeSelected(); |