summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/diveplanner.cpp5
-rw-r--r--qt-ui/maintab.cpp20
-rw-r--r--qt-ui/maintab.h3
-rw-r--r--qt-ui/mainwindow.cpp21
4 files changed, 39 insertions, 10 deletions
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 9a1f0cb3d..fe1342112 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -1113,7 +1113,7 @@ struct diveplan DivePlannerPointsModel::getDiveplan()
void DivePlannerPointsModel::cancelPlan()
{
- if(rowCount()){
+ if(mode == PLAN && rowCount()){
if (QMessageBox::warning(mainWindow(), tr("Save the Plan?"),
tr("You have a working plan, \n are you sure that you wanna cancel it?"),
QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok){
@@ -1150,7 +1150,8 @@ void DivePlannerPointsModel::createTemporaryPlan()
tempDive = NULL;
char *errorString = NULL;
plan(&diveplan, &cache, &tempDive, isPlanner(), &errorString);
- mainWindow()->information()->updateDiveInfo(get_divenr(tempDive));
+ if (mode == ADD)
+ copy_samples(tempDive, current_dive);
#if DEBUG_PLAN
dump_plan(&diveplan);
#endif
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index a0fcdf744..fcde96e0a 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -14,6 +14,7 @@
#include "modeldelegates.h"
#include "globe.h"
#include "completionmodels.h"
+#include "diveplanner.h"
#include <QLabel>
#include <QCompleter>
@@ -90,9 +91,15 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
ui->suit->setCompleter(completers.suit);
}
+void MainTab::addDiveStarted()
+{
+ enableEdition();
+ editMode = ADD;
+}
+
void MainTab::enableEdition()
{
- if (!selected_dive)
+ if (selected_dive < 0 || editMode != NONE)
return;
mainWindow()->dive_list()->setEnabled(false);
@@ -383,6 +390,13 @@ void MainTab::acceptChanges()
mainWindow()->globe()->centerOn(current_dive);
}
}
+ if (editMode == ADD) {
+ // clean up the dive data (get duration, depth information from samples)
+ fixup_dive(current_dive);
+ DivePlannerPointsModel::instance()->cancelPlan();
+ mainWindow()->showProfile();
+ mainWindow()->refreshDisplay();
+ }
editMode = NONE;
QPalette p;
@@ -500,7 +514,7 @@ void MainTab::on_location_textChanged(const QString& text)
// we are editing a trip
dive_trip_t *currentTrip = *mainWindow()->dive_list()->selectedTrips.begin();
EDIT_TEXT(currentTrip->location, text);
- } else if (editMode == DIVE){
+ } else if (editMode == DIVE || editMode == ADD){
struct dive* dive;
int i = 0;
for_each_dive(i, dive){
@@ -535,7 +549,7 @@ void MainTab::on_notes_textChanged()
// we are editing a trip
dive_trip_t *currentTrip = *mainWindow()->dive_list()->selectedTrips.begin();
EDIT_TEXT(currentTrip->notes, ui->notes->toPlainText());
- } else if (editMode == DIVE) {
+ } else if (editMode == DIVE || editMode == ADD) {
EDIT_SELECTED_DIVES( EDIT_TEXT(mydive->notes, ui->notes->toPlainText()) );
}
markChangedWidget(ui->notes);
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index 25fe67743..041611b26 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -68,13 +68,14 @@ public slots:
void on_visibility_valueChanged(int value);
void editCylinderWidget(const QModelIndex& index);
void editWeigthWidget(const QModelIndex& index);
+ void addDiveStarted();
private:
Ui::MainTab *ui;
WeightModel *weightModel;
CylindersModel *cylindersModel;
QMap<dive*, NotesBackup> notesBackup;
- enum { NONE, DIVE, TRIP } editMode;
+ enum { NONE, DIVE, TRIP, ADD } editMode;
Completers completers;
void enableEdition();
};
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 593bbf166..c544dd812 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -36,6 +36,8 @@
#include "about.h"
#include "printdialog.h"
+#include "glib/gi18n.h"
+
static MainWindow* instance = 0;
MainWindow* mainWindow()
@@ -255,14 +257,25 @@ void MainWindow::on_actionEditDeviceNames_triggered()
void MainWindow::on_actionAddDive_triggered()
{
+ // clear the selection
+ for (int i = 0; i < dive_table.nr; i++) {
+ struct dive *d = get_dive(i);
+ if (d && d->selected)
+ deselect_dive(i);
+ }
disableDcShortcuts();
DivePlannerPointsModel::instance()->setPlanMode(false);
+ // now cheat - create one dive that we use to store the info tab data in
+ struct dive *dive = alloc_dive();
+ dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L;
+ dive->dc.model = _("manually added dive");
+ record_dive(dive);
+ select_dive(get_divenr(dive));
+ ui->InfoWidget->updateDiveInfo(selected_dive);
ui->stackedWidget->setCurrentIndex(1);
ui->infoPane->setCurrentIndex(0);
- ui->InfoWidget->clearStats();
- ui->InfoWidget->clearInfo();
- ui->InfoWidget->clearEquipment();
- ui->InfoWidget->updateDiveInfo(-1);
+ refreshDisplay();
+ ui->InfoWidget->addDiveStarted();
}
void MainWindow::on_actionRenumber_triggered()