[Kde-imaging] [kipiplugins] [Bug 335493] New: Fix for issues in loading metadata into mediawiki kipi-plugin [patch]
H Law
hhclaw.eb at gmail.com
Wed May 28 20:23:17 UTC 2014
https://bugs.kde.org/show_bug.cgi?id=335493
Bug ID: 335493
Summary: Fix for issues in loading metadata into mediawiki
kipi-plugin [patch]
Classification: Unclassified
Product: kipiplugins
Version: 4.0.0
Platform: Compiled Sources
OS: Linux
Status: UNCONFIRMED
Severity: normal
Priority: NOR
Component: MediaWiki
Assignee: kde-imaging at kde.org
Reporter: hhclaw.eb at gmail.com
This patch fixes two issues with the loading of metadata for the mediawiki
plugin
Reproducible: Always
Steps to Reproduce:
1. In digikam, select two pictures for export to mediawiki, the first one
(pic1) with geolocation in its metadata, the second one (pic2) without.
2. In the mediawiki export dialog, add one picture (pic3) managed by digikam
into the export list
Actual Results:
1. Both pictures, pic1 and pic2, get the geolocation from pic1. This is
because the loop in WmWidget::loadImageInfoFirstLoad does not clear the lat /
lon data between iterations.
2. Pic3 will not contain the metadata from digiKam, because
WmWidget::loadImageInfoFirstLoad is only called for the initial list of
pictures.
Expected Results:
1. The geolocation for pic2 should remain blank.
2. Metadata for pic3 should be loaded from digikam.
Patch file:
====
diff --git a/mediawiki/wmwidget.cpp b/mediawiki/wmwidget.cpp
index d08c67c..64ccd22 100644
--- a/mediawiki/wmwidget.cpp
+++ b/mediawiki/wmwidget.cpp
@@ -781,56 +781,54 @@ void WmWidget::loadImageInfoFirstLoad()
{
KUrl::List urls = d->imgList->imageUrls(false);
- QString title;
- QString date;
- QString description;
- QString currentCategories;
- QString latitude;
- QString longitude;
-
d->imagesDescInfo.clear();
- for(int j = 0; j < urls.size(); j++)
+ for (int j = 0; j < urls.size(); j++)
{
- KPImageInfo info(urls.at(j).path());
- QStringList keywar = info.keywords();
- date = info.date().toString(Qt::ISODate);
- date = date.replace("T", " ", Qt::CaseSensitive);
- title = info.name();
- description = info.title();
- currentCategories = "";
-
- for( int i = 0; i < keywar.size(); i++)
- {
- if(i == keywar.size()-1)
- {
- currentCategories.append(keywar.at(i));
- }
- else
- {
- currentCategories.append(keywar.at(i)).append("\n");
- }
- }
+ loadImageInfo(urls.at(j));
+ }
+}
- if(info.hasLatitude())
+void WmWidget::loadImageInfo(const KUrl url)
+{
+ KPImageInfo info(url.path());
+ QStringList keywar = info.keywords();
+ QString date = info.date().toString(Qt::ISODate).replace("T", " ",
Qt::CaseSensitive);
+ QString title = info.name();
+ QString description = info.title();
+ QString currentCategories = "";
+ QString latitude = "";
+ QString longitude = "";
+
+ for (int i = 0; i < keywar.size(); i++)
+ {
+ if (i == keywar.size() - 1)
{
- latitude = QString::number(info.latitude(), 'f', 9);
- }
-
- if(info.hasLongitude())
+ currentCategories.append(keywar.at(i));
+ } else
{
- longitude = QString::number(info.longitude(), 'f', 9);
+ currentCategories.append(keywar.at(i)).append("\n");
}
+ }
- QMap<QString, QString> imageMetaData;
- imageMetaData["title"] = title;
- imageMetaData["date"] = date;
- imageMetaData["categories"] = currentCategories;
- imageMetaData["description"] = description;
- imageMetaData["latitude"] = latitude;
- imageMetaData["longitude"] = longitude;
- d->imagesDescInfo.insert(urls.at(j).path(), imageMetaData);
+ if (info.hasLatitude())
+ {
+ latitude = QString::number(info.latitude(), 'f', 9);
+ }
+
+ if (info.hasLongitude())
+ {
+ longitude = QString::number(info.longitude(), 'f', 9);
}
+
+ QMap<QString, QString> imageMetaData;
+ imageMetaData["title"] = title;
+ imageMetaData["date"] = date;
+ imageMetaData["categories"] = currentCategories;
+ imageMetaData["description"] = description;
+ imageMetaData["latitude"] = latitude;
+ imageMetaData["longitude"] = longitude;
+ d->imagesDescInfo.insert(url.path(), imageMetaData);
}
void WmWidget::clearEditFields()
@@ -847,8 +845,14 @@ void WmWidget::slotLoadImagesDesc(QTreeWidgetItem* item)
{
QList<QTreeWidgetItem*> selectedItems =
d->imgList->listView()->selectedItems();
KPImagesListViewItem* l_item =
dynamic_cast<KPImagesListViewItem*>(item);
- QMap<QString, QString> imageMetaData =
d->imagesDescInfo[l_item->url().path()];
-
+ QMap<QString, QString> imageMetaData;
+
+ if (!d->imagesDescInfo.contains(l_item->url().path()))
+ {
+ loadImageInfo(l_item->url());
+ }
+ imageMetaData = d->imagesDescInfo[l_item->url().path()];
+
d->titleEdit->setText(imageMetaData["title"]);
d->dateEdit->setText(imageMetaData["date"].replace("T", " ",
Qt::CaseSensitive));
d->latitudeEdit->setText(imageMetaData["latitude"]);
diff --git a/mediawiki/wmwidget.h b/mediawiki/wmwidget.h
index c2f971d..f623651 100644
--- a/mediawiki/wmwidget.h
+++ b/mediawiki/wmwidget.h
@@ -96,6 +96,7 @@ public:
void readSettings(KConfigGroup& group);
void saveSettings(KConfigGroup& group);
void loadImageInfoFirstLoad();
+ void loadImageInfo(const KUrl url);
void clearEditFields();
Q_SIGNALS:
====
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the Kde-imaging
mailing list