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
This commit is contained in:
Edwin Leuven 2006-06-11 14:28:10 +00:00
parent 7c00f14cc1
commit 73a4be7143
2 changed files with 15 additions and 38 deletions

View File

@ -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 <QString>
#include <QToolTip>
#include <QPainter>
#include <QCoreApplication>
namespace lyx {
@ -75,8 +73,12 @@ 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_;
@ -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<QMouseEvent *>(event);
mouseMoveEvent(me);
return true;
}
case QEvent::MouseButtonRelease: {
QMouseEvent * me = dynamic_cast<QMouseEvent *>(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);

View File

@ -16,8 +16,6 @@
#include "frontends/LyXView.h"
#include <QWidget>
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: