1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Code cleanup

This commit is contained in:
Martin Tůma 2020-11-22 14:51:57 +01:00
parent dc209bd96e
commit 524a854d35
4 changed files with 6 additions and 20 deletions

View File

@ -11,11 +11,11 @@ AxisLabelItem::AxisLabelItem(Type type, QGraphicsItem *parent)
_font.setFamily(FONT_FAMILY);
}
void AxisLabelItem::setLabel(const QString& label)
void AxisLabelItem::setLabel(const QString& label, const QString &units)
{
prepareGeometryChange();
QFontMetrics fm(_font);
_label = label;
_label = QString("%1 [%2]").arg(label, units.isEmpty() ? "-" : units);
_labelBB = fm.tightBoundingRect(label);
updateBoundingRect();
update();

View File

@ -15,7 +15,7 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
void setLabel(const QString& label);
void setLabel(const QString& label, const QString &units);
private:
void updateBoundingRect();

View File

@ -89,28 +89,16 @@ GraphView::~GraphView()
delete _message;
}
void GraphView::createXLabel()
{
_xAxisLabel->setLabel(QString("%1 [%2]").arg(_xLabel,
_xUnits.isEmpty() ? "-" : _xUnits));
}
void GraphView::createYLabel()
{
_yAxisLabel->setLabel(QString("%1 [%2]").arg(_yLabel,
_yUnits.isEmpty() ? "-" : _yUnits));
}
void GraphView::setYLabel(const QString &label)
{
_yLabel = label;
createYLabel();
_yAxisLabel->setLabel(_yLabel, _yUnits);
}
void GraphView::setYUnits(const QString &units)
{
_yUnits = units;
createYLabel();
_yAxisLabel->setLabel(_yLabel, _yUnits);
}
void GraphView::setXUnits()
@ -154,7 +142,7 @@ void GraphView::setXUnits()
}
}
createXLabel();
_xAxisLabel->setLabel(_xLabel, _xUnits);
}
void GraphView::setUnits(Units units)

View File

@ -87,8 +87,6 @@ private slots:
private:
void redraw(const QSizeF &size);
void setXUnits();
void createXLabel();
void createYLabel();
void updateSliderPosition();
void updateSliderInfo();
void removeItem(QGraphicsItem *item);