summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2005-03-30 23:17:42 (UTC)
committer zautrix <zautrix>2005-03-30 23:17:42 (UTC)
commit529c0fb8a8bf15e7bd375ddeb355c5802baf4c93 (patch) (side-by-side diff)
tree72ebca6de7e54f2cf89d3d6df61d3b40aa66a444 /kaddressbook
parent28ac86e2efbc10f210dbd2d5ac0053f4e6198d57 (diff)
downloadkdepimpi-529c0fb8a8bf15e7bd375ddeb355c5802baf4c93.zip
kdepimpi-529c0fb8a8bf15e7bd375ddeb355c5802baf4c93.tar.gz
kdepimpi-529c0fb8a8bf15e7bd375ddeb355c5802baf4c93.tar.bz2
key fix
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kaddressbookview.cpp4
-rw-r--r--kaddressbook/kaddressbookview.h6
-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
8 files changed, 83 insertions, 6 deletions
diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp
index 09859c2..86898e2 100644
--- a/kaddressbook/kaddressbookview.cpp
+++ b/kaddressbook/kaddressbookview.cpp
@@ -40,13 +40,13 @@
#include "kaddressbookview.h"
KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent,
const char *name )
: QWidget( parent, name ), mAddressBook( ab ), mFieldList()
{
-
+
initGUI();
}
KAddressBookView::~KAddressBookView()
{
@@ -178,9 +178,11 @@ ViewConfigureWidget *ViewFactory::configureWidget( KABC::AddressBook *ab,
QWidget *parent,
const char *name )
{
return new ViewConfigureWidget( ab, parent, name );
}
+
+
#ifndef KAB_EMBEDDED
#include "kaddressbookview.moc"
#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h
index 6bbb9c2..3a3f71a 100644
--- a/kaddressbook/kaddressbookview.h
+++ b/kaddressbook/kaddressbookview.h
@@ -227,13 +227,14 @@ class KAddressBookView : public QWidget
This signal is emitted whenever the user drops something on the
view. The individual view should handle checking if the item is
droppable (ie: if it is a vcard).
*/
void dropped( QDropEvent* );
- protected:
+ protected:
+
/**
Returns a list of the addressees that should be displayed. This method
should always be used by the subclass to get a list of addressees. This
method internally takes many factors into account, including the current
filter.
*/
@@ -301,12 +302,13 @@ class ViewFactory
protected:
virtual QObject* createObject( QObject*, const char*, const char*,
const QStringList & )
{
return 0;
- }
+ }
+
};
#endif
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
@@ -30,12 +30,13 @@
#include <qtimer.h>
#include <qdatetime.h>
#include <qlabel.h>
#include <qstyle.h>
#include <qcursor.h>
#include <qtooltip.h>
+#include <qapplication.h>
#include "kabprefs.h"
#include <kdebug.h>
#include <kglobalsettings.h>
//END includes
@@ -636,12 +637,14 @@ CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const
//BEGIN CardView
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();
d->mFm = new QFontMetrics(f);
f.setBold(true);
@@ -1348,13 +1351,21 @@ void CardView::keyPressEvent( QKeyEvent *e )
{
if ( ! ( childCount() && d->mCurrentItem ) )
{
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;
switch ( e->key() )
{
@@ -1712,11 +1723,29 @@ int CardView::maxFieldLines() const
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"
#endif //KAB_EMBEDDED
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
@@ -402,13 +402,17 @@ class CardView : public QScrollView
void currentChanged( CardViewItem * );
/** 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);
/** Sets the layout to dirty and repaints.
@@ -441,13 +445,12 @@ class CardView : public QScrollView
virtual void enterEvent( QEvent * );
virtual void leaveEvent( QEvent * );
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.
*/
virtual void startDrag();
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
@@ -26,12 +26,13 @@
#include <qimage.h>
#include <qdragobject.h>
#include <qcombobox.h>
#include <qpainter.h>
#include <qbrush.h>
#include <qevent.h>
+#include <qapplication.h>
#include <klocale.h>
#include <kglobalsettings.h>
#include <kiconloader.h>
#include <kdebug.h>
#include <kconfig.h>
@@ -245,12 +246,14 @@ ContactListView::ContactListView(KAddressBookTableView *view,
QWidget *parent,
const char *name )
: KListView( parent, name ),
pabWidget( view ),
oldColumn( 0 )
{
+ mFlagBlockKeyPressed = false;
+ mFlagKeyPressed = false;
mABackground = true;
mSingleLine = false;
mToolTips = true;
#ifndef KAB_EMBEDDED
mAlternateColor = KGlobalSettings::alternateBackgroundColor();
#else //KAB_EMBEDDED
@@ -392,9 +395,35 @@ void ContactListView::setBackgroundPixmap(const QString &filename)
qDebug("ContactListView::setBackgroundPixmap has to be verified");
//US setPaletteBackgroundPixmap(QPixmap(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
@@ -89,12 +89,16 @@ public:
* QString is empty (QString::isEmpty()), then the background
* pixmap will be disabled.
*/
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 );
virtual void contentsMousePressEvent(QMouseEvent*);
void contentsMouseMoveEvent( QMouseEvent *e );
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
@@ -205,18 +205,22 @@ 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);
// costum colors?
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
@@ -58,17 +58,21 @@ 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)
{
disconnect(mListView, SIGNAL(selectionChanged()),