From 2d52beb4dbf4f4de6b066ca2068aa2efbb8f6614 Mon Sep 17 00:00:00 2001 From: Vladimir Surguchev Date: Wed, 6 Sep 2017 14:39:14 +0000 Subject: [PATCH] =?UTF-8?q?=D1=8B=D1=89=D0=BA=D0=B5=20other=20formats=20by?= =?UTF-8?q?=20library,name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/arclite/changelog | 4 ++++ plugins/arclite/project.ini | 2 +- plugins/arclite/ui.cpp | 31 ++++++++++++++++++++----------- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/plugins/arclite/changelog b/plugins/arclite/changelog index 06beecca37..d85e783ae8 100644 --- a/plugins/arclite/changelog +++ b/plugins/arclite/changelog @@ -1,3 +1,7 @@ +w17 06.09.2017 17:35:57 +0300 - build 258 + +1. Sort other formats by (library, name). + w17 06.09.2017 15:56:47 +0300 - build 257 1. Skip external Zip codecs in 7z compression method list. diff --git a/plugins/arclite/project.ini b/plugins/arclite/project.ini index 4009271c6b..8fa9c8d029 100644 --- a/plugins/arclite/project.ini +++ b/plugins/arclite/project.ini @@ -2,4 +2,4 @@ MODULE = arclite VER_MAJOR = 3 VER_MINOR = 0 -VER_BUILD = 257 +VER_BUILD = 258 diff --git a/plugins/arclite/ui.cpp b/plugins/arclite/ui.cpp index f4880d7835..b7a6ca07a5 100644 --- a/plugins/arclite/ui.cpp +++ b/plugins/arclite/ui.cpp @@ -1306,29 +1306,38 @@ class UpdateDialog: public Far::Dialog { } }; - vector format_names; - unsigned other_format_index = 0; - bool found = false; for (ArcFormats::const_iterator arc_iter = arc_formats.begin(); arc_iter != arc_formats.end(); arc_iter++) { if (arc_iter->second.updatable && (!multifile || !ArcAPI::is_single_file_format(arc_iter->first))) { if (!multifile && arc_iter->first == c_SWFc && !is_SWFu(options.arc_path)) continue; - const auto main_type = find(main_formats.begin(), main_formats.end(), arc_iter->first); - if (main_type == main_formats.end()) { + if (find(main_formats.begin(), main_formats.end(), arc_iter->first) == main_formats.end()) { other_formats.push_back(arc_iter->first); - format_names.push_back(arc_iter->second.name); - if (options.arc_type == arc_iter->first) { - other_format_index = static_cast(other_formats.size()) - 1; - found = true; - } } } } + std::sort(other_formats.begin(), other_formats.end(), [&](const auto& a, const auto& b) { + const auto& a_format = arc_formats.at(a); + const auto& b_format = arc_formats.at(b); + if (a_format.lib_index != b_format.lib_index) + return a_format.lib_index < b_format.lib_index; + else + return _wcsicmp(a_format.name.data(), b_format.name.data()) < 0; + }); + vector other_format_names; + unsigned other_format_index = 0; + bool found = false; + for (const auto& t : other_formats) { + if (t == options.arc_type) { + other_format_index = static_cast(other_formats.size()) - 1; + found = true; + } + other_format_names.push_back(arc_formats.at(t).name); + } if (!other_formats.empty()) { if (!main_formats.empty()) spacer(1); other_formats_ctrl_id = radio_button(Far::get_msg(MSG_UPDATE_DLG_ARC_TYPE_OTHER), found); - combo_box(format_names, other_format_index, AUTO_SIZE, DIF_DROPDOWNLIST); + combo_box(other_format_names, other_format_index, AUTO_SIZE, DIF_DROPDOWNLIST); } new_line();