exif panel: further tweaks to the metadata selection
(cherry picked from commit 207e51b64726367f2d932c000060f00b2697523f)
This commit is contained in:
committed by
Lawrence Lee
parent
a26e627282
commit
8a5aa6c119
@@ -39,11 +39,11 @@ ExifPanel::ExifPanel() :
|
|||||||
{"Exif.Photo.UserComment", "User Comment"},
|
{"Exif.Photo.UserComment", "User Comment"},
|
||||||
{"Exif.Image.Artist", "Artist"},
|
{"Exif.Image.Artist", "Artist"},
|
||||||
{"Exif.Image.Copyright", "Copyright"},
|
{"Exif.Image.Copyright", "Copyright"},
|
||||||
{"Exif.Image.ImageDescription", "Image Description"}
|
{"Exif.Image.ImageDescription", "Image Description"},
|
||||||
|
{ "Exif.Photo.LensModel", "Lens Model" }
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
set_orientation(Gtk::ORIENTATION_VERTICAL);
|
set_orientation(Gtk::ORIENTATION_VERTICAL);
|
||||||
|
|
||||||
exifTree = Gtk::manage (new Gtk::TreeView());
|
exifTree = Gtk::manage (new Gtk::TreeView());
|
||||||
scrolledWindow = Gtk::manage (new Gtk::ScrolledWindow());
|
scrolledWindow = Gtk::manage (new Gtk::ScrolledWindow());
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ ExifPanel::ExifPanel() :
|
|||||||
exifTreeModel = Gtk::TreeStore::create(exifColumns);
|
exifTreeModel = Gtk::TreeStore::create(exifColumns);
|
||||||
exifTree->set_model(exifTreeModel);
|
exifTree->set_model(exifTreeModel);
|
||||||
exifTree->set_grid_lines(Gtk::TREE_VIEW_GRID_LINES_NONE);
|
exifTree->set_grid_lines(Gtk::TREE_VIEW_GRID_LINES_NONE);
|
||||||
exifTree->set_show_expanders(false);
|
//exifTree->set_show_expanders(false);
|
||||||
exifTree->set_tooltip_column(0);
|
exifTree->set_tooltip_column(0);
|
||||||
|
|
||||||
keepicon = RTImage::createPixbufFromFile ("tick-small.png");
|
keepicon = RTImage::createPixbufFromFile ("tick-small.png");
|
||||||
@@ -93,6 +93,7 @@ ExifPanel::ExifPanel() :
|
|||||||
exifTree->append_column(exif_active_column_);
|
exifTree->append_column(exif_active_column_);
|
||||||
|
|
||||||
exifTree->append_column(*viewcol);
|
exifTree->append_column(*viewcol);
|
||||||
|
exifTree->set_expander_column(*viewcol);
|
||||||
|
|
||||||
Gtk::TreeView::Column *viewcolv = Gtk::manage(new Gtk::TreeView::Column ("Value"));
|
Gtk::TreeView::Column *viewcolv = Gtk::manage(new Gtk::TreeView::Column ("Value"));
|
||||||
Gtk::CellRendererText *render_txtv = Gtk::manage(new Gtk::CellRendererText());
|
Gtk::CellRendererText *render_txtv = Gtk::manage(new Gtk::CellRendererText());
|
||||||
@@ -183,8 +184,19 @@ void ExifPanel::write (ProcParams* pp, ParamsEdited* pedited)
|
|||||||
bool none_active = true;
|
bool none_active = true;
|
||||||
|
|
||||||
auto root = exifTreeModel->children();
|
auto root = exifTreeModel->children();
|
||||||
for (auto &entry : root->children()) {
|
// for (auto &entry : root->children()) {
|
||||||
Glib::ustring key = entry[exifColumns.key];
|
// Glib::ustring key = entry[exifColumns.key];
|
||||||
|
// prev.erase(key);
|
||||||
|
// if (entry[exifColumns.active]) {
|
||||||
|
// pp->metadata.exifKeys.push_back(key);
|
||||||
|
// none_active = false;
|
||||||
|
// } else {
|
||||||
|
// all_active = false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
for (auto &group : root->children()) {
|
||||||
|
for (auto &entry : group.children()) {
|
||||||
|
std::string key = entry[exifColumns.key];
|
||||||
prev.erase(key);
|
prev.erase(key);
|
||||||
if (entry[exifColumns.active]) {
|
if (entry[exifColumns.active]) {
|
||||||
pp->metadata.exifKeys.push_back(key);
|
pp->metadata.exifKeys.push_back(key);
|
||||||
@@ -193,6 +205,7 @@ void ExifPanel::write (ProcParams* pp, ParamsEdited* pedited)
|
|||||||
all_active = false;
|
all_active = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (all_active) {
|
if (all_active) {
|
||||||
pp->metadata.exifKeys = { "ALL" };
|
pp->metadata.exifKeys = { "ALL" };
|
||||||
@@ -209,11 +222,10 @@ void ExifPanel::setDefaults (const ProcParams* defParams, const ParamsEdited* pe
|
|||||||
|
|
||||||
void ExifPanel::setImageData (const FramesMetaData* id)
|
void ExifPanel::setImageData (const FramesMetaData* id)
|
||||||
{
|
{
|
||||||
|
|
||||||
idata = id;
|
idata = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void 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 std::pair<Glib::ustring, Glib::ustring> &label, const Glib::ustring &value, bool editable, bool edited)
|
||||||
{
|
{
|
||||||
|
|
||||||
// TODO Re-fix #5923 if necessary
|
// TODO Re-fix #5923 if necessary
|
||||||
@@ -221,18 +233,47 @@ void ExifPanel::addTag(const std::string &key, const Glib::ustring &label, const
|
|||||||
// value = "???";
|
// value = "???";
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
// auto root = exifTreeModel->children();
|
||||||
|
|
||||||
|
const auto getgroup =
|
||||||
|
[&]() -> Gtk::TreeNodeChildren
|
||||||
|
{
|
||||||
auto root = exifTreeModel->children();
|
auto root = exifTreeModel->children();
|
||||||
|
|
||||||
|
for (auto it = root.rbegin(), end = root.rend(); it != end; ++it) {
|
||||||
|
auto row = *it;
|
||||||
|
std::string key = row[exifColumns.key];
|
||||||
|
if (row[exifColumns.is_group] && key == label.first) {
|
||||||
|
return it->children();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto it = exifTreeModel->append(root);
|
||||||
|
auto row = *it;
|
||||||
|
|
||||||
|
row[exifColumns.editable] = false;
|
||||||
|
row[exifColumns.edited] = false;
|
||||||
|
row[exifColumns.key] = label.first;
|
||||||
|
row[exifColumns.label] = "<i>" + label.first + "</i>";
|
||||||
|
row[exifColumns.value_nopango] = "";
|
||||||
|
row[exifColumns.value] = "";
|
||||||
|
row[exifColumns.is_group] = true;
|
||||||
|
|
||||||
|
return it->children();
|
||||||
|
};
|
||||||
|
|
||||||
|
auto root = getgroup();
|
||||||
|
|
||||||
Gtk::TreeModel::Row row = *(exifTreeModel->append(root));
|
Gtk::TreeModel::Row row = *(exifTreeModel->append(root));
|
||||||
row[exifColumns.editable] = editable;
|
row[exifColumns.editable] = editable;
|
||||||
row[exifColumns.edited] = edited;
|
row[exifColumns.edited] = edited;
|
||||||
row[exifColumns.key] = key;
|
row[exifColumns.key] = key;
|
||||||
row[exifColumns.label] = label;
|
row[exifColumns.is_group] = false;
|
||||||
|
//row[exifColumns.label] = label.second;
|
||||||
row[exifColumns.value_nopango] = value;
|
row[exifColumns.value_nopango] = value;
|
||||||
row[exifColumns.value] = value;
|
//row[exifColumns.value] = value;
|
||||||
|
|
||||||
row[exifColumns.label] = escapeHtmlChars(label);
|
row[exifColumns.label] = escapeHtmlChars(label.second);
|
||||||
row[exifColumns.value] = escapeHtmlChars(value);
|
row[exifColumns.value] = value;//escapeHtmlChars(value);
|
||||||
|
|
||||||
bool active = (cur_active_keys_.size() == 1 && *(cur_active_keys_.begin()) == "ALL") || cur_active_keys_.find(key) != cur_active_keys_.end();
|
bool active = (cur_active_keys_.size() == 1 && *(cur_active_keys_.begin()) == "ALL") || cur_active_keys_.find(key) != cur_active_keys_.end();
|
||||||
row[exifColumns.active] = active;
|
row[exifColumns.active] = active;
|
||||||
@@ -266,14 +307,20 @@ void ExifPanel::refreshTags()
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto to_label =
|
const auto to_label =
|
||||||
[](const Exiv2::Exifdatum &tag) -> Glib::ustring
|
[](const Exiv2::Exifdatum &tag) -> std::pair<Glib::ustring, Glib::ustring>
|
||||||
{
|
{
|
||||||
auto s = tag.key();
|
auto s = tag.key();
|
||||||
auto pos = s.find('.');
|
auto pos = s.find('.');
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos) {
|
||||||
s = s.substr(pos+1);
|
s = s.substr(pos+1);
|
||||||
}
|
}
|
||||||
return s;
|
Glib::ustring g = "";
|
||||||
|
pos = s.find('.');
|
||||||
|
if (pos != std::string::npos) {
|
||||||
|
g = s.substr(0, pos);
|
||||||
|
s = s.substr(pos+1);
|
||||||
|
}
|
||||||
|
return std::make_pair(g, Glib::ustring(s));
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -281,6 +328,17 @@ void ExifPanel::refreshTags()
|
|||||||
meta.load();
|
meta.load();
|
||||||
auto& exif = meta.exifData();
|
auto& exif = meta.exifData();
|
||||||
|
|
||||||
|
const auto to_value =
|
||||||
|
[&](Exiv2::Exifdatum &tag) -> Glib::ustring
|
||||||
|
{
|
||||||
|
if (!tag.tagLabel().empty() && tag.typeId() != Exiv2::undefined &&
|
||||||
|
(tag.typeId() == Exiv2::asciiString || tag.size() < 256)) {
|
||||||
|
return escapeHtmlChars(tag.print(&exif));
|
||||||
|
}
|
||||||
|
return "<i>(Not shown)</i>";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
for (const auto& p : *changeList) {
|
for (const auto& p : *changeList) {
|
||||||
try {
|
try {
|
||||||
exif[p.first] = p.second;
|
exif[p.first] = p.second;
|
||||||
@@ -295,28 +353,16 @@ void ExifPanel::refreshTags()
|
|||||||
addTag(pos->key(), to_label(*pos), pos->print(&exif), true, edited);
|
addTag(pos->key(), to_label(*pos), pos->print(&exif), true, edited);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::multimap<std::string, std::string> keymap;
|
std::set<std::string> keyset;
|
||||||
for (const auto& tag : exif) {
|
for (const auto& tag : exif) {
|
||||||
const bool editable = ed.find(tag.key()) != ed.end();
|
const bool editable = ed.find(tag.key()) != ed.end();
|
||||||
if (
|
if (!editable) {
|
||||||
!editable
|
keyset.insert(tag.key());
|
||||||
&& !tag.tagLabel().empty()
|
|
||||||
&& tag.typeId() != Exiv2::undefined
|
|
||||||
&& (
|
|
||||||
tag.typeId() == Exiv2::asciiString
|
|
||||||
|| tag.size() < 256
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
std::string lbl = to_label(tag);
|
|
||||||
for (auto &c : lbl) {
|
|
||||||
c = std::tolower(c);
|
|
||||||
}
|
|
||||||
keymap.insert(std::make_pair(lbl, tag.key()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto &p : keymap) {
|
for (auto &k : keyset) {
|
||||||
auto &tag = *(exif.findKey(Exiv2::ExifKey(p.second)));
|
auto &tag = *(exif.findKey(Exiv2::ExifKey(k)));
|
||||||
addTag(tag.key(), to_label(tag), tag.print(&exif), false, false);
|
addTag(tag.key(), to_label(tag), to_value(tag), false, false);
|
||||||
}
|
}
|
||||||
} catch (const std::exception& exc) {
|
} catch (const std::exception& exc) {
|
||||||
return;
|
return;
|
||||||
@@ -325,6 +371,8 @@ void ExifPanel::refreshTags()
|
|||||||
for (const auto& p : sel) {
|
for (const auto& p : sel) {
|
||||||
exifTree->get_selection()->select(p);
|
exifTree->get_selection()->select(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exifTree->expand_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExifPanel::exifSelectionChanged ()
|
void ExifPanel::exifSelectionChanged ()
|
||||||
@@ -463,9 +511,12 @@ void ExifPanel::activateAllPressed()
|
|||||||
{
|
{
|
||||||
disableListener();
|
disableListener();
|
||||||
auto root = exifTreeModel->children();
|
auto root = exifTreeModel->children();
|
||||||
for (auto &row : root->children()) {
|
for (auto &group : root->children()) {
|
||||||
|
group[exifColumns.active] = true;
|
||||||
|
for (auto &row : group.children()) {
|
||||||
row[exifColumns.active] = true;
|
row[exifColumns.active] = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
enableListener();
|
enableListener();
|
||||||
notifyListener();
|
notifyListener();
|
||||||
}
|
}
|
||||||
@@ -475,9 +526,12 @@ void ExifPanel::activateNonePressed()
|
|||||||
{
|
{
|
||||||
disableListener();
|
disableListener();
|
||||||
auto root = exifTreeModel->children();
|
auto root = exifTreeModel->children();
|
||||||
for (auto &row : root->children()) {
|
for (auto &group : root->children()) {
|
||||||
|
group[exifColumns.active] = false;
|
||||||
|
for (auto &row : group.children()) {
|
||||||
row[exifColumns.active] = false;
|
row[exifColumns.active] = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
enableListener();
|
enableListener();
|
||||||
notifyListener();
|
notifyListener();
|
||||||
}
|
}
|
||||||
@@ -496,7 +550,13 @@ void ExifPanel::onKeyActiveToggled(const Glib::ustring &path)
|
|||||||
auto it = exifTreeModel->get_iter(path);
|
auto it = exifTreeModel->get_iter(path);
|
||||||
if (it) {
|
if (it) {
|
||||||
auto row = *it;
|
auto row = *it;
|
||||||
row[exifColumns.active] = !row[exifColumns.active];
|
bool b = !row[exifColumns.active];
|
||||||
|
row[exifColumns.active] = b;
|
||||||
|
if (row[exifColumns.is_group]) {
|
||||||
|
for (auto &c : row.children()) {
|
||||||
|
c[exifColumns.active] = b;
|
||||||
|
}
|
||||||
|
}
|
||||||
notifyListener();
|
notifyListener();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -51,13 +51,14 @@ private:
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
|
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
|
||||||
Gtk::TreeModelColumn<Glib::ustring> key;
|
Gtk::TreeModelColumn<std::string> key;
|
||||||
Gtk::TreeModelColumn<Glib::ustring> label;
|
Gtk::TreeModelColumn<Glib::ustring> label;
|
||||||
Gtk::TreeModelColumn<Glib::ustring> value;
|
Gtk::TreeModelColumn<Glib::ustring> value;
|
||||||
Gtk::TreeModelColumn<Glib::ustring> value_nopango;
|
Gtk::TreeModelColumn<Glib::ustring> value_nopango;
|
||||||
Gtk::TreeModelColumn<bool> editable;
|
Gtk::TreeModelColumn<bool> editable;
|
||||||
Gtk::TreeModelColumn<bool> edited;
|
Gtk::TreeModelColumn<bool> edited;
|
||||||
Gtk::TreeModelColumn<bool> active;
|
Gtk::TreeModelColumn<bool> active;
|
||||||
|
Gtk::TreeModelColumn<bool> is_group;
|
||||||
|
|
||||||
ExifColumns()
|
ExifColumns()
|
||||||
{
|
{
|
||||||
@@ -69,6 +70,7 @@ private:
|
|||||||
add(value_nopango);
|
add(value_nopango);
|
||||||
add(editable);
|
add(editable);
|
||||||
add(active);
|
add(active);
|
||||||
|
add(is_group);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Glib::RefPtr<Gdk::Pixbuf> keepicon;
|
Glib::RefPtr<Gdk::Pixbuf> keepicon;
|
||||||
@@ -93,7 +95,7 @@ private:
|
|||||||
std::unordered_set<std::string> initial_active_keys_;
|
std::unordered_set<std::string> initial_active_keys_;
|
||||||
std::unordered_set<std::string> cur_active_keys_;
|
std::unordered_set<std::string> cur_active_keys_;
|
||||||
|
|
||||||
void addTag(const std::string &key, const Glib::ustring &label, const Glib::ustring &value, bool editable, bool edited);
|
void addTag(const std::string &key, const std::pair<Glib::ustring, Glib::ustring> &label, const Glib::ustring &value, bool editable, bool edited);
|
||||||
void refreshTags();
|
void refreshTags();
|
||||||
void resetIt(const Gtk::TreeModel::const_iterator& iter);
|
void resetIt(const Gtk::TreeModel::const_iterator& iter);
|
||||||
void resetPressed();
|
void resetPressed();
|
||||||
|
Reference in New Issue
Block a user