SVN commit 772640 by cgilles:
kipi-plugins from trunk (KDE4) : digiKam has a new tool to edit a GPS track list using googlemaps ! More than one point can be edited over the ma at the same time... A fresh screenshot of the tool in action is available here : http://digikam3rdparty.free.fr/Screenshots/gpstracklisteditor.png BUG: 135451 BUG: 135386 CCMAIL: [hidden email] CCMAIL: [hidden email] M +7 -2 gpstracklistcontainer.h M +19 -7 gpstracklisteditdialog.cpp M +2 -0 gpstracklisteditdialog.h M +2 -10 gpstracklistviewitem.cpp M +1 -1 gpstracklistwidget.cpp M +51 -2 plugin_gpssync.cpp --- trunk/extragear/libs/kipi-plugins/gpssync/gpstracklistcontainer.h #772639:772640 @@ -44,11 +44,11 @@ { public: - GPSTrackListItem(): m_id(0), m_url(KUrl()), m_gpsData(GPSDataContainer()) + GPSTrackListItem(): m_dirty(false), m_id(0), m_url(KUrl()), m_gpsData(GPSDataContainer()) {}; GPSTrackListItem(const KUrl& url, const GPSDataContainer gpsData) - : m_id(0), m_url(url), m_gpsData(gpsData) + : m_dirty(false), m_id(0), m_url(url), m_gpsData(gpsData) {}; ~GPSTrackListItem() @@ -56,16 +56,19 @@ GPSTrackListItem& operator=(const GPSTrackListItem& data) { + m_dirty = data.isDirty(); m_id = data.id(); m_url = data.url(); m_gpsData = data.gpsData(); return *this; }; + void setDirty(bool dirty) { m_dirty = dirty; }; void setId(int id) { m_id = id; }; void setUrl(const KUrl& url) { m_url = url; }; void setGPSData(const GPSDataContainer& gpsData) { m_gpsData = gpsData; }; + int isDirty() const { return m_dirty; }; int id() const { return m_id; }; KUrl url() const { return m_url; }; QString fileName() const { return m_url.fileName(); }; @@ -73,6 +76,8 @@ private: + bool m_dirty; + int m_id; KUrl m_url; --- trunk/extragear/libs/kipi-plugins/gpssync/gpstracklisteditdialog.cpp #772639:772640 @@ -116,7 +116,7 @@ // --------------------------------------------------------------- vlay->addWidget(d->worldMap->view(), 10); - vlay->addWidget(d->listView, 3); + vlay->addWidget(d->listView, 4); vlay->setSpacing(spacingHint()); vlay->setMargin(0); @@ -172,6 +172,12 @@ QTimer::singleShot(0, this, SLOT(slotUpdateWorldMap())); } +GPSTrackListEditDialog::~GPSTrackListEditDialog() +{ + delete d->about; + delete d; +} + void GPSTrackListEditDialog::slotThumbnail(const KUrl& url, const QPixmap& pix) { Q3ListViewItemIterator it(d->listView); @@ -187,15 +193,14 @@ } } -GPSTrackListEditDialog::~GPSTrackListEditDialog() +void GPSTrackListEditDialog::slotHelp() { - delete d->about; - delete d; + KToolInvocation::invokeHelp("gpssync", "kipi-plugins"); } -void GPSTrackListEditDialog::slotHelp() +GPSTrackList GPSTrackListEditDialog::trackList() const { - KToolInvocation::invokeHelp("gpssync", "kipi-plugins"); + return d->gpsTrackList; } void GPSTrackListEditDialog::closeEvent(QCloseEvent *e) @@ -269,11 +274,18 @@ data.setLatitude(lat); data.setLongitude(lng); info.setGPSData(data); + info.setDirty(true); item->setData(item->dateTime(), info); - item->setDirty(true); + + // Update track list info. + d->gpsTrackList.remove(item->dateTime()); + d->gpsTrackList.insert(item->dateTime(), info); + + // Refresh item in list view d->listView->repaintItem(item); d->listView->setCurrentItem(item); d->listView->ensureItemVisible(item); + kDebug() << id << "::" << lat << "::" << lng << endl; return; } --- trunk/extragear/libs/kipi-plugins/gpssync/gpstracklisteditdialog.h #772639:772640 @@ -48,6 +48,8 @@ GPSTrackListEditDialog(KIPI::Interface *interface, QWidget *parent, const GPSTrackList& gpsTrackList); ~GPSTrackListEditDialog(); + + GPSTrackList trackList() const; protected slots: --- trunk/extragear/libs/kipi-plugins/gpssync/gpstracklistviewitem.cpp #772639:772640 @@ -44,11 +44,8 @@ GPSTrackListViewItemPriv() { - dirty = false; } - bool dirty; - QDateTime dateTime; GPSTrackListItem data; @@ -66,15 +63,9 @@ delete d; } -void GPSTrackListViewItem::setDirty(bool dirty) -{ - d->dirty = dirty; - setText(7, d->dirty ? i18n("Yes") : i18n("No")); -} - bool GPSTrackListViewItem::isDirty() const { - return d->dirty; + return d->data.isDirty(); } void GPSTrackListViewItem::setData(const QDateTime& dt, const GPSTrackListItem& data) @@ -87,6 +78,7 @@ setText(4, QString::number(d->data.gpsData().latitude(), 'g', 12)); setText(5, QString::number(d->data.gpsData().longitude(), 'g', 12)); setText(6, QString::number(d->data.gpsData().altitude(), 'g', 12)); + setText(7, isDirty() ? i18n("Yes") : i18n("No")); } GPSTrackListItem GPSTrackListViewItem::gpsInfo() const --- trunk/extragear/libs/kipi-plugins/gpssync/gpstracklistwidget.cpp #772639:772640 @@ -110,7 +110,7 @@ QString latTxt = status.section(",", 1, 1); latTxt.remove(0, 5); QString lngTxt = status.section(",", 2, 2); - lngTxt.remove(0, 6); + lngTxt.remove(0, 5); int id = idTxt.toInt(); double lat = latTxt.toDouble(); double lng = lngTxt.toDouble(); --- trunk/extragear/libs/kipi-plugins/gpssync/plugin_gpssync.cpp #772639:772640 @@ -269,13 +269,13 @@ double alt, lat, lng; QDateTime dt; + KExiv2Iface::KExiv2 exiv2Iface; KIPIGPSSyncPlugin::GPSTrackList trackList; KUrl::List urls = images.images(); for( KUrl::List::iterator it = urls.begin() ; it != urls.end() ; ++it) { - KExiv2Iface::KExiv2 exiv2Iface; exiv2Iface.load((*it).path()); if(exiv2Iface.getGPSInfo(alt, lat, lng)) { @@ -299,7 +299,56 @@ if (dlg.exec() == KDialog::Accepted) { - // TODO + trackList = dlg.trackList(); + KUrl::List updatedURLs; + QStringList errorFiles; + + for( KIPIGPSSyncPlugin::GPSTrackList::iterator it = trackList.begin() ; + it != trackList.end() ; ++it) + { + if ((*it).isDirty()) + { + KUrl url = (*it).url(); + + // We only add all JPEG files as R/W because Exiv2 can't yet + // update metadata on others file formats. + + QFileInfo fi(url.path()); + QString ext = fi.suffix().toUpper(); + bool ret = false; + if (ext == QString("JPG") || ext == QString("JPEG") || ext == QString("JPE")) + { + ret = true; + ret &= exiv2Iface.load(url.path()); + if (ret) + { + ret &= exiv2Iface.setGPSInfo((*it).gpsData().altitude(), + (*it).gpsData().latitude(), + (*it).gpsData().longitude()); + ret &= exiv2Iface.save(url.path()); + } + } + + if (!ret) + errorFiles.append(url.fileName()); + else + updatedURLs.append(url); + } + } + + // We use kipi interface refreshImages() method to tell to host than + // metadata from pictures have changed and need to be re-readed. + + m_interface->refreshImages(updatedURLs); + + if (!errorFiles.isEmpty()) + { + KMessageBox::errorList( + kapp->activeWindow(), + i18n("Unable to save geographical coordinates into:"), + errorFiles, + i18n("Edit Geographical Coordinates")); + } } } _______________________________________________ Digikam-devel mailing list [hidden email] https://mail.kde.org/mailman/listinfo/digikam-devel |
Free forum by Nabble | Edit this page |