summaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.h
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-22 15:57:26 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-22 15:57:26 -0700
commit31449dca22873e500842ab1cfcca3a211764d98a (patch)
tree51142e5b4148f25d5e416b6b621ed83447cc43cc /qt-ui/diveplanner.h
parent81858167ac3f69e99a1108fa305f2865417e2b81 (diff)
parent880b98ed35c2dbf3b5a015784323894c59bc7feb (diff)
downloadsubsurface-31449dca22873e500842ab1cfcca3a211764d98a.tar.gz
Merge branch 'divePlannerTry3' of github.com:tcanabrava/subsurface
Diffstat (limited to 'qt-ui/diveplanner.h')
-rw-r--r--qt-ui/diveplanner.h106
1 files changed, 106 insertions, 0 deletions
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
new file mode 100644
index 000000000..453cec63e
--- /dev/null
+++ b/qt-ui/diveplanner.h
@@ -0,0 +1,106 @@
+#ifndef DIVEPLANNER_H
+#define DIVEPLANNER_H
+
+#include <QGraphicsView>
+#include <QGraphicsPathItem>
+#include <QDialog>
+
+class Button : public QObject, public QGraphicsPixmapItem {
+ Q_OBJECT
+public:
+ explicit Button(QObject* parent = 0);
+protected:
+ virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
+signals:
+ void clicked();
+};
+
+class DiveHandler : public QGraphicsEllipseItem{
+public:
+ DiveHandler();
+ QGraphicsLineItem *from;
+ QGraphicsLineItem *to;
+ qreal time;
+ qreal depth;
+};
+
+class Ruler : public QGraphicsLineItem{
+public:
+ Ruler();
+ void setMinimum(double minimum);
+ void setMaximum(double maximum);
+ void setTickInterval(double interval);
+ void setOrientation(Qt::Orientation orientation);
+ void updateTicks();
+ double minimum() const;
+ double maximum() const;
+ qreal valueAt(const QPointF& p);
+ qreal posAtValue(qreal value);
+
+private:
+ Qt::Orientation orientation;
+ QList<QGraphicsLineItem*> ticks;
+ double min;
+ double max;
+ double interval;
+ double posBegin;
+ double posEnd;
+};
+
+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);
+
+ void clear_generated_deco();
+ void create_deco_stop();
+ bool isPointOutOfBoundaries(const QPointF& point);
+
+private slots:
+ void increaseTime();
+ void increaseDepth();
+
+private:
+
+ void moveActiveHandler(const QPointF& pos);
+ QList<QGraphicsLineItem*> lines;
+ QList<DiveHandler *> handles;
+ QGraphicsLineItem *verticalLine;
+ QGraphicsLineItem *horizontalLine;
+ DiveHandler *activeDraggedHandler;
+
+ Ruler *timeLine;
+ QGraphicsSimpleTextItem *timeString;
+
+ Ruler *depthLine;
+ QGraphicsSimpleTextItem *depthString;
+
+ Button *plusTime;
+ Button *plusDepth;
+ Button *lessTime;
+ Button *lessDepth;
+
+};
+
+namespace Ui{
+ class DivePlanner;
+}
+
+class DivePlanner : public QDialog{
+ Q_OBJECT
+public:
+ static DivePlanner *instance();
+ struct dive* getDive();
+
+private:
+ DivePlanner();
+ Ui::DivePlanner *ui;
+};
+#endif