This code is not ported to the new profile, but from what I can understand from it, it doesn't need to be. The purpose of this code was to setup the correct colors and strings for the current mouse position, we already do this on the Profile in a different way, on the Notification Area. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
243 lines
5.9 KiB
C++
243 lines
5.9 KiB
C++
#ifndef DIVEPLANNER_H
|
|
#define DIVEPLANNER_H
|
|
|
|
#include <QGraphicsView>
|
|
#include <QGraphicsPathItem>
|
|
#include <QDialog>
|
|
#include <QAbstractTableModel>
|
|
#include <QDateTime>
|
|
|
|
#include "dive.h"
|
|
|
|
class QListView;
|
|
class QModelIndex;
|
|
|
|
class DivePlannerPointsModel : public QAbstractTableModel {
|
|
Q_OBJECT
|
|
public:
|
|
static DivePlannerPointsModel *instance();
|
|
enum Sections {
|
|
REMOVE,
|
|
DEPTH,
|
|
DURATION,
|
|
RUNTIME,
|
|
GAS,
|
|
CCSETPOINT,
|
|
COLUMNS
|
|
};
|
|
enum Mode {
|
|
NOTHING,
|
|
PLAN,
|
|
ADD
|
|
};
|
|
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);
|
|
void setPlanMode(Mode mode);
|
|
bool isPlanner();
|
|
void createSimpleDive();
|
|
void clear();
|
|
Mode currentMode() const;
|
|
bool setRecalc(bool recalc);
|
|
bool recalcQ();
|
|
void tanksUpdated();
|
|
void rememberTanks();
|
|
bool tankInUse(int o2, int he);
|
|
void copyCylinders(struct dive *d);
|
|
void copyCylindersFrom(struct dive *d);
|
|
/**
|
|
* @return the row number.
|
|
*/
|
|
void editStop(int row, divedatapoint newData);
|
|
divedatapoint at(int row);
|
|
int size();
|
|
struct diveplan &getDiveplan();
|
|
QStringList &getGasList();
|
|
QVector<QPair<int, int> > collectGases(dive *d);
|
|
int lastEnteredPoint();
|
|
void removeDeco();
|
|
static bool addingDeco;
|
|
|
|
public
|
|
slots:
|
|
int addStop(int millimeters = 0, int seconds = 0, int o2 = 0, int he = 0, int ccpoint = 0, bool entered = true);
|
|
void addCylinder_clicked();
|
|
void setGFHigh(const int gfhigh);
|
|
void setGFLow(const int 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 remove(const QModelIndex &index);
|
|
void cancelPlan();
|
|
void createTemporaryPlan();
|
|
void deleteTemporaryPlan();
|
|
void loadFromDive(dive *d);
|
|
void restoreBackupDive();
|
|
|
|
signals:
|
|
void planCreated();
|
|
void planCanceled();
|
|
void cylinderModelEdited();
|
|
|
|
private:
|
|
explicit DivePlannerPointsModel(QObject *parent = 0);
|
|
bool addGas(int o2, int he);
|
|
struct diveplan diveplan;
|
|
Mode mode;
|
|
bool recalc;
|
|
QVector<divedatapoint> divepoints;
|
|
struct dive *tempDive;
|
|
struct dive backupDive;
|
|
void deleteTemporaryPlan(struct divedatapoint *dp);
|
|
QVector<sample> backupSamples; // For editing added dives.
|
|
struct dive *stagingDive;
|
|
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 contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
|
signals:
|
|
void moved();
|
|
private:
|
|
int parentIndex();
|
|
public
|
|
slots:
|
|
void selfRemove();
|
|
void changeGas();
|
|
};
|
|
|
|
class DivePlannerGraphics : public QGraphicsView {
|
|
Q_OBJECT
|
|
public:
|
|
DivePlannerGraphics(QWidget *parent = 0);
|
|
|
|
protected:
|
|
virtual void showEvent(QShowEvent *event);
|
|
virtual void resizeEvent(QResizeEvent *event);
|
|
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();
|
|
|
|
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 */
|
|
QGraphicsSimpleTextItem *timeString;
|
|
|
|
/* this is the left ruler, the y axis, and it's associated text. */
|
|
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 {
|
|
Q_OBJECT
|
|
public:
|
|
explicit DivePlannerWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
|
|
|
public
|
|
slots:
|
|
void settingsChanged();
|
|
void atmPressureChanged(const QString &pressure);
|
|
void bottomSacChanged(const QString &bottomSac);
|
|
void decoSacChanged(const QString &decosac);
|
|
|
|
private:
|
|
Ui::DivePlanner ui;
|
|
};
|
|
|
|
QString gasToStr(const int o2Permille, const int hePermille);
|
|
QString dpGasToStr(const divedatapoint &p);
|
|
|
|
#endif // DIVEPLANNER_H
|