Type filtering fix

This commit is contained in:
David Kocik 2022-01-31 11:24:45 +01:00
parent 3dec56da12
commit e33c80a681

View File

@ -915,51 +915,54 @@ void PageMaterials::update_lists(int sel_type, int sel_vendor, int last_selected
sel_printers_count = list_printer->GetSelections(sel_printers); sel_printers_count = list_printer->GetSelections(sel_printers);
} }
} }
if (sel_printers[0] != 0 && sel_printers[0] != 1) { }
for (int i = 0; i < sel_printers_count; i++) { if (sel_printers_count > 0 && sel_printers[0] != 0 && sel_printers[0] != 1) {
const std::string& printer_name = list_printer->get_data(sel_printers[i]); for (int i = 0; i < sel_printers_count; i++) {
const Preset* printer = nullptr; const std::string& printer_name = list_printer->get_data(sel_printers[i]);
for (const Preset* it : materials->printers) { const Preset* printer = nullptr;
if (it->name == printer_name) { for (const Preset* it : materials->printers) {
printer = it; if (it->name == printer_name) {
break; printer = it;
} break;
} }
materials->filter_presets(printer, printer_name, EMPTY, EMPTY, [this](const Preset* p) { }
const std::string& type = this->materials->get_type(p); materials->filter_presets(printer, printer_name, EMPTY, EMPTY, [this](const Preset* p) {
if (list_type->find(type) == wxNOT_FOUND) {
list_type->append(type, &type);
}
});
}
} else if(last_selected_printer == 0){
//clear selection except "ALL"
list_printer->SetSelection(wxNOT_FOUND);
list_printer->SetSelection(0);
sel_printers_count = list_printer->GetSelections(sel_printers);
materials->filter_presets(nullptr, EMPTY, EMPTY, EMPTY, [this](const Preset* p) {
const std::string& type = this->materials->get_type(p);
if (list_type->find(type) == wxNOT_FOUND) {
list_type->append(type, &type);
}
});
} else if (last_selected_printer == 1) {
//clear selection except "CUSTOM"
list_printer->SetSelection(wxNOT_FOUND);
list_printer->SetSelection(1);
sel_printers_count = list_printer->GetSelections(sel_printers);
materials->filter_presets(nullptr, CUSTOM, CUSTOM, CUSTOM, [this](const Preset* p) {
const std::string& type = this->materials->get_type(p); const std::string& type = this->materials->get_type(p);
if (list_type->find(type) == wxNOT_FOUND) { if (list_type->find(type) == wxNOT_FOUND) {
list_type->append(type, &type); list_type->append(type, &type);
} }
}); });
} }
sort_list_data(list_type, true, true); }
} else if (sel_printers_count > 0 && last_selected_printer == 0) {
//clear selection except "ALL"
list_printer->SetSelection(wxNOT_FOUND);
list_printer->SetSelection(0);
sel_printers_count = list_printer->GetSelections(sel_printers);
materials->filter_presets(nullptr, EMPTY, EMPTY, EMPTY, [this](const Preset* p) {
const std::string& type = this->materials->get_type(p);
if (list_type->find(type) == wxNOT_FOUND) {
list_type->append(type, &type);
}
});
}
else if (sel_printers_count > 0 && last_selected_printer == 1) {
//clear selection except "CUSTOM"
list_printer->SetSelection(wxNOT_FOUND);
list_printer->SetSelection(1);
sel_printers_count = list_printer->GetSelections(sel_printers);
materials->filter_presets(nullptr, CUSTOM, EMPTY, EMPTY, [this](const Preset* p) {
const std::string& type = this->materials->get_type(p);
if (list_type->find(type) == wxNOT_FOUND) {
list_type->append(type, &type);
}
});
}
sort_list_data(list_type, true, true);
sel_printers_prev = sel_printers; sel_printers_prev = sel_printers;
sel_type = 0; sel_type = 0;
sel_type_prev = wxNOT_FOUND; sel_type_prev = wxNOT_FOUND;