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/cardview.cpp31
-rw-r--r--kaddressbook/views/cardview.h7
-rw-r--r--kaddressbook/views/contactlistview.cpp29
-rw-r--r--kaddressbook/views/contactlistview.h4
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp4
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp4
6 files changed, 76 insertions, 3 deletions
diff --git a/kaddressbook/views/cardview.cpp b/kaddressbook/views/cardview.cpp
index 03df444..84d3116 100644
--- a/kaddressbook/views/cardview.cpp
+++ b/kaddressbook/views/cardview.cpp
@@ -32,8 +32,9 @@
#include <qlabel.h>
#include <qstyle.h>
#include <qcursor.h>
#include <qtooltip.h>
+#include <qapplication.h>
#include "kabprefs.h"
#include <kdebug.h>
#include <kglobalsettings.h>
@@ -638,8 +639,10 @@ CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const
CardView::CardView(QWidget *parent, const char *name)
: QScrollView(parent, name),
d(new CardViewPrivate())
{
+ mFlagKeyPressed = false;
+ mFlagBlockKeyPressed = false;
d->mItemList.setAutoDelete(true);
d->mSeparatorList.setAutoDelete(true);
QFont f = font();
@@ -1350,9 +1353,17 @@ void CardView::keyPressEvent( QKeyEvent *e )
{
e->ignore();
return;
}
-
+ if ( mFlagBlockKeyPressed )
+ return;
+ qApp->processEvents();
+ if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
+ e->accept();
+ return;
+ }
+ if (! e->isAutoRepeat() )
+ mFlagKeyPressed = true;
uint pos = d->mItemList.findRef( d->mCurrentItem );
CardViewItem *aItem = 0L; // item that gets the focus
CardViewItem *old = d->mCurrentItem;
@@ -1714,8 +1725,26 @@ void CardView::setMaxFieldLines( int howmany )
{
d->mMaxFieldLines = howmany ? howmany : INT_MAX;
// FIXME update, forcing the items to recalc height!!
}
+
+void CardView::keyReleaseEvent ( QKeyEvent * e )
+{
+ if ( mFlagBlockKeyPressed )
+ return;
+ if ( !e->isAutoRepeat() ) {
+ mFlagBlockKeyPressed = true;
+ qApp->processEvents();
+ mFlagBlockKeyPressed = false;
+ mFlagKeyPressed = false;
+ }
+ QScrollView::keyReleaseEvent ( e );
+}
+
+
+
+
+
//END Cardview
#ifndef KAB_EMBEDDED
#include "cardview.moc"
diff --git a/kaddressbook/views/cardview.h b/kaddressbook/views/cardview.h
index 37dddb6..2ea3771 100644
--- a/kaddressbook/views/cardview.h
+++ b/kaddressbook/views/cardview.h
@@ -404,9 +404,13 @@ class CardView : public QScrollView
/** Emitted when the return key is pressed in an item.
*/
void returnPressed( CardViewItem * );
- protected:
+ protected:
+ bool mFlagKeyPressed;
+ bool mFlagBlockKeyPressed;
+ virtual void keyPressEvent ( QKeyEvent * );
+ virtual void keyReleaseEvent ( QKeyEvent * );
/** Determines which cards intersect that region and tells them to paint
* themselves.
*/
void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph);
@@ -443,9 +447,8 @@ class CardView : public QScrollView
virtual void focusInEvent( QFocusEvent * );
virtual void focusOutEvent( QFocusEvent * );
- virtual void keyPressEvent( QKeyEvent * );
/** Overload this method to be told when a drag should be started.
* In most cases you will want to start a drag event with the currently
* selected item.
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp
index e75810e..09d9c03 100644
--- a/kaddressbook/views/contactlistview.cpp
+++ b/kaddressbook/views/contactlistview.cpp
@@ -28,8 +28,9 @@
#include <qcombobox.h>
#include <qpainter.h>
#include <qbrush.h>
#include <qevent.h>
+#include <qapplication.h>
#include <klocale.h>
#include <kglobalsettings.h>
#include <kiconloader.h>
@@ -247,8 +248,10 @@ ContactListView::ContactListView(KAddressBookTableView *view,
: KListView( parent, name ),
pabWidget( view ),
oldColumn( 0 )
{
+ mFlagBlockKeyPressed = false;
+ mFlagKeyPressed = false;
mABackground = true;
mSingleLine = false;
mToolTips = true;
#ifndef KAB_EMBEDDED
@@ -394,7 +397,33 @@ void ContactListView::setBackgroundPixmap(const QString &filename)
KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename));
}
}
+
+void ContactListView::keyPressEvent ( QKeyEvent * e )
+{
+ if ( mFlagBlockKeyPressed )
+ return;
+ qApp->processEvents();
+ if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
+ e->accept();
+ return;
+ }
+ if (! e->isAutoRepeat() )
+ mFlagKeyPressed = true;
+ KListView::keyPressEvent ( e );
+}
+void ContactListView::keyReleaseEvent ( QKeyEvent * e )
+{
+ if ( mFlagBlockKeyPressed )
+ return;
+ if ( !e->isAutoRepeat() ) {
+ mFlagBlockKeyPressed = true;
+ qApp->processEvents();
+ mFlagBlockKeyPressed = false;
+ mFlagKeyPressed = false;
+ }
+ KListView::keyReleaseEvent ( e );
+}
#ifndef KAB_EMBEDDED
#include "contactlistview.moc"
#endif //KAB_EMBEDDED
diff --git a/kaddressbook/views/contactlistview.h b/kaddressbook/views/contactlistview.h
index 9d1a672..46477e1 100644
--- a/kaddressbook/views/contactlistview.h
+++ b/kaddressbook/views/contactlistview.h
@@ -91,8 +91,12 @@ public:
*/
void setBackgroundPixmap(const QString &filename);
protected:
+ bool mFlagKeyPressed;
+ bool mFlagBlockKeyPressed;
+ virtual void keyPressEvent ( QKeyEvent * );
+ virtual void keyReleaseEvent ( QKeyEvent * );
/** Paints the background pixmap in the empty area. This method is needed
* since Qt::FixedPixmap will not scroll with the list view.
*/
virtual void paintEmptyArea( QPainter * p, const QRect & rect );
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index cce68b9..9c35fd6 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -207,14 +207,18 @@ void KAddressBookCardView::setFocusAV()
void KAddressBookCardView::scrollUP()
{
QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
QApplication::postEvent( mCardView, ev );
+ ev = new QKeyEvent ( QEvent::KeyRelease, 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 );
+ ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 );
+ QApplication::postEvent( mCardView, ev );
}
void KAddressBookCardView::readConfig(KConfig *config)
{
KAddressBookView::readConfig(config);
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index f4b008c..e322473 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -60,13 +60,17 @@ void KAddressBookTableView::setFocusAV()
void KAddressBookTableView::scrollUP()
{
QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
QApplication::postEvent( mListView, ev );
+ ev = new QKeyEvent ( QEvent::KeyRelease, 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 );
+ ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 );
+ QApplication::postEvent( mListView, ev );
}
void KAddressBookTableView::reconstructListView()
{
if (mListView)