-rw-r--r-- | kaddressbook/incsearchwidget.cpp | 8 | ||||
-rw-r--r-- | kaddressbook/incsearchwidget.h | 2 | ||||
-rw-r--r-- | kaddressbook/kabcore.cpp | 3 | ||||
-rw-r--r-- | kaddressbook/kaddressbookview.h | 2 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 11 | ||||
-rw-r--r-- | kaddressbook/viewmanager.h | 2 | ||||
-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 |
12 files changed, 82 insertions, 7 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp index 3533427..78eaf65 100644 --- a/kaddressbook/incsearchwidget.cpp +++ b/kaddressbook/incsearchwidget.cpp @@ -80,8 +80,14 @@ IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) SLOT( announceDoSearch() ) ); connect( mFieldCombo, SIGNAL( activated( const QString& ) ), SLOT( announceFieldChanged() ) ); + + + connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() )); + connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() )); + + setFocusProxy( mSearchText ); } IncSearchWidget::~IncSearchWidget() @@ -95,9 +101,9 @@ void IncSearchWidget::announceDoSearch2() emit doSearch( mSearchText->text() ); //qDebug("emit dosreach "); } -void IncSearchWidget::announceDoSearch() +void IncSearchWidget::announceDoSearch() { emit doSearch( mSearchText->text() ); // qDebug("emit dosreach "); diff --git a/kaddressbook/incsearchwidget.h b/kaddressbook/incsearchwidget.h index 5c95438..1546a51 100644 --- a/kaddressbook/incsearchwidget.h +++ b/kaddressbook/incsearchwidget.h @@ -47,8 +47,10 @@ class IncSearchWidget : public QWidget void setCurrentItem( int pos ); int currentItem() const; signals: + void scrollUP(); + void scrollDOWN(); /** This signal is emmited whenever the text in the input widget is changed. You can get the sorting field by @ref currentField. diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index cd261f6..f2d4cd6 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -1672,9 +1672,10 @@ void KABCore::initGUI() //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); // mIncSearchWidget->hide(); connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), SLOT( incrementalSearch( const QString& ) ) ); - + connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); + connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); mJumpButtonBar = new JumpButtonBar( this, this ); topLayout->addWidget( mJumpButtonBar ); diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h index 17106e8..c134e96 100644 --- a/kaddressbook/kaddressbookview.h +++ b/kaddressbook/kaddressbookview.h @@ -64,8 +64,10 @@ class KAddressBookView : public QWidget all the uids of selected contacts. */ virtual QStringList selectedUids() = 0; virtual void doSearch( const QString& s ,KABC::Field *field ) = 0; + virtual void scrollUP() = 0; + virtual void scrollDOWN() = 0; /** Called whenever this view should read the config. This can be used as a sign that the config has changed, therefore the view should diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index c6baeac..f4fb08b 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp @@ -84,9 +84,18 @@ ViewManager::~ViewManager() { unloadViews(); mViewFactoryDict.clear(); } - +void ViewManager::scrollUP() +{ + if ( mActiveView ) + mActiveView->scrollUP(); +} +void ViewManager::scrollDOWN() +{ + if ( mActiveView ) + mActiveView->scrollDOWN(); +} void ViewManager::restoreSettings() { mViewNameList = KABPrefs::instance()->mViewNames; QString activeViewName = KABPrefs::instance()->mCurrentView; diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h index 6def6b6..585f4e9 100644 --- a/kaddressbook/viewmanager.h +++ b/kaddressbook/viewmanager.h @@ -65,8 +65,10 @@ class ViewManager : public QWidget KABC::Addressee::List selectedAddressees() const; void setListSelected(QStringList); public slots: + void scrollUP(); + void scrollDOWN(); //US void setSelected( const QString &uid = QString::null, bool selected = true ); void setSelected( const QString &uid, bool); //US added another method with no parameter, since my moc compiler does not support default parameters. 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 @@ -26,8 +26,9 @@ #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> @@ -168,8 +169,19 @@ KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab, 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); @@ -289,10 +301,14 @@ void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field ) } } 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; 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 @@ -59,8 +59,10 @@ class KAddressBookCardView : public KAddressBookView 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*/); 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 @@ -40,8 +40,9 @@ #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 { @@ -210,8 +211,18 @@ KAddressBookIconView::KAddressBookIconView( KABC::AddressBook *ab, 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); @@ -279,8 +290,14 @@ void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field ) } } } 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; 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 @@ -60,8 +60,10 @@ class KAddressBookIconView : public KAddressBookView 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 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 @@ -50,9 +50,18 @@ KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, 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) { @@ -158,9 +167,14 @@ void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) } // 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) { 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 @@ -62,8 +62,10 @@ friend class ContactListView; 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(); |