diff options
Diffstat (limited to 'qt-ui/diveplanner.h')
-rw-r--r-- | qt-ui/diveplanner.h | 82 |
1 files changed, 72 insertions, 10 deletions
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 2239e013d..0aea77788 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -4,11 +4,58 @@ #include <QGraphicsView> #include <QGraphicsPathItem> #include <QDialog> +#include <QAbstractTableModel> +#include <QDateTime> + +#include "dive.h" + +namespace Ui{ + class DivePlanner; +}; class QListView; class QStringListModel; class QModelIndex; +// Return a Model containing the air types. +QStringListModel *airTypes(); + +class DivePlannerPointsModel : public QAbstractTableModel{ + Q_OBJECT +public: + static DivePlannerPointsModel* instance(); + enum Sections{REMOVE, DEPTH, DURATION, GAS, CCSETPOINT, COLUMNS}; + virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; + virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; + virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; + virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); + virtual Qt::ItemFlags flags(const QModelIndex& index) const; + void removeSelectedPoints(const QVector<int>& rows); + + /** + * @return the row number. + */ + int addStop(int meters, int minutes,const QString& gas, int ccpoint ); + void editStop(int row, divedatapoint newData ); + divedatapoint at(int row); +public slots: + void setGFHigh(short gfhigh); + void setGFLow(short ghflow); + void setSurfacePressure(int pressure); + void setBottomSac(int sac); + void setDecoSac(int sac); + void setStartTime(const QTime& t); + void setLastStop6m(bool value); + void createPlan(); + void removePoint(const QModelIndex& index); + +private: + explicit DivePlannerPointsModel(QObject* parent = 0); + struct diveplan diveplan; + QVector<divedatapoint> divepoints; +}; + class Button : public QObject, public QGraphicsRectItem { Q_OBJECT public: @@ -28,10 +75,8 @@ private: class DiveHandler : public QGraphicsEllipseItem{ public: DiveHandler(); - int sec; - int mm; protected: - void mousePressEvent(QGraphicsSceneMouseEvent* event); + void mousePressEvent(QGraphicsSceneMouseEvent* event); }; class Ruler : public QGraphicsLineItem{ @@ -72,8 +117,6 @@ protected: virtual void mouseMoveEvent(QMouseEvent* event); virtual void mousePressEvent(QMouseEvent* event); virtual void mouseReleaseEvent(QMouseEvent* event); - - void createDecoStops(); bool isPointOutOfBoundaries(const QPointF& point); void deleteTemporaryDivePlan(struct divedatapoint* dp); qreal fromPercent(qreal percent, Qt::Orientation orientation); @@ -88,11 +131,12 @@ private slots: void increaseDepth(); void decreaseTime(); void decreaseDepth();; - void okClicked(); - void cancelClicked(); + void createDecoStops(); + void cancelPlan(); void prepareSelectGas(); void selectGas(const QModelIndex& index); - + void pointInserted(const QModelIndex&, int start, int end); + void pointsRemoved(const QModelIndex&, int start, int end); private: void moveActiveHandler(const QPointF& pos); @@ -138,11 +182,29 @@ private: Button *plusDepth; // adds 10 meters to the depth ruler. Button *lessTime; // remove 10 minutes to the time ruler. Button *lessDepth; // remove 10 meters to the depth ruler. - Button *okBtn; // accepts, and creates a new dive based on the plan. - Button *cancelBtn; // rejects, and clears the dive plan. int minMinutes; // this holds the minimum duration of the dive. int dpMaxTime; // this is the time of the dive calculated by the deco. }; +class DivePlannerWidget : public QWidget { + Q_OBJECT + void initialUiSetup(); +public: + explicit DivePlannerWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); + +public slots: + void startTimeChanged(const QTime& time); + void atmPressureChanged(const QString& pressure); + void bottomSacChanged(const QString& bottomSac); + void decoSacChanged(const QString& decosac); + void gflowChanged(const QString& gflow); + void gfhighChanged(const QString& gfhigh); + void lastStopChanged(bool checked); +protected: + virtual void hideEvent(QHideEvent* ); +private: + Ui::DivePlanner *ui; +}; + #endif |