[Digikam-devel] extragear/libs/kipi-plugins/gpssync
Caulier Gilles
caulier.gilles at kdemail.net
Tue Oct 24 19:21:53 BST 2006
Le Mardi 24 Octobre 2006 20:09, Achim Bohnet a écrit :
> On Tuesday 24 October 2006 10:00, Gilles Caulier wrote:
> > SVN commit 598625 by cgilles:
> >
> > kipiplugins from trunk : GPSSync plugin:
> >
> > plugin now provides 3 sub-menu entries (instead just one) :
> >
> > - Start GPS device correlator using current pictures selection.
> > - Start Geographical Coordinates editor to tag current pictures
> > selection. - Remove Geographical Coordinates from current pictures
> > selection
> >
> > CCBUGS: 135451
> > CCMAIL: kde-imaging at kde.org, digikam-devel at kde.org
> >
> >
> > M +6 -3 gpseditdialog.cpp
> > M +140 -14 plugin_gpssync.cpp
> > M +5 -3 plugin_gpssync.h
> >
> >
> > --- trunk/extragear/libs/kipi-plugins/gpssync/gpseditdialog.cpp
> > #598624:598625 @@ -196,21 +196,24 @@
> > d->altitudeInput->text().toDouble(&ok);
> > if (!ok)
> > {
> > - KMessageBox::error(this, i18n("Altitude value is not correct!"),
> > i18n("GPS Sync")); + KMessageBox::error(this, i18n("Altitude value
> > is not correct!"), + i18n("Edit Geographical
> > Coordinates"));
>
> Hi Gilles,
>
> have a look at revision 598475. Kde-i18n guy did a lot of s/!/./ in
> i18n() strings. Commit comment: Don't shout.
>
> Looks like '!' should be reserved for really dangerous error.
>
> Achim
ok, i will fix it
Gilles
>
> > return;
> > }
> >
> > d->latitudeInput->text().toDouble(&ok);
> > if (!ok)
> > {
> > - KMessageBox::error(this, i18n("Latitude value is not correct!"),
> > i18n("GPS Sync")); + KMessageBox::error(this, i18n("Latitude value
> > is not correct!"), + i18n("Edit Geographical
> > Coordinates")); return;
> > }
> >
> > d->longitudeInput->text().toDouble(&ok);
> > if (!ok)
> > {
> > - KMessageBox::error(this, i18n("Longitude value is not
> > correct!"), i18n("GPS Sync")); + KMessageBox::error(this,
> > i18n("Longitude value is not correct!"), +
> > i18n("Edit Geographical Coordinates")); return;
> > }
> >
> > --- trunk/extragear/libs/kipi-plugins/gpssync/plugin_gpssync.cpp
> > #598624:598625 @@ -19,6 +19,10 @@
> > *
> > * ============================================================ */
> >
> > +// Qt includes.
> > +
> > +#include <qfileinfo.h>
> > +
> > // KDE includes.
> >
> > #include <klocale.h>
> > @@ -36,7 +40,10 @@
> >
> > // Local includes.
> >
> > +#include "exiv2iface.h"
> > #include "gpsbabelbinary.h"
> > +#include "gpsdatacontainer.h"
> > +#include "gpseditdialog.h"
> > #include "gpssyncdialog.h"
> > #include "plugin_gpssync.h"
> > #include "plugin_gpssync.moc"
> > @@ -55,18 +62,37 @@
> > {
> > KIPI::Plugin::setup( widget );
> >
> > - // this is our action shown in the menubar/toolbar of the mainwindow
> > + m_action_geolocalization = new KActionMenu(i18n("Geolocalization"),
> > + 0,
> > + actionCollection(),
> > + "geolocalization");
> >
> > - m_actionGPSSync = new KAction (i18n("Geolocalization..."),
> > - "gpsimagetag",
> > - 0,
> > - this,
> > - SLOT(slotActivate()),
> > - actionCollection(),
> > - "gpssync");
> > + m_action_geolocalization->insert(new KAction (i18n("Correlator..."),
> > + "gpsimagetag",
> > + 0,
> > + this,
> > + SLOT(slotGPSSync()),
> > + actionCollection(),
> > + "gpssync"));
> >
> > - addAction( m_actionGPSSync );
> > + m_action_geolocalization->insert(new KAction (i18n("Edit
> > coordinates..."), + 0,
> > + 0,
> > + this,
> > + SLOT(slotGPSEdit()),
> > + actionCollection(),
> > + "gpsedit"));
> >
> > + m_action_geolocalization->insert(new KAction (i18n("Remove
> > coordinates..."), + 0,
> > + 0,
> > + this,
> > + SLOT(slotGPSRemove()),
> > + actionCollection(),
> > + "gpsremove"));
> > +
> > + addAction( m_action_geolocalization );
> > +
> > m_interface = dynamic_cast< KIPI::Interface* >( parent() );
> >
> > if ( !m_interface )
> > @@ -76,10 +102,10 @@
> > }
> >
> > KIPI::ImageCollection selection = m_interface->currentSelection();
> > - m_actionGPSSync->setEnabled( selection.isValid() &&
> > !selection.images().isEmpty() ); +
> > m_action_geolocalization->setEnabled( selection.isValid() &&
> > !selection.images().isEmpty() );
> >
> > connect( m_interface, SIGNAL(selectionChanged(bool)),
> > - m_actionGPSSync, SLOT(setEnabled(bool)));
> > + m_action_geolocalization, SLOT(setEnabled(bool)));
> > }
> >
> > bool Plugin_GPSSync::checkBinaries(QString &gpsBabelVersion)
> > @@ -127,9 +153,8 @@
> > return true;
> > }
> >
> > -void Plugin_GPSSync::slotActivate()
> > +void Plugin_GPSSync::slotGPSSync()
> > {
> > - // Get the current/selected album from host
> > KIPI::ImageCollection images = m_interface->currentSelection();
> >
> > if ( !images.isValid() || images.images().isEmpty() )
> > @@ -147,9 +172,110 @@
> > dialog->show();
> > }
> >
> > +void Plugin_GPSSync::slotGPSEdit()
> > +{
> > + KIPI::ImageCollection images = m_interface->currentSelection();
> > +
> > + if ( !images.isValid() || images.images().isEmpty() )
> > + return;
> > +
> > + KURL img = images.images().first();
> > + KIPIPlugins::Exiv2Iface exiv2Iface;
> > + exiv2Iface.load(img.path());
> > + double alt, lat, lng;
> > + bool hasGPSInfo = exiv2Iface.getGPSInfo(alt, lat, lng);
> > + KIPIGPSSyncPlugin::GPSDataContainer gpsData(alt, lat, lng, false);
> > +
> > + KIPIGPSSyncPlugin::GPSEditDialog dlg(kapp->activeWindow(),
> > + gpsData, img.fileName(),
> > hasGPSInfo); +
> > + if (dlg.exec() == KDialogBase::Accepted)
> > + {
> > + gpsData = dlg.getGPSInfo();
> > + KURL::List imageURLs = images.images();
> > + KURL::List errorURLs;
> > +
> > + for( KURL::List::iterator it = imageURLs.begin() ;
> > + it != imageURLs.end(); ++it)
> > + {
> > + KURL url = *it;
> > +
> > + // 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.extension(false).upper();
> > + if (ext == QString("JPG") || ext == QString("JPEG") || ext
> > == QString("JPE")) + {
> > + if (exiv2Iface.load(url.path()))
> > + {
> > + bool ret = exiv2Iface.setGPSInfo(gpsData.altitude(),
> > + gpsData.latitude(),
> > +
> > gpsData.longitude()); + ret &=
> > exiv2Iface.save(url.path());
> > +
> > + if (!ret)
> > + errorURLs.append(url);
> > + }
> > + }
> > + }
> > +
> > + if (!errorURLs.isEmpty())
> > + {
> > + KMessageBox::errorList(
> > + kapp->activeWindow(),
> > + i18n("Unable to save geographical coordinates
> > to:"), + errorURLs.toStringList(),
> > + i18n("Edit Geographical Coordinates"));
> > + }
> > + }
> > +}
> > +
> > +void Plugin_GPSSync::slotGPSRemove()
> > +{
> > + KIPI::ImageCollection images = m_interface->currentSelection();
> > +
> > + if ( !images.isValid() || images.images().isEmpty() )
> > + return;
> > +
> > + KURL::List imageURLs = images.images();
> > + KURL::List errorURLs;
> > +
> > + for( KURL::List::iterator it = imageURLs.begin() ;
> > + it != imageURLs.end(); ++it)
> > + {
> > + KURL url = *it;
> > +
> > + // 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.extension(false).upper();
> > + if (ext == QString("JPG") || ext == QString("JPEG") || ext ==
> > QString("JPE")) + {
> > + KIPIPlugins::Exiv2Iface exiv2Iface;
> > + exiv2Iface.load(url.path());
> > + bool ret = exiv2Iface.removeGPSInfo();
> > + ret &= exiv2Iface.save(url.path());
> > +
> > + if (!ret)
> > + errorURLs.append(url);
> > + }
> > + }
> > +
> > + if (!errorURLs.isEmpty())
> > + {
> > + KMessageBox::errorList(
> > + kapp->activeWindow(),
> > + i18n("Unable to remove geographical coordinates
> > from:"), + errorURLs.toStringList(),
> > + i18n("Remove Geographical Coordinates"));
> > + }
> > +}
> > +
> > KIPI::Category Plugin_GPSSync::category( KAction* action ) const
> > {
> > - if ( action == m_actionGPSSync )
> > + if ( action == m_action_geolocalization )
> > return KIPI::IMAGESPLUGIN;
> >
> > kdWarning( 51000 ) << "Unrecognized action for plugin category
> > identification" << endl; ---
> > trunk/extragear/libs/kipi-plugins/gpssync/plugin_gpssync.h #598624:598625
> > @@ -26,7 +26,7 @@
> >
> > #include <libkipi/plugin.h>
> >
> > -class KAction;
> > +class KActionMenu;
> >
> > class Plugin_GPSSync : public KIPI::Plugin
> > {
> > @@ -41,7 +41,9 @@
> >
> > protected slots:
> >
> > - void slotActivate();
> > + void slotGPSSync();
> > + void slotGPSEdit();
> > + void slotGPSRemove();
> >
> > private:
> >
> > @@ -49,7 +51,7 @@
> >
> > private:
> >
> > - KAction *m_actionGPSSync;
> > + KActionMenu *m_action_geolocalization;
> >
> > KIPI::Interface *m_interface;
> > };
> > _______________________________________________
> > Digikam-devel mailing list
> > Digikam-devel at kde.org
> > https://mail.kde.org/mailman/listinfo/digikam-devel
More information about the Digikam-devel
mailing list