From f74799d5815bb1d6e7d6c6c531ccf9ba6e966191 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 16 Sep 2013 12:30:58 -0300 Subject: Ok on the planner now correctly creates a Dive. Ok on the planner now correctly creates a dive, a few remarks, tougth: 1 - the number of the added dive is always 0 ( but I may be testing it wrong ) 2 - the information pane is working only when the mouse is clicked, this is a regression and it will be fixed. ;) Signed-off-by: Tomaz Canabrava --- qt-ui/diveplanner.cpp | 28 +++++++++++++++++++++++----- qt-ui/diveplanner.h | 1 - 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 5cecd0f96..98a0c89b1 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -813,6 +813,7 @@ DivePlannerWidget::DivePlannerWidget(QWidget* parent, Qt::WindowFlags f): QWidge connect(ui->buttonBox, SIGNAL(accepted()), plannerModel, SLOT(createPlan())); connect(ui->buttonBox, SIGNAL(rejected()), plannerModel, SLOT(cancelPlan())); connect(plannerModel, SIGNAL(planCreated()), mainWindow(), SLOT(showProfile())); + connect(plannerModel, SIGNAL(planCreated()), mainWindow(), SLOT(refreshDisplay())); connect(plannerModel, SIGNAL(planCanceled()), mainWindow(), SLOT(showProfile())); /* set defaults. */ @@ -950,11 +951,6 @@ DivePlannerPointsModel* DivePlannerPointsModel::instance() return self; } -void DivePlannerPointsModel::createPlan() -{ - -} - void DivePlannerPointsModel::setBottomSac(int sac) { diveplan.bottomsac = sac; @@ -1130,3 +1126,25 @@ void DivePlannerPointsModel::deleteTemporaryPlan(struct divedatapoint *dp) deleteTemporaryPlan(dp->next); free(dp); } + +void DivePlannerPointsModel::createPlan() +{ + // Ok, so, here the diveplan creates a dive, + // puts it on the dive list, and we need to remember + // to not delete it later. mumble. ;p + char *cache = NULL; + tempDive = NULL; + char *errorString = NULL; + + createTemporaryPlan(); + plan(&diveplan, &cache, &tempDive, &errorString); + mark_divelist_changed(TRUE); + diveplan.dp = NULL; + + beginRemoveRows(QModelIndex(), 0, rowCount() -1 ); + divepoints.clear(); + endRemoveRows(); + + // show_error(error_string); + planCreated(); +} diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h index ea528068a..84545ce40 100644 --- a/qt-ui/diveplanner.h +++ b/qt-ui/diveplanner.h @@ -130,7 +130,6 @@ protected: virtual void mousePressEvent(QMouseEvent* event); virtual void mouseReleaseEvent(QMouseEvent* event); bool isPointOutOfBoundaries(const QPointF& point); - void deleteTemporaryDivePlan(struct divedatapoint* dp); qreal fromPercent(qreal percent, Qt::Orientation orientation); private slots: void keyEscAction(); -- cgit v1.2.3-70-g09d2