Cleanup: constify threshold pointers in DiveProfileItem

These were pointers into the global prefs object. The user must
not use these to modify the settings, therefore make them
pointers-to-const.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-09-02 22:26:19 +02:00 committed by Dirk Hohndel
parent 2bd0c2143e
commit db57a633d5
4 changed files with 6 additions and 6 deletions

View file

@ -999,7 +999,7 @@ void PartialPressureGasItem::paint(QPainter *painter, const QStyleOptionGraphics
painter->restore(); painter->restore();
} }
void PartialPressureGasItem::setThresholdSettingsKey(double *prefPointerMin, double *prefPointerMax) void PartialPressureGasItem::setThresholdSettingsKey(const double *prefPointerMin, const double *prefPointerMax)
{ {
thresholdPtrMin = prefPointerMin; thresholdPtrMin = prefPointerMin;
thresholdPtrMax = prefPointerMax; thresholdPtrMax = prefPointerMax;

View file

@ -213,14 +213,14 @@ public:
PartialPressureGasItem(); PartialPressureGasItem();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex()); void modelDataChanged(const QModelIndex &topLeft = QModelIndex(), const QModelIndex &bottomRight = QModelIndex());
void setThresholdSettingsKey(double *prefPointerMin, double *prefPointerMax); void setThresholdSettingsKey(const double *prefPointerMin, const double *prefPointerMax);
void setVisibilitySettingsKey(const QString &setVisibilitySettingsKey); void setVisibilitySettingsKey(const QString &setVisibilitySettingsKey);
void setColors(const QColor &normalColor, const QColor &alertColor); void setColors(const QColor &normalColor, const QColor &alertColor);
private: private:
QVector<QPolygonF> alertPolygons; QVector<QPolygonF> alertPolygons;
double *thresholdPtrMin; const double *thresholdPtrMin;
double *thresholdPtrMax; const double *thresholdPtrMax;
QString visibilityKey; QString visibilityKey;
QColor normalColor; QColor normalColor;
QColor alertColor; QColor alertColor;

View file

@ -378,7 +378,7 @@ void ProfileWidget2::replot(struct dive *d)
} }
void ProfileWidget2::createPPGas(PartialPressureGasItem *item, int verticalColumn, color_index_t color, color_index_t colorAlert, void ProfileWidget2::createPPGas(PartialPressureGasItem *item, int verticalColumn, color_index_t color, color_index_t colorAlert,
double *thresholdSettingsMin, double *thresholdSettingsMax) const double *thresholdSettingsMin, const double *thresholdSettingsMax)
{ {
setupItem(item, gasYAxis, verticalColumn, DivePlotDataModel::TIME, 0); setupItem(item, gasYAxis, verticalColumn, DivePlotDataModel::TIME, 0);
item->setThresholdSettingsKey(thresholdSettingsMin, thresholdSettingsMax); item->setThresholdSettingsKey(thresholdSettingsMin, thresholdSettingsMax);

View file

@ -171,7 +171,7 @@ private: /*methods*/
struct plot_data *getEntryFromPos(QPointF pos); struct plot_data *getEntryFromPos(QPointF pos);
void addActionShortcut(const Qt::Key shortcut, void (ProfileWidget2::*slot)()); void addActionShortcut(const Qt::Key shortcut, void (ProfileWidget2::*slot)());
void createPPGas(PartialPressureGasItem *item, int verticalColumn, color_index_t color, color_index_t colorAlert, void createPPGas(PartialPressureGasItem *item, int verticalColumn, color_index_t color, color_index_t colorAlert,
double *thresholdSettingsMin, double *thresholdSettingsMax); const double *thresholdSettingsMin, const double *thresholdSettingsMax);
void clearPictures(); void clearPictures();
private: private:
DivePlotDataModel *dataModel; DivePlotDataModel *dataModel;