From f62f6807a7c03d33a7d4c4969604806e62cb8b0f Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Tue, 7 Apr 2020 09:48:14 -0700 Subject: [PATCH] exifpanel: sort the list of exif tags (cherry picked from commit 88e5ec5dc6a47d3a9cc751d2902aadc540ce0826) --- rtgui/exifpanel.cc | 17 ++++++++++++----- rtgui/exifpanel.h | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/rtgui/exifpanel.cc b/rtgui/exifpanel.cc index 5cc4af341..5b93f25c8 100644 --- a/rtgui/exifpanel.cc +++ b/rtgui/exifpanel.cc @@ -174,7 +174,7 @@ void ExifPanel::setImageData (const FramesMetaData* id) idata = id; } -Gtk::TreeModel::Children ExifPanel::addTag(const std::string &key, const Glib::ustring &label, const Glib::ustring &value, bool editable, bool edited) +void ExifPanel::addTag(const std::string &key, const Glib::ustring &label, const Glib::ustring &value, bool editable, bool edited) { // TODO Re-fix #5923 if necessary @@ -184,7 +184,7 @@ Gtk::TreeModel::Children ExifPanel::addTag(const std::string &key, const Glib::u auto root = exifTreeModel->children(); - Gtk::TreeModel::Row row = * (exifTreeModel->append (root)); + Gtk::TreeModel::Row row = *(exifTreeModel->append(root)); row[exifColumns.editable] = editable; row[exifColumns.edited] = edited; row[exifColumns.key] = key; @@ -200,8 +200,6 @@ Gtk::TreeModel::Children ExifPanel::addTag(const std::string &key, const Glib::u } else if (editable) { row[exifColumns.icon] = keepicon; } - - return row.children(); } void ExifPanel::refreshTags() @@ -244,6 +242,7 @@ void ExifPanel::refreshTags() addTag(pos->key(), pos->tagLabel(), pos->print(&exif), true, edited); } } + std::map keymap; for (const auto& tag : exif) { const bool editable = ed.find(tag.key()) != ed.end(); if ( @@ -255,9 +254,17 @@ void ExifPanel::refreshTags() || tag.size() < 256 ) ) { - addTag(tag.key(), tag.tagLabel(), tag.print(&exif), false, false); + std::string lbl = tag.tagLabel(); + for (auto &c : lbl) { + c = std::tolower(c); + } + keymap[lbl] = tag.key(); } } + for (auto &p : keymap) { + auto &tag = *(exif.findKey(Exiv2::ExifKey(p.second))); + addTag(tag.key(), tag.tagLabel(), tag.print(&exif), false, false); + } } catch (const std::exception& exc) { return; } diff --git a/rtgui/exifpanel.h b/rtgui/exifpanel.h index 47ad33c83..cfcf77e4d 100644 --- a/rtgui/exifpanel.h +++ b/rtgui/exifpanel.h @@ -82,7 +82,7 @@ private: const std::vector> editableTags; - Gtk::TreeModel::Children addTag(const std::string &key, const Glib::ustring &label, const Glib::ustring &value, bool editable, bool edited); + void addTag(const std::string &key, const Glib::ustring &label, const Glib::ustring &value, bool editable, bool edited); void refreshTags(); void resetIt(const Gtk::TreeModel::const_iterator& iter); void resetPressed();