-rw-r--r-- | kaddressbook/kaddressbookview.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/kaddressbookview.h | 6 | ||||
-rw-r--r-- | kaddressbook/views/cardview.cpp | 31 | ||||
-rw-r--r-- | kaddressbook/views/cardview.h | 7 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.cpp | 29 | ||||
-rw-r--r-- | kaddressbook/views/contactlistview.h | 4 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbookcardview.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 4 |
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 @@ -38,17 +38,17 @@ #include <kdebug.h> #include "kaddressbookview.h" KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name ) : QWidget( parent, name ), mAddressBook( ab ), mFieldList() { - + initGUI(); } KAddressBookView::~KAddressBookView() { } @@ -176,11 +176,13 @@ QWidget *KAddressBookView::viewWidget() 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 @@ -225,17 +225,18 @@ 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. */ KABC::Addressee::List addressees(); @@ -299,14 +300,15 @@ class ViewFactory QWidget *parent, const char *name = 0 ); 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 @@ -28,16 +28,17 @@ #include <qpainter.h> #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 #define MIN_ITEM_WIDTH 80 @@ -634,16 +635,18 @@ CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const //END CardViewItem //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); d->mHeaderFont = f; d->mBFm = new QFontMetrics(f); @@ -1346,17 +1349,25 @@ void CardView::focusOutEvent( QFocusEvent * ) 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() ) { case Key_Up: if ( pos > 0 ) @@ -1710,13 +1721,31 @@ int CardView::maxFieldLines() const return d->mMaxFieldLines; } 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 @@ -400,17 +400,21 @@ class CardView : public QScrollView /** Emitted when the current item changes */ 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. */ void resizeEvent(QResizeEvent *e); @@ -439,17 +443,16 @@ class CardView : public QScrollView virtual void contentsMouseDoubleClickEvent(QMouseEvent *e); 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(); private slots: 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 @@ -24,16 +24,17 @@ #include <qheader.h> #include <qiconset.h> #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> #include <kapplication.h> #include <kurl.h> @@ -243,16 +244,18 @@ void ContactListViewItem::refresh() ContactListView::ContactListView(KAddressBookTableView *view, KABC::AddressBook* /* doc */, 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 mAlternateColor = QColor(240, 240, 240); #endif //KAB_EMBEDDED @@ -390,11 +393,37 @@ void ContactListView::setBackgroundPixmap(const QString &filename) else { 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 @@ -87,16 +87,20 @@ public: /** Sets the background pixmap to <i>filename</i>. If the * 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 ); void contentsDropEvent( QDropEvent *e ); virtual bool acceptDrag(QDropEvent *e) const; 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 @@ -203,22 +203,26 @@ void KAddressBookCardView::setFocusAV() if ( mCardView ) mCardView->setFocus(); } 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? if ( config->readBoolEntry( "EnableCustomColors", false ) ) { 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 @@ -56,21 +56,25 @@ void KAddressBookTableView::setFocusAV() if ( mListView ) mListView->setFocus(); } 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()), this, SLOT(addresseeSelected())); disconnect(mListView, SIGNAL(executed(QListViewItem*)), |