mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: remove filterconstraint C boilerplate code
Since all code can now directly access C++ structures these accessor functions were not necessary. Split out the table from the filterconstraint source file and include it directly into the divelog. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
2bdcdab391
commit
91968ac579
20 changed files with 212 additions and 250 deletions
|
@ -1,23 +1,26 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#include "command_filter.h"
|
||||
#include "core/divelog.h"
|
||||
#include "core/filterpreset.h"
|
||||
#include "core/filterpresettable.h"
|
||||
#include "core/subsurface-qt/divelistnotifier.h"
|
||||
|
||||
namespace Command {
|
||||
|
||||
static int createFilterPreset(const std::string &name, const FilterData &data)
|
||||
{
|
||||
int index = filter_preset_add(name, data);
|
||||
int index = divelog.filter_presets.add(name, data);
|
||||
emit diveListNotifier.filterPresetAdded(index);
|
||||
return index;
|
||||
}
|
||||
|
||||
static std::pair<std::string, FilterData> removeFilterPreset(int index)
|
||||
{
|
||||
std::string oldName = filter_preset_name(index);
|
||||
FilterData oldData = filter_preset_get(index);
|
||||
filter_preset_delete(index);
|
||||
const filter_preset &preset = divelog.filter_presets[index];
|
||||
std::string oldName = preset.name;
|
||||
FilterData oldData = preset.data;
|
||||
divelog.filter_presets.remove(index);
|
||||
emit diveListNotifier.filterPresetRemoved(index);
|
||||
return { oldName, oldData };
|
||||
}
|
||||
|
@ -46,7 +49,8 @@ void CreateFilterPreset::undo()
|
|||
|
||||
RemoveFilterPreset::RemoveFilterPreset(int indexIn) : index(indexIn)
|
||||
{
|
||||
setText(Command::Base::tr("Delete filter preset %1").arg(QString(filter_preset_name(index).c_str())));
|
||||
const std::string &name = divelog.filter_presets[index].name;
|
||||
setText(Command::Base::tr("Delete filter preset %1").arg(QString::fromStdString(name)));
|
||||
}
|
||||
|
||||
bool RemoveFilterPreset::workToBeDone()
|
||||
|
@ -68,7 +72,8 @@ void RemoveFilterPreset::undo()
|
|||
EditFilterPreset::EditFilterPreset(int indexIn, const FilterData &dataIn) :
|
||||
index(indexIn), data(dataIn)
|
||||
{
|
||||
setText(Command::Base::tr("Edit filter preset %1").arg(QString(filter_preset_name(index).c_str())));
|
||||
const std::string &name = divelog.filter_presets[index].name;
|
||||
setText(Command::Base::tr("Edit filter preset %1").arg(QString::fromStdString(name)));
|
||||
}
|
||||
|
||||
bool EditFilterPreset::workToBeDone()
|
||||
|
@ -78,9 +83,8 @@ bool EditFilterPreset::workToBeDone()
|
|||
|
||||
void EditFilterPreset::redo()
|
||||
{
|
||||
FilterData oldData = filter_preset_get(index);
|
||||
filter_preset_set(index, data);
|
||||
data = std::move(oldData);
|
||||
filter_preset &preset = divelog.filter_presets[index];
|
||||
std::swap(data, preset.data);
|
||||
}
|
||||
|
||||
void EditFilterPreset::undo()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue