1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01:00

Code cleanup

This commit is contained in:
Martin Tůma 2016-10-29 18:01:25 +02:00
parent c89f8dbb47
commit 0d1b416c4f
2 changed files with 15 additions and 29 deletions

View File

@ -1,5 +1,6 @@
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsScene>
#include <QEvent>
#include <QMouseEvent>
#include <QPaintEngine>
#include <QPaintDevice>
#include "config.h"
@ -16,20 +17,10 @@
#define MARGIN 10.0
void Scene::mousePressEvent(QGraphicsSceneMouseEvent *e)
{
if (e->button() == Qt::LeftButton)
emit mouseClicked(e->scenePos());
QGraphicsScene::mousePressEvent(e);
}
GraphView::GraphView(QWidget *parent)
: QGraphicsView(parent)
{
_scene = new Scene(this);
_scene = new QGraphicsScene();
setScene(_scene);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@ -48,8 +39,6 @@ GraphView::GraphView(QWidget *parent)
connect(_slider, SIGNAL(positionChanged(const QPointF&)), this,
SLOT(emitSliderPositionChanged(const QPointF&)));
connect(_scene, SIGNAL(mouseClicked(const QPointF&)), this,
SLOT(newSliderPosition(const QPointF&)));
_xScale = 1;
_yScale = 1;
@ -322,6 +311,14 @@ void GraphView::resizeEvent(QResizeEvent *)
redraw();
}
void GraphView::mousePressEvent(QMouseEvent *e)
{
if (e->button() == Qt::LeftButton)
newSliderPosition(mapToScene(e->pos()));
QGraphicsView::mousePressEvent(e);
}
void GraphView::plot(QPainter *painter, const QRectF &target)
{
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()

View File

@ -2,11 +2,9 @@
#define GRAPHVIEW_H
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QVector>
#include <QList>
#include <QSet>
#include <QPointF>
#include "palette.h"
#include "units.h"
#include "graph.h"
@ -20,17 +18,6 @@ class GraphItem;
class PathItem;
class GridItem;
class Scene : public QGraphicsScene
{
Q_OBJECT
public:
Scene(QObject *parent = 0) : QGraphicsScene(parent) {}
void mousePressEvent(QGraphicsSceneMouseEvent *e);
signals:
void mouseClicked(const QPointF &pos);
};
class GraphView : public QGraphicsView
{
@ -76,7 +63,6 @@ protected:
void addInfo(const QString &key, const QString &value);
void clearInfo();
void skipColor() {_palette.color();}
void resizeEvent(QResizeEvent *);
private slots:
void emitSliderPositionChanged(const QPointF &pos);
@ -91,6 +77,9 @@ private:
void removeItem(QGraphicsItem *item);
void addItem(QGraphicsItem *item);
void resizeEvent(QResizeEvent *);
void mousePressEvent(QMouseEvent *);
qreal _xScale, _yScale;
qreal _yOffset;
QString _xUnits, _yUnits;
@ -99,7 +88,7 @@ private:
qreal _minYRange;
qreal _sliderPos;
Scene *_scene;
QGraphicsScene *_scene;
AxisItem *_xAxis, *_yAxis;
SliderItem *_slider;