1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Fixed broken slider position setting

Refactoring
This commit is contained in:
Martin Tůma 2016-03-23 09:22:26 +01:00
parent de71aa0d0c
commit 58bed99d14
2 changed files with 14 additions and 11 deletions

View File

@ -161,10 +161,10 @@ void GraphView::loadData(const QVector<QPointF> &data)
void GraphView::redraw()
{
if (!_graphs.isEmpty())
resize(viewport()->size() - QSizeF(MARGIN, MARGIN));
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
}
void GraphView::resize(const QSizeF &size)
void GraphView::redraw(const QSizeF &size)
{
QRectF r;
QSizeF mx, my;
@ -220,6 +220,7 @@ void GraphView::resize(const QSizeF &size)
_scene->addItem(_xAxis);
_scene->addItem(_yAxis);
qreal sp = (_slider->pos().x() == _slider->area().left())
? 0 : (_slider->pos().x() - _slider->area().left())
/ _slider->area().width();
@ -251,13 +252,13 @@ void GraphView::plot(QPainter *painter, const QRectF &target)
QSizeF orig = _scene->sceneRect().size();
QSizeF canvas = QSizeF(orig.height() * ratio, orig.height());
resize(canvas);
redraw(canvas);
_slider->hide();
_info->hide();
_scene->render(painter, target, QRectF());
_slider->show();
_info->show();
resize(orig);
redraw(orig);
}
void GraphView::clear()
@ -352,6 +353,9 @@ qreal GraphView::sliderPosition() const
void GraphView::setSliderPosition(qreal pos)
{
if (_graphs.isEmpty())
return;
if (pos > (_xMax - _xMin))
_slider->setVisible(false);
else {

View File

@ -44,24 +44,23 @@ public:
void setPrecision(int precision) {_precision = precision;}
void setMinRange(qreal range) {_minRange = range;}
void redraw();
void plot(QPainter *painter, const QRectF &target);
void clear();
qreal sliderPosition() const;
void setSliderPosition(qreal pos);
void addInfo(const QString &key, const QString &value);
void clearInfo();
void skipColor() {_palette.color();}
int count() const {return _graphs.count();}
signals:
void sliderPositionChanged(qreal);
protected:
void resizeEvent(QResizeEvent *);
void redraw();
void addInfo(const QString &key, const QString &value);
void clearInfo();
void skipColor() {_palette.color();}
qreal _xScale, _yScale;
QString _xUnits, _yUnits;
@ -77,7 +76,7 @@ private:
void createXLabel();
void createYLabel();
void updateBounds(const QPointF &point);
void resize(const QSizeF &size);
void redraw(const QSizeF &size);
Scene *_scene;