diff options
Diffstat (limited to 'qt-ui/diveplanner.h')
-rw-r--r-- | qt-ui/diveplanner.h | 151 |
1 files changed, 7 insertions, 144 deletions
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 506953275..4aa5f0094 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -55,7 +55,7 @@ public: void editStop(int row, divedatapoint newData); divedatapoint at(int row); int size(); - struct diveplan getDiveplan(); + struct diveplan &getDiveplan(); QStringList &getGasList(); QVector<QPair<int, int> > collectGases(dive *d); int lastEnteredPoint(); @@ -80,7 +80,6 @@ slots: void deleteTemporaryPlan(); void loadFromDive(dive *d); void restoreBackupDive(); - void emitCylinderModelEdited(); signals: void planCreated(); @@ -102,47 +101,16 @@ private: QVector<QPair<int, int> > oldGases; }; -class Button : public QObject, public QGraphicsRectItem { - Q_OBJECT -public: - Button(QObject *parent = 0, QGraphicsItem *itemParent = 0); - void setText(const QString &text); - void setPixmap(const QPixmap &pixmap); - -protected: - virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); -signals: - void clicked(); - -private: - QGraphicsPixmapItem *icon; - QGraphicsSimpleTextItem *text; -}; - - -class ExpanderGraphics : public QGraphicsRectItem { -public: - ExpanderGraphics(QGraphicsItem *parent = 0); - - QGraphicsPixmapItem *icon; - Button *increaseBtn; - Button *decreaseBtn; - -private: - QGraphicsPixmapItem *bg; - QGraphicsPixmapItem *leftWing; - QGraphicsPixmapItem *rightWing; -}; - class DiveHandler : public QObject, public QGraphicsEllipseItem { Q_OBJECT public: DiveHandler(); protected: - void mousePressEvent(QGraphicsSceneMouseEvent *event); void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); - + void mouseMoveEvent(QGraphicsSceneMouseEvent *event); +signals: + void moved(); private: int parentIndex(); public @@ -151,114 +119,6 @@ slots: void changeGas(); }; -class Ruler : public QGraphicsLineItem { -public: - Ruler(); - ~Ruler(); - void setMinimum(double minimum); - void setMaximum(double maximum); - void setTickInterval(double interval); - void setOrientation(Qt::Orientation orientation); - void setTickSize(qreal size); - void updateTicks(); - double minimum() const; - double maximum() const; - qreal valueAt(const QPointF &p); - qreal percentAt(const QPointF &p); - qreal posAtValue(qreal value); - void setColor(const QColor &color); - void setTextColor(const QColor &color); - int unitSystem; - -private: - void eraseAll(); - - Qt::Orientation orientation; - QList<QGraphicsLineItem *> ticks; - QList<QGraphicsSimpleTextItem *> labels; - double min; - double max; - double interval; - double tickSize; - QColor textColor; -}; - -class DivePlannerGraphics : public QGraphicsView { - Q_OBJECT -public: - DivePlannerGraphics(QWidget *parent = 0); - -protected: - virtual void mouseDoubleClickEvent(QMouseEvent *event); - virtual void showEvent(QShowEvent *event); - virtual void resizeEvent(QResizeEvent *event); - virtual void mouseMoveEvent(QMouseEvent *event); - virtual void mousePressEvent(QMouseEvent *event); - virtual void mouseReleaseEvent(QMouseEvent *event); - bool isPointOutOfBoundaries(const QPointF &point); - qreal fromPercent(qreal percent, Qt::Orientation orientation); -public -slots: - void settingsChanged(); -private -slots: - void keyEscAction(); - void keyDeleteAction(); - void keyUpAction(); - void keyDownAction(); - void keyLeftAction(); - void keyRightAction(); - void increaseTime(); - void increaseDepth(); - void decreaseTime(); - void decreaseDepth(); - void drawProfile(); - void pointInserted(const QModelIndex &, int start, int end); - void pointsRemoved(const QModelIndex &, int start, int end); - -private: - void moveActiveHandler(const QPointF &MappedPos, const int pos); - - /* This are the lines of the plotted dive. */ - QList<QGraphicsLineItem *> lines; - - /* This is the user-entered handles. */ - QList<DiveHandler *> handles; - QList<QGraphicsSimpleTextItem *> gases; - - /* those are the lines that follows the mouse. */ - QGraphicsLineItem *verticalLine; - QGraphicsLineItem *horizontalLine; - - /* This is the handler that's being dragged. */ - DiveHandler *activeDraggedHandler; - - // When we start to move the handler, this pos is saved. - // so we can revert it later. - QPointF originalHandlerPos; - - /* this is the background of the dive, the blue-gradient. */ - QGraphicsPolygonItem *diveBg; - - /* This is the bottom ruler - the x axis, and it's associated text */ - Ruler *timeLine; - QGraphicsSimpleTextItem *timeString; - - /* this is the left ruler, the y axis, and it's associated text. */ - Ruler *depthLine; - QGraphicsSimpleTextItem *depthString; - - /* Buttons */ - ExpanderGraphics *depthHandler; - ExpanderGraphics *timeHandler; - - int minMinutes; // this holds the minimum requested window time - int minDepth; // this holds the minimum requested window depth - int dpMaxTime; // this is the time of the dive calculated by the deco. - - friend class DiveHandler; -}; - #include "ui_diveplanner.h" class DivePlannerWidget : public QWidget { @@ -277,4 +137,7 @@ private: Ui::DivePlanner ui; }; +QString gasToStr(const int o2Permille, const int hePermille); +QString dpGasToStr(const divedatapoint &p); + #endif // DIVEPLANNER_H |