It's becomming harder to find bugs. and to fix them.
From 75977ae588c8f7e8d552d31bfb53bcfed4cebfc4 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 28 May 2014 15:54:04 -0300 Subject: [PATCH 1/3] Move code from the Planner that doesn't belongs there.
Moved the connections between DivePlannerPointsModel and MainWindow from inside the Planner class to the MainWindow. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/diveplanner.cpp | 7 +------ qt-ui/mainwindow.cpp | 10 +++++++++- qt-ui/mainwindow.h | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index 6943283..f1177ae 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -254,9 +254,6 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg // Creating (and canceling) the plan connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(createPlan())); connect(ui.buttonBox, SIGNAL(rejected()), plannerModel, SLOT(cancelPlan())); - connect(plannerModel, SIGNAL(planCreated()), MainWindow::instance(), SLOT(removeFakeDiveForAddAndPlan())); - connect(plannerModel, SIGNAL(planCreated()), MainWindow::instance(), SLOT(showProfile())); - connect(plannerModel, SIGNAL(planCanceled()), MainWindow::instance(), SLOT(planCanceled())); /* set defaults. */ ui.startTime->setTime(QTime(1, 0)); @@ -859,10 +856,8 @@ void DivePlannerPointsModel::createPlan() // Remove and clean the diveplan, so we don't delete // the dive by mistake. diveplan.dp = NULL; - planCreated(); setPlanMode(NOTHING); free(stagingDive); stagingDive = NULL; - // we unselected all dives earlier, so as a side effect recreating the dive list will select the new dive - MainWindow::instance()->refreshDisplay(); + planCreated(); } diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 82276f3..a6a014c 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -77,7 +77,8 @@ MainWindow::MainWindow() : QMainWindow(), connect(ui.actionRecent3, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool))); connect(ui.actionRecent4, SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool))); connect(information(), SIGNAL(addDiveFinished()), ui.newProfile, SLOT(setProfileState())); - + connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), MainWindow::instance(), SLOT(planCreated())); + connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), MainWindow::instance(), SLOT(planCanceled())); ui.mainErrorMessage->hide(); initialUiSetup(); readSettings(); @@ -406,6 +407,13 @@ void MainWindow::planCanceled() refreshDisplay(); } +void MainWindow::planCreated() +{ + removeFakeDiveForAddAndPlan(); + showProfile(); + refreshDisplay(); +} + void MainWindow::on_actionDivePlanner_triggered() { if(!plannerStateClean()) diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index f34c7a5..9501e97 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -153,6 +153,7 @@ slots: void editCurrentDive(); void removeFakeDiveForAddAndPlan(); void planCanceled(); + void planCreated(); private: Ui::MainWindow ui; -- 1.9.3
From 59cb35c02b8c0bc7d4a2e4747a2356086b263cc1 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 28 May 2014 19:03:10 -0300 Subject: [PATCH 2/3] Fix Crash on Adding / Removing a dives from Add Menu This patch removes some inconsistencies that where happening on the Add Dive / cancel actions. a bit of legacy code from the old system was still in, wich makes things quite... EXPLOSIVE. this fixes restoring the selection only if we have a selection and not deleting the temporary dive twice. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/divelistview.cpp | 7 ++++++- qt-ui/divelistview.h | 1 + qt-ui/maintab.cpp | 35 +++++++++++++++-------------------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index a6cca47..8f54448 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -29,7 +29,7 @@ #include "../qthelper.h" DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false), sortColumn(0), - currentOrder(Qt::DescendingOrder), searchBox(this), dontEmitDiveChangedSignal(false) + currentOrder(Qt::DescendingOrder), searchBox(this), dontEmitDiveChangedSignal(false), selectionSaved(false) { setItemDelegate(new DiveListDelegate(this)); setUniformRowHeights(true); @@ -147,10 +147,15 @@ void DiveListView::rememberSelection() if (d) selectedDives.insert(d->divetrip, get_divenr(d)); } + selectionSaved = true; } void DiveListView::restoreSelection() { + if (!selectionSaved) + return; + + selectionSaved = false; unselectDives(); Q_FOREACH (dive_trip_t *trip, selectedDives.keys()) { QList<int> divesOnTrip = getDivesInTrip(trip); diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h index 23ca1cc..320bf95 100644 --- a/qt-ui/divelistview.h +++ b/qt-ui/divelistview.h @@ -65,6 +65,7 @@ private: QLineEdit searchBox; QModelIndex contextMenuIndex; bool dontEmitDiveChangedSignal; + bool selectionSaved; /* if dive_trip_t is null, there's no problem. */ QMultiHash<dive_trip_t *, int> selectedDives; diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 8505281..ec3c389 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -804,24 +804,27 @@ void MainTab::rejectChanges() if (lastMode == ADD) { // clean up DivePlannerPointsModel::instance()->cancelPlan(); + hideMessage(); + resetPallete(); + return; } else if (lastMode == MANUALLY_ADDED_DIVE) { // when we tried to edit a manually added dive, we destroyed // the dive we edited, so let's just restore it from backup DivePlannerPointsModel::instance()->restoreBackupDive(); } struct dive *curr = current_dive; - ui.notes->setText(notesBackup[curr].notes); - ui.location->setText(notesBackup[curr].location); - ui.buddy->setText(notesBackup[curr].buddy); - ui.suit->setText(notesBackup[curr].suit); - ui.divemaster->setText(notesBackup[curr].divemaster); - ui.rating->setCurrentStars(notesBackup[curr].rating); - ui.visibility->setCurrentStars(notesBackup[curr].visibility); - ui.airtemp->setText(notesBackup[curr].airtemp); - ui.watertemp->setText(notesBackup[curr].watertemp); - ui.tagWidget->setText(notesBackup[curr].tags); - // it's a little harder to do the right thing for the date time widget if (curr) { + ui.notes->setText(notesBackup[curr].notes); + ui.location->setText(notesBackup[curr].location); + ui.buddy->setText(notesBackup[curr].buddy); + ui.suit->setText(notesBackup[curr].suit); + ui.divemaster->setText(notesBackup[curr].divemaster); + ui.rating->setCurrentStars(notesBackup[curr].rating); + ui.visibility->setCurrentStars(notesBackup[curr].visibility); + ui.airtemp->setText(notesBackup[curr].airtemp); + ui.watertemp->setText(notesBackup[curr].watertemp); + ui.tagWidget->setText(notesBackup[curr].tags); + // it's a little harder to do the right thing for the date time widget ui.dateTimeEdit->setDateTime(QDateTime::fromString(notesBackup[curr].datetime)); } else { QLineEdit *le = ui.dateTimeEdit->findChild<QLineEdit *>(); @@ -854,12 +857,6 @@ void MainTab::rejectChanges() } } updateGpsCoordinates(curr); - if (lastMode == ADD) { - delete_single_dive(selected_dive); - MainWindow::instance()->dive_list()->reload(DiveTripModel::CURRENT); - MainWindow::instance()->dive_list()->restoreSelection(); - emit addDiveFinished(); - } if (selected_dive >= 0) { multiEditEquipmentPlaceholder = *get_dive(selected_dive); cylindersModel->setDive(&multiEditEquipmentPlaceholder); @@ -873,17 +870,15 @@ void MainTab::rejectChanges() hideMessage(); MainWindow::instance()->dive_list()->setEnabled(true); - notesBackup.clear(); resetPallete(); MainWindow::instance()->globe()->reload(); - if (lastMode == ADD || lastMode == MANUALLY_ADDED_DIVE) { + if (lastMode == MANUALLY_ADDED_DIVE) { // more clean up updateDiveInfo(selected_dive); MainWindow::instance()->showProfile(); // we already reloaded the divelist above, so don't recreate it or we'll lose the selection MainWindow::instance()->refreshDisplay(false); } - DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING); MainWindow::instance()->dive_list()->setFocus(); // the user could have edited the location and then canceled the edit // let's get the correct location back in view -- 1.9.3
From aa36138ec874b557d3bddfdc14b1e55ddaed4025 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 28 May 2014 20:50:01 -0300 Subject: [PATCH 3/3] Fix edition of manually added dives. This patch correctly sets the state of the planner to "NOTHING" after trying to edit a manually added dive. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/maintab.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index ec3c389..f308292 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -883,6 +883,7 @@ void MainTab::rejectChanges() // the user could have edited the location and then canceled the edit // let's get the correct location back in view MainWindow::instance()->globe()->centerOnCurrentDive(); + DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::NOTHING); } #undef EDIT_TEXT2 -- 1.9.3
_______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
