From 493f366765cf3bc8d1ff166b874433a8c0a900aa Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 16 Sep 2013 19:21:13 -0300 Subject: 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 --- qt-ui/diveplanner.cpp | 26 ++++++++++++++++++++------ qt-ui/graphicsview-common.cpp | 5 +++++ 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 #include #include +#include #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 > profile_color; - void fill_profile_color(); -- cgit v1.2.3-70-g09d2