mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 03:03:06 +00:00
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:
parent
7c00f14cc1
commit
73a4be7143
@ -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,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<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);
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user