author | zautrix <zautrix> | 2005-03-30 23:17:42 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-30 23:17:42 (UTC) |
commit | 529c0fb8a8bf15e7bd375ddeb355c5802baf4c93 (patch) (unidiff) | |
tree | 72ebca6de7e54f2cf89d3d6df61d3b40aa66a444 /kaddressbook/views | |
parent | 28ac86e2efbc10f210dbd2d5ac0053f4e6198d57 (diff) | |
download | kdepimpi-529c0fb8a8bf15e7bd375ddeb355c5802baf4c93.zip kdepimpi-529c0fb8a8bf15e7bd375ddeb355c5802baf4c93.tar.gz kdepimpi-529c0fb8a8bf15e7bd375ddeb355c5802baf4c93.tar.bz2 |
key fix
-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 |
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 | |||
@@ -28,16 +28,17 @@ | |||
28 | 28 | ||
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qlabel.h> | 32 | #include <qlabel.h> |
33 | #include <qstyle.h> | 33 | #include <qstyle.h> |
34 | #include <qcursor.h> | 34 | #include <qcursor.h> |
35 | #include <qtooltip.h> | 35 | #include <qtooltip.h> |
36 | #include <qapplication.h> | ||
36 | 37 | ||
37 | #include "kabprefs.h" | 38 | #include "kabprefs.h" |
38 | #include <kdebug.h> | 39 | #include <kdebug.h> |
39 | #include <kglobalsettings.h> | 40 | #include <kglobalsettings.h> |
40 | //END includes | 41 | //END includes |
41 | 42 | ||
42 | #define MIN_ITEM_WIDTH 80 | 43 | #define MIN_ITEM_WIDTH 80 |
43 | 44 | ||
@@ -634,16 +635,18 @@ CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const | |||
634 | //END CardViewItem | 635 | //END CardViewItem |
635 | 636 | ||
636 | //BEGIN CardView | 637 | //BEGIN CardView |
637 | 638 | ||
638 | CardView::CardView(QWidget *parent, const char *name) | 639 | CardView::CardView(QWidget *parent, const char *name) |
639 | : QScrollView(parent, name), | 640 | : QScrollView(parent, name), |
640 | d(new CardViewPrivate()) | 641 | d(new CardViewPrivate()) |
641 | { | 642 | { |
643 | mFlagKeyPressed = false; | ||
644 | mFlagBlockKeyPressed = false; | ||
642 | d->mItemList.setAutoDelete(true); | 645 | d->mItemList.setAutoDelete(true); |
643 | d->mSeparatorList.setAutoDelete(true); | 646 | d->mSeparatorList.setAutoDelete(true); |
644 | 647 | ||
645 | QFont f = font(); | 648 | QFont f = font(); |
646 | d->mFm = new QFontMetrics(f); | 649 | d->mFm = new QFontMetrics(f); |
647 | f.setBold(true); | 650 | f.setBold(true); |
648 | d->mHeaderFont = f; | 651 | d->mHeaderFont = f; |
649 | d->mBFm = new QFontMetrics(f); | 652 | d->mBFm = new QFontMetrics(f); |
@@ -1346,17 +1349,25 @@ void CardView::focusOutEvent( QFocusEvent * ) | |||
1346 | 1349 | ||
1347 | void CardView::keyPressEvent( QKeyEvent *e ) | 1350 | void CardView::keyPressEvent( QKeyEvent *e ) |
1348 | { | 1351 | { |
1349 | if ( ! ( childCount() && d->mCurrentItem ) ) | 1352 | if ( ! ( childCount() && d->mCurrentItem ) ) |
1350 | { | 1353 | { |
1351 | e->ignore(); | 1354 | e->ignore(); |
1352 | return; | 1355 | return; |
1353 | } | 1356 | } |
1354 | 1357 | if ( mFlagBlockKeyPressed ) | |
1358 | return; | ||
1359 | qApp->processEvents(); | ||
1360 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | ||
1361 | e->accept(); | ||
1362 | return; | ||
1363 | } | ||
1364 | if (! e->isAutoRepeat() ) | ||
1365 | mFlagKeyPressed = true; | ||
1355 | uint pos = d->mItemList.findRef( d->mCurrentItem ); | 1366 | uint pos = d->mItemList.findRef( d->mCurrentItem ); |
1356 | CardViewItem *aItem = 0L; // item that gets the focus | 1367 | CardViewItem *aItem = 0L; // item that gets the focus |
1357 | CardViewItem *old = d->mCurrentItem; | 1368 | CardViewItem *old = d->mCurrentItem; |
1358 | 1369 | ||
1359 | switch ( e->key() ) | 1370 | switch ( e->key() ) |
1360 | { | 1371 | { |
1361 | case Key_Up: | 1372 | case Key_Up: |
1362 | if ( pos > 0 ) | 1373 | if ( pos > 0 ) |
@@ -1710,13 +1721,31 @@ int CardView::maxFieldLines() const | |||
1710 | return d->mMaxFieldLines; | 1721 | return d->mMaxFieldLines; |
1711 | } | 1722 | } |
1712 | 1723 | ||
1713 | void CardView::setMaxFieldLines( int howmany ) | 1724 | void CardView::setMaxFieldLines( int howmany ) |
1714 | { | 1725 | { |
1715 | d->mMaxFieldLines = howmany ? howmany : INT_MAX; | 1726 | d->mMaxFieldLines = howmany ? howmany : INT_MAX; |
1716 | // FIXME update, forcing the items to recalc height!! | 1727 | // FIXME update, forcing the items to recalc height!! |
1717 | } | 1728 | } |
1729 | |||
1730 | void CardView::keyReleaseEvent ( QKeyEvent * e ) | ||
1731 | { | ||
1732 | if ( mFlagBlockKeyPressed ) | ||
1733 | return; | ||
1734 | if ( !e->isAutoRepeat() ) { | ||
1735 | mFlagBlockKeyPressed = true; | ||
1736 | qApp->processEvents(); | ||
1737 | mFlagBlockKeyPressed = false; | ||
1738 | mFlagKeyPressed = false; | ||
1739 | } | ||
1740 | QScrollView::keyReleaseEvent ( e ); | ||
1741 | } | ||
1742 | |||
1743 | |||
1744 | |||
1745 | |||
1746 | |||
1718 | //END Cardview | 1747 | //END Cardview |
1719 | 1748 | ||
1720 | #ifndef KAB_EMBEDDED | 1749 | #ifndef KAB_EMBEDDED |
1721 | #include "cardview.moc" | 1750 | #include "cardview.moc" |
1722 | #endif //KAB_EMBEDDED | 1751 | #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 | |||
400 | /** Emitted when the current item changes | 400 | /** Emitted when the current item changes |
401 | */ | 401 | */ |
402 | void currentChanged( CardViewItem * ); | 402 | void currentChanged( CardViewItem * ); |
403 | 403 | ||
404 | /** Emitted when the return key is pressed in an item. | 404 | /** Emitted when the return key is pressed in an item. |
405 | */ | 405 | */ |
406 | void returnPressed( CardViewItem * ); | 406 | void returnPressed( CardViewItem * ); |
407 | 407 | ||
408 | protected: | 408 | protected: |
409 | bool mFlagKeyPressed; | ||
410 | bool mFlagBlockKeyPressed; | ||
411 | virtual void keyPressEvent ( QKeyEvent * ); | ||
412 | virtual void keyReleaseEvent ( QKeyEvent * ); | ||
409 | /** Determines which cards intersect that region and tells them to paint | 413 | /** Determines which cards intersect that region and tells them to paint |
410 | * themselves. | 414 | * themselves. |
411 | */ | 415 | */ |
412 | void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph); | 416 | void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph); |
413 | 417 | ||
414 | /** Sets the layout to dirty and repaints. | 418 | /** Sets the layout to dirty and repaints. |
415 | */ | 419 | */ |
416 | void resizeEvent(QResizeEvent *e); | 420 | void resizeEvent(QResizeEvent *e); |
@@ -439,17 +443,16 @@ class CardView : public QScrollView | |||
439 | virtual void contentsMouseDoubleClickEvent(QMouseEvent *e); | 443 | virtual void contentsMouseDoubleClickEvent(QMouseEvent *e); |
440 | 444 | ||
441 | virtual void enterEvent( QEvent * ); | 445 | virtual void enterEvent( QEvent * ); |
442 | virtual void leaveEvent( QEvent * ); | 446 | virtual void leaveEvent( QEvent * ); |
443 | 447 | ||
444 | virtual void focusInEvent( QFocusEvent * ); | 448 | virtual void focusInEvent( QFocusEvent * ); |
445 | virtual void focusOutEvent( QFocusEvent * ); | 449 | virtual void focusOutEvent( QFocusEvent * ); |
446 | 450 | ||
447 | virtual void keyPressEvent( QKeyEvent * ); | ||
448 | 451 | ||
449 | /** Overload this method to be told when a drag should be started. | 452 | /** Overload this method to be told when a drag should be started. |
450 | * In most cases you will want to start a drag event with the currently | 453 | * In most cases you will want to start a drag event with the currently |
451 | * selected item. | 454 | * selected item. |
452 | */ | 455 | */ |
453 | virtual void startDrag(); | 456 | virtual void startDrag(); |
454 | 457 | ||
455 | private slots: | 458 | 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 @@ | |||
24 | #include <qheader.h> | 24 | #include <qheader.h> |
25 | #include <qiconset.h> | 25 | #include <qiconset.h> |
26 | #include <qimage.h> | 26 | #include <qimage.h> |
27 | #include <qdragobject.h> | 27 | #include <qdragobject.h> |
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qbrush.h> | 30 | #include <qbrush.h> |
31 | #include <qevent.h> | 31 | #include <qevent.h> |
32 | #include <qapplication.h> | ||
32 | 33 | ||
33 | #include <klocale.h> | 34 | #include <klocale.h> |
34 | #include <kglobalsettings.h> | 35 | #include <kglobalsettings.h> |
35 | #include <kiconloader.h> | 36 | #include <kiconloader.h> |
36 | #include <kdebug.h> | 37 | #include <kdebug.h> |
37 | #include <kconfig.h> | 38 | #include <kconfig.h> |
38 | #include <kapplication.h> | 39 | #include <kapplication.h> |
39 | #include <kurl.h> | 40 | #include <kurl.h> |
@@ -243,16 +244,18 @@ void ContactListViewItem::refresh() | |||
243 | ContactListView::ContactListView(KAddressBookTableView *view, | 244 | ContactListView::ContactListView(KAddressBookTableView *view, |
244 | KABC::AddressBook* /* doc */, | 245 | KABC::AddressBook* /* doc */, |
245 | QWidget *parent, | 246 | QWidget *parent, |
246 | const char *name ) | 247 | const char *name ) |
247 | : KListView( parent, name ), | 248 | : KListView( parent, name ), |
248 | pabWidget( view ), | 249 | pabWidget( view ), |
249 | oldColumn( 0 ) | 250 | oldColumn( 0 ) |
250 | { | 251 | { |
252 | mFlagBlockKeyPressed = false; | ||
253 | mFlagKeyPressed = false; | ||
251 | mABackground = true; | 254 | mABackground = true; |
252 | mSingleLine = false; | 255 | mSingleLine = false; |
253 | mToolTips = true; | 256 | mToolTips = true; |
254 | #ifndef KAB_EMBEDDED | 257 | #ifndef KAB_EMBEDDED |
255 | mAlternateColor = KGlobalSettings::alternateBackgroundColor(); | 258 | mAlternateColor = KGlobalSettings::alternateBackgroundColor(); |
256 | #else //KAB_EMBEDDED | 259 | #else //KAB_EMBEDDED |
257 | mAlternateColor = QColor(240, 240, 240); | 260 | mAlternateColor = QColor(240, 240, 240); |
258 | #endif //KAB_EMBEDDED | 261 | #endif //KAB_EMBEDDED |
@@ -390,11 +393,37 @@ void ContactListView::setBackgroundPixmap(const QString &filename) | |||
390 | else | 393 | else |
391 | { | 394 | { |
392 | qDebug("ContactListView::setBackgroundPixmap has to be verified"); | 395 | qDebug("ContactListView::setBackgroundPixmap has to be verified"); |
393 | //US setPaletteBackgroundPixmap(QPixmap(filename)); | 396 | //US setPaletteBackgroundPixmap(QPixmap(filename)); |
394 | KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); | 397 | KListView::setBackgroundPixmap((const QPixmap&)QPixmap(filename)); |
395 | } | 398 | } |
396 | 399 | ||
397 | } | 400 | } |
401 | |||
402 | void ContactListView::keyPressEvent ( QKeyEvent * e ) | ||
403 | { | ||
404 | if ( mFlagBlockKeyPressed ) | ||
405 | return; | ||
406 | qApp->processEvents(); | ||
407 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | ||
408 | e->accept(); | ||
409 | return; | ||
410 | } | ||
411 | if (! e->isAutoRepeat() ) | ||
412 | mFlagKeyPressed = true; | ||
413 | KListView::keyPressEvent ( e ); | ||
414 | } | ||
415 | void ContactListView::keyReleaseEvent ( QKeyEvent * e ) | ||
416 | { | ||
417 | if ( mFlagBlockKeyPressed ) | ||
418 | return; | ||
419 | if ( !e->isAutoRepeat() ) { | ||
420 | mFlagBlockKeyPressed = true; | ||
421 | qApp->processEvents(); | ||
422 | mFlagBlockKeyPressed = false; | ||
423 | mFlagKeyPressed = false; | ||
424 | } | ||
425 | KListView::keyReleaseEvent ( e ); | ||
426 | } | ||
398 | #ifndef KAB_EMBEDDED | 427 | #ifndef KAB_EMBEDDED |
399 | #include "contactlistview.moc" | 428 | #include "contactlistview.moc" |
400 | #endif //KAB_EMBEDDED | 429 | #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: | |||
87 | 87 | ||
88 | /** Sets the background pixmap to <i>filename</i>. If the | 88 | /** Sets the background pixmap to <i>filename</i>. If the |
89 | * QString is empty (QString::isEmpty()), then the background | 89 | * QString is empty (QString::isEmpty()), then the background |
90 | * pixmap will be disabled. | 90 | * pixmap will be disabled. |
91 | */ | 91 | */ |
92 | void setBackgroundPixmap(const QString &filename); | 92 | void setBackgroundPixmap(const QString &filename); |
93 | 93 | ||
94 | protected: | 94 | protected: |
95 | bool mFlagKeyPressed; | ||
96 | bool mFlagBlockKeyPressed; | ||
97 | virtual void keyPressEvent ( QKeyEvent * ); | ||
98 | virtual void keyReleaseEvent ( QKeyEvent * ); | ||
95 | /** Paints the background pixmap in the empty area. This method is needed | 99 | /** Paints the background pixmap in the empty area. This method is needed |
96 | * since Qt::FixedPixmap will not scroll with the list view. | 100 | * since Qt::FixedPixmap will not scroll with the list view. |
97 | */ | 101 | */ |
98 | virtual void paintEmptyArea( QPainter * p, const QRect & rect ); | 102 | virtual void paintEmptyArea( QPainter * p, const QRect & rect ); |
99 | virtual void contentsMousePressEvent(QMouseEvent*); | 103 | virtual void contentsMousePressEvent(QMouseEvent*); |
100 | void contentsMouseMoveEvent( QMouseEvent *e ); | 104 | void contentsMouseMoveEvent( QMouseEvent *e ); |
101 | void contentsDropEvent( QDropEvent *e ); | 105 | void contentsDropEvent( QDropEvent *e ); |
102 | virtual bool acceptDrag(QDropEvent *e) const; | 106 | 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() | |||
203 | if ( mCardView ) | 203 | if ( mCardView ) |
204 | mCardView->setFocus(); | 204 | mCardView->setFocus(); |
205 | 205 | ||
206 | } | 206 | } |
207 | void KAddressBookCardView::scrollUP() | 207 | void KAddressBookCardView::scrollUP() |
208 | { | 208 | { |
209 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); | 209 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); |
210 | QApplication::postEvent( mCardView, ev ); | 210 | QApplication::postEvent( mCardView, ev ); |
211 | ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 ); | ||
212 | QApplication::postEvent( mCardView, ev ); | ||
211 | 213 | ||
212 | } | 214 | } |
213 | void KAddressBookCardView::scrollDOWN() | 215 | void KAddressBookCardView::scrollDOWN() |
214 | { | 216 | { |
215 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); | 217 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); |
216 | QApplication::postEvent( mCardView, ev ); | 218 | QApplication::postEvent( mCardView, ev ); |
219 | ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 ); | ||
220 | QApplication::postEvent( mCardView, ev ); | ||
217 | } | 221 | } |
218 | void KAddressBookCardView::readConfig(KConfig *config) | 222 | void KAddressBookCardView::readConfig(KConfig *config) |
219 | { | 223 | { |
220 | KAddressBookView::readConfig(config); | 224 | KAddressBookView::readConfig(config); |
221 | 225 | ||
222 | // costum colors? | 226 | // costum colors? |
223 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) | 227 | if ( config->readBoolEntry( "EnableCustomColors", false ) ) |
224 | { | 228 | { |
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() | |||
56 | if ( mListView ) | 56 | if ( mListView ) |
57 | mListView->setFocus(); | 57 | mListView->setFocus(); |
58 | 58 | ||
59 | } | 59 | } |
60 | void KAddressBookTableView::scrollUP() | 60 | void KAddressBookTableView::scrollUP() |
61 | { | 61 | { |
62 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); | 62 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); |
63 | QApplication::postEvent( mListView, ev ); | 63 | QApplication::postEvent( mListView, ev ); |
64 | ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Up, 0,0 ); | ||
65 | QApplication::postEvent( mListView, ev ); | ||
64 | } | 66 | } |
65 | void KAddressBookTableView::scrollDOWN() | 67 | void KAddressBookTableView::scrollDOWN() |
66 | { | 68 | { |
67 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); | 69 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); |
68 | QApplication::postEvent( mListView, ev ); | 70 | QApplication::postEvent( mListView, ev ); |
71 | ev = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Down, 0,0 ); | ||
72 | QApplication::postEvent( mListView, ev ); | ||
69 | } | 73 | } |
70 | void KAddressBookTableView::reconstructListView() | 74 | void KAddressBookTableView::reconstructListView() |
71 | { | 75 | { |
72 | if (mListView) | 76 | if (mListView) |
73 | { | 77 | { |
74 | disconnect(mListView, SIGNAL(selectionChanged()), | 78 | disconnect(mListView, SIGNAL(selectionChanged()), |
75 | this, SLOT(addresseeSelected())); | 79 | this, SLOT(addresseeSelected())); |
76 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), | 80 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), |