From 1935f3d76d583d5ca082fc7e1580ed27b918189a Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Fri, 10 Apr 2020 06:47:13 -0700 Subject: [PATCH] exif panel: ensure that keys are not empty in the displayed tag tree (cherry picked from commit da45bf30bddf311b6c7d0d990d078b2a37d4b500) --- rtdata/languages/default | 1 + rtgui/exifpanel.cc | 28 ++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index a5ce4fa54..1b625bdac 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -78,6 +78,7 @@ EXIFPANEL_RESETALL;Reset All EXIFPANEL_RESETALLHINT;Reset all tags to their original values. EXIFPANEL_RESETHINT;Reset the selected tags to their original values. EXIFPANEL_BASIC_GROUP;Basic +EXIFPANEL_VALUE_NOT_SHOWN;Not shown EXPORT_BYPASS;Processing steps to bypass EXPORT_BYPASS_ALL;Select / Unselect All EXPORT_BYPASS_DEFRINGE;Bypass Defringe diff --git a/rtgui/exifpanel.cc b/rtgui/exifpanel.cc index a130a09b8..4957cc0b6 100644 --- a/rtgui/exifpanel.cc +++ b/rtgui/exifpanel.cc @@ -293,9 +293,12 @@ void ExifPanel::refreshTags() pos = s.find('.'); if (pos != std::string::npos) { g = s.substr(0, pos); - // s = s.substr(pos+1); + s = s.substr(pos+1); + } + auto l = tag.tagLabel(); + if (!l.empty()) { + s = l; } - s = tag.tagLabel(); return std::make_pair(g, Glib::ustring(s)); }; @@ -311,7 +314,7 @@ void ExifPanel::refreshTags() (tag.typeId() == Exiv2::asciiString || tag.size() < 256)) { return escapeHtmlChars(tag.print(&exif)); } - return "(Not shown)"; + return "(" + M("EXIFPANEL_VALUE_NOT_SHOWN") + ")"; }; if (const rtengine::FramesData *fd = dynamic_cast(idata)) { @@ -338,7 +341,24 @@ void ExifPanel::refreshTags() } addTag(p.first, lbl, value, true, edited); } - std::set keyset; + struct KeyLt { + bool operator()(const std::string &a, const std::string &b) const + { + auto p1 = a.find_last_of('.'); + auto p2 = b.find_last_of('.'); + const char *sa = a.c_str(); + const char *sb = b.c_str(); + if (p1 != std::string::npos && p2 != std::string::npos) { + bool hex_a = strncmp(sa+p1+1, "0x", 2) == 0; + bool hex_b = strncmp(sb+p2+1, "0x", 2) == 0; + if (hex_a != hex_b) { + return !hex_a; + } + } + return strcmp(sa, sb) < 0; + } + }; + std::set keyset; for (const auto& tag : exif) { const bool editable = ed.find(tag.key()) != ed.end(); if (!editable) {