summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2004-10-10 23:26:49 (UTC)
committer zautrix <zautrix>2004-10-10 23:26:49 (UTC)
commitea40295e233db219dc2431960e18fb4398ddb75c (patch) (side-by-side diff)
tree1d654ae51d7f65f4375787105951a8f4f9fc359e /kaddressbook
parent640874bb21ea348edb33a54690ad225e0efdd1e4 (diff)
downloadkdepimpi-ea40295e233db219dc2431960e18fb4398ddb75c.zip
kdepimpi-ea40295e233db219dc2431960e18fb4398ddb75c.tar.gz
kdepimpi-ea40295e233db219dc2431960e18fb4398ddb75c.tar.bz2
added better searching in kapi
Diffstat (limited to 'kaddressbook') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/incsearchwidget.cpp6
-rw-r--r--kaddressbook/incsearchwidget.h2
-rw-r--r--kaddressbook/kabcore.cpp3
-rw-r--r--kaddressbook/kaddressbookview.h2
-rw-r--r--kaddressbook/viewmanager.cpp11
-rw-r--r--kaddressbook/viewmanager.h2
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp18
-rw-r--r--kaddressbook/views/kaddressbookcardview.h2
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp17
-rw-r--r--kaddressbook/views/kaddressbookiconview.h2
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp16
-rw-r--r--kaddressbook/views/kaddressbooktableview.h2
12 files changed, 79 insertions, 4 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp
index 3533427..78eaf65 100644
--- a/kaddressbook/incsearchwidget.cpp
+++ b/kaddressbook/incsearchwidget.cpp
@@ -78,12 +78,18 @@ IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
connect( mSearchText, SIGNAL( returnPressed() ),
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()
{
diff --git a/kaddressbook/incsearchwidget.h b/kaddressbook/incsearchwidget.h
index 5c95438..1546a51 100644
--- a/kaddressbook/incsearchwidget.h
+++ b/kaddressbook/incsearchwidget.h
@@ -45,12 +45,14 @@ class IncSearchWidget : public QWidget
KABC::Field *currentField() const;
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.
*/
void doSearch( const QString& text );
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index cd261f6..f2d4cd6 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1670,13 +1670,14 @@ void KABCore::initGUI()
// mActionQuit->plug ( mMainWindow->toolBar());
//mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
//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 );
//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h
index 17106e8..c134e96 100644
--- a/kaddressbook/kaddressbookview.h
+++ b/kaddressbook/kaddressbookview.h
@@ -62,12 +62,14 @@ class KAddressBookView : public QWidget
/**
Must be overloaded in subclasses. Should return a list of
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
assume the worst and rebuild itself if necessary. For example,
in a table view this method may be called when the user adds or
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index c6baeac..f4fb08b 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -82,13 +82,22 @@ ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name )
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;
mActionSelectView->setItems( mViewNameList );
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h
index 6def6b6..585f4e9 100644
--- a/kaddressbook/viewmanager.h
+++ b/kaddressbook/viewmanager.h
@@ -63,12 +63,14 @@ class ViewManager : public QWidget
QStringList selectedUids() const;
QStringList selectedEmails() const;
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.
void setSelected();
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
@@ -24,12 +24,13 @@
#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>
@@ -166,12 +167,23 @@ 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);
// costum colors?
if ( config->readBoolEntry( "EnableCustomColors", false ) )
@@ -287,13 +299,17 @@ void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
}
}
}
}
mCardView->viewport()->setUpdatesEnabled( true );
mCardView->viewport()->update();
- // by default nothing is selected
+ if ( mCardView->firstItem() ) {
+ mCardView->setCurrentItem ( mCardView->firstItem() );
+ mCardView->setSelected ( mCardView->firstItem() , true );
+ }
+ else
emit selected(QString::null);
}
QStringList KAddressBookCardView::selectedUids()
{
QStringList uidList;
CardViewItem *item;
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
@@ -57,12 +57,14 @@ class KAddressBookCardView : public KAddressBookView
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();
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
@@ -38,12 +38,13 @@
#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 )
@@ -208,12 +209,22 @@ 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);
//US method executed is part of KIconView
//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)),
@@ -277,12 +288,18 @@ void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
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;
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
@@ -58,12 +58,14 @@ 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);
+ 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);
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
@@ -48,13 +48,22 @@ KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab,
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()));
@@ -156,12 +165,17 @@ void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
}
}
}
// Sometimes the background pixmap gets messed up when we add lots
// of items.
mListView->repaint();
+ 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);
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
@@ -60,12 +60,14 @@ friend class ContactListView;
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.