diff options
-rw-r--r-- | qt-ui/diveplanner.cpp | 26 | ||||
-rw-r--r-- | qt-ui/graphicsview-common.cpp | 5 | ||||
-rw-r--r-- | qt-ui/graphicsview-common.h | 1 |
3 files changed, 25 insertions, 7 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 98a0c89b1..6ac0d5863 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -5,6 +5,7 @@ #include "ui_diveplanner.h" #include "mainwindow.h" #include "tableview.h" +#include "graphicsview-common.h" #include "../dive.h" #include "../divelist.h" @@ -19,6 +20,7 @@ #include <QModelIndex> #include <QSettings> #include <QTableView> +#include <QColor> #define TIME_INITIAL_MAX 30 @@ -40,6 +42,11 @@ QString strForAir(const divedatapoint& p){ : QObject::tr("Choose Gas"); } +QColor getColor(const color_indice_t i) +{ + return profile_color[i].at(0); +} + static DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent), activeDraggedHandler(0) @@ -66,6 +73,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent) fromPercent(100, Qt::Horizontal), fromPercent(0, Qt::Vertical) ); + horizontalLine->setPen(QPen(Qt::DotLine)); scene()->addItem(horizontalLine); @@ -73,6 +81,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent) timeLine->setMinimum(0); timeLine->setMaximum(TIME_INITIAL_MAX); timeLine->setTickInterval(10); + timeLine->setColor(getColor(TIME_GRID)); timeLine->setLine( fromPercent(10, Qt::Horizontal), fromPercent(90, Qt::Vertical), @@ -81,7 +90,6 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent) ); timeLine->setOrientation(Qt::Horizontal); timeLine->setTickSize(fromPercent(1, Qt::Vertical)); - timeLine->setColor(profile_color[TIME_GRID].at(0)); timeLine->updateTicks(); scene()->addItem(timeLine); @@ -97,7 +105,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent) ); depthLine->setOrientation(Qt::Vertical); depthLine->setTickSize(fromPercent(1, Qt::Horizontal)); - depthLine->setColor(profile_color[DEPTH_GRID].at(0)); + depthLine->setColor(getColor(DEPTH_GRID)); depthLine->updateTicks(); scene()->addItem(depthLine); @@ -749,7 +757,12 @@ double Ruler::minimum() const void Ruler::setColor(const QColor& color) { - setPen(QPen(color)); + QPen defaultPen(color); + defaultPen.setJoinStyle(Qt::RoundJoin); + defaultPen.setCapStyle(Qt::RoundCap); + defaultPen.setWidth(2); + defaultPen.setCosmetic(true); + setPen(defaultPen); } Button::Button(QObject* parent): QObject(parent), QGraphicsRectItem() @@ -1139,12 +1152,13 @@ void DivePlannerPointsModel::createPlan() createTemporaryPlan(); plan(&diveplan, &cache, &tempDive, &errorString); mark_divelist_changed(TRUE); - diveplan.dp = NULL; + // Remove and clean the diveplan, so we don't delete + // the dive by mistake. + diveplan.dp = NULL; beginRemoveRows(QModelIndex(), 0, rowCount() -1 ); divepoints.clear(); endRemoveRows(); - - // show_error(error_string); + planCreated(); } diff --git a/qt-ui/graphicsview-common.cpp b/qt-ui/graphicsview-common.cpp index fbe196e98..30b9ccb08 100644 --- a/qt-ui/graphicsview-common.cpp +++ b/qt-ui/graphicsview-common.cpp @@ -55,3 +55,8 @@ void fill_profile_color() profile_color[CALC_CEILING_DEEP] = COLOR(APPLE1_HIGH_TRANS, BLACK1_HIGH_TRANS, APPLE1_HIGH_TRANS); #undef COLOR } + +QColor getColor(const color_indice_t i, bool isGrayscale = false) +{ + return profile_color[i].at((isGrayscale) ? 1 : 0); +} diff --git a/qt-ui/graphicsview-common.h b/qt-ui/graphicsview-common.h index 96cecc8e6..d2499c823 100644 --- a/qt-ui/graphicsview-common.h +++ b/qt-ui/graphicsview-common.h @@ -33,7 +33,6 @@ typedef enum { /* profile_color[color indice] = COLOR(screen color, b/w printer color, color printer}} printer & screen colours could be different */ extern QMap<color_indice_t, QVector<QColor> > profile_color; - void fill_profile_color(); |