From 73a4be7143725e0348dce5a16f1bb949ac61f4c8 Mon Sep 17 00:00:00 2001 From: Edwin Leuven Date: Sun, 11 Jun 2006 14:28:10 +0000 Subject: [PATCH] more cleanup: some formatting and handle mouse events in their event handlers (and not in event()) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14072 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/InsertTableWidget.C | 49 ++++++++------------------- src/frontends/qt4/InsertTableWidget.h | 4 +-- 2 files changed, 15 insertions(+), 38 deletions(-) diff --git a/src/frontends/qt4/InsertTableWidget.C b/src/frontends/qt4/InsertTableWidget.C index 270bf3820e..319e6fd227 100644 --- a/src/frontends/qt4/InsertTableWidget.C +++ b/src/frontends/qt4/InsertTableWidget.C @@ -16,7 +16,6 @@ #include "FuncStatus.h" #include "funcrequest.h" #include "LyXView.h" -#include "debug.h" #include "qt_helpers.h" @@ -25,7 +24,6 @@ #include #include #include -#include namespace lyx { @@ -75,13 +73,17 @@ void InsertTableWidget::mouseMoveEvent(QMouseEvent * event) // do this ourselves because when the mouse leaves the app // we get an enter event (ie underMouse() is true)!! underMouse_ = geometry().contains(event->globalPos()); - if (!underMouse_) + if (!underMouse_) { + bottom_ = 0; + right_ = 0; + update(); return; + } int const r0 = right_; int const b0 = bottom_; - right_ = event->x()/colwidth_ + 1; - bottom_ = event->y()/rowheight_ + 1; + right_ = event->x() / colwidth_ + 1; + bottom_ = event->y() / rowheight_ + 1; if (bottom_ == rows_) { ++rows_; @@ -95,41 +97,12 @@ void InsertTableWidget::mouseMoveEvent(QMouseEvent * event) if (bottom_ != b0 || right_ != r0) { update(); - QString status = QString("%1x%2").arg(bottom_).arg(right_); + QString const status = QString("%1x%2").arg(bottom_).arg(right_); QToolTip::showText(event->globalPos(), status , this); } } -bool InsertTableWidget::event(QEvent * event) -{ - switch (event->type()) { - case QEvent::MouseMove: { - QMouseEvent * me = dynamic_cast(event); - mouseMoveEvent(me); - return true; - } - case QEvent::MouseButtonRelease: { - QMouseEvent * me = dynamic_cast(event); - mouseReleaseEvent(me); - return true; - } - case QEvent::MouseButtonPress: { - // swallow this one... - return true; - } - case QEvent::Leave: { - bottom_ = 0; - right_ = 0; - update(); - return true; - } - default: - return QWidget::event(event); - } -} - - void InsertTableWidget::mouseReleaseEvent(QMouseEvent * event) { if (underMouse_) { @@ -141,6 +114,12 @@ void InsertTableWidget::mouseReleaseEvent(QMouseEvent * event) } +void InsertTableWidget::mousePressEvent(QMouseEvent * event) +{ + // swallow this one +} + + void InsertTableWidget::paintEvent(QPaintEvent * event) { drawGrid(rows_, cols_, Qt::white); diff --git a/src/frontends/qt4/InsertTableWidget.h b/src/frontends/qt4/InsertTableWidget.h index c055048290..176ed95417 100644 --- a/src/frontends/qt4/InsertTableWidget.h +++ b/src/frontends/qt4/InsertTableWidget.h @@ -16,8 +16,6 @@ #include "frontends/LyXView.h" #include -class QSize; - namespace lyx { namespace frontend { @@ -39,9 +37,9 @@ public slots: void updateParent(); protected slots: - bool event(QEvent *); void mouseMoveEvent(QMouseEvent *); void mouseReleaseEvent(QMouseEvent *); + void mousePressEvent(QMouseEvent *); void paintEvent(QPaintEvent *); private: