summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Caulier <[email protected]>2015-11-07 11:42:04 +0059
committerGilles Caulier <[email protected]>2015-11-07 11:42:04 +0059
commit5af4937fbfb1e2b9a3218cb35875076261e5ec38 (patch)
treee932e02eef48c8752ed0e23391c87cfd33e86cce
parent6f24d3dc712d4313900656b27319cf238779ca00 (diff)
add new MetadataProcessor implementation based on libkexiv2 for tests code.
dependency is optional : - permit to test kipi-plugins as stand alone with Metadata Processing support - give a example of implementation to use in kipi interface from host application
-rw-r--r--README1
-rw-r--r--src/interface.h2
-rw-r--r--tests/CMakeLists.txt20
-rw-r--r--tests/common/kipiinterface.cpp276
4 files changed, 294 insertions, 5 deletions
diff --git a/README b/README
index 12f5e9e..1dfc274 100644
--- a/README
+++ b/README
@@ -23,6 +23,7 @@ libkde >= 5.0.0 http://www.kde.org
Optionals (for tests implementations):
libkdcraw >= 5.0.0 https://projects.kde.org/projects/kde/kdegraphics/libs/libkdcraw
+libkexiv2 >= 5.0.0 https://projects.kde.org/projects/kde/kdegraphics/libs/libkexiv2
-- INSTALL ------------------------------------------------------------
diff --git a/src/interface.h b/src/interface.h
index 98ed10c..5337481 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -199,7 +199,7 @@ public:
/**
* A Kipi MetadataProcessor refers to application-wide to process file metadata
* about Exif/Iptc/Xmp management; it is created with Interface::createMetadataProcessor().
- * You can use libkexiv2 to re-implement this class.
+ * You can use libkexiv2 to re-implement this class as it's implemented in tests/common/kipiinterface.cpp.
*/
class LIBKIPI_EXPORT MetadataProcessor : public QObject
{
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 0c3a500..e3ee191 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -9,10 +9,20 @@ if (POLICY CMP0063)
endif (POLICY CMP0063)
find_package(KF5KDcraw 5.0.0)
+find_package(KF5KExiv2 5.0.0)
if(KF5KDcraw_FOUND)
- message(STATUS "libkdcraw detected : test Kipi interface will support Raw decoding")
+ message(STATUS "libkdcraw detected : test Kipi interface will support Raw processing")
add_definitions(-DHAVE_KDCRAW)
+else()
+ message(STATUS "libkdcraw not detected : test Kipi interface will not support Raw processing")
+endif()
+
+if(KF5KExiv2_FOUND)
+ message(STATUS "libkexiv2 detected : test Kipi interface will support Metadata processing")
+ add_definitions(-DHAVE_KDEXIV2)
+else()
+ message(STATUS "libkdkexiv2 not detected : test Kipi interface will not support Metadata processing")
endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR}/..
@@ -50,6 +60,10 @@ if(KF5KDcraw_FOUND)
target_link_libraries(kxmlkipicmd KF5::KDcraw)
endif()
+if(KF5KExiv2_FOUND)
+ target_link_libraries(kxmlkipicmd KF5::KExiv2)
+endif()
+
install(TARGETS kxmlkipicmd DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES kxmlkipicmd/kxmlkipicmd_defaultui.rc DESTINATION ${DATA_INSTALL_DIR}/kxmlkipicmd)
install(FILES kxmlkipicmd/kxmlkipicmd_gwenviewui.rc DESTINATION ${DATA_INSTALL_DIR}/kxmlkipicmd)
@@ -76,3 +90,7 @@ target_link_libraries(kipicmd
if(KF5KDcraw_FOUND)
target_link_libraries(kipicmd KF5::KDcraw)
endif()
+
+if(KF5KExiv2_FOUND)
+ target_link_libraries(kipicmd KF5::KExiv2)
+endif()
diff --git a/tests/common/kipiinterface.cpp b/tests/common/kipiinterface.cpp
index cbf4b98..7f9e2f3 100644
--- a/tests/common/kipiinterface.cpp
+++ b/tests/common/kipiinterface.cpp
@@ -44,6 +44,10 @@
# include <kdcraw/kdcraw.h>
#endif
+#ifdef HAVE_KEXIV2
+# include <kexiv2/kexiv2.h>
+#endif
+
// local includes
#include "kipiimageinfoshared.h"
@@ -146,6 +150,10 @@ int KipiInterface::features() const
#ifdef HAVE_KDCRAW
| HostSupportsRawProcessing
#endif
+#ifdef HAVE_KEXIV2
+ | HostSupportsMetadataProcessing
+#endif
+
;
}
@@ -227,7 +235,7 @@ class KipiRawProcessor : public RawProcessor
public:
KipiRawProcessor() {};
- virtual ~KipiRawProcessor() {};
+ ~KipiRawProcessor() {};
bool loadRawPreview(const QUrl& url, QImage& image)
{
@@ -272,7 +280,7 @@ RawProcessor* KipiInterface::createRawProcessor() const
RawProcessor* KipiInterface::createRawProcessor() const
{
- qDebug() << "This interface was not compiled with libkdcraw to support Raw Decoding";
+ qDebug() << "This interface was not compiled with libkdcraw to support Raw processing";
return 0;
}
@@ -280,11 +288,273 @@ RawProcessor* KipiInterface::createRawProcessor() const
// ---------------------------------------------------------------------------------------
+#ifdef HAVE_KEXIV2
+
+class KipiMetadataProcessor : public KIPI::MetadataProcessor
+{
+public:
+
+ KipiMetadataProcessor() {};
+ ~KipiMetadataProcessor() {};
+
+ bool load(const QUrl& url)
+ {
+ return m_meta.load(url.toLocalFile());
+ }
+
+ bool save(const QUrl& url, bool writeToFileOnly)
+ {
+ if (writeToFileOnly)
+ m_meta.setMetadataWritingMode((int)DMetadata::WRITETOIMAGEONLY);
+
+ return m_meta.save(url.toLocalFile());
+ }
+
+ bool applyChanges()
+ {
+ return m_meta.applyChanges();
+ }
+
+ QSize getPixelSize()
+ {
+ return m_meta.getPixelSize();
+ }
+
+ bool setImageProgramId(const QString& program, const QString& version)
+ {
+ return m_meta.setImageProgramId(program, version);
+ }
+
+ QSize getImageDimensions()
+ {
+ return m_meta.getImageDimensions();
+ }
+
+ bool setImageDimensions(const QSize& size)
+ {
+ return m_meta.setImageDimensions(size);
+ }
+
+ int getImageOrientation()
+ {
+ return m_meta.getImageOrientation();
+ }
+
+ bool setImageOrientation(int orientation)
+ {
+ return m_meta.setImageOrientation((DMetadata::ImageOrientation)orientation);
+ }
+
+ bool rotateExifQImage(QImage& img, int orientation)
+ {
+ return m_meta.rotateExifQImage(img, (DMetadata::ImageOrientation)orientation);
+ }
+
+ QDateTime getImageDateTime()
+ {
+ return m_meta.getImageDateTime();
+ }
+
+ bool setImageDateTime(const QDateTime& dt)
+ {
+ return m_meta.setImageDateTime(dt);
+ }
+
+ bool getImagePreview(QImage& img)
+ {
+ return m_meta.getImagePreview(img);
+ }
+
+ bool setImagePreview(const QImage& img)
+ {
+ return m_meta.setImagePreview(img);
+ }
+
+ bool hasExif()
+ {
+ return m_meta.hasExif();
+ }
+
+ bool hasIptc()
+ {
+ return m_meta.hasIptc();
+ }
+
+ bool hasXmp()
+ {
+ return m_meta.hasXmp();
+ }
+
+ QByteArray getExif()
+ {
+ return m_meta.getExifEncoded();
+ }
+
+ QByteArray getIptc()
+ {
+ return m_meta.getIptc();
+ }
+
+ QByteArray getXmp()
+ {
+ return m_meta.getXmp();
+ }
+
+ bool setExif(const QByteArray& data)
+ {
+ return m_meta.setExif(data);
+ }
+
+ bool setIptc(const QByteArray& data)
+ {
+ return m_meta.setIptc(data);
+ }
+
+ bool setXmp(const QByteArray& data)
+ {
+ return m_meta.setXmp(data);
+ }
+
+ bool registerXmpNameSpace(const QString& uri, const QString& prefix)
+ {
+ return m_meta.registerXmpNameSpace(uri, prefix);
+ }
+
+ bool supportXmp()
+ {
+ return m_meta.supportXmp();
+ }
+
+ bool canWriteXmp(const QUrl& url)
+ {
+ return m_meta.canWriteXmp(url.toLocalFile());
+ }
+
+ bool removeExifTags(const QStringList& tagFilters)
+ {
+ DMetadata::MetaDataMap m = m_meta.getExifTagsDataList(tagFilters);
+
+ if (m.isEmpty())
+ return false;
+
+ for (DMetadata::MetaDataMap::iterator it = m.begin(); it != m.end(); ++it)
+ {
+ m_meta.removeExifTag(it.key().toLatin1().constData());
+ }
+
+ return true;
+ }
+
+ bool removeIptcTags(const QStringList& tagFilters)
+ {
+ DMetadata::MetaDataMap m = m_meta.getIptcTagsDataList(tagFilters);
+
+ if (m.isEmpty())
+ return false;
+
+ for (DMetadata::MetaDataMap::iterator it = m.begin(); it != m.end(); ++it)
+ {
+ m_meta.removeIptcTag(it.key().toLatin1().constData());
+ }
+
+ return true;
+ }
+
+ bool removeXmpTags(const QStringList& tagFilters)
+ {
+ DMetadata::MetaDataMap m = m_meta.getXmpTagsDataList(tagFilters);
+
+ if (m.isEmpty())
+ return false;
+
+ for (DMetadata::MetaDataMap::iterator it = m.begin(); it != m.end(); ++it)
+ {
+ m_meta.removeXmpTag(it.key().toLatin1().constData());
+ }
+
+ return true;
+ }
+
+ bool getGPSInfo(double& alt, double& lat, double& lon)
+ {
+ return m_meta.getGPSInfo(alt, lat, lon);
+ }
+
+ bool setGPSInfo(const double alt, const double lat, const double lon)
+ {
+ return m_meta.setGPSInfo(alt, lat, lon);
+ }
+
+ bool removeGPSInfo()
+ {
+ return m_meta.removeGPSInfo();
+ }
+
+ QString getExifTagString(const QString& tag)
+ {
+ return m_meta.getExifTagString(tag.toLatin1().constData());
+ }
+
+ bool setExifTagString(const QString& tag, const QString& val)
+ {
+ return m_meta.setExifTagString(tag.toLatin1().constData(), val);
+ }
+
+ bool getExifTagRational(const QString& tag, long int& num, long int& den)
+ {
+ return m_meta.getExifTagRational(tag.toLatin1().constData(), num, den);
+ }
+
+ bool setExifTagRational(const QString& tag, long int num, long int den)
+ {
+ return m_meta.setExifTagRational(tag.toLatin1().constData(), num, den);
+ }
+
+ QString getXmpTagString(const QString& tag)
+ {
+ return m_meta.getXmpTagString(tag.toLatin1().constData());
+ }
+
+ bool setXmpTagString(const QString& tag, const QString& val)
+ {
+ return m_meta.setXmpTagString(tag.toLatin1().constData(), val);
+ }
+
+ QStringList getXmpKeywords()
+ {
+ return m_meta.getXmpKeywords();
+ }
+
+ bool setXmpKeywords(const QStringList& keywords)
+ {
+ return m_meta.setXmpKeywords(keywords);
+ }
+
+ QVariant getXmpTagVariant(const QString& tag)
+ {
+ return m_meta.getXmpTagVariant(tag.toLatin1().constData());
+ }
+
+private:
+
+ KExiv2Iface::KExiv2 m_meta;
+};
+
MetadataProcessor* KipiInterface::createMetadataProcessor() const
{
- return 0; // TODO
+ return (new KipiMetadataProcessor);
+}
+
+#else // HAVE_KEXIV2
+
+MetadataProcessor* KipiInterface::createMetadataProcessor() const
+{
+ qDebug() << "This interface was not compiled with libkexiv2 to support Metadata processing";
+ return 0;
}
+#endif // HAVE_KEXIV2
+
// ---------------------------------------------------------------------------------------
FileReadWriteLock* KipiInterface::createReadWriteLock(const QUrl&) const