mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: explicitly clear profile items
In contrast to most other items, which are cleared in the setEmptyState() function, the profile items are cleared indirectly via a signal from the model. Very hard to follow and indeed, I thought I could just remove the slot. Do this explicitly instead for deterministic code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
e61466e178
commit
02fbaffe4c
3 changed files with 10 additions and 9 deletions
|
@ -18,12 +18,18 @@ AbstractProfilePolygonItem::AbstractProfilePolygonItem(const DivePlotDataModel &
|
||||||
{
|
{
|
||||||
setCacheMode(DeviceCoordinateCache);
|
setCacheMode(DeviceCoordinateCache);
|
||||||
connect(&dataModel, &DivePlotDataModel::dataChanged, this, &AbstractProfilePolygonItem::modelDataChanged);
|
connect(&dataModel, &DivePlotDataModel::dataChanged, this, &AbstractProfilePolygonItem::modelDataChanged);
|
||||||
connect(&dataModel, &DivePlotDataModel::rowsAboutToBeRemoved, this, &AbstractProfilePolygonItem::modelDataRemoved);
|
|
||||||
connect(&hAxis, &DiveCartesianAxis::sizeChanged, this, &AbstractProfilePolygonItem::replot);
|
connect(&hAxis, &DiveCartesianAxis::sizeChanged, this, &AbstractProfilePolygonItem::replot);
|
||||||
connect(&vAxis, &DiveCartesianAxis::sizeChanged, this, &AbstractProfilePolygonItem::replot);
|
connect(&vAxis, &DiveCartesianAxis::sizeChanged, this, &AbstractProfilePolygonItem::replot);
|
||||||
connect(&vAxis, &DiveCartesianAxis::maxChanged, this, &AbstractProfilePolygonItem::replot);
|
connect(&vAxis, &DiveCartesianAxis::maxChanged, this, &AbstractProfilePolygonItem::replot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AbstractProfilePolygonItem::clear()
|
||||||
|
{
|
||||||
|
setPolygon(QPolygonF());
|
||||||
|
qDeleteAll(texts);
|
||||||
|
texts.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void AbstractProfilePolygonItem::replot()
|
void AbstractProfilePolygonItem::replot()
|
||||||
{
|
{
|
||||||
modelDataChanged();
|
modelDataChanged();
|
||||||
|
@ -34,13 +40,6 @@ void AbstractProfilePolygonItem::setVisible(bool visible)
|
||||||
QGraphicsPolygonItem::setVisible(visible);
|
QGraphicsPolygonItem::setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractProfilePolygonItem::modelDataRemoved(const QModelIndex&, int, int)
|
|
||||||
{
|
|
||||||
setPolygon(QPolygonF());
|
|
||||||
qDeleteAll(texts);
|
|
||||||
texts.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AbstractProfilePolygonItem::shouldCalculateStuff(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
bool AbstractProfilePolygonItem::shouldCalculateStuff(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
||||||
{
|
{
|
||||||
if (dataModel.rowCount() == 0)
|
if (dataModel.rowCount() == 0)
|
||||||
|
|
|
@ -37,10 +37,10 @@ class AbstractProfilePolygonItem : public QObject, public QGraphicsPolygonItem {
|
||||||
public:
|
public:
|
||||||
AbstractProfilePolygonItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
AbstractProfilePolygonItem(const DivePlotDataModel &model, const DiveCartesianAxis &hAxis, int hColumn, const DiveCartesianAxis &vAxis, int vColumn);
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0;
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0;
|
||||||
|
void clear();
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
|
virtual void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
|
||||||
virtual void modelDataRemoved(const QModelIndex &parent, int from, int to);
|
|
||||||
void replot();
|
void replot();
|
||||||
void setVisible(bool visible);
|
void setVisible(bool visible);
|
||||||
|
|
||||||
|
|
|
@ -1123,6 +1123,8 @@ void ProfileWidget2::setEmptyState()
|
||||||
heartBeatAxis->setVisible(false);
|
heartBeatAxis->setVisible(false);
|
||||||
heartBeatItem->setVisible(false);
|
heartBeatItem->setVisible(false);
|
||||||
#endif
|
#endif
|
||||||
|
for (AbstractProfilePolygonItem *item: profileItems)
|
||||||
|
item->clear();
|
||||||
|
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
hideAll(allTissues);
|
hideAll(allTissues);
|
||||||
|
|
Loading…
Add table
Reference in a new issue