Use Planner dialog to add dive

Right now this is just calling the same code and setting a flag whether we
are planning or adding a dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-09-18 21:33:53 -05:00
parent 40462d5008
commit 882b2c146b
3 changed files with 24 additions and 14 deletions

View file

@ -894,6 +894,16 @@ void DivePlannerWidget::lastStopChanged(bool checked)
plannerModel->setLastStop6m(checked); plannerModel->setLastStop6m(checked);
} }
void DivePlannerPointsModel::setPlanMode(bool isPlan)
{
mode = isPlan ? PLAN : ADD;
}
bool DivePlannerPointsModel::isPlanner()
{
return mode == PLAN;
}
int DivePlannerPointsModel::columnCount(const QModelIndex& parent) const int DivePlannerPointsModel::columnCount(const QModelIndex& parent) const
{ {
return COLUMNS; return COLUMNS;

View file

@ -29,9 +29,12 @@ public:
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
virtual Qt::ItemFlags flags(const QModelIndex& index) const; virtual Qt::ItemFlags flags(const QModelIndex& index) const;
void removeSelectedPoints(const QVector<int>& rows); void removeSelectedPoints(const QVector<int>& rows);
enum Modes { PLAN, ADD };
void setPlanMode(bool);
bool isPlanner();
/** /**
* @return the row number. * @return the row number.
@ -50,9 +53,9 @@ public slots:
void setLastStop6m(bool value); void setLastStop6m(bool value);
void createPlan(); void createPlan();
void remove(const QModelIndex& index); void remove(const QModelIndex& index);
void cancelPlan(); void cancelPlan();
void createTemporaryPlan(); void createTemporaryPlan();
void deleteTemporaryPlan(); void deleteTemporaryPlan();
signals: signals:
void planCreated(); void planCreated();
@ -61,6 +64,7 @@ signals:
private: private:
explicit DivePlannerPointsModel(QObject* parent = 0); explicit DivePlannerPointsModel(QObject* parent = 0);
struct diveplan diveplan; struct diveplan diveplan;
Modes mode;
QVector<divedatapoint> divepoints; QVector<divedatapoint> divepoints;
struct dive *tempDive; struct dive *tempDive;
void deleteTemporaryPlan(struct divedatapoint *dp); void deleteTemporaryPlan(struct divedatapoint *dp);

View file

@ -209,6 +209,7 @@ void MainWindow::enableDcShortcuts()
void MainWindow::on_actionDivePlanner_triggered() void MainWindow::on_actionDivePlanner_triggered()
{ {
disableDcShortcuts(); disableDcShortcuts();
DivePlannerPointsModel::instance()->setPlanMode(true);
ui->stackedWidget->setCurrentIndex(1); ui->stackedWidget->setCurrentIndex(1);
ui->infoPane->setCurrentIndex(1); ui->infoPane->setCurrentIndex(1);
} }
@ -254,15 +255,10 @@ void MainWindow::on_actionEditDeviceNames_triggered()
void MainWindow::on_actionAddDive_triggered() void MainWindow::on_actionAddDive_triggered()
{ {
struct dive *dive; disableDcShortcuts();
dive = alloc_dive(); DivePlannerPointsModel::instance()->setPlanMode(false);
record_dive(dive); ui->stackedWidget->setCurrentIndex(1);
process_dives(FALSE, FALSE); ui->infoPane->setCurrentIndex(1);
ui->InfoWidget->reload();
ui->globe->reload();
ui->ListWidget->reload(DiveTripModel::TREE);
ui->ListWidget->setFocus();
} }
void MainWindow::on_actionRenumber_triggered() void MainWindow::on_actionRenumber_triggered()