From 9a4f8b50bd9b88b00959a08524e1617be1486c95 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Thu, 8 May 2014 23:36:45 +0200 Subject: When starting the planner, copy cylinders from currently selected dive. This way, the user can save dives containing sets of "standard cylinders". Selecting one of those prepopulates the gas list for the planner. Signed-off-by: Robert C. Helling Signed-off-by: Dirk Hohndel --- qt-ui/models.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'qt-ui/models.cpp') diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 0564add12..43f08e106 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -332,6 +332,23 @@ void CylindersModel::setDive(dive *d) } } +void CylindersModel::copyFromDive(dive *d) +{ + if (!d) + return; + rows = 0; + for (int i = 0; i < MAX_CYLINDERS; i++) { + if (!cylinder_none(&d->cylinder[i]) && + (prefs.display_unused_tanks || d->cylinder[i].used)) { + rows = i + 1; + } + } + if (rows > 0) { + beginInsertRows(QModelIndex(), 0, rows - 1); + endInsertRows(); + } +} + Qt::ItemFlags CylindersModel::flags(const QModelIndex &index) const { if (index.column() == REMOVE) -- cgit v1.2.3-70-g09d2