From 9ffb459ff365ce1c09e6b7775c486559e39350da Mon Sep 17 00:00:00 2001 From: Boris Barbulovski Date: Sun, 9 Feb 2014 19:30:52 +0100 Subject: diveplanner.cpp improvements * Add missing variable members to the initializer lists. * Add *lazy* structure initializations. Signed-off-by: Boris Barbulovski Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 46 +++++++++++++++++++++------------------------- qt-ui/diveplanner.h | 2 +- 2 files changed, 22 insertions(+), 26 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 85703bf54..6c2395272 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -52,7 +52,19 @@ QColor getColor(const color_indice_t i) static DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance(); -DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent), activeDraggedHandler(0) +DivePlannerGraphics::DivePlannerGraphics(QWidget* parent) : QGraphicsView(parent), + verticalLine(new QGraphicsLineItem(fromPercent(0, Qt::Horizontal), fromPercent(0, Qt::Vertical), fromPercent(0, Qt::Horizontal), fromPercent(100, Qt::Vertical))), + horizontalLine(new QGraphicsLineItem(fromPercent(0, Qt::Horizontal), fromPercent(0, Qt::Vertical), fromPercent(100, Qt::Horizontal), fromPercent(0, Qt::Vertical))), + activeDraggedHandler(0), + diveBg(new QGraphicsPolygonItem()), + timeLine(new Ruler()), + timeString(new QGraphicsSimpleTextItem()), + depthString(new QGraphicsSimpleTextItem()), + depthHandler(new ExpanderGraphics()), + timeHandler(new ExpanderGraphics()), + minMinutes(TIME_INITIAL_MAX), + minDepth(M_OR_FT(40,120)), + dpMaxTime(0) { fill_profile_color(); setBackgroundBrush(profile_color[BACKGROUND].at(0)); @@ -60,27 +72,12 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent) setScene(new QGraphicsScene()); scene()->setSceneRect(0,0,1920,1080); - verticalLine = new QGraphicsLineItem( - fromPercent(0, Qt::Horizontal), - fromPercent(0, Qt::Vertical), - fromPercent(0, Qt::Horizontal), - fromPercent(100, Qt::Vertical) - ); - verticalLine->setPen(QPen(Qt::DotLine)); scene()->addItem(verticalLine); - horizontalLine = new QGraphicsLineItem( - fromPercent(0, Qt::Horizontal), - fromPercent(0, Qt::Vertical), - fromPercent(100, Qt::Horizontal), - fromPercent(0, Qt::Vertical) - ); - horizontalLine->setPen(QPen(Qt::DotLine)); scene()->addItem(horizontalLine); - timeLine = new Ruler(); timeLine->setMinimum(0); timeLine->setMaximum(TIME_INITIAL_MAX); timeLine->setTickInterval(10); @@ -115,17 +112,14 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent) depthLine->unitSystem = prefs.units.length; scene()->addItem(depthLine); - timeString = new QGraphicsSimpleTextItem(); timeString->setFlag(QGraphicsItem::ItemIgnoresTransformations); timeString->setBrush(profile_color[TIME_TEXT].at(0)); scene()->addItem(timeString); - depthString = new QGraphicsSimpleTextItem(); depthString->setFlag(QGraphicsItem::ItemIgnoresTransformations); depthString->setBrush(profile_color[SAMPLE_DEEP].at(0)); scene()->addItem(depthString); - diveBg = new QGraphicsPolygonItem(); diveBg->setPen(QPen(QBrush(),0)); scene()->addItem(diveBg); @@ -135,7 +129,6 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent) else incrText = tr("30ft"); - timeHandler = new ExpanderGraphics(); timeHandler->increaseBtn->setPixmap(QString(":plan_plus")); timeHandler->decreaseBtn->setPixmap(QString(":plan_minus")); timeHandler->icon->setPixmap(QString(":icon_time")); @@ -145,7 +138,6 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent) timeHandler->setZValue(-2); scene()->addItem(timeHandler); - depthHandler = new ExpanderGraphics(); depthHandler->increaseBtn->setPixmap(QString(":arrow_up")); depthHandler->decreaseBtn->setPixmap(QString(":arrow_down")); depthHandler->icon->setPixmap(QString(":icon_depth")); @@ -157,8 +149,6 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent) depthHandler->setZValue(-2); scene()->addItem(depthHandler); - minMinutes = TIME_INITIAL_MAX; - minDepth = M_OR_FT(40,120); QAction *action = NULL; #define ADD_ACTION( SHORTCUT, Slot ) \ @@ -790,7 +780,12 @@ void Ruler::eraseAll() labels.clear(); } -Ruler::Ruler() : orientation(Qt::Horizontal) +Ruler::Ruler() : unitSystem(0), + orientation(Qt::Horizontal), + min(0), + max(0), + interval(0), + tickSize(0) { } @@ -1119,7 +1114,8 @@ int DivePlannerPointsModel::rowCount(const QModelIndex& parent) const DivePlannerPointsModel::DivePlannerPointsModel(QObject* parent): QAbstractTableModel(parent), mode(NOTHING), tempDive(NULL), stagingDive(NULL) { - diveplan.dp = NULL; + memset(&diveplan, 0, sizeof(diveplan)); + memset(&backupDive, 0, sizeof(backupDive)); } DivePlannerPointsModel* DivePlannerPointsModel::instance() diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index 95dc31fb4..5ed5b0568 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -179,7 +179,7 @@ private slots: void increaseTime(); void increaseDepth(); void decreaseTime(); - void decreaseDepth();; + void decreaseDepth(); void drawProfile(); void pointInserted(const QModelIndex&, int start, int end); void pointsRemoved(const QModelIndex&, int start, int end); -- cgit v1.2.3-70-g09d2