ENH: show category for multi extruders in search
Change-Id: I2441097f076e772dcc0b11245c6d22ed22bfad2b Jira: STUDIO-10187
This commit is contained in:
parent
7fca7c9884
commit
6eba5f3b48
|
@ -122,6 +122,19 @@ void OptionsSearcher::append_options(DynamicPrintConfig *config, Preset::Type ty
|
|||
}
|
||||
}
|
||||
|
||||
inline void OptionsSearcher::sort_options()
|
||||
{
|
||||
std::sort(options.begin(), options.end(), [](const Option &o1, const Option &o2) { return o1.label < o2.label; });
|
||||
Option * last = nullptr;
|
||||
for (auto& opt : options) {
|
||||
if (last && last->label == opt.label && last->group == opt.group && last->type == opt.type && last->category != opt.category) {
|
||||
last->multi_category = true;
|
||||
opt.multi_category = true;
|
||||
}
|
||||
last = &opt;
|
||||
}
|
||||
}
|
||||
|
||||
// Mark a string using ColorMarkerStart and ColorMarkerEnd symbols
|
||||
static std::wstring mark_string(const std::wstring &str, const std::vector<uint16_t> &matches, Preset::Type type, PrinterTechnology pt)
|
||||
{
|
||||
|
@ -180,7 +193,7 @@ bool OptionsSearcher::search(const std::string &search, bool force /* = false*/,
|
|||
std::wstring out;
|
||||
if (marked) out += marker_by_type(opt.type, printer_technology);
|
||||
const std::wstring *prev = nullptr;
|
||||
for (const std::wstring *const s : {view_params.category ? &opt.category_local : nullptr, &opt.group_local, &opt.label_local})
|
||||
for (const std::wstring *const s : {view_params.category || opt.multi_category ? &opt.category_local : nullptr, &opt.group_local, &opt.label_local})
|
||||
if (s != nullptr && (prev == nullptr || *prev != *s)) {
|
||||
if (out.size() > 2) out += sep;
|
||||
out += *s;
|
||||
|
@ -193,7 +206,7 @@ bool OptionsSearcher::search(const std::string &search, bool force /* = false*/,
|
|||
std::wstring out;
|
||||
if (marked) out += marker_by_type(opt.type, printer_technology);
|
||||
const std::wstring *prev = nullptr;
|
||||
for (const std::wstring *const s : {view_params.category ? &opt.category : nullptr, &opt.group, &opt.label})
|
||||
for (const std::wstring *const s : {view_params.category || opt.multi_category ? &opt.category : nullptr, &opt.group, &opt.label})
|
||||
if (s != nullptr && (prev == nullptr || *prev != *s)) {
|
||||
if (out.size() > 2) out += sep;
|
||||
out += *s;
|
||||
|
|
|
@ -62,6 +62,7 @@ struct Option
|
|||
std::wstring group_local;
|
||||
std::wstring category;
|
||||
std::wstring category_local;
|
||||
bool multi_category { false };
|
||||
|
||||
std::string opt_key() const;
|
||||
};
|
||||
|
@ -100,10 +101,7 @@ class OptionsSearcher
|
|||
|
||||
void append_options(DynamicPrintConfig *config, Preset::Type type, ConfigOptionMode mode);
|
||||
|
||||
void sort_options()
|
||||
{
|
||||
std::sort(options.begin(), options.end(), [](const Option &o1, const Option &o2) { return o1.label < o2.label; });
|
||||
}
|
||||
void sort_options();
|
||||
void sort_found()
|
||||
{
|
||||
std::sort(found.begin(), found.end(),
|
||||
|
|
|
@ -4210,13 +4210,20 @@ void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/)
|
|||
// BBS. No extra extruder page for single physical extruder machine
|
||||
// # remove extra pages
|
||||
#if 1
|
||||
auto &first_extruder_title = const_cast<wxString &>(m_pages[n_before_extruders]->title());
|
||||
if (m_extruders_count < m_extruders_count_old) {
|
||||
m_pages.erase( m_pages.begin() + n_before_extruders + m_extruders_count,
|
||||
m_pages.begin() + n_before_extruders + m_extruders_count_old);
|
||||
if (m_extruders_count == 1)
|
||||
const_cast<wxString&>(m_pages[n_before_extruders]->title()) = wxString::Format("Extruder");
|
||||
first_extruder_title = wxString::Format("Extruder");
|
||||
} else if (m_extruders_count_old == 1) {
|
||||
const_cast<wxString &>(m_pages[n_before_extruders]->title()) = wxString::Format("Extruder %d", 1);
|
||||
first_extruder_title = wxString::Format("Extruder %d", 1);
|
||||
}
|
||||
auto & searcher = wxGetApp().sidebar().get_searcher();
|
||||
for (auto &group : m_pages[n_before_extruders]->m_optgroups) {
|
||||
group->set_config_category_and_type(first_extruder_title, m_type);
|
||||
for (auto &opt : group->opt_map())
|
||||
searcher.add_key(opt.first + "#0", m_type, group->title, first_extruder_title);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue