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
|
|
@ -97,7 +97,7 @@ void FilterWidget::selectPreset(int i)
|
|||
void FilterWidget::loadPreset(int index)
|
||||
{
|
||||
ignoreSignal = true; // When reloading the filter UI, we get numerous constraintChanged signals. Ignore them.
|
||||
FilterData filter = filter_preset_get(index);
|
||||
FilterData filter = divelog.filter_presets[index].data;
|
||||
setFilterData(filter);
|
||||
ignoreSignal = false;
|
||||
presetModified = false;
|
||||
|
|
@ -227,7 +227,8 @@ void FilterWidget::updatePresetLabel()
|
|||
int presetId = selectedPreset();
|
||||
QString text;
|
||||
if (presetId >= 0) {
|
||||
text = QString(filter_preset_name(presetId).c_str());
|
||||
const std::string &name = divelog.filter_presets[presetId].name;
|
||||
text = QString::fromStdString(name);
|
||||
if (presetModified)
|
||||
text += " (" + tr("modified") + ")";
|
||||
}
|
||||
|
|
@ -240,13 +241,15 @@ void FilterWidget::on_addSetButton_clicked()
|
|||
// Thus, if the user selects an item and modify the filter,
|
||||
// they can simply overwrite the preset.
|
||||
int presetId = selectedPreset();
|
||||
QString selectedPreset = presetId >= 0 ? QString(filter_preset_name(presetId).c_str()) : QString();
|
||||
QString selectedPreset = presetId >= 0 ?
|
||||
QString::fromStdString(divelog.filter_presets[presetId].name) :
|
||||
QString();
|
||||
|
||||
AddFilterPresetDialog dialog(selectedPreset, this);
|
||||
QString name = dialog.doit();
|
||||
if (name.isEmpty())
|
||||
return;
|
||||
int idx = filter_preset_id(name.toStdString());
|
||||
int idx = divelog.filter_presets.preset_id(name.toStdString());
|
||||
if (idx >= 0)
|
||||
Command::editFilterPreset(idx, createFilterData());
|
||||
else
|
||||
|
|
|
|||
|
|
@ -374,10 +374,9 @@ AddFilterPresetDialog::AddFilterPresetDialog(const QString &defaultName, QWidget
|
|||
|
||||
// Create a completer so that the user can easily overwrite existing presets.
|
||||
QStringList presets;
|
||||
int count = filter_presets_count();
|
||||
presets.reserve(count);
|
||||
for (int i = 0; i < count; ++i)
|
||||
presets.push_back(QString(filter_preset_name(i).c_str()));
|
||||
presets.reserve(divelog.filter_presets.size());
|
||||
for (auto &filter_preset: divelog.filter_presets)
|
||||
presets.push_back(QString::fromStdString(filter_preset.name));
|
||||
QCompleter *completer = new QCompleter(presets, this);
|
||||
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
ui.name->setCompleter(completer);
|
||||
|
|
@ -387,7 +386,7 @@ void AddFilterPresetDialog::nameChanged(const QString &text)
|
|||
{
|
||||
QString trimmed = text.trimmed();
|
||||
bool isEmpty = trimmed.isEmpty();
|
||||
bool exists = !isEmpty && filter_preset_id(trimmed.toStdString()) >= 0;
|
||||
bool exists = !isEmpty && divelog.filter_presets.preset_id(trimmed.toStdString()) >= 0;
|
||||
ui.duplicateWarning->setVisible(exists);
|
||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!isEmpty);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue