Diffstat (limited to 'kaddressbook/views/cardview.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kaddressbook/views/cardview.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/kaddressbook/views/cardview.cpp b/kaddressbook/views/cardview.cpp index 6351c11..da552c3 100644 --- a/kaddressbook/views/cardview.cpp +++ b/kaddressbook/views/cardview.cpp | |||
@@ -13,48 +13,49 @@ | |||
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | //BEGIN Includes | 24 | //BEGIN Includes |
25 | #include "cardview.h" | 25 | #include "cardview.h" |
26 | 26 | ||
27 | #include <limits.h> | 27 | #include <limits.h> |
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 | 36 | ||
37 | #include "kabprefs.h" | ||
37 | #include <kdebug.h> | 38 | #include <kdebug.h> |
38 | #include <kglobalsettings.h> | 39 | #include <kglobalsettings.h> |
39 | //END includes | 40 | //END includes |
40 | 41 | ||
41 | #define MIN_ITEM_WIDTH 80 | 42 | #define MIN_ITEM_WIDTH 80 |
42 | 43 | ||
43 | //BEGIN Helpers | 44 | //BEGIN Helpers |
44 | ////////////////////////////////////// | 45 | ////////////////////////////////////// |
45 | // CardViewTip | 46 | // CardViewTip |
46 | class CardViewTip : public QLabel { | 47 | class CardViewTip : public QLabel { |
47 | public: | 48 | public: |
48 | CardViewTip(QWidget *parent=0, const char *name=0) : QLabel( parent, name ) | 49 | CardViewTip(QWidget *parent=0, const char *name=0) : QLabel( parent, name ) |
49 | { | 50 | { |
50 | setPalette( QToolTip::palette() ); | 51 | setPalette( QToolTip::palette() ); |
51 | setFrameStyle( Panel|Plain ); | 52 | setFrameStyle( Panel|Plain ); |
52 | setMidLineWidth(0); | 53 | setMidLineWidth(0); |
53 | setIndent(1); | 54 | setIndent(1); |
54 | } | 55 | } |
55 | 56 | ||
56 | ~CardViewTip() {}; | 57 | ~CardViewTip() {}; |
57 | protected: | 58 | protected: |
58 | void leaveEvent( QEvent * ) | 59 | void leaveEvent( QEvent * ) |
59 | { | 60 | { |
60 | hide(); | 61 | hide(); |
@@ -635,49 +636,48 @@ CardViewItem::Field *CardViewItem::fieldAt( const QPoint & itempos ) const | |||
635 | //BEGIN CardView | 636 | //BEGIN CardView |
636 | 637 | ||
637 | CardView::CardView(QWidget *parent, const char *name) | 638 | CardView::CardView(QWidget *parent, const char *name) |
638 | : QScrollView(parent, name), | 639 | : QScrollView(parent, name), |
639 | d(new CardViewPrivate()) | 640 | d(new CardViewPrivate()) |
640 | { | 641 | { |
641 | d->mItemList.setAutoDelete(true); | 642 | d->mItemList.setAutoDelete(true); |
642 | d->mSeparatorList.setAutoDelete(true); | 643 | d->mSeparatorList.setAutoDelete(true); |
643 | 644 | ||
644 | QFont f = font(); | 645 | QFont f = font(); |
645 | d->mFm = new QFontMetrics(f); | 646 | d->mFm = new QFontMetrics(f); |
646 | f.setBold(true); | 647 | f.setBold(true); |
647 | d->mHeaderFont = f; | 648 | d->mHeaderFont = f; |
648 | d->mBFm = new QFontMetrics(f); | 649 | d->mBFm = new QFontMetrics(f); |
649 | d->mTip = ( new CardViewTip( viewport() ) ), | 650 | d->mTip = ( new CardViewTip( viewport() ) ), |
650 | d->mTip->hide(); | 651 | d->mTip->hide(); |
651 | d->mTimer = ( new QTimer(this, "mouseTimer") ), | 652 | d->mTimer = ( new QTimer(this, "mouseTimer") ), |
652 | 653 | ||
653 | viewport()->setMouseTracking( true ); | 654 | viewport()->setMouseTracking( true ); |
654 | viewport()->setFocusProxy(this); | 655 | viewport()->setFocusProxy(this); |
655 | viewport()->setFocusPolicy(WheelFocus); | 656 | viewport()->setFocusPolicy(WheelFocus); |
656 | viewport()->setBackgroundMode(PaletteBase); | 657 | viewport()->setBackgroundMode(PaletteBase); |
657 | 658 | ||
658 | connect( d->mTimer, SIGNAL(timeout()), this, SLOT(tryShowFullText()) ); | 659 | connect( d->mTimer, SIGNAL(timeout()), this, SLOT(tryShowFullText()) ); |
659 | connect( this, SIGNAL(executed(CardViewItem *)), this, SIGNAL( doubleClicked(CardViewItem *)) ); | ||
660 | 660 | ||
661 | //US setBackgroundMode(PaletteBackground, PaletteBase); | 661 | //US setBackgroundMode(PaletteBackground, PaletteBase); |
662 | setBackgroundMode(PaletteBackground); | 662 | setBackgroundMode(PaletteBackground); |
663 | 663 | ||
664 | // no reason for a vertical scrollbar | 664 | // no reason for a vertical scrollbar |
665 | setVScrollBarMode(AlwaysOff); | 665 | setVScrollBarMode(AlwaysOff); |
666 | } | 666 | } |
667 | 667 | ||
668 | CardView::~CardView() | 668 | CardView::~CardView() |
669 | { | 669 | { |
670 | delete d->mFm; | 670 | delete d->mFm; |
671 | delete d->mBFm; | 671 | delete d->mBFm; |
672 | delete d; | 672 | delete d; |
673 | d = 0; | 673 | d = 0; |
674 | } | 674 | } |
675 | 675 | ||
676 | void CardView::insertItem(CardViewItem *item) | 676 | void CardView::insertItem(CardViewItem *item) |
677 | { | 677 | { |
678 | d->mItemList.inSort(item); | 678 | d->mItemList.inSort(item); |
679 | setLayoutDirty(true); | 679 | setLayoutDirty(true); |
680 | } | 680 | } |
681 | 681 | ||
682 | void CardView::takeItem(CardViewItem *item) | 682 | void CardView::takeItem(CardViewItem *item) |
683 | { | 683 | { |
@@ -1226,66 +1226,66 @@ void CardView::contentsMouseReleaseEvent(QMouseEvent *e) | |||
1226 | // hide rubber bands | 1226 | // hide rubber bands |
1227 | int newiw = d->mItemWidth - ((d->mResizeAnchor - d->mRubberBandAnchor)/d->span); | 1227 | int newiw = d->mItemWidth - ((d->mResizeAnchor - d->mRubberBandAnchor)/d->span); |
1228 | drawRubberBands( 0 ); | 1228 | drawRubberBands( 0 ); |
1229 | // we should move to reflect the new position if we are scrolled. | 1229 | // we should move to reflect the new position if we are scrolled. |
1230 | if ( contentsX() ) | 1230 | if ( contentsX() ) |
1231 | { | 1231 | { |
1232 | int newX = QMAX( 0, ( d->pressed * ( newiw + d->colspace + d->mSepWidth ) ) - e->x() ); | 1232 | int newX = QMAX( 0, ( d->pressed * ( newiw + d->colspace + d->mSepWidth ) ) - e->x() ); |
1233 | setContentsPos( newX, contentsY() ); | 1233 | setContentsPos( newX, contentsY() ); |
1234 | } | 1234 | } |
1235 | // set new item width | 1235 | // set new item width |
1236 | setItemWidth( newiw ); | 1236 | setItemWidth( newiw ); |
1237 | // reset anchors | 1237 | // reset anchors |
1238 | d->mResizeAnchor = 0; | 1238 | d->mResizeAnchor = 0; |
1239 | d->mRubberBandAnchor = 0; | 1239 | d->mRubberBandAnchor = 0; |
1240 | return; | 1240 | return; |
1241 | } | 1241 | } |
1242 | 1242 | ||
1243 | // If there are accel keys, we will not emit signals | 1243 | // If there are accel keys, we will not emit signals |
1244 | if ((e->state() & Qt::ShiftButton) || (e->state() & Qt::ControlButton)) | 1244 | if ((e->state() & Qt::ShiftButton) || (e->state() & Qt::ControlButton)) |
1245 | return; | 1245 | return; |
1246 | 1246 | ||
1247 | // Get the item at this position | 1247 | // Get the item at this position |
1248 | CardViewItem *item = itemAt(e->pos()); | 1248 | CardViewItem *item = itemAt(e->pos()); |
1249 | 1249 | ||
1250 | if (item && KGlobalSettings::singleClick()) | 1250 | if (item && KABPrefs::instance()->mHonorSingleClick) |
1251 | { | 1251 | { |
1252 | emit executed(item); | 1252 | emit executed(item); |
1253 | } | 1253 | } |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | void CardView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1256 | void CardView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
1257 | { | 1257 | { |
1258 | QScrollView::contentsMouseDoubleClickEvent(e); | 1258 | QScrollView::contentsMouseDoubleClickEvent(e); |
1259 | 1259 | ||
1260 | CardViewItem *item = itemAt(e->pos()); | 1260 | CardViewItem *item = itemAt(e->pos()); |
1261 | 1261 | ||
1262 | if (item) | 1262 | if (item) |
1263 | { | 1263 | { |
1264 | d->mCurrentItem = item; | 1264 | d->mCurrentItem = item; |
1265 | } | 1265 | } |
1266 | 1266 | ||
1267 | if (item && !KGlobalSettings::singleClick()) | 1267 | if (item && !KABPrefs::instance()->mHonorSingleClick) |
1268 | { | 1268 | { |
1269 | emit executed(item); | 1269 | emit executed(item); |
1270 | } else | 1270 | } else |
1271 | emit doubleClicked(item); | 1271 | emit doubleClicked(item); |
1272 | } | 1272 | } |
1273 | 1273 | ||
1274 | void CardView::contentsMouseMoveEvent( QMouseEvent *e ) | 1274 | void CardView::contentsMouseMoveEvent( QMouseEvent *e ) |
1275 | { | 1275 | { |
1276 | // resizing | 1276 | // resizing |
1277 | if ( d->mResizeAnchor ) | 1277 | if ( d->mResizeAnchor ) |
1278 | { | 1278 | { |
1279 | int x = e->x(); | 1279 | int x = e->x(); |
1280 | if ( x != d->mRubberBandAnchor ) | 1280 | if ( x != d->mRubberBandAnchor ) |
1281 | drawRubberBands( x ); | 1281 | drawRubberBands( x ); |
1282 | return; | 1282 | return; |
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | if (d->mLastClickOnItem && (e->state() & Qt::LeftButton) && | 1285 | if (d->mLastClickOnItem && (e->state() & Qt::LeftButton) && |
1286 | ((e->pos() - d->mLastClickPos).manhattanLength() > 4)) { | 1286 | ((e->pos() - d->mLastClickPos).manhattanLength() > 4)) { |
1287 | 1287 | ||
1288 | startDrag(); | 1288 | startDrag(); |
1289 | return; | 1289 | return; |
1290 | } | 1290 | } |
1291 | 1291 | ||