summaryrefslogtreecommitdiffstats
path: root/src/libs/widgets/metadata
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2024-11-22 18:41:30 +0900
committerMichele Calgaro <[email protected]>2024-11-22 18:41:30 +0900
commitee0d99607c14cb63d3ebdb3a970b508949fa8219 (patch)
tree94ac1efedb94cb38bf6879ba0610fe75b554216b /src/libs/widgets/metadata
parent4adff739380e4ae9f30e443ee95644f184456869 (diff)
downloaddigikam-ee0d99607c14cb63d3ebdb3a970b508949fa8219.tar.gz
digikam-ee0d99607c14cb63d3ebdb3a970b508949fa8219.zip
Rename 'digikam' folder to 'src'
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'src/libs/widgets/metadata')
-rw-r--r--src/libs/widgets/metadata/Makefile.am17
-rw-r--r--src/libs/widgets/metadata/exifwidget.cpp185
-rw-r--r--src/libs/widgets/metadata/exifwidget.h73
-rw-r--r--src/libs/widgets/metadata/gpswidget.cpp340
-rw-r--r--src/libs/widgets/metadata/gpswidget.h95
-rw-r--r--src/libs/widgets/metadata/iptcwidget.cpp167
-rw-r--r--src/libs/widgets/metadata/iptcwidget.h69
-rw-r--r--src/libs/widgets/metadata/makernotewidget.cpp210
-rw-r--r--src/libs/widgets/metadata/makernotewidget.h70
-rw-r--r--src/libs/widgets/metadata/mdkeylistviewitem.cpp94
-rw-r--r--src/libs/widgets/metadata/mdkeylistviewitem.h63
-rw-r--r--src/libs/widgets/metadata/metadatalistview.cpp283
-rw-r--r--src/libs/widgets/metadata/metadatalistview.h85
-rw-r--r--src/libs/widgets/metadata/metadatalistviewitem.cpp75
-rw-r--r--src/libs/widgets/metadata/metadatalistviewitem.h59
-rw-r--r--src/libs/widgets/metadata/metadatawidget.cpp454
-rw-r--r--src/libs/widgets/metadata/metadatawidget.h120
-rw-r--r--src/libs/widgets/metadata/worldmapwidget.cpp211
-rw-r--r--src/libs/widgets/metadata/worldmapwidget.h73
19 files changed, 2743 insertions, 0 deletions
diff --git a/src/libs/widgets/metadata/Makefile.am b/src/libs/widgets/metadata/Makefile.am
new file mode 100644
index 00000000..4fe62356
--- /dev/null
+++ b/src/libs/widgets/metadata/Makefile.am
@@ -0,0 +1,17 @@
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libmetadatawidgets.la
+
+libmetadatawidgets_la_SOURCES = metadatalistview.cpp metadatalistviewitem.cpp metadatawidget.cpp \
+ iptcwidget.cpp exifwidget.cpp mdkeylistviewitem.cpp \
+ makernotewidget.cpp gpswidget.cpp worldmapwidget.cpp
+
+libmetadatawidgets_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_TQT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor
+
+INCLUDES = -I$(top_srcdir)/src/libs/dmetadata \
+ -I$(top_srcdir)/src/libs/dimg \
+ -I$(top_srcdir)/src/libs/themeengine \
+ -I$(top_srcdir)/src/libs/widgets/common \
+ -I$(top_srcdir)/src/digikam \
+ $(LIBKEXIV2_CFLAGS) $(LIBKDCRAW_CFLAGS) \
+ $(all_includes)
diff --git a/src/libs/widgets/metadata/exifwidget.cpp b/src/libs/widgets/metadata/exifwidget.cpp
new file mode 100644
index 00000000..7761c250
--- /dev/null
+++ b/src/libs/widgets/metadata/exifwidget.cpp
@@ -0,0 +1,185 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-20
+ * Description : a widget to display Standard Exif metadata
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// TQt includes.
+
+#include <tqmap.h>
+#include <tqfile.h>
+
+// KDE includes.
+
+#include <tdelocale.h>
+
+// Local includes.
+
+#include "ddebug.h"
+#include "dmetadata.h"
+#include "metadatalistview.h"
+#include "exifwidget.h"
+#include "exifwidget.moc"
+
+namespace Digikam
+{
+
+static const char* ExifHumanList[] =
+{
+ "Make",
+ "Model",
+ "DateTime",
+ "ImageDescription",
+ "Copyright",
+ "ShutterSpeedValue",
+ "ApertureValue",
+ "ExposureProgram",
+ "ExposureMode",
+ "ExposureBiasValue",
+ "ExposureTime",
+ "WhiteBalance",
+ "ISOSpeedRatings",
+ "FocalLength",
+ "SubjectDistance",
+ "MeteringMode",
+ "Contrast",
+ "Saturation",
+ "Sharpness",
+ "LightSource",
+ "Flash",
+ "FNumber",
+ "-1"
+};
+
+// Standard Exif Entry list from to less important to the most important for photograph.
+// This will not including GPS information because they are displayed on another tab.
+static const char* StandardExifEntryList[] =
+{
+ "Iop",
+ "Thumbnail",
+ "SubImage1",
+ "SubImage2",
+ "Image",
+ "Photo",
+ "-1"
+};
+
+ExifWidget::ExifWidget(TQWidget* parent, const char* name)
+ : MetadataWidget(parent, name)
+{
+ view()->setSortColumn(-1);
+
+ for (int i=0 ; TQString(StandardExifEntryList[i]) != TQString("-1") ; i++)
+ m_keysFilter << StandardExifEntryList[i];
+
+ for (int i=0 ; TQString(ExifHumanList[i]) != TQString("-1") ; i++)
+ m_tagsfilter << ExifHumanList[i];
+}
+
+ExifWidget::~ExifWidget()
+{
+}
+
+TQString ExifWidget::getMetadataTitle()
+{
+ return i18n("Standard EXIF Tags");
+}
+
+bool ExifWidget::loadFromURL(const KURL& url)
+{
+ setFileName(url.path());
+
+ if (url.isEmpty())
+ {
+ setMetadata();
+ return false;
+ }
+ else
+ {
+ DMetadata metadata(url.path());
+ TQByteArray exifData = metadata.getExif();
+
+ if (exifData.isEmpty())
+ {
+ setMetadata();
+ return false;
+ }
+ else
+ setMetadata(exifData);
+ }
+
+ return true;
+}
+
+bool ExifWidget::decodeMetadata()
+{
+ DMetadata metaData;
+ if (!metaData.setExif(getMetadata()))
+ return false;
+
+ // Update all metadata contents.
+ setMetadataMap(metaData.getExifTagsDataList(m_keysFilter));
+ return true;
+}
+
+void ExifWidget::buildView()
+{
+ if (getMode() == SIMPLE)
+ {
+ setIfdList(getMetadataMap(), m_keysFilter, m_tagsfilter);
+ }
+ else
+ {
+ setIfdList(getMetadataMap(), m_keysFilter, TQStringList());
+ }
+
+ MetadataWidget::buildView();
+}
+
+TQString ExifWidget::getTagTitle(const TQString& key)
+{
+ DMetadata meta;
+ TQString title = meta.getExifTagTitle(key.ascii());
+
+ if (title.isEmpty())
+ return key.section('.', -1);
+
+ return title;
+}
+
+TQString ExifWidget::getTagDescription(const TQString& key)
+{
+ DMetadata meta;
+ TQString desc = meta.getExifTagDescription(key.ascii());
+
+ if (desc.isEmpty())
+ return i18n("No description available");
+
+ return desc;
+}
+
+void ExifWidget::slotSaveMetadataToFile()
+{
+ KURL url = saveMetadataToFile(i18n("EXIF File to Save"),
+ TQString("*.exif|"+i18n("EXIF binary Files (*.exif)")));
+ storeMetadataToFile(url);
+}
+
+} // namespace Digikam
diff --git a/src/libs/widgets/metadata/exifwidget.h b/src/libs/widgets/metadata/exifwidget.h
new file mode 100644
index 00000000..ba66d085
--- /dev/null
+++ b/src/libs/widgets/metadata/exifwidget.h
@@ -0,0 +1,73 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-20
+ * Description : a widget to display Standard Exif metadata
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef EXIFWIDGET_H
+#define EXIFWIDGET_H
+
+// TQt includes.
+
+#include <tqstring.h>
+
+// Local includes.
+
+#include "metadatawidget.h"
+#include "digikam_export.h"
+
+namespace Digikam
+{
+
+class DIGIKAM_EXPORT ExifWidget : public MetadataWidget
+{
+ TQ_OBJECT
+
+
+public:
+
+ ExifWidget(TQWidget* parent, const char* name=0);
+ ~ExifWidget();
+
+ bool loadFromURL(const KURL& url);
+
+ TQString getTagDescription(const TQString& key);
+ TQString getTagTitle(const TQString& key);
+
+ TQString getMetadataTitle();
+
+protected slots:
+
+ virtual void slotSaveMetadataToFile();
+
+private:
+
+ bool decodeMetadata();
+ void buildView();
+
+private:
+
+ TQStringList m_tagsfilter;
+ TQStringList m_keysFilter;
+};
+
+} // namespace Digikam
+
+#endif /* EXIFWIDGET_H */
diff --git a/src/libs/widgets/metadata/gpswidget.cpp b/src/libs/widgets/metadata/gpswidget.cpp
new file mode 100644
index 00000000..033423e9
--- /dev/null
+++ b/src/libs/widgets/metadata/gpswidget.cpp
@@ -0,0 +1,340 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-22
+ * Description : a tab widget to display GPS info
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+/*
+Any good explainations about GPS (in French) can be found at this url :
+http://www.gpspassion.com/forumsen/topic.asp?TOPIC_ID=16593
+*/
+
+// TQt includes.
+
+#include <tqlayout.h>
+#include <tqpushbutton.h>
+#include <tqmap.h>
+#include <tqhbox.h>
+#include <tqfile.h>
+#include <tqcombobox.h>
+#include <tqgroupbox.h>
+
+// KDE includes.
+
+#include <kdialogbase.h>
+#include <tdelocale.h>
+#include <tdeapplication.h>
+
+// Local includes.
+
+#include "ddebug.h"
+#include "dmetadata.h"
+#include "metadatalistview.h"
+#include "worldmapwidget.h"
+#include "gpswidget.h"
+#include "gpswidget.moc"
+
+namespace Digikam
+{
+
+static const char* ExifGPSHumanList[] =
+{
+ "GPSLatitude",
+ "GPSLongitude",
+ "GPSAltitude",
+ "-1"
+};
+
+// Standard Exif Entry list from to less important to the most important for photograph.
+static const char* StandardExifGPSEntryList[] =
+{
+ "GPSInfo",
+ "-1"
+};
+
+class GPSWidgetPriv
+{
+
+public:
+
+ GPSWidgetPriv()
+ {
+ detailsButton = 0;
+ detailsCombo = 0;
+ map = 0;
+ }
+
+ TQStringList tagsfilter;
+ TQStringList keysFilter;
+
+ TQPushButton *detailsButton;
+
+ TQComboBox *detailsCombo;
+
+ WorldMapWidget *map;
+};
+
+GPSWidget::GPSWidget(TQWidget* parent, const char* name)
+ : MetadataWidget(parent, name)
+{
+ d = new GPSWidgetPriv;
+
+ for (int i=0 ; TQString(StandardExifGPSEntryList[i]) != TQString("-1") ; i++)
+ d->keysFilter << StandardExifGPSEntryList[i];
+
+ for (int i=0 ; TQString(ExifGPSHumanList[i]) != TQString("-1") ; i++)
+ d->tagsfilter << ExifGPSHumanList[i];
+
+ // --------------------------------------------------------
+
+ TQWidget *gpsInfo = new TQWidget(this);
+ TQGridLayout *layout = new TQGridLayout(gpsInfo, 3, 2);
+ d->map = new WorldMapWidget(256, 256, gpsInfo);
+
+ // --------------------------------------------------------
+
+ TQGroupBox* box2 = new TQGroupBox( 0, TQt::Vertical, gpsInfo );
+ box2->setInsideMargin(0);
+ box2->setInsideSpacing(0);
+ box2->setFrameStyle( TQFrame::NoFrame );
+ TQGridLayout* box2Layout = new TQGridLayout( box2->layout(), 0, 2, KDialog::spacingHint() );
+
+ d->detailsCombo = new TQComboBox( false, box2 );
+ d->detailsButton = new TQPushButton(i18n("More Info..."), box2);
+ d->detailsCombo->insertItem(TQString("MapQuest"), MapQuest);
+ d->detailsCombo->insertItem(TQString("Google Maps"), GoogleMaps);
+ d->detailsCombo->insertItem(TQString("MSN Maps"), MsnMaps);
+ d->detailsCombo->insertItem(TQString("MultiMap"), MultiMap);
+
+ box2Layout->addMultiCellWidget( d->detailsCombo, 0, 0, 0, 0 );
+ box2Layout->addMultiCellWidget( d->detailsButton, 0, 0, 1, 1 );
+ box2Layout->setColStretch(2, 10);
+
+ // --------------------------------------------------------
+
+ layout->addMultiCellWidget(d->map, 0, 0, 0, 2);
+ layout->addMultiCell(new TQSpacerItem(KDialog::spacingHint(), KDialog::spacingHint(),
+ TQSizePolicy::Minimum, TQSizePolicy::MinimumExpanding), 1, 1, 0, 2);
+ layout->addMultiCellWidget(box2, 2, 2, 0, 0);
+ layout->setColStretch(2, 10);
+ layout->setRowStretch(3, 10);
+
+ // --------------------------------------------------------
+
+ connect(d->detailsButton, TQ_SIGNAL(clicked()),
+ this, TQ_SLOT(slotGPSDetails()));
+
+ setUserAreaWidget(gpsInfo);
+ decodeMetadata();
+}
+
+GPSWidget::~GPSWidget()
+{
+ delete d;
+}
+
+int GPSWidget::getWebGPSLocator()
+{
+ return ( d->detailsCombo->currentItem() );
+}
+
+void GPSWidget::setWebGPSLocator(int locator)
+{
+ d->detailsCombo->setCurrentItem(locator);
+}
+
+void GPSWidget::slotGPSDetails()
+{
+ TQString val, url;
+
+ switch( getWebGPSLocator() )
+ {
+ case MapQuest:
+ {
+ url.append("http://www.mapquest.com/maps/map.adp?searchtype=address"
+ "&formtype=address&latlongtype=decimal");
+ url.append("&latitude=");
+ url.append(val.setNum(d->map->getLatitude(), 'g', 12));
+ url.append("&longitude=");
+ url.append(val.setNum(d->map->getLongitude(), 'g', 12));
+ break;
+ }
+
+ case GoogleMaps:
+ {
+ url.append("http://maps.google.com/?q=");
+ url.append(val.setNum(d->map->getLatitude(), 'g', 12));
+ url.append(",");
+ url.append(val.setNum(d->map->getLongitude(), 'g', 12));
+ url.append("&spn=0.05,0.05&t=h&om=1&hl=en");
+ break;
+ }
+
+ case MsnMaps:
+ {
+ url.append("http://maps.msn.com/map.aspx?");
+ url.append("&lats1=");
+ url.append(val.setNum(d->map->getLatitude(), 'g', 12));
+ url.append("&lons1=");
+ url.append(val.setNum(d->map->getLongitude(), 'g', 12));
+ url.append("&name=HERE");
+ url.append("&alts1=7");
+ break;
+ }
+
+ case MultiMap:
+ {
+ url.append("http://www.multimap.com/map/browse.cgi?");
+ url.append("lat=");
+ url.append(val.setNum(d->map->getLatitude(), 'g', 12));
+ url.append("&lon=");
+ url.append(val.setNum(d->map->getLongitude(), 'g', 12));
+ url.append("&scale=10000");
+ url.append("&icon=x");
+ break;
+ }
+ }
+
+ TDEApplication::kApplication()->invokeBrowser(url);
+}
+
+TQString GPSWidget::getMetadataTitle()
+{
+ return i18n("Global Positioning System Information");
+}
+
+bool GPSWidget::loadFromURL(const KURL& url)
+{
+ setFileName(url.path());
+
+ if (url.isEmpty())
+ {
+ setMetadata();
+ return false;
+ }
+ else
+ {
+ DMetadata metadata(url.path());
+ TQByteArray exifData = metadata.getExif();
+
+ if (exifData.isEmpty())
+ {
+ setMetadata();
+ return false;
+ }
+ else
+ setMetadata(exifData);
+ }
+
+ return true;
+}
+
+bool GPSWidget::decodeMetadata()
+{
+ DMetadata metaData;
+ if (!metaData.setExif(getMetadata()))
+ {
+ setMetadataEmpty();
+ return false;
+ }
+
+ // Update all metadata contents.
+ setMetadataMap(metaData.getExifTagsDataList(d->keysFilter));
+
+ bool ret = decodeGPSPosition();
+ if (!ret)
+ {
+ setMetadataEmpty();
+ return false;
+ }
+
+ d->map->setEnabled(true);
+ d->detailsButton->setEnabled(true);
+ d->detailsCombo->setEnabled(true);
+ return true;
+}
+
+void GPSWidget::setMetadataEmpty()
+{
+ MetadataWidget::setMetadataEmpty();
+ d->map->setEnabled(false);
+ d->detailsButton->setEnabled(false);
+ d->detailsCombo->setEnabled(false);
+}
+
+void GPSWidget::buildView()
+{
+ if (getMode() == SIMPLE)
+ {
+ setIfdList(getMetadataMap(), d->keysFilter, d->tagsfilter);
+ }
+ else
+ {
+ setIfdList(getMetadataMap(), d->keysFilter, TQStringList());
+ }
+
+ MetadataWidget::buildView();
+}
+
+TQString GPSWidget::getTagTitle(const TQString& key)
+{
+ DMetadata meta;
+ TQString title = meta.getExifTagTitle(key.ascii());
+
+ if (title.isEmpty())
+ return key.section('.', -1);
+
+ return title;
+}
+
+TQString GPSWidget::getTagDescription(const TQString& key)
+{
+ DMetadata meta;
+ TQString desc = meta.getExifTagDescription(key.ascii());
+
+ if (desc.isEmpty())
+ return i18n("No description available");
+
+ return desc;
+}
+
+bool GPSWidget::decodeGPSPosition()
+{
+ double latitude=0.0, longitude=0.0, altitude=0.0;
+
+ DMetadata meta;
+ meta.setExif(getMetadata());
+
+ if (meta.getGPSInfo(altitude, latitude, longitude))
+ d->map->setGPSPosition(latitude, longitude);
+ else
+ return false;
+
+ return true;
+}
+
+void GPSWidget::slotSaveMetadataToFile()
+{
+ KURL url = saveMetadataToFile(i18n("EXIF File to Save"),
+ TQString("*.exif|"+i18n("EXIF binary Files (*.exif)")));
+ storeMetadataToFile(url);
+}
+
+} // namespace Digikam
diff --git a/src/libs/widgets/metadata/gpswidget.h b/src/libs/widgets/metadata/gpswidget.h
new file mode 100644
index 00000000..fd787d67
--- /dev/null
+++ b/src/libs/widgets/metadata/gpswidget.h
@@ -0,0 +1,95 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-22
+ * Description : a tab widget to display GPS info
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef GPSWIDGET_H
+#define GPSWIDGET_H
+
+// TQt includes.
+
+#include <tqwidget.h>
+#include <tqstring.h>
+
+// Local includes.
+
+#include "metadatawidget.h"
+#include "digikam_export.h"
+
+namespace Digikam
+{
+
+class GPSWidgetPriv;
+class WorldMapWidget;
+
+class DIGIKAM_EXPORT GPSWidget : public MetadataWidget
+{
+ TQ_OBJECT
+
+
+public:
+
+ enum WebGPSLocator
+ {
+ MapQuest = 0,
+ GoogleMaps,
+ MsnMaps,
+ MultiMap
+ };
+
+public:
+
+ GPSWidget(TQWidget* parent, const char* name=0);
+ ~GPSWidget();
+
+ bool loadFromURL(const KURL& url);
+
+ TQString getTagDescription(const TQString& key);
+ TQString getTagTitle(const TQString& key);
+
+ TQString getMetadataTitle();
+
+ int getWebGPSLocator();
+ void setWebGPSLocator(int locator);
+
+protected slots:
+
+ virtual void slotSaveMetadataToFile();
+
+private slots:
+
+ void slotGPSDetails();
+
+private:
+
+ bool decodeMetadata();
+ void buildView();
+ bool decodeGPSPosition();
+ virtual void setMetadataEmpty();
+
+private:
+
+ GPSWidgetPriv *d;
+};
+
+} // namespace Digikam
+
+#endif /* GPSWIDGET_H */
diff --git a/src/libs/widgets/metadata/iptcwidget.cpp b/src/libs/widgets/metadata/iptcwidget.cpp
new file mode 100644
index 00000000..b0bcb009
--- /dev/null
+++ b/src/libs/widgets/metadata/iptcwidget.cpp
@@ -0,0 +1,167 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-20
+ * Description : A widget to display IPTC metadata
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// TQt includes.
+
+#include <tqmap.h>
+#include <tqfile.h>
+
+// KDE includes.
+
+#include <tdelocale.h>
+
+// Local includes.
+
+#include "ddebug.h"
+#include "dmetadata.h"
+#include "iptcwidget.h"
+#include "iptcwidget.moc"
+
+namespace Digikam
+{
+
+static const char* IptcHumanList[] =
+{
+ "Caption",
+ "City",
+ "Contact",
+ "Copyright",
+ "Credit",
+ "DateCreated",
+ "Headline",
+ "Keywords",
+ "ProvinceState",
+ "Source",
+ "Urgency",
+ "Writer",
+ "-1"
+};
+
+static const char* StandardIptcEntryList[] =
+{
+ "Envelope",
+ "Application2",
+ "-1"
+};
+
+IptcWidget::IptcWidget(TQWidget* parent, const char* name)
+ : MetadataWidget(parent, name)
+{
+ for (int i=0 ; TQString(StandardIptcEntryList[i]) != TQString("-1") ; i++)
+ m_keysFilter << StandardIptcEntryList[i];
+
+ for (int i=0 ; TQString(IptcHumanList[i]) != TQString("-1") ; i++)
+ m_tagsfilter << IptcHumanList[i];
+}
+
+IptcWidget::~IptcWidget()
+{
+}
+
+TQString IptcWidget::getMetadataTitle()
+{
+ return i18n("IPTC Records");
+}
+
+bool IptcWidget::loadFromURL(const KURL& url)
+{
+ setFileName(url.filename());
+
+ if (url.isEmpty())
+ {
+ setMetadata();
+ return false;
+ }
+ else
+ {
+ DMetadata metadata(url.path());
+ TQByteArray iptcData = metadata.getIptc();
+
+ if (iptcData.isEmpty())
+ {
+ setMetadata();
+ return false;
+ }
+ else
+ setMetadata(iptcData);
+ }
+
+ return true;
+}
+
+bool IptcWidget::decodeMetadata()
+{
+ DMetadata metaData;
+ if (!metaData.setIptc(getMetadata()))
+ return false;
+
+ // Update all metadata contents.
+ setMetadataMap(metaData.getIptcTagsDataList(m_keysFilter));
+ return true;
+}
+
+void IptcWidget::buildView()
+{
+ if (getMode() == SIMPLE)
+ {
+ setIfdList(getMetadataMap(), m_tagsfilter);
+ }
+ else
+ {
+ setIfdList(getMetadataMap());
+ }
+
+ MetadataWidget::buildView();
+}
+
+TQString IptcWidget::getTagTitle(const TQString& key)
+{
+ DMetadata meta;
+ TQString title = meta.getIptcTagTitle(key.ascii());
+
+ if (title.isEmpty())
+ return key.section('.', -1);
+
+ return title;
+}
+
+TQString IptcWidget::getTagDescription(const TQString& key)
+{
+ DMetadata meta;
+ TQString desc = meta.getIptcTagDescription(key.ascii());
+
+ if (desc.isEmpty())
+ return i18n("No description available");
+
+ return desc;
+}
+
+void IptcWidget::slotSaveMetadataToFile()
+{
+ KURL url = saveMetadataToFile(i18n("IPTC File to Save"),
+ TQString("*.iptc|"+i18n("IPTC binary Files (*.iptc)")));
+ storeMetadataToFile(url);
+}
+
+} // namespace Digikam
+
diff --git a/src/libs/widgets/metadata/iptcwidget.h b/src/libs/widgets/metadata/iptcwidget.h
new file mode 100644
index 00000000..58f1449e
--- /dev/null
+++ b/src/libs/widgets/metadata/iptcwidget.h
@@ -0,0 +1,69 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-20
+ * Description : A widget to display IPTC metadata
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef IPTCWIDGET_H
+#define IPTCWIDGET_H
+
+// Local includes.
+
+#include "metadatawidget.h"
+#include "digikam_export.h"
+
+namespace Digikam
+{
+
+class DIGIKAM_EXPORT IptcWidget : public MetadataWidget
+{
+ TQ_OBJECT
+
+
+public:
+
+ IptcWidget(TQWidget* parent, const char* name=0);
+ ~IptcWidget();
+
+ bool loadFromURL(const KURL& url);
+
+ TQString getTagDescription(const TQString& key);
+ TQString getTagTitle(const TQString& key);
+
+ TQString getMetadataTitle();
+
+protected slots:
+
+ virtual void slotSaveMetadataToFile();
+
+private:
+
+ bool decodeMetadata();
+ void buildView();
+
+private:
+
+ TQStringList m_tagsfilter;
+ TQStringList m_keysFilter;
+};
+
+} // namespace Digikam
+
+#endif /* IPTCWIDGET_H */
diff --git a/src/libs/widgets/metadata/makernotewidget.cpp b/src/libs/widgets/metadata/makernotewidget.cpp
new file mode 100644
index 00000000..ddd1fe3c
--- /dev/null
+++ b/src/libs/widgets/metadata/makernotewidget.cpp
@@ -0,0 +1,210 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-20
+ * Description : a widget to display non standard Exif metadata
+ * used by camera makers
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// TQt includes.
+
+#include <tqmap.h>
+#include <tqfile.h>
+
+// KDE includes.
+
+#include <tdelocale.h>
+
+// Local includes.
+
+#include "ddebug.h"
+#include "dmetadata.h"
+#include "makernotewidget.h"
+#include "makernotewidget.moc"
+
+namespace Digikam
+{
+
+// This list mix differents tags name used by camera makers.
+static const char* MakerNoteHumanList[] =
+{
+ "AFFocusPos",
+ "AFMode",
+ "AFPoint",
+ "AutofocusMode",
+ "ColorMode",
+ "ColorTemperature",
+ "Contrast",
+ "DigitalZoom",
+ "ExposureMode",
+ "ExposureProgram",
+ "ExposureCompensation",
+ "ExposureManualBias",
+ "Flash",
+ "FlashBias",
+ "FlashMode",
+ "FlashType",
+ "FlashDevice",
+ "FNumber",
+ "Focus"
+ "FocusDistance",
+ "FocusMode",
+ "FocusSetting",
+ "FocusType",
+ "Hue",
+ "HueAdjustment",
+ "ImageStabilizer",
+ "ImageStabilization",
+ "InternalFlash",
+ "ISOSelection",
+ "ISOSpeed",
+ "Lens",
+ "LensType",
+ "LensRange",
+ "Macro",
+ "MacroFocus",
+ "MeteringMode",
+ "NoiseReduction",
+ "OwnerName",
+ "Quality",
+ "Tone",
+ "ToneComp",
+ "Saturation",
+ "Sharpness",
+ "ShootingMode",
+ "ShutterSpeedValue",
+ "SpotMode",
+ "SubjectDistance",
+ "WhiteBalance",
+ "WhiteBalanceBias",
+ "-1"
+};
+
+static const char* ExifEntryListToIgnore[] =
+{
+ "GPSInfo",
+ "Iop",
+ "Thumbnail",
+ "SubImage1",
+ "SubImage2",
+ "Image",
+ "Photo",
+ "-1"
+};
+
+MakerNoteWidget::MakerNoteWidget(TQWidget* parent, const char* name)
+ : MetadataWidget(parent, name)
+{
+ for (int i=0 ; TQString(ExifEntryListToIgnore[i]) != TQString("-1") ; i++)
+ m_keysFilter << ExifEntryListToIgnore[i];
+
+ for (int i=0 ; TQString(MakerNoteHumanList[i]) != TQString("-1") ; i++)
+ m_tagsfilter << MakerNoteHumanList[i];
+}
+
+MakerNoteWidget::~MakerNoteWidget()
+{
+}
+
+TQString MakerNoteWidget::getMetadataTitle()
+{
+ return i18n("MakerNote EXIF Tags");
+}
+
+bool MakerNoteWidget::loadFromURL(const KURL& url)
+{
+ setFileName(url.path());
+
+ if (url.isEmpty())
+ {
+ setMetadata();
+ return false;
+ }
+ else
+ {
+ DMetadata metadata(url.path());
+ TQByteArray exifData = metadata.getExif();
+
+ if (exifData.isEmpty())
+ {
+ setMetadata();
+ return false;
+ }
+ else
+ setMetadata(exifData);
+ }
+
+ return true;
+}
+
+bool MakerNoteWidget::decodeMetadata()
+{
+ DMetadata metaData;
+ if (!metaData.setExif(getMetadata()))
+ return false;
+
+ // Update all metadata contents.
+ setMetadataMap(metaData.getExifTagsDataList(m_keysFilter, true));
+ return true;
+}
+
+void MakerNoteWidget::buildView()
+{
+ if (getMode() == SIMPLE)
+ {
+ setIfdList(getMetadataMap(), m_tagsfilter);
+ }
+ else
+ {
+ setIfdList(getMetadataMap());
+ }
+
+ MetadataWidget::buildView();
+}
+
+TQString MakerNoteWidget::getTagTitle(const TQString& key)
+{
+ DMetadata meta;
+ TQString title = meta.getExifTagTitle(key.ascii());
+
+ if (title.isEmpty())
+ return key.section('.', -1);
+
+ return title;
+}
+
+TQString MakerNoteWidget::getTagDescription(const TQString& key)
+{
+ DMetadata meta;
+ TQString desc = meta.getExifTagDescription(key.ascii());
+
+ if (desc.isEmpty())
+ return i18n("No description available");
+
+ return desc;
+}
+
+void MakerNoteWidget::slotSaveMetadataToFile()
+{
+ KURL url = saveMetadataToFile(i18n("EXIF File to Save"),
+ TQString("*.exif|"+i18n("EXIF binary Files (*.exif)")));
+ storeMetadataToFile(url);
+}
+
+} // namespace Digikam
diff --git a/src/libs/widgets/metadata/makernotewidget.h b/src/libs/widgets/metadata/makernotewidget.h
new file mode 100644
index 00000000..f6549591
--- /dev/null
+++ b/src/libs/widgets/metadata/makernotewidget.h
@@ -0,0 +1,70 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-20
+ * Description : a widget to display non standard Exif metadata
+ * used by camera makers
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef MARKERNOTEWIDGET_H
+#define MARKERNOTEWIDGET_H
+
+// Local includes.
+
+#include "metadatawidget.h"
+#include "digikam_export.h"
+
+namespace Digikam
+{
+
+class DIGIKAM_EXPORT MakerNoteWidget : public MetadataWidget
+{
+ TQ_OBJECT
+
+
+public:
+
+ MakerNoteWidget(TQWidget* parent, const char* name=0);
+ ~MakerNoteWidget();
+
+ bool loadFromURL(const KURL& url);
+
+ TQString getTagDescription(const TQString& key);
+ TQString getTagTitle(const TQString& key);
+
+ TQString getMetadataTitle();
+
+protected slots:
+
+ virtual void slotSaveMetadataToFile();
+
+private:
+
+ bool decodeMetadata();
+ void buildView();
+
+private:
+
+ TQStringList m_tagsfilter;
+ TQStringList m_keysFilter;
+};
+
+} // namespace Digikam
+
+#endif /* MARKERNOTEWIDGET_H */
diff --git a/src/libs/widgets/metadata/mdkeylistviewitem.cpp b/src/libs/widgets/metadata/mdkeylistviewitem.cpp
new file mode 100644
index 00000000..27963eaf
--- /dev/null
+++ b/src/libs/widgets/metadata/mdkeylistviewitem.cpp
@@ -0,0 +1,94 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-21
+ * Description : a generic list view item widget to
+ * display metadata key like a title
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// TQt includes.
+
+#include <tqpalette.h>
+#include <tqfont.h>
+#include <tqpainter.h>
+
+// KDE includes.
+
+#include <tdelocale.h>
+
+// Local includes.
+
+#include "themeengine.h"
+#include "ddebug.h"
+#include "mdkeylistviewitem.h"
+
+namespace Digikam
+{
+
+MdKeyListViewItem::MdKeyListViewItem(TQListView *parent, const TQString& key)
+ : TQListViewItem(parent)
+{
+ m_decryptedKey = key;
+
+ // Standard Exif key descriptions.
+ if (key == "Iop") m_decryptedKey = i18n("Interoperability");
+ else if (key == "Image") m_decryptedKey = i18n("Image Information");
+ else if (key == "Photo") m_decryptedKey = i18n("Photograph Information");
+ else if (key == "GPSInfo") m_decryptedKey = i18n("Global Positioning System");
+ else if (key == "Thumbnail") m_decryptedKey = i18n("Embedded Thumbnail");
+
+ // Standard IPTC key descriptions.
+ else if (key == "Envelope") m_decryptedKey = i18n("IIM Envelope");
+ else if (key == "Application2") m_decryptedKey = i18n("IIM Application 2");
+
+ setOpen(true);
+ setSelected(false);
+ setSelectable(false);
+}
+
+MdKeyListViewItem::~MdKeyListViewItem()
+{
+}
+
+TQString MdKeyListViewItem::getMdKey()
+{
+ return m_decryptedKey;
+}
+
+void MdKeyListViewItem::paintCell(TQPainter* p, const TQColorGroup&,
+ int column, int, int)
+{
+ p->save();
+ TQFont fn(p->font());
+ fn.setBold(true);
+ fn.setItalic(false);
+ p->setFont(fn);
+ p->setPen(ThemeEngine::instance()->textSelColor());
+ int width = listView()->contentsWidth();
+ TQRect rect(0, 0, width, fn.weight());
+
+ if (column == 1)
+ rect.moveLeft(-width/2);
+
+ p->fillRect(rect, ThemeEngine::instance()->thumbSelColor());
+ p->drawText(rect, TQt::AlignHCenter, m_decryptedKey);
+ p->restore();
+}
+
+} // namespace Digikam
diff --git a/src/libs/widgets/metadata/mdkeylistviewitem.h b/src/libs/widgets/metadata/mdkeylistviewitem.h
new file mode 100644
index 00000000..aeaf7e4c
--- /dev/null
+++ b/src/libs/widgets/metadata/mdkeylistviewitem.h
@@ -0,0 +1,63 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-21
+ * Description : a generic list view item widget to
+ * display metadata key like a title
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef MDKEYLISTVIEWITEM_H
+#define MDKEYLISTVIEWITEM_H
+
+// TQt includes.
+
+#include <tqstring.h>
+#include <tqlistview.h>
+
+// Local includes.
+
+#include "digikam_export.h"
+
+class TQPainter;
+
+namespace Digikam
+{
+
+class DIGIKAM_EXPORT MdKeyListViewItem : public TQListViewItem
+{
+
+public:
+
+ MdKeyListViewItem(TQListView *parent, const TQString& key);
+ ~MdKeyListViewItem();
+
+ TQString getMdKey();
+
+protected:
+
+ void paintCell(TQPainter*, const TQColorGroup &, int, int, int);
+
+private:
+
+ TQString m_decryptedKey;
+};
+
+} // namespace Digikam
+
+#endif /* MDKEYLISTVIEWITEM_H */
diff --git a/src/libs/widgets/metadata/metadatalistview.cpp b/src/libs/widgets/metadata/metadatalistview.cpp
new file mode 100644
index 00000000..612eed1e
--- /dev/null
+++ b/src/libs/widgets/metadata/metadatalistview.cpp
@@ -0,0 +1,283 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-21
+ * Description : a generic list view widget to
+ * display metadata
+ *
+ * Copyright (c) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// TQt includes.
+
+#include <tqtimer.h>
+#include <tqptrlist.h>
+#include <tqpalette.h>
+#include <tqheader.h>
+#include <tqwhatsthis.h>
+
+// KDE includes.
+
+#include <tdelocale.h>
+
+// Local includes.
+
+#include "mdkeylistviewitem.h"
+#include "metadatalistviewitem.h"
+#include "metadatalistview.h"
+#include "metadatalistview.moc"
+
+namespace Digikam
+{
+
+MetadataListView::MetadataListView(TQWidget* parent)
+ : TQListView(parent)
+{
+ header()->hide();
+ addColumn("Name"); // No need i18n here.
+ addColumn("Value"); // No need i18n here.
+ setItemMargin(0);
+ setAllColumnsShowFocus(true);
+ setResizeMode(TQListView::AllColumns);
+ // Vertical scroll bar is always disable to give more
+ // free space to metadata content
+ setVScrollBarMode(TQScrollView::AlwaysOff);
+
+ m_parent = dynamic_cast<MetadataWidget *>(parent);
+
+ connect(this, TQ_SIGNAL(selectionChanged(TQListViewItem*)),
+ this, TQ_SLOT(slotSelectionChanged(TQListViewItem*)));
+}
+
+MetadataListView::~MetadataListView()
+{
+}
+
+TQString MetadataListView::getCurrentItemKey()
+{
+ if (currentItem())
+ {
+ if (currentItem()->isSelectable())
+ {
+ MetadataListViewItem *item = static_cast<MetadataListViewItem *>(currentItem());
+ return item->getKey();
+ }
+ }
+
+ return TQString();
+}
+
+void MetadataListView::setCurrentItemByKey(TQString itemKey)
+{
+ if (itemKey.isNull())
+ return;
+
+ TQListViewItemIterator it(this);
+ while ( it.current() )
+ {
+ if ( it.current()->isSelectable() )
+ {
+ MetadataListViewItem *item = dynamic_cast<MetadataListViewItem *>(it.current());
+
+ if (item->getKey() == itemKey)
+ {
+ setSelected(item, true);
+ ensureItemVisible(item);
+ m_selectedItemKey = itemKey;
+ return;
+ }
+ }
+
+ ++it;
+ }
+}
+
+void MetadataListView::slotSelectionChanged(TQListViewItem *item)
+{
+ if (!item)
+ return;
+
+ MetadataListViewItem* viewItem = static_cast<MetadataListViewItem *>(item);
+ m_selectedItemKey = viewItem->getKey();
+ TQString tagValue = viewItem->getValue().simplifyWhiteSpace();
+ TQString tagTitle = m_parent->getTagTitle(m_selectedItemKey);
+ TQString tagDesc = m_parent->getTagDescription(m_selectedItemKey);
+ if (tagValue.length() > 128)
+ {
+ tagValue.truncate(128);
+ tagValue.append("...");
+ }
+
+ TQWhatsThis::add(this, i18n("<b>Title: </b><p>%1<p>"
+ "<b>Value: </b><p>%2<p>"
+ "<b>Description: </b><p>%3")
+ .arg(tagTitle)
+ .arg(tagValue)
+ .arg(tagDesc));
+}
+
+void MetadataListView::setIfdList(const DMetadata::MetaDataMap& ifds, const TQStringList& tagsfilter)
+{
+ clear();
+
+ uint subItems = 0;
+ TQString ifDItemName;
+ MdKeyListViewItem *parentifDItem = 0;
+
+ for (DMetadata::MetaDataMap::const_iterator it = ifds.begin(); it != ifds.end(); ++it)
+ {
+ // We checking if we have changed of ifDName
+ TQString currentIfDName = it.key().section('.', 1, 1);
+
+ if ( currentIfDName != ifDItemName )
+ {
+ ifDItemName = currentIfDName;
+
+ // Check if the current IfD have any items. If no remove it before to toggle to the next IfD.
+ if ( subItems == 0 && parentifDItem)
+ delete parentifDItem;
+
+ parentifDItem = new MdKeyListViewItem(this, currentIfDName);
+ subItems = 0;
+ }
+
+ // We ignore all unknown tags if necessary.
+ if (!it.key().section('.', 2, 2).startsWith("0x"))
+ {
+ if (!tagsfilter.isEmpty())
+ {
+ // We using the filter to make a more user friendly output (Simple Mode)
+
+ if (tagsfilter.contains(it.key().section('.', 2, 2)))
+ {
+ TQString tagTitle = m_parent->getTagTitle(it.key());
+ new MetadataListViewItem(parentifDItem, it.key(), tagTitle, it.data());
+ subItems++;
+ }
+ }
+ else
+ {
+ // We don't filter the output (Complete Mode)
+
+ TQString tagTitle = m_parent->getTagTitle(it.key());
+ new MetadataListViewItem(parentifDItem, it.key(), tagTitle, it.data());
+ subItems++;
+ }
+ }
+ }
+
+ // To check if the last IfD have any items...
+ if ( subItems == 0 && parentifDItem)
+ delete parentifDItem;
+
+ setCurrentItemByKey(m_selectedItemKey);
+ TQTimer::singleShot( 0, this, TQ_SLOT( triggerUpdate() ) );
+}
+
+void MetadataListView::setIfdList(const DMetadata::MetaDataMap& ifds, const TQStringList& keysFilter,
+ const TQStringList& tagsFilter)
+{
+ clear();
+
+ uint subItems = 0;
+ MdKeyListViewItem *parentifDItem = 0;
+
+ for (TQStringList::const_iterator itKeysFilter = keysFilter.begin();
+ itKeysFilter != keysFilter.end();
+ ++itKeysFilter)
+ {
+ subItems = 0;
+ parentifDItem = new MdKeyListViewItem(this, *itKeysFilter);
+
+ DMetadata::MetaDataMap::const_iterator it = ifds.end();
+
+ while(1)
+ {
+ if ( *itKeysFilter == it.key().section('.', 1, 1) )
+ {
+ // We ignore all unknown tags if necessary.
+ if (!it.key().section('.', 2, 2).startsWith("0x"))
+ {
+ if (!tagsFilter.isEmpty())
+ {
+ // We using the filter to make a more user friendly output (Simple Mode)
+
+ if (tagsFilter.contains(it.key().section('.', 2, 2)))
+ {
+ TQString tagTitle = m_parent->getTagTitle(it.key());
+ new MetadataListViewItem(parentifDItem, it.key(), tagTitle, it.data());
+ subItems++;
+ }
+ }
+ else
+ {
+ // We don't filter the output (Complete Mode)
+
+ TQString tagTitle = m_parent->getTagTitle(it.key());
+ new MetadataListViewItem(parentifDItem, it.key(), tagTitle, it.data());
+ subItems++;
+ }
+ }
+ }
+
+ if (it == ifds.begin()) break;
+ --it;
+ }
+
+ // We checking if the last IfD have any items. If no, we remove it.
+ if ( subItems == 0 && parentifDItem)
+ delete parentifDItem;
+ }
+
+ setCurrentItemByKey(m_selectedItemKey);
+ TQTimer::singleShot( 0, this, TQ_SLOT( triggerUpdate() ) );
+}
+
+void MetadataListView::viewportResizeEvent(TQResizeEvent* e)
+{
+ TQListView::viewportResizeEvent(e);
+ TQTimer::singleShot( 0, this, TQ_SLOT( triggerUpdate() ) );
+}
+
+void MetadataListView::slotSearchTextChanged(const TQString& filter)
+{
+ bool query = false;
+ TQString search = filter.lower();
+
+ TQListViewItemIterator it(this);
+ for ( ; it.current(); ++it )
+ {
+ MetadataListViewItem *item = dynamic_cast<MetadataListViewItem*>(it.current());
+ if (item)
+ {
+ if (item->text(0).lower().contains(search) ||
+ item->text(1).lower().contains(search))
+ {
+ query = true;
+ item->setVisible(true);
+ }
+ else
+ {
+ item->setVisible(false);
+ }
+ }
+ }
+
+ emit signalTextFilterMatch(query);
+}
+
+} // namespace Digikam
diff --git a/src/libs/widgets/metadata/metadatalistview.h b/src/libs/widgets/metadata/metadatalistview.h
new file mode 100644
index 00000000..aefe6498
--- /dev/null
+++ b/src/libs/widgets/metadata/metadatalistview.h
@@ -0,0 +1,85 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-21
+ * Description : a generic list view widget to
+ * display metadata
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef METADATALISTVIEW_H
+#define METADATALISTVIEW_H
+
+// TQt includes.
+
+#include <tqstring.h>
+#include <tqptrlist.h>
+#include <tqmap.h>
+#include <tqlistview.h>
+
+// Local includes.
+
+#include "metadatawidget.h"
+#include "digikam_export.h"
+
+namespace Digikam
+{
+
+class DIGIKAM_EXPORT MetadataListView : public TQListView
+{
+ TQ_OBJECT
+
+
+public:
+
+ MetadataListView(TQWidget* parent);
+ ~MetadataListView();
+
+ TQString getCurrentItemKey();
+ void setCurrentItemByKey(TQString itemKey);
+
+ void setIfdList(const DMetadata::MetaDataMap& ifds, const TQStringList& tagsfilter);
+ void setIfdList(const DMetadata::MetaDataMap& ifds, const TQStringList& keysFilter,
+ const TQStringList& tagsFilter);
+
+signals:
+
+ void signalTextFilterMatch(bool);
+
+public slots:
+
+ void slotSearchTextChanged(const TQString&);
+
+protected:
+
+ void viewportResizeEvent(TQResizeEvent*);
+
+private slots:
+
+ void slotSelectionChanged(TQListViewItem *item);
+
+private:
+
+ TQString m_selectedItemKey;
+
+ MetadataWidget *m_parent;
+};
+
+} // namespace Digikam
+
+#endif // METADATALISTVIEW_H
diff --git a/src/libs/widgets/metadata/metadatalistviewitem.cpp b/src/libs/widgets/metadata/metadatalistviewitem.cpp
new file mode 100644
index 00000000..f18056b5
--- /dev/null
+++ b/src/libs/widgets/metadata/metadatalistviewitem.cpp
@@ -0,0 +1,75 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-21
+ * Description : a generic list view item widget to
+ * display metadata
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// TQt includes.
+
+#include <tqpalette.h>
+#include <tqfont.h>
+#include <tqpainter.h>
+
+// Local includes.
+
+#include "metadatalistviewitem.h"
+
+namespace Digikam
+{
+
+MetadataListViewItem::MetadataListViewItem(TQListViewItem *parent, const TQString& key,
+ const TQString& title, const TQString& value)
+ : TQListViewItem(parent)
+{
+ m_key = key;
+
+ setSelectable(true);
+ setText(0, title);
+
+ TQString tagVal = value.simplifyWhiteSpace();
+ if (tagVal.length() > 128)
+ {
+ tagVal.truncate(128);
+ tagVal.append("...");
+ }
+ setText(1, tagVal);
+}
+
+MetadataListViewItem::~MetadataListViewItem()
+{
+}
+
+TQString MetadataListViewItem::getKey()
+{
+ return m_key;
+}
+
+TQString MetadataListViewItem::getTitle()
+{
+ return text(0);
+}
+
+TQString MetadataListViewItem::getValue()
+{
+ return text(1);
+}
+
+} // namespace Digikam
diff --git a/src/libs/widgets/metadata/metadatalistviewitem.h b/src/libs/widgets/metadata/metadatalistviewitem.h
new file mode 100644
index 00000000..4a860d5b
--- /dev/null
+++ b/src/libs/widgets/metadata/metadatalistviewitem.h
@@ -0,0 +1,59 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-21
+ * Description : a generic list view item widget to
+ * display metadata
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef METADATALISTVIEWITEM_H
+#define METADATALISTVIEWITEM_H
+
+// TQt includes.
+
+#include <tqstring.h>
+#include <tqlistview.h>
+
+// Local includes.
+
+#include "digikam_export.h"
+
+namespace Digikam
+{
+
+class DIGIKAM_EXPORT MetadataListViewItem : public TQListViewItem
+{
+public:
+
+ MetadataListViewItem(TQListViewItem *parent, const TQString& key,
+ const TQString& title, const TQString& value);
+ ~MetadataListViewItem();
+
+ TQString getKey();
+ TQString getTitle();
+ TQString getValue();
+
+private:
+
+ TQString m_key;
+};
+
+} // namespace Digikam
+
+#endif /* METADATALISTVIEWITEM_H */
diff --git a/src/libs/widgets/metadata/metadatawidget.cpp b/src/libs/widgets/metadata/metadatawidget.cpp
new file mode 100644
index 00000000..d0bd5b19
--- /dev/null
+++ b/src/libs/widgets/metadata/metadatawidget.cpp
@@ -0,0 +1,454 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-22
+ * Description : a generic widget to display metadata
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// TQt includes.
+
+#include <tqlayout.h>
+#include <tqmap.h>
+#include <tqfile.h>
+#include <tqmime.h>
+#include <tqheader.h>
+#include <tqwhatsthis.h>
+#include <tqpainter.h>
+#include <tqhbuttongroup.h>
+#include <tqpushbutton.h>
+#include <tqlabel.h>
+#include <tqdragobject.h>
+#include <tqclipboard.h>
+#include <tqsimplerichtext.h>
+#include <tqpaintdevicemetrics.h>
+#include <tqstylesheet.h>
+#include <tqlistview.h>
+#include <tqtooltip.h>
+
+// KDE includes.
+
+#include <kdialogbase.h>
+#include <tdelocale.h>
+#include <tdefiledialog.h>
+#include <tdeglobalsettings.h>
+#include <kprinter.h>
+#include <tdeglobal.h>
+#include <kiconloader.h>
+#include <tdeapplication.h>
+
+// Local includes.
+
+#include "ddebug.h"
+#include "metadatalistview.h"
+#include "mdkeylistviewitem.h"
+#include "searchtextbar.h"
+#include "metadatawidget.h"
+#include "metadatawidget.moc"
+
+namespace Digikam
+{
+
+class MetadataWidgetPriv
+{
+
+public:
+
+ MetadataWidgetPriv()
+ {
+ toolButtons = 0;
+ levelButtons = 0;
+ view = 0;
+ mainLayout = 0;
+ searchBar = 0;
+ }
+
+ TQGridLayout *mainLayout;
+
+ TQHButtonGroup *toolButtons;
+ TQHButtonGroup *levelButtons;
+
+ TQByteArray metadata;
+
+ TQString fileName;
+
+ MetadataListView *view;
+
+ SearchTextBar *searchBar;
+
+ DMetadata::MetaDataMap metaDataMap;
+};
+
+MetadataWidget::MetadataWidget(TQWidget* parent, const char* name)
+ : TQWidget(parent, name)
+{
+ d = new MetadataWidgetPriv;
+
+ d->mainLayout = new TQGridLayout(this, 3, 4, KDialog::spacingHint(), KDialog::spacingHint());
+ TDEIconLoader *iconLoader = TDEApplication::kApplication()->iconLoader();
+
+ d->levelButtons = new TQHButtonGroup(this);
+ d->levelButtons->setInsideMargin( 0 );
+ d->levelButtons->setExclusive(true);
+ d->levelButtons->setFrameShape(TQFrame::NoFrame);
+
+ TQPushButton *simpleLevel = new TQPushButton( d->levelButtons );
+ simpleLevel->setPixmap( iconLoader->loadIcon( "text-vnd.tde.ascii", (TDEIcon::Group)TDEIcon::Toolbar ) );
+ simpleLevel->setToggleButton(true);
+ TQWhatsThis::add( simpleLevel, i18n( "Switch the tags view to a simple human-readable list" ) );
+ TQToolTip::add( simpleLevel, i18n( "Simple list" ));
+ d->levelButtons->insert(simpleLevel, SIMPLE);
+
+ TQPushButton *fullLevel = new TQPushButton( d->levelButtons );
+ fullLevel->setPixmap( iconLoader->loadIcon( "text-x-generic", (TDEIcon::Group)TDEIcon::Toolbar ) );
+ fullLevel->setToggleButton(true);
+ TQWhatsThis::add( fullLevel, i18n( "Switch the tags view to a full list" ) );
+ TQToolTip::add( fullLevel, i18n( "Full list" ));
+ d->levelButtons->insert(fullLevel, FULL);
+
+ d->toolButtons = new TQHButtonGroup(this);
+ d->toolButtons->setInsideMargin( 0 );
+ d->toolButtons->setFrameShape(TQFrame::NoFrame);
+
+ TQPushButton *saveMetadata = new TQPushButton( d->toolButtons );
+ saveMetadata->setPixmap( iconLoader->loadIcon( "document-save", (TDEIcon::Group)TDEIcon::Toolbar ) );
+ TQWhatsThis::add( saveMetadata, i18n( "Save metadata to a binary file" ) );
+ TQToolTip::add( saveMetadata, i18n( "Save metadata" ));
+ d->toolButtons->insert(saveMetadata);
+
+ TQPushButton *printMetadata = new TQPushButton( d->toolButtons );
+ printMetadata->setPixmap( iconLoader->loadIcon( "document-print", (TDEIcon::Group)TDEIcon::Toolbar ) );
+ TQWhatsThis::add( printMetadata, i18n( "Print metadata to printer" ) );
+ TQToolTip::add( printMetadata, i18n( "Print metadata" ));
+ d->toolButtons->insert(printMetadata);
+
+ TQPushButton *copy2ClipBoard = new TQPushButton( d->toolButtons );
+ copy2ClipBoard->setPixmap( iconLoader->loadIcon( "edit-copy", (TDEIcon::Group)TDEIcon::Toolbar ) );
+ TQWhatsThis::add( copy2ClipBoard, i18n( "Copy metadata to clipboard" ) );
+ TQToolTip::add( copy2ClipBoard, i18n( "Copy metadata to clipboard" ));
+ d->toolButtons->insert(copy2ClipBoard);
+
+ d->view = new MetadataListView(this);
+ TQString barName = TQString(name) + "SearchBar";
+ d->searchBar = new SearchTextBar(this, barName.ascii());
+
+ // -----------------------------------------------------------------
+
+ d->mainLayout->addMultiCellWidget(d->levelButtons, 0, 0, 0, 1);
+ d->mainLayout->addMultiCellWidget(d->toolButtons, 0, 0, 4, 4);
+ d->mainLayout->addMultiCellWidget(d->view, 1, 1, 0, 4);
+ d->mainLayout->addMultiCellWidget(d->searchBar, 2, 2, 0, 4);
+ d->mainLayout->setRowStretch(1, 10);
+ d->mainLayout->setColStretch(3, 10);
+
+ // -----------------------------------------------------------------
+
+ connect(d->levelButtons, TQ_SIGNAL(released(int)),
+ this, TQ_SLOT(slotModeChanged(int)));
+
+ connect(copy2ClipBoard, TQ_SIGNAL(clicked()),
+ this, TQ_SLOT(slotCopy2Clipboard()));
+
+ connect(printMetadata, TQ_SIGNAL(clicked()),
+ this, TQ_SLOT(slotPrintMetadata()));
+
+ connect(saveMetadata, TQ_SIGNAL(clicked()),
+ this, TQ_SLOT(slotSaveMetadataToFile()));
+
+ connect(d->searchBar, TQ_SIGNAL(signalTextChanged(const TQString&)),
+ d->view, TQ_SLOT(slotSearchTextChanged(const TQString&)));
+
+ connect(d->view, TQ_SIGNAL(signalTextFilterMatch(bool)),
+ d->searchBar, TQ_SLOT(slotSearchResult(bool)));
+}
+
+MetadataWidget::~MetadataWidget()
+{
+ delete d;
+}
+
+MetadataListView* MetadataWidget::view()
+{
+ return d->view;
+}
+
+void MetadataWidget::enabledToolButtons(bool b)
+{
+ d->toolButtons->setEnabled(b);
+}
+
+bool MetadataWidget::setMetadata(const TQByteArray& data)
+{
+ d->metadata = data;
+
+ // Cleanup all metadata contents.
+ setMetadataMap();
+
+ if (d->metadata.isEmpty())
+ {
+ setMetadataEmpty();
+ return false;
+ }
+
+ // Try to decode current metadata.
+ if (decodeMetadata())
+ enabledToolButtons(true);
+ else
+ enabledToolButtons(false);
+
+ // Refresh view using decoded metadata.
+ buildView();
+
+ return true;
+}
+
+void MetadataWidget::setMetadataEmpty()
+{
+ d->view->clear();
+ enabledToolButtons(false);
+}
+
+const TQByteArray& MetadataWidget::getMetadata()
+{
+ return d->metadata;
+}
+
+bool MetadataWidget::storeMetadataToFile(const KURL& url)
+{
+ if( url.isEmpty() )
+ return false;
+
+ TQFile file(url.path());
+ if ( !file.open(IO_WriteOnly) )
+ return false;
+
+ TQDataStream stream( &file );
+ stream.writeRawBytes(d->metadata.data(), d->metadata.size());
+ file.close();
+ return true;
+}
+
+void MetadataWidget::setMetadataMap(const DMetadata::MetaDataMap& data)
+{
+ d->metaDataMap = data;
+}
+
+const DMetadata::MetaDataMap& MetadataWidget::getMetadataMap()
+{
+ return d->metaDataMap;
+}
+
+void MetadataWidget::setIfdList(const DMetadata::MetaDataMap &ifds, const TQStringList& tagsFilter)
+{
+ d->view->setIfdList(ifds, tagsFilter);
+}
+
+void MetadataWidget::setIfdList(const DMetadata::MetaDataMap &ifds, const TQStringList& keysFilter,
+ const TQStringList& tagsFilter)
+{
+ d->view->setIfdList(ifds, keysFilter, tagsFilter);
+}
+
+void MetadataWidget::slotModeChanged(int)
+{
+ buildView();
+}
+
+void MetadataWidget::slotCopy2Clipboard()
+{
+ TQString textmetadata = i18n("File name: %1 (%2)").arg(d->fileName).arg(getMetadataTitle());
+ TQListViewItemIterator it( d->view );
+
+ while ( it.current() )
+ {
+ if ( !it.current()->isSelectable() )
+ {
+ MdKeyListViewItem *item = dynamic_cast<MdKeyListViewItem *>(it.current());
+ textmetadata.append("\n\n>>> ");
+ textmetadata.append(item->getMdKey());
+ textmetadata.append(" <<<\n\n");
+ }
+ else
+ {
+ TQListViewItem *item = it.current();
+ textmetadata.append(item->text(0));
+ textmetadata.append(" : ");
+ textmetadata.append(item->text(1));
+ textmetadata.append("\n");
+ }
+
+ ++it;
+ }
+
+ TQApplication::clipboard()->setData(new TQTextDrag(textmetadata), TQClipboard::Clipboard);
+}
+
+void MetadataWidget::slotPrintMetadata()
+{
+ TQString textmetadata = i18n("<p><big><big><b>File name: %1 (%2)</b></big></big>")
+ .arg(d->fileName)
+ .arg(getMetadataTitle());
+ TQListViewItemIterator it( d->view );
+
+ while ( it.current() )
+ {
+ if ( !it.current()->isSelectable() )
+ {
+ MdKeyListViewItem *item = dynamic_cast<MdKeyListViewItem *>(it.current());
+ textmetadata.append("<br><br><b>");
+ textmetadata.append(item->getMdKey());
+ textmetadata.append("</b><br><br>");
+ }
+ else
+ {
+ TQListViewItem *item = it.current();
+ textmetadata.append(item->text(0));
+ textmetadata.append(" : <i>");
+ textmetadata.append(item->text(1));
+ textmetadata.append("</i><br>");
+ }
+
+ ++it;
+ }
+
+ textmetadata.append("</p>");
+
+ KPrinter printer;
+ printer.setFullPage( true );
+
+ if ( printer.setup( this ) )
+ {
+ TQPainter p( &printer );
+
+ if ( !p.device() )
+ return;
+
+ TQPaintDeviceMetrics metrics(p.device());
+ int dpiy = metrics.logicalDpiY();
+ int margin = (int) ( (2/2.54)*dpiy ); // 2 cm margins
+ TQRect view( margin, margin, metrics.width() - 2*margin, metrics.height() - 2*margin );
+ TQFont font(TDEApplication::font());
+ font.setPointSize( 10 ); // we define 10pt to be a nice base size for printing
+ TQSimpleRichText richText( textmetadata, font,
+ TQString(),
+ TQStyleSheet::defaultSheet(),
+ TQMimeSourceFactory::defaultFactory(),
+ view.height() );
+ richText.setWidth( &p, view.width() );
+ int page = 1;
+
+ do
+ {
+ richText.draw( &p, margin, margin, view, colorGroup() );
+ view.moveBy( 0, view.height() );
+ p.translate( 0 , -view.height() );
+ p.setFont( font );
+ p.drawText( view.right() - p.fontMetrics().width( TQString::number( page ) ),
+ view.bottom() + p.fontMetrics().ascent() + 5, TQString::number( page ) );
+
+ if ( view.top() - margin >= richText.height() )
+ break;
+
+ printer.newPage();
+ page++;
+ }
+ while (true);
+ }
+}
+
+KURL MetadataWidget::saveMetadataToFile(const TQString& caption, const TQString& fileFilter)
+{
+ KFileDialog fileSaveDialog(TDEGlobalSettings::documentPath(),
+ TQString(),
+ this,
+ "MetadataFileSaveDialog",
+ false);
+
+ fileSaveDialog.setOperationMode(KFileDialog::Saving);
+ fileSaveDialog.setMode(KFile::File);
+ fileSaveDialog.setSelection(d->fileName);
+ fileSaveDialog.setCaption(caption);
+ fileSaveDialog.setFilter(fileFilter);
+
+ // Check for cancel.
+ if ( fileSaveDialog.exec() == KFileDialog::Accepted )
+ return fileSaveDialog.selectedURL().path();
+
+ return KURL();
+}
+
+void MetadataWidget::setMode(int mode)
+{
+ if (d->levelButtons->selectedId() == mode)
+ return;
+
+ d->levelButtons->setButton(mode);
+ buildView();
+}
+
+int MetadataWidget::getMode()
+{
+ int level = d->levelButtons->selectedId();
+ return level;
+}
+
+TQString MetadataWidget::getCurrentItemKey() const
+{
+ return d->view->getCurrentItemKey();
+}
+
+void MetadataWidget::setCurrentItemByKey(const TQString& itemKey)
+{
+ d->view->setCurrentItemByKey(itemKey);
+}
+
+bool MetadataWidget::loadFromData(const TQString& fileName, const TQByteArray& data)
+{
+ setFileName(fileName);
+ return(setMetadata(data));
+}
+
+TQString MetadataWidget::getTagTitle(const TQString&)
+{
+ return TQString();
+}
+
+TQString MetadataWidget::getTagDescription(const TQString&)
+{
+ return TQString();
+}
+
+void MetadataWidget::setFileName(const TQString& fileName)
+{
+ d->fileName = fileName;
+}
+
+void MetadataWidget::setUserAreaWidget(TQWidget *w)
+{
+ TQVBoxLayout *vLayout = new TQVBoxLayout( KDialog::spacingHint() );
+ vLayout->addWidget(w);
+ vLayout->addStretch();
+ d->mainLayout->addMultiCellLayout(vLayout, 3, 3, 0, 4);
+}
+
+void MetadataWidget::buildView()
+{
+ d->view->slotSearchTextChanged(d->searchBar->text());
+}
+
+} // namespace Digikam
diff --git a/src/libs/widgets/metadata/metadatawidget.h b/src/libs/widgets/metadata/metadatawidget.h
new file mode 100644
index 00000000..5d2feb64
--- /dev/null
+++ b/src/libs/widgets/metadata/metadatawidget.h
@@ -0,0 +1,120 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-22
+ * Description : a generic widget to display metadata
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef METADATAWIDGET_H
+#define METADATAWIDGET_H
+
+// TQt includes.
+
+#include <tqwidget.h>
+#include <tqstring.h>
+
+// KDE includes.
+
+#include <kurl.h>
+
+// Local includes.
+
+#include "dmetadata.h"
+#include "digikam_export.h"
+
+namespace Digikam
+{
+
+class MetadataListView;
+class MetadataWidgetPriv;
+
+class DIGIKAM_EXPORT MetadataWidget : public TQWidget
+{
+ TQ_OBJECT
+
+
+public:
+
+ enum Mode
+ {
+ SIMPLE=0,
+ FULL
+ };
+
+public:
+
+ MetadataWidget(TQWidget* parent, const char* name=0);
+ ~MetadataWidget();
+
+ int getMode();
+ void setMode(int mode);
+
+ TQString getCurrentItemKey() const;
+ void setCurrentItemByKey(const TQString& itemKey);
+
+ void setUserAreaWidget(TQWidget *w);
+
+ virtual TQString getTagTitle(const TQString& key);
+ virtual TQString getTagDescription(const TQString& key);
+
+ virtual bool loadFromData(const TQString &fileName, const TQByteArray& data=TQByteArray());
+ virtual bool loadFromURL(const KURL& url)=0;
+
+private slots:
+
+ void slotModeChanged(int);
+ void slotCopy2Clipboard();
+ void slotPrintMetadata();
+
+protected slots:
+
+ virtual void slotSaveMetadataToFile()=0;
+
+protected:
+
+ void enabledToolButtons(bool);
+ void setFileName(const TQString& fileName);
+ MetadataListView* view();
+
+ bool setMetadata(const TQByteArray& data=TQByteArray());
+ const TQByteArray& getMetadata();
+
+ void setMetadataMap(const DMetadata::MetaDataMap& data=DMetadata::MetaDataMap());
+ const DMetadata::MetaDataMap& getMetadataMap();
+
+ void setIfdList(const DMetadata::MetaDataMap &ifds, const TQStringList& tagsFilter=TQStringList());
+ void setIfdList(const DMetadata::MetaDataMap &ifds, const TQStringList& keysFilter,
+ const TQStringList& tagsFilter);
+
+ KURL saveMetadataToFile(const TQString& caption, const TQString& fileFilter);
+ bool storeMetadataToFile(const KURL& url);
+
+ virtual void buildView();
+ virtual bool decodeMetadata()=0;
+ virtual TQString getMetadataTitle()=0;
+ virtual void setMetadataEmpty();
+
+private:
+
+ MetadataWidgetPriv* d;
+};
+
+} // namespace Digikam
+
+#endif /* METADATAWIDGET_H */
diff --git a/src/libs/widgets/metadata/worldmapwidget.cpp b/src/libs/widgets/metadata/worldmapwidget.cpp
new file mode 100644
index 00000000..811e9148
--- /dev/null
+++ b/src/libs/widgets/metadata/worldmapwidget.cpp
@@ -0,0 +1,211 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-20
+ * Description : a widget to display GPS info on a world map
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// TQt includes.
+
+#include <tqpainter.h>
+#include <tqstring.h>
+#include <tqpixmap.h>
+#include <tqlabel.h>
+
+// KDE includes.
+
+#include <kstandarddirs.h>
+#include <kcursor.h>
+#include <tdelocale.h>
+#include <kstaticdeleter.h>
+
+// Local includes.
+
+#include "ddebug.h"
+#include "worldmapwidget.h"
+#include "worldmapwidget.moc"
+
+namespace Digikam
+{
+
+class WorldMapWidgetPriv
+{
+
+public:
+
+ WorldMapWidgetPriv()
+ {
+ latitude = 0;
+ longitude = 0;
+ latLonPos = 0;
+ }
+
+ int xPos;
+ int yPos;
+ int xMousePos;
+ int yMousePos;
+
+ double latitude;
+ double longitude;
+
+ TQLabel *latLonPos;
+
+ static TQPixmap *worldMap;
+};
+
+static KStaticDeleter<TQPixmap> pixmapDeleter;
+
+TQPixmap *WorldMapWidgetPriv::worldMap = 0;
+
+WorldMapWidget::WorldMapWidget(int w, int h, TQWidget *parent)
+ : TQScrollView(parent, 0, TQt::WDestructiveClose)
+{
+ d = new WorldMapWidgetPriv;
+
+ setVScrollBarMode(TQScrollView::AlwaysOff);
+ setHScrollBarMode(TQScrollView::AlwaysOff);
+ viewport()->setMouseTracking(true);
+ viewport()->setPaletteBackgroundColor(colorGroup().background());
+ setMinimumWidth(w);
+ setMaximumHeight(h);
+ resizeContents(worldMapPixmap().width(), worldMapPixmap().height());
+
+ d->latLonPos = new TQLabel(viewport());
+ d->latLonPos->setMaximumHeight(fontMetrics().height());
+ d->latLonPos->setAlignment(TQt::AlignHCenter | TQt::AlignVCenter);
+ d->latLonPos->setFrameStyle(TQFrame::Panel | TQFrame::Sunken);
+ addChild(d->latLonPos);
+}
+
+WorldMapWidget::~WorldMapWidget()
+{
+ delete d;
+}
+
+TQPixmap &WorldMapWidget::worldMapPixmap()
+{
+ if (!d->worldMap)
+ {
+ TDEGlobal::dirs()->addResourceType("worldmap", TDEGlobal::dirs()->kde_default("data") + "digikam/data");
+ TQString directory = TDEGlobal::dirs()->findResourceDir("worldmap", "worldmap.jpg");
+ pixmapDeleter.setObject(d->worldMap, new TQPixmap(directory + "worldmap.jpg"));
+ }
+ return *d->worldMap;
+}
+
+double WorldMapWidget::getLatitude()
+{
+ return d->latitude;
+}
+
+double WorldMapWidget::getLongitude()
+{
+ return d->longitude;
+}
+
+void WorldMapWidget::setEnabled(bool b)
+{
+ if (!b)
+ d->latLonPos->hide();
+ else
+ d->latLonPos->show();
+
+ TQScrollView::setEnabled(b);
+}
+
+void WorldMapWidget::setGPSPosition(double lat, double lng)
+{
+ d->latitude = lat;
+ d->longitude = lng;
+
+ double latMid = contentsHeight() / 2.0;
+ double longMid = contentsWidth() / 2.0;
+
+ double latOffset = ( d->latitude * latMid ) / 90.0;
+ double longOffset = ( d->longitude * longMid ) / 180.0;
+
+ d->xPos = (int)(longMid + longOffset);
+ d->yPos = (int)(latMid - latOffset);
+
+ repaintContents(false);
+ center(d->xPos, d->yPos);
+
+ TQString la, lo;
+ d->latLonPos->setText(TQString("(%1, %2)").arg(la.setNum(d->latitude, 'f', 2))
+ .arg(lo.setNum(d->longitude, 'f', 2)));
+
+ moveChild(d->latLonPos, contentsX()+10, contentsY()+10);
+}
+
+void WorldMapWidget::drawContents(TQPainter *p, int x, int y, int w, int h)
+{
+ if (isEnabled())
+ {
+ p->drawPixmap(x, y, worldMapPixmap(), x, y, w, h);
+ p->setPen(TQPen(TQt::white, 0, TQt::SolidLine));
+ p->drawLine(d->xPos, 0, d->xPos, contentsHeight());
+ p->drawLine(0, d->yPos, contentsWidth(), d->yPos);
+ p->setPen(TQPen(TQt::red, 0, TQt::DotLine));
+ p->drawLine(d->xPos, 0, d->xPos, contentsHeight());
+ p->drawLine(0, d->yPos, contentsWidth(), d->yPos);
+ p->setPen( TQt::red );
+ p->setBrush( TQt::red );
+ p->drawEllipse( d->xPos-2, d->yPos-2, 4, 4 );
+ }
+ else
+ {
+ p->fillRect(x, y, w, h, palette().disabled().background());
+ }
+}
+
+void WorldMapWidget::contentsMousePressEvent ( TQMouseEvent * e )
+{
+ if ( e->button() == TQt::LeftButton )
+ {
+ d->xMousePos = e->x();
+ d->yMousePos = e->y();
+ setCursor( KCursor::sizeAllCursor() );
+ }
+}
+
+void WorldMapWidget::contentsMouseReleaseEvent ( TQMouseEvent * )
+{
+ unsetCursor();
+}
+
+void WorldMapWidget::contentsMouseMoveEvent( TQMouseEvent * e )
+{
+ if ( e->state() == TQt::LeftButton )
+ {
+ uint newxpos = e->x();
+ uint newypos = e->y();
+
+ scrollBy (-(newxpos - d->xMousePos), -(newypos - d->yMousePos));
+ repaintContents(false);
+
+ d->xMousePos = newxpos - (newxpos-d->xMousePos);
+ d->yMousePos = newypos - (newypos-d->yMousePos);
+ return;
+ }
+
+ setCursor( KCursor::handCursor() );
+}
+
+} // namespace Digikam
+
diff --git a/src/libs/widgets/metadata/worldmapwidget.h b/src/libs/widgets/metadata/worldmapwidget.h
new file mode 100644
index 00000000..bfb8ad8f
--- /dev/null
+++ b/src/libs/widgets/metadata/worldmapwidget.h
@@ -0,0 +1,73 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2006-02-20
+ * Description : a widget to display GPS info on a world map
+ *
+ * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef WORLDMAPWIDGET_H
+#define WORLDMAPWIDGET_H
+
+// TQt includes.
+
+#include <tqscrollview.h>
+
+// Local includes.
+
+#include "digikam_export.h"
+
+namespace Digikam
+{
+
+class WorldMapWidgetPriv;
+
+class DIGIKAM_EXPORT WorldMapWidget : public TQScrollView
+{
+TQ_OBJECT
+
+
+public:
+
+ WorldMapWidget(int w, int h, TQWidget *parent);
+ ~WorldMapWidget();
+
+ void setGPSPosition(double lat, double lng);
+
+ double getLatitude();
+ double getLongitude();
+ void setEnabled(bool);
+
+private:
+
+ void drawContents(TQPainter *p, int x, int y, int w, int h);
+ void contentsMousePressEvent ( TQMouseEvent * e );
+ void contentsMouseReleaseEvent ( TQMouseEvent * e );
+ void contentsMouseMoveEvent( TQMouseEvent * e );
+
+ TQPixmap &worldMapPixmap();
+
+private:
+
+ WorldMapWidgetPriv *d;
+
+};
+
+} // namespace Digikam
+
+#endif /* WORLDMAPWIDGET_H */