diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2014-02-04 17:34:16 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-02-05 06:30:33 -0800 |
commit | 25b0a846af1d4661d16c3de9784879ad44476d08 (patch) | |
tree | aaf3618ea0a81da09c26f03c2dc95eea6e24ae21 /qt-ui/profile/diveprofileitem.h | |
parent | 0ae7c820f24a4f0609fc0f08e425f0a506cf5d92 (diff) | |
download | subsurface-25b0a846af1d4661d16c3de9784879ad44476d08.tar.gz |
Created a method to check if calculations should take place.
Created a method to check if calculations should take place
taking into consideration what changed on the model. if the
model changes *everything*, them, all calculations should
be done, but if just some of the columns of the model are
changed, only those columns should trigger an visual update
on the items.
In theory this patch looks right, but something is wrong (
calculations are not being made. ), so I'll commit this any
how, and fix on the next commit.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/diveprofileitem.h')
-rw-r--r-- | qt-ui/profile/diveprofileitem.h | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h index 980b99213..4dd32b9fa 100644 --- a/qt-ui/profile/diveprofileitem.h +++ b/qt-ui/profile/diveprofileitem.h @@ -3,6 +3,8 @@ #include <QObject> #include <QGraphicsPolygonItem> +#include <QModelIndex> + #include "graphicsview-common.h" #include "divelineitem.h" @@ -41,8 +43,17 @@ public: virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) = 0; public slots: virtual void preferencesChanged(); - virtual void modelDataChanged(); + virtual void modelDataChanged(const QModelIndex& topLeft = QModelIndex(), const QModelIndex& bottomRight = QModelIndex()); protected: + /* when the model emits a 'datachanged' signal, this method below should be used to check if the + * modified data affects this particular item ( for example, when setting the '3m increment' + * the data for Ceiling and tissues will be changed, and only those. so, the topLeft will be the CEILING + * column and the bottomRight will have the TISSUE_16 column. this method takes the vDataColumn and hDataColumn + * into consideration when returning 'true' for "yes, continue the calculation', and 'false' for + * 'do not recalculate, we already have the right data. + */ + bool shouldCalculateStuff(const QModelIndex& topLeft, const QModelIndex& bottomRight); + DiveCartesianAxis *hAxis; DiveCartesianAxis *vAxis; DivePlotDataModel *dataModel; @@ -56,7 +67,7 @@ class DiveProfileItem : public AbstractProfilePolygonItem{ public: virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); - virtual void modelDataChanged(); + virtual void modelDataChanged(const QModelIndex& topLeft = QModelIndex(), const QModelIndex& bottomRight = QModelIndex()); virtual void preferencesChanged(); void plot_depth_sample(struct plot_data *entry,QFlags<Qt::AlignmentFlag> flags,const QColor& color); private: @@ -68,7 +79,7 @@ class DiveTemperatureItem : public AbstractProfilePolygonItem{ Q_OBJECT public: DiveTemperatureItem(); - virtual void modelDataChanged(); + virtual void modelDataChanged(const QModelIndex& topLeft = QModelIndex(), const QModelIndex& bottomRight = QModelIndex()); virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); private: void createTextItem(int seconds, int mkelvin); @@ -78,7 +89,7 @@ class DiveGasPressureItem : public AbstractProfilePolygonItem{ Q_OBJECT public: - virtual void modelDataChanged(); + virtual void modelDataChanged(const QModelIndex& topLeft = QModelIndex(), const QModelIndex& bottomRight = QModelIndex()); virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); private: void plot_pressure_value(int mbar, int sec, QFlags<Qt::AlignmentFlag> align); @@ -91,10 +102,11 @@ class DiveCalculatedCeiling : public AbstractProfilePolygonItem{ public: DiveCalculatedCeiling(); - virtual void modelDataChanged(); + virtual void modelDataChanged(const QModelIndex& topLeft = QModelIndex(), const QModelIndex& bottomRight = QModelIndex()); virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); virtual void preferencesChanged(); private: + bool is3mIncrement; DiveTextItem *gradientFactor; }; @@ -102,7 +114,7 @@ class DiveReportedCeiling : public AbstractProfilePolygonItem{ Q_OBJECT public: - virtual void modelDataChanged(); + virtual void modelDataChanged(const QModelIndex& topLeft = QModelIndex(), const QModelIndex& bottomRight = QModelIndex()); virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); virtual void preferencesChanged(); }; @@ -131,7 +143,7 @@ class PartialPressureGasItem : public AbstractProfilePolygonItem{ public: PartialPressureGasItem(); virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); - virtual void modelDataChanged(); + virtual void modelDataChanged(const QModelIndex& topLeft = QModelIndex(), const QModelIndex& bottomRight = QModelIndex()); virtual void preferencesChanged(); void setThreshouldSettingsKey(const QString& threshouldSettingsKey); void setVisibilitySettingsKey(const QString& setVisibilitySettingsKey); |