metadata: fixed glitches in importing IPTC tags
(cherry picked from commit 3d03f654e22ca01f058492eab2c8fcbc564dc1b9)
This commit is contained in:
parent
f2248dce9d
commit
2ce81cccc5
@ -198,6 +198,7 @@ void Exiv2Metadata::do_merge_xmp(Exiv2::Image *dst, bool keep_all) const
|
||||
Exiv2::IptcData iptc;
|
||||
Exiv2::copyXmpToIptc(xmp, iptc);
|
||||
Exiv2::moveXmpToExif(xmp, exif);
|
||||
std::unordered_set<std::string> seen;
|
||||
|
||||
if (!keep_all) {
|
||||
remove_unwanted(exif);
|
||||
@ -207,10 +208,18 @@ void Exiv2Metadata::do_merge_xmp(Exiv2::Image *dst, bool keep_all) const
|
||||
dst->exifData()[datum.key()] = datum;
|
||||
}
|
||||
for (auto &datum : iptc) {
|
||||
if (seen.insert(datum.key()).second) {
|
||||
dst->iptcData()[datum.key()] = datum;
|
||||
} else {
|
||||
dst->iptcData().add(datum);
|
||||
}
|
||||
}
|
||||
for (auto &datum : xmp) {
|
||||
if (seen.insert(datum.key()).second) {
|
||||
dst->xmpData()[datum.key()] = datum;
|
||||
} else {
|
||||
dst->xmpData().add(datum);
|
||||
}
|
||||
}
|
||||
} catch (std::exception &exc) {
|
||||
if (settings->verbose) {
|
||||
|
@ -455,7 +455,7 @@ IPTCPanel::IPTCPanel():
|
||||
province->set_max_length(32);
|
||||
country->set_max_length(64);
|
||||
title->set_max_length(64);
|
||||
dateCreated->set_max_length (8);
|
||||
dateCreated->set_max_length(10);
|
||||
transReference->set_max_length(32);
|
||||
|
||||
show_all();
|
||||
@ -518,15 +518,16 @@ void IPTCPanel::notifyListener ()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IPTCPanel::addKeyWord()
|
||||
{
|
||||
|
||||
keyword->get_entry()->select_region(0, keyword->get_entry()->get_text().size());
|
||||
|
||||
for (unsigned int i = 0; i < keywords->size(); i++)
|
||||
for (unsigned int i = 0; i < keywords->size(); i++) {
|
||||
if (keywords->get_text(i) == keyword->get_entry()->get_text()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
keywords->append(keyword->get_entry()->get_text());
|
||||
keyword->prepend(keyword->get_entry()->get_text());
|
||||
@ -549,9 +550,9 @@ void IPTCPanel::addKeyWord ()
|
||||
updateChangeList();
|
||||
}
|
||||
|
||||
|
||||
void IPTCPanel::delKeyWord()
|
||||
{
|
||||
|
||||
std::vector<int> selection = keywords->get_selected();
|
||||
|
||||
if (!selection.empty()) {
|
||||
@ -634,14 +635,23 @@ void IPTCPanel::updateChangeList ()
|
||||
(*changeList)[HEADLINE].push_back(headline->get_text());
|
||||
(*changeList)[INSTRUCTIONS].push_back(instructions->get_text());
|
||||
|
||||
std::set<Glib::ustring> sset;
|
||||
sset.clear();
|
||||
for (unsigned int i = 0; i < keywords->size(); i++) {
|
||||
(*changeList)[KEYWORDS].push_back (keywords->get_text (i));
|
||||
sset.insert(keywords->get_text(i));
|
||||
}
|
||||
for (auto &s : sset) {
|
||||
(*changeList)[KEYWORDS].push_back(s);
|
||||
}
|
||||
|
||||
(*changeList)[CATEGORY].push_back(category->get_entry()->get_text());
|
||||
|
||||
sset.clear();
|
||||
for (unsigned int i = 0; i < suppCategories->size(); i++) {
|
||||
(*changeList)[SUPPLEMENTAL_CATEGORIES].push_back (suppCategories->get_text (i));
|
||||
sset.insert(suppCategories->get_text(i));
|
||||
}
|
||||
for (auto &s : sset) {
|
||||
(*changeList)[SUPPLEMENTAL_CATEGORIES].push_back(s);
|
||||
}
|
||||
|
||||
(*changeList)[CREATOR].push_back(creator->get_text());
|
||||
@ -659,9 +669,9 @@ void IPTCPanel::updateChangeList ()
|
||||
notifyListener();
|
||||
}
|
||||
|
||||
|
||||
void IPTCPanel::applyChangeList()
|
||||
{
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
conns[i].block(true);
|
||||
}
|
||||
@ -696,17 +706,25 @@ void IPTCPanel::applyChangeList ()
|
||||
headline->set_text(i->second.at(0));
|
||||
} else if (i->first == INSTRUCTIONS && !i->second.empty()) {
|
||||
instructions->set_text(i->second.at(0));
|
||||
} else if (i->first == KEYWORDS)
|
||||
} else if (i->first == KEYWORDS) {
|
||||
std::set<Glib::ustring> sset;
|
||||
for (unsigned int j = 0; j < i->second.size(); j++) {
|
||||
keywords->append (i->second.at(j));
|
||||
sset.insert(i->second[j]);
|
||||
}
|
||||
else if (i->first == CATEGORY && !i->second.empty()) {
|
||||
for (auto &s : sset) {
|
||||
keywords->append(s);
|
||||
}
|
||||
} else if (i->first == CATEGORY && !i->second.empty()) {
|
||||
category->get_entry()->set_text(i->second.at(0));
|
||||
} else if (i->first == SUPPLEMENTAL_CATEGORIES)
|
||||
} else if (i->first == SUPPLEMENTAL_CATEGORIES) {
|
||||
std::set<Glib::ustring> sset;
|
||||
for (unsigned int j = 0; j < i->second.size(); j++) {
|
||||
suppCategories->append (i->second.at(j));
|
||||
sset.insert(i->second[j]);
|
||||
}
|
||||
else if (i->first == CREATOR && !i->second.empty()) {
|
||||
for (auto &s : sset) {
|
||||
suppCategories->append(s);
|
||||
}
|
||||
} else if (i->first == CREATOR && !i->second.empty()) {
|
||||
creator->set_text(i->second.at(0));
|
||||
} else if (i->first == CREATOR_JOB_TITLE && !i->second.empty()) {
|
||||
creatorJobTitle->set_text(i->second.at(0));
|
||||
|
Loading…
x
Reference in New Issue
Block a user