diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-09-16 19:21:13 -0300 |
---|---|---|
committer | Tomaz Canabrava <tcanabrava@kde.org> | 2013-09-16 19:21:13 -0300 |
commit | 493f366765cf3bc8d1ff166b874433a8c0a900aa (patch) | |
tree | 5d09f31b007552ebfa3429d77a638e23769bb663 /qt-ui/diveplanner.cpp | |
parent | f74799d5815bb1d6e7d6c6c531ccf9ba6e966191 (diff) | |
download | subsurface-493f366765cf3bc8d1ff166b874433a8c0a900aa.tar.gz |
Use the same line dimensions as the profile, on the planner.
The Planner should be 'almost' like the profile, with the possibility
to use the mouse and keyboard to input a new plan, so this is a bit
of 'getting there.' I don't like too much code duplication but since
the current Profile Graphics is a crude cut-and-paste from the old
Cairo backend, it's easyer to start from scratch and have it well
organized as Qt code.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/diveplanner.cpp')
-rw-r--r-- | qt-ui/diveplanner.cpp | 26 |
1 files changed, 20 insertions, 6 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(); } |