mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Make gaschange from contex menu act as a gaschange
so it affect no longer the previous leg but all the following ones with the same gas (i.e. until the next gaschange). This makes the add dive/planner behaviour more consistent with the rest of the program regarding gas changes. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
907ccb0b71
commit
043bd3afb7
2 changed files with 14 additions and 1 deletions
|
@ -241,7 +241,7 @@ void DiveHandler::changeGas()
|
|||
{
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
QModelIndex index = plannerModel->index(parentIndex(), DivePlannerPointsModel::GAS);
|
||||
plannerModel->setData(index, action->text());
|
||||
plannerModel->gaschange(index.sibling(index.row() + 1, index.column()), action->text());
|
||||
}
|
||||
|
||||
void DiveHandler::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
|
@ -741,6 +741,18 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v
|
|||
return QAbstractItemModel::setData(index, value, role);
|
||||
}
|
||||
|
||||
void DivePlannerPointsModel::gaschange(const QModelIndex &index, QString newgas)
|
||||
{
|
||||
int i = index.row();
|
||||
gasmix oldgas = divepoints[i].gasmix;
|
||||
gasmix gas = { 0 };
|
||||
if (!validate_gas(newgas.toUtf8().data(), &gas))
|
||||
return;
|
||||
while (i < plannerModel->rowCount() && gasmix_distance(&oldgas, &divepoints[i].gasmix) == 0)
|
||||
divepoints[i++].gasmix = gas;
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, COLUMNS - 1));
|
||||
}
|
||||
|
||||
QVariant DivePlannerPointsModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
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 Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
void gaschange(const QModelIndex &index, QString newgas);
|
||||
void removeSelectedPoints(const QVector<int> &rows);
|
||||
void setPlanMode(Mode mode);
|
||||
bool isPlanner();
|
||||
|
|
Loading…
Reference in a new issue