mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Undo: update cylinder and weight models on paste
When pasting (or undoing paste) the cylinders or weights may change. Send the appropriate signals and update the models accordingly. Currently, this means copying from current dive to displayed dive, but hopefully we can get rid of "displayed_dive" in the not so distant future. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9ed5cf16a4
commit
9fd87fa080
8 changed files with 52 additions and 5 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#include "core/color.h"
|
||||
#include "qt-models/diveplannermodel.h"
|
||||
#include "core/gettextfromc.h"
|
||||
#include "core/subsurface-qt/DiveListNotifier.h"
|
||||
|
||||
CylindersModel::CylindersModel(QObject *parent) :
|
||||
CleanerTableModel(parent),
|
||||
|
|
@ -16,6 +17,7 @@ CylindersModel::CylindersModel(QObject *parent) :
|
|||
setHeaderDataStrings(QStringList() << "" << tr("Type") << tr("Size") << tr("Work press.") << tr("Start press.") << tr("End press.") << tr("O₂%") << tr("He%")
|
||||
<< tr("Deco switch at") <<tr("Bot. MOD") <<tr("MND") << tr("Use"));
|
||||
|
||||
connect(&diveListNotifier, &DiveListNotifier::cylindersReset, this, &CylindersModel::cylindersReset);
|
||||
}
|
||||
|
||||
QVariant CylindersModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
|
|
@ -630,3 +632,17 @@ bool CylindersModel::updateBestMixes()
|
|||
emit dataChanged(createIndex(0, 0), createIndex(MAX_CYLINDERS - 1, COLUMNS - 1));
|
||||
return gasUpdated;
|
||||
}
|
||||
|
||||
void CylindersModel::cylindersReset(dive_trip *trip, const QVector<dive *> &dives)
|
||||
{
|
||||
// This model only concerns the currently displayed dive. If this is not among the
|
||||
// dives that had their cylinders reset, exit.
|
||||
if (!current_dive || std::find(dives.begin(), dives.end(), current_dive) == dives.end())
|
||||
return;
|
||||
|
||||
// Copy the cylinders from the current dive to the displayed dive.
|
||||
copy_cylinders(current_dive, &displayed_dive, false);
|
||||
|
||||
// And update the model..
|
||||
updateDive();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue