1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-18 03:42:09 +01:00

Some more performance improvement magic

This commit is contained in:
Martin Tůma 2016-09-14 22:37:12 +02:00
parent 6034685fa0
commit b369ffacef
3 changed files with 15 additions and 7 deletions

View File

@ -18,6 +18,7 @@
#include <QLabel>
#include <QSettings>
#include <QLocale>
#include <QPixmapCache>
#include "config.h"
#include "icons.h"
#include "keys.h"
@ -90,6 +91,8 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
_exportOrientation = QPrinter::Portrait;
_exportFileName = QString("%1/export.pdf").arg(QDir::currentPath());
_exportMargins = MarginsF(5.0, 5.0, 5.0, 5.0);
QPixmapCache::setCacheLimit(65536);
}
GUI::~GUI()

View File

@ -26,6 +26,11 @@ void RouteItem::updateShape()
QPainterPathStroker s;
s.setWidth(HOVER_WIDTH * 1.0/scale());
_shape = s.createStroke(_path);
if (qMax(boundingRect().width(), boundingRect().height()) * scale() <= 768)
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
else
setCacheMode(QGraphicsItem::NoCache);
}
RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
@ -53,7 +58,6 @@ RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
setToolTip(toolTip());
setCursor(Qt::ArrowCursor);
setAcceptHoverEvents(true);
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
updateShape();
@ -74,8 +78,7 @@ void RouteItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
painter->drawPath(_path);
/*
QPen p = QPen(Qt::red);
p.setWidthF(1.0/scale());
QPen p = QPen(QBrush(Qt::red), 0);
painter->setPen(p);
painter->drawRect(boundingRect());
*/

View File

@ -30,6 +30,11 @@ void TrackItem::updateShape()
QPainterPathStroker s;
s.setWidth(HOVER_WIDTH * 1.0/scale());
_shape = s.createStroke(_path);
if (qMax(boundingRect().width(), boundingRect().height()) * scale() <= 768)
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
else
setCacheMode(QGraphicsItem::NoCache);
}
TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
@ -53,7 +58,6 @@ TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
setToolTip(toolTip());
setCursor(Qt::ArrowCursor);
setAcceptHoverEvents(true);
setCacheMode(QGraphicsItem::DeviceCoordinateCache);
updateShape();
@ -74,10 +78,8 @@ void TrackItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
painter->drawPath(_path);
/*
QPen p = QPen(Qt::red);
p.setWidthF(1.0/scale());
QPen p = QPen(QBrush(Qt::red), 0);
painter->setPen(p);
painter->setBrush(Qt::NoBrush);
painter->drawRect(boundingRect());
*/
}