Implemented Preset::compatible and improved doxygen comment.

This commit is contained in:
Joseph Lenox 2018-11-18 00:26:01 -06:00 committed by Joseph Lenox
parent 8059bff31e
commit 54d40bbc04
2 changed files with 14 additions and 3 deletions

View File

@ -121,4 +121,14 @@ t_config_option_keys Preset::_group_overrides() const {
}
}
bool Preset::compatible(const std::string& printer_name) const {
if (!this->_dirty_config->has("compatible_printers") || this->default_preset || this->group == preset_t::Printer) {
return true;
}
auto compatible_list {this->_dirty_config->get<ConfigOptionStrings>("compatible_printers").values};
if (compatible_list.size() == 0) return true;
return std::any_of(compatible_list.cbegin(), compatible_list.cend(), [printer_name] (const std::string& x) -> bool { return x.compare(printer_name) == 0; });
}
}} // namespace Slic3r::GUI

View File

@ -48,9 +48,10 @@ public:
/// Search the compatible_printers config option list for this preset name.
/// Assume that Printer configs are compatible with other Printer configs
bool compatible(std::string printer_name) { return true; }
bool compatible(const wxString& printer_name) { if (group == preset_t::Printer) return true; return true; }
bool compatible(const Preset& other) {return (this->group == preset_t::Printer || (compatible(other.name) && other.group == preset_t::Printer));}
/// @param [in] Printer preset name to use to compare.
bool compatible(const std::string& printer_name) const;
bool compatible(const wxString& printer_name) const { return this->compatible(printer_name.ToStdString()); }
bool compatible(const Preset& other) const {return (this->group == preset_t::Printer || (compatible(other.name) && other.group == preset_t::Printer));}
/// Format the name appropriately.
wxString dropdown_name() { return (this->dirty() ? this->name << " " << _("(modified)") : this->name); }