diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-17 08:33:13 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-17 08:33:13 +0000 |
commit | 5543c8d9438bdee5065f9c30e418f9b664aee170 (patch) | |
tree | 3f360005ae611849a11adab769c34033dee2147f /digikam/libs/widgets/metadata | |
download | digikam-5543c8d9438bdee5065f9c30e418f9b664aee170.tar.gz digikam-5543c8d9438bdee5065f9c30e418f9b664aee170.zip |
Added developer-abandoned KDE3 version of Digikam
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/digikam@1075997 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'digikam/libs/widgets/metadata')
19 files changed, 2736 insertions, 0 deletions
diff --git a/digikam/libs/widgets/metadata/Makefile.am b/digikam/libs/widgets/metadata/Makefile.am new file mode 100644 index 0000000..3ae468f --- /dev/null +++ b/digikam/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) + +INCLUDES = -I$(top_srcdir)/digikam/libs/dmetadata \ + -I$(top_srcdir)/digikam/libs/dimg \ + -I$(top_srcdir)/digikam/libs/themeengine \ + -I$(top_srcdir)/digikam/libs/widgets/common \ + -I$(top_srcdir)/digikam/digikam \ + $(LIBKEXIV2_CFLAGS) \ + $(all_includes) diff --git a/digikam/libs/widgets/metadata/exifwidget.cpp b/digikam/libs/widgets/metadata/exifwidget.cpp new file mode 100644 index 0000000..f0a269a --- /dev/null +++ b/digikam/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. + * + * ============================================================ */ + +// Qt includes. + +#include <qmap.h> +#include <qfile.h> + +// KDE includes. + +#include <klocale.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(QWidget* parent, const char* name) + : MetadataWidget(parent, name) +{ + view()->setSortColumn(-1); + + for (int i=0 ; QString(StandardExifEntryList[i]) != QString("-1") ; i++) + m_keysFilter << StandardExifEntryList[i]; + + for (int i=0 ; QString(ExifHumanList[i]) != QString("-1") ; i++) + m_tagsfilter << ExifHumanList[i]; +} + +ExifWidget::~ExifWidget() +{ +} + +QString 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()); + QByteArray 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, QStringList()); + } + + MetadataWidget::buildView(); +} + +QString ExifWidget::getTagTitle(const QString& key) +{ + DMetadata meta; + QString title = meta.getExifTagTitle(key.ascii()); + + if (title.isEmpty()) + return key.section('.', -1); + + return title; +} + +QString ExifWidget::getTagDescription(const QString& key) +{ + DMetadata meta; + QString 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"), + QString("*.exif|"+i18n("EXIF binary Files (*.exif)"))); + storeMetadataToFile(url); +} + +} // namespace Digikam diff --git a/digikam/libs/widgets/metadata/exifwidget.h b/digikam/libs/widgets/metadata/exifwidget.h new file mode 100644 index 0000000..54217da --- /dev/null +++ b/digikam/libs/widgets/metadata/exifwidget.h @@ -0,0 +1,72 @@ +/* ============================================================ + * + * 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 + +// Qt includes. + +#include <qstring.h> + +// Local includes. + +#include "metadatawidget.h" +#include "digikam_export.h" + +namespace Digikam +{ + +class DIGIKAM_EXPORT ExifWidget : public MetadataWidget +{ + Q_OBJECT + +public: + + ExifWidget(QWidget* parent, const char* name=0); + ~ExifWidget(); + + bool loadFromURL(const KURL& url); + + QString getTagDescription(const QString& key); + QString getTagTitle(const QString& key); + + QString getMetadataTitle(); + +protected slots: + + virtual void slotSaveMetadataToFile(); + +private: + + bool decodeMetadata(); + void buildView(); + +private: + + QStringList m_tagsfilter; + QStringList m_keysFilter; +}; + +} // namespace Digikam + +#endif /* EXIFWIDGET_H */ diff --git a/digikam/libs/widgets/metadata/gpswidget.cpp b/digikam/libs/widgets/metadata/gpswidget.cpp new file mode 100644 index 0000000..34ee2da --- /dev/null +++ b/digikam/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 +*/ + +// Qt includes. + +#include <qlayout.h> +#include <qpushbutton.h> +#include <qmap.h> +#include <qhbox.h> +#include <qfile.h> +#include <qcombobox.h> +#include <qgroupbox.h> + +// KDE includes. + +#include <kdialogbase.h> +#include <klocale.h> +#include <kapplication.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; + } + + QStringList tagsfilter; + QStringList keysFilter; + + QPushButton *detailsButton; + + QComboBox *detailsCombo; + + WorldMapWidget *map; +}; + +GPSWidget::GPSWidget(QWidget* parent, const char* name) + : MetadataWidget(parent, name) +{ + d = new GPSWidgetPriv; + + for (int i=0 ; QString(StandardExifGPSEntryList[i]) != QString("-1") ; i++) + d->keysFilter << StandardExifGPSEntryList[i]; + + for (int i=0 ; QString(ExifGPSHumanList[i]) != QString("-1") ; i++) + d->tagsfilter << ExifGPSHumanList[i]; + + // -------------------------------------------------------- + + QWidget *gpsInfo = new QWidget(this); + QGridLayout *layout = new QGridLayout(gpsInfo, 3, 2); + d->map = new WorldMapWidget(256, 256, gpsInfo); + + // -------------------------------------------------------- + + QGroupBox* box2 = new QGroupBox( 0, Qt::Vertical, gpsInfo ); + box2->setInsideMargin(0); + box2->setInsideSpacing(0); + box2->setFrameStyle( QFrame::NoFrame ); + QGridLayout* box2Layout = new QGridLayout( box2->layout(), 0, 2, KDialog::spacingHint() ); + + d->detailsCombo = new QComboBox( false, box2 ); + d->detailsButton = new QPushButton(i18n("More Info..."), box2); + d->detailsCombo->insertItem(QString("MapQuest"), MapQuest); + d->detailsCombo->insertItem(QString("Google Maps"), GoogleMaps); + d->detailsCombo->insertItem(QString("MSN Maps"), MsnMaps); + d->detailsCombo->insertItem(QString("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 QSpacerItem(KDialog::spacingHint(), KDialog::spacingHint(), + QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 1, 1, 0, 2); + layout->addMultiCellWidget(box2, 2, 2, 0, 0); + layout->setColStretch(2, 10); + layout->setRowStretch(3, 10); + + // -------------------------------------------------------- + + connect(d->detailsButton, SIGNAL(clicked()), + this, 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() +{ + QString 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; + } + } + + KApplication::kApplication()->invokeBrowser(url); +} + +QString 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()); + QByteArray 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, QStringList()); + } + + MetadataWidget::buildView(); +} + +QString GPSWidget::getTagTitle(const QString& key) +{ + DMetadata meta; + QString title = meta.getExifTagTitle(key.ascii()); + + if (title.isEmpty()) + return key.section('.', -1); + + return title; +} + +QString GPSWidget::getTagDescription(const QString& key) +{ + DMetadata meta; + QString 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"), + QString("*.exif|"+i18n("EXIF binary Files (*.exif)"))); + storeMetadataToFile(url); +} + +} // namespace Digikam diff --git a/digikam/libs/widgets/metadata/gpswidget.h b/digikam/libs/widgets/metadata/gpswidget.h new file mode 100644 index 0000000..3718138 --- /dev/null +++ b/digikam/libs/widgets/metadata/gpswidget.h @@ -0,0 +1,94 @@ +/* ============================================================ + * + * 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 + +// Qt includes. + +#include <qwidget.h> +#include <qstring.h> + +// Local includes. + +#include "metadatawidget.h" +#include "digikam_export.h" + +namespace Digikam +{ + +class GPSWidgetPriv; +class WorldMapWidget; + +class DIGIKAM_EXPORT GPSWidget : public MetadataWidget +{ + Q_OBJECT + +public: + + enum WebGPSLocator + { + MapQuest = 0, + GoogleMaps, + MsnMaps, + MultiMap + }; + +public: + + GPSWidget(QWidget* parent, const char* name=0); + ~GPSWidget(); + + bool loadFromURL(const KURL& url); + + QString getTagDescription(const QString& key); + QString getTagTitle(const QString& key); + + QString 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/digikam/libs/widgets/metadata/iptcwidget.cpp b/digikam/libs/widgets/metadata/iptcwidget.cpp new file mode 100644 index 0000000..f841422 --- /dev/null +++ b/digikam/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. + * + * ============================================================ */ + +// Qt includes. + +#include <qmap.h> +#include <qfile.h> + +// KDE includes. + +#include <klocale.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(QWidget* parent, const char* name) + : MetadataWidget(parent, name) +{ + for (int i=0 ; QString(StandardIptcEntryList[i]) != QString("-1") ; i++) + m_keysFilter << StandardIptcEntryList[i]; + + for (int i=0 ; QString(IptcHumanList[i]) != QString("-1") ; i++) + m_tagsfilter << IptcHumanList[i]; +} + +IptcWidget::~IptcWidget() +{ +} + +QString 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()); + QByteArray 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(); +} + +QString IptcWidget::getTagTitle(const QString& key) +{ + DMetadata meta; + QString title = meta.getIptcTagTitle(key.ascii()); + + if (title.isEmpty()) + return key.section('.', -1); + + return title; +} + +QString IptcWidget::getTagDescription(const QString& key) +{ + DMetadata meta; + QString 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"), + QString("*.iptc|"+i18n("IPTC binary Files (*.iptc)"))); + storeMetadataToFile(url); +} + +} // namespace Digikam + diff --git a/digikam/libs/widgets/metadata/iptcwidget.h b/digikam/libs/widgets/metadata/iptcwidget.h new file mode 100644 index 0000000..f1d57a8 --- /dev/null +++ b/digikam/libs/widgets/metadata/iptcwidget.h @@ -0,0 +1,68 @@ +/* ============================================================ + * + * 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 +{ + Q_OBJECT + +public: + + IptcWidget(QWidget* parent, const char* name=0); + ~IptcWidget(); + + bool loadFromURL(const KURL& url); + + QString getTagDescription(const QString& key); + QString getTagTitle(const QString& key); + + QString getMetadataTitle(); + +protected slots: + + virtual void slotSaveMetadataToFile(); + +private: + + bool decodeMetadata(); + void buildView(); + +private: + + QStringList m_tagsfilter; + QStringList m_keysFilter; +}; + +} // namespace Digikam + +#endif /* IPTCWIDGET_H */ diff --git a/digikam/libs/widgets/metadata/makernotewidget.cpp b/digikam/libs/widgets/metadata/makernotewidget.cpp new file mode 100644 index 0000000..75072b5 --- /dev/null +++ b/digikam/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. + * + * ============================================================ */ + +// Qt includes. + +#include <qmap.h> +#include <qfile.h> + +// KDE includes. + +#include <klocale.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(QWidget* parent, const char* name) + : MetadataWidget(parent, name) +{ + for (int i=0 ; QString(ExifEntryListToIgnore[i]) != QString("-1") ; i++) + m_keysFilter << ExifEntryListToIgnore[i]; + + for (int i=0 ; QString(MakerNoteHumanList[i]) != QString("-1") ; i++) + m_tagsfilter << MakerNoteHumanList[i]; +} + +MakerNoteWidget::~MakerNoteWidget() +{ +} + +QString 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()); + QByteArray 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(); +} + +QString MakerNoteWidget::getTagTitle(const QString& key) +{ + DMetadata meta; + QString title = meta.getExifTagTitle(key.ascii()); + + if (title.isEmpty()) + return key.section('.', -1); + + return title; +} + +QString MakerNoteWidget::getTagDescription(const QString& key) +{ + DMetadata meta; + QString 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"), + QString("*.exif|"+i18n("EXIF binary Files (*.exif)"))); + storeMetadataToFile(url); +} + +} // namespace Digikam diff --git a/digikam/libs/widgets/metadata/makernotewidget.h b/digikam/libs/widgets/metadata/makernotewidget.h new file mode 100644 index 0000000..be5bd7e --- /dev/null +++ b/digikam/libs/widgets/metadata/makernotewidget.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 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 +{ + Q_OBJECT + +public: + + MakerNoteWidget(QWidget* parent, const char* name=0); + ~MakerNoteWidget(); + + bool loadFromURL(const KURL& url); + + QString getTagDescription(const QString& key); + QString getTagTitle(const QString& key); + + QString getMetadataTitle(); + +protected slots: + + virtual void slotSaveMetadataToFile(); + +private: + + bool decodeMetadata(); + void buildView(); + +private: + + QStringList m_tagsfilter; + QStringList m_keysFilter; +}; + +} // namespace Digikam + +#endif /* MARKERNOTEWIDGET_H */ diff --git a/digikam/libs/widgets/metadata/mdkeylistviewitem.cpp b/digikam/libs/widgets/metadata/mdkeylistviewitem.cpp new file mode 100644 index 0000000..36bf65d --- /dev/null +++ b/digikam/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. + * + * ============================================================ */ + +// Qt includes. + +#include <qpalette.h> +#include <qfont.h> +#include <qpainter.h> + +// KDE includes. + +#include <klocale.h> + +// Local includes. + +#include "themeengine.h" +#include "ddebug.h" +#include "mdkeylistviewitem.h" + +namespace Digikam +{ + +MdKeyListViewItem::MdKeyListViewItem(QListView *parent, const QString& key) + : QListViewItem(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() +{ +} + +QString MdKeyListViewItem::getMdKey() +{ + return m_decryptedKey; +} + +void MdKeyListViewItem::paintCell(QPainter* p, const QColorGroup&, + int column, int, int) +{ + p->save(); + QFont fn(p->font()); + fn.setBold(true); + fn.setItalic(false); + p->setFont(fn); + p->setPen(ThemeEngine::instance()->textSelColor()); + int width = listView()->contentsWidth(); + QRect rect(0, 0, width, fn.weight()); + + if (column == 1) + rect.moveLeft(-width/2); + + p->fillRect(rect, ThemeEngine::instance()->thumbSelColor()); + p->drawText(rect, Qt::AlignHCenter, m_decryptedKey); + p->restore(); +} + +} // namespace Digikam diff --git a/digikam/libs/widgets/metadata/mdkeylistviewitem.h b/digikam/libs/widgets/metadata/mdkeylistviewitem.h new file mode 100644 index 0000000..f034bbb --- /dev/null +++ b/digikam/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 + +// Qt includes. + +#include <qstring.h> +#include <qlistview.h> + +// Local includes. + +#include "digikam_export.h" + +class QPainter; + +namespace Digikam +{ + +class DIGIKAM_EXPORT MdKeyListViewItem : public QListViewItem +{ + +public: + + MdKeyListViewItem(QListView *parent, const QString& key); + ~MdKeyListViewItem(); + + QString getMdKey(); + +protected: + + void paintCell(QPainter*, const QColorGroup &, int, int, int); + +private: + + QString m_decryptedKey; +}; + +} // namespace Digikam + +#endif /* MDKEYLISTVIEWITEM_H */ diff --git a/digikam/libs/widgets/metadata/metadatalistview.cpp b/digikam/libs/widgets/metadata/metadatalistview.cpp new file mode 100644 index 0000000..b829823 --- /dev/null +++ b/digikam/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. + * + * ============================================================ */ + +// Qt includes. + +#include <qtimer.h> +#include <qptrlist.h> +#include <qpalette.h> +#include <qheader.h> +#include <qwhatsthis.h> + +// KDE includes. + +#include <klocale.h> + +// Local includes. + +#include "mdkeylistviewitem.h" +#include "metadatalistviewitem.h" +#include "metadatalistview.h" +#include "metadatalistview.moc" + +namespace Digikam +{ + +MetadataListView::MetadataListView(QWidget* parent) + : QListView(parent) +{ + header()->hide(); + addColumn("Name"); // No need i18n here. + addColumn("Value"); // No need i18n here. + setItemMargin(0); + setAllColumnsShowFocus(true); + setResizeMode(QListView::AllColumns); + // Vertical scroll bar is always disable to give more + // free space to metadata content + setVScrollBarMode(QScrollView::AlwaysOff); + + m_parent = dynamic_cast<MetadataWidget *>(parent); + + connect(this, SIGNAL(selectionChanged(QListViewItem*)), + this, SLOT(slotSelectionChanged(QListViewItem*))); +} + +MetadataListView::~MetadataListView() +{ +} + +QString MetadataListView::getCurrentItemKey() +{ + if (currentItem()) + { + if (currentItem()->isSelectable()) + { + MetadataListViewItem *item = static_cast<MetadataListViewItem *>(currentItem()); + return item->getKey(); + } + } + + return QString(); +} + +void MetadataListView::setCurrentItemByKey(QString itemKey) +{ + if (itemKey.isNull()) + return; + + QListViewItemIterator 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(QListViewItem *item) +{ + if (!item) + return; + + MetadataListViewItem* viewItem = static_cast<MetadataListViewItem *>(item); + m_selectedItemKey = viewItem->getKey(); + QString tagValue = viewItem->getValue().simplifyWhiteSpace(); + QString tagTitle = m_parent->getTagTitle(m_selectedItemKey); + QString tagDesc = m_parent->getTagDescription(m_selectedItemKey); + if (tagValue.length() > 128) + { + tagValue.truncate(128); + tagValue.append("..."); + } + + QWhatsThis::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 QStringList& tagsfilter) +{ + clear(); + + uint subItems = 0; + QString ifDItemName; + MdKeyListViewItem *parentifDItem = 0; + + for (DMetadata::MetaDataMap::const_iterator it = ifds.begin(); it != ifds.end(); ++it) + { + // We checking if we have changed of ifDName + QString 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))) + { + QString tagTitle = m_parent->getTagTitle(it.key()); + new MetadataListViewItem(parentifDItem, it.key(), tagTitle, it.data()); + subItems++; + } + } + else + { + // We don't filter the output (Complete Mode) + + QString 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); + QTimer::singleShot( 0, this, SLOT( triggerUpdate() ) ); +} + +void MetadataListView::setIfdList(const DMetadata::MetaDataMap& ifds, const QStringList& keysFilter, + const QStringList& tagsFilter) +{ + clear(); + + uint subItems = 0; + MdKeyListViewItem *parentifDItem = 0; + + for (QStringList::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))) + { + QString tagTitle = m_parent->getTagTitle(it.key()); + new MetadataListViewItem(parentifDItem, it.key(), tagTitle, it.data()); + subItems++; + } + } + else + { + // We don't filter the output (Complete Mode) + + QString 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); + QTimer::singleShot( 0, this, SLOT( triggerUpdate() ) ); +} + +void MetadataListView::viewportResizeEvent(QResizeEvent* e) +{ + QListView::viewportResizeEvent(e); + QTimer::singleShot( 0, this, SLOT( triggerUpdate() ) ); +} + +void MetadataListView::slotSearchTextChanged(const QString& filter) +{ + bool query = false; + QString search = filter.lower(); + + QListViewItemIterator 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/digikam/libs/widgets/metadata/metadatalistview.h b/digikam/libs/widgets/metadata/metadatalistview.h new file mode 100644 index 0000000..2fa415d --- /dev/null +++ b/digikam/libs/widgets/metadata/metadatalistview.h @@ -0,0 +1,84 @@ +/* ============================================================ + * + * 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 + +// Qt includes. + +#include <qstring.h> +#include <qptrlist.h> +#include <qmap.h> +#include <qlistview.h> + +// Local includes. + +#include "metadatawidget.h" +#include "digikam_export.h" + +namespace Digikam +{ + +class DIGIKAM_EXPORT MetadataListView : public QListView +{ + Q_OBJECT + +public: + + MetadataListView(QWidget* parent); + ~MetadataListView(); + + QString getCurrentItemKey(); + void setCurrentItemByKey(QString itemKey); + + void setIfdList(const DMetadata::MetaDataMap& ifds, const QStringList& tagsfilter); + void setIfdList(const DMetadata::MetaDataMap& ifds, const QStringList& keysFilter, + const QStringList& tagsFilter); + +signals: + + void signalTextFilterMatch(bool); + +public slots: + + void slotSearchTextChanged(const QString&); + +protected: + + void viewportResizeEvent(QResizeEvent*); + +private slots: + + void slotSelectionChanged(QListViewItem *item); + +private: + + QString m_selectedItemKey; + + MetadataWidget *m_parent; +}; + +} // namespace Digikam + +#endif // METADATALISTVIEW_H diff --git a/digikam/libs/widgets/metadata/metadatalistviewitem.cpp b/digikam/libs/widgets/metadata/metadatalistviewitem.cpp new file mode 100644 index 0000000..dafdf95 --- /dev/null +++ b/digikam/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. + * + * ============================================================ */ + +// Qt includes. + +#include <qpalette.h> +#include <qfont.h> +#include <qpainter.h> + +// Local includes. + +#include "metadatalistviewitem.h" + +namespace Digikam +{ + +MetadataListViewItem::MetadataListViewItem(QListViewItem *parent, const QString& key, + const QString& title, const QString& value) + : QListViewItem(parent) +{ + m_key = key; + + setSelectable(true); + setText(0, title); + + QString tagVal = value.simplifyWhiteSpace(); + if (tagVal.length() > 128) + { + tagVal.truncate(128); + tagVal.append("..."); + } + setText(1, tagVal); +} + +MetadataListViewItem::~MetadataListViewItem() +{ +} + +QString MetadataListViewItem::getKey() +{ + return m_key; +} + +QString MetadataListViewItem::getTitle() +{ + return text(0); +} + +QString MetadataListViewItem::getValue() +{ + return text(1); +} + +} // namespace Digikam diff --git a/digikam/libs/widgets/metadata/metadatalistviewitem.h b/digikam/libs/widgets/metadata/metadatalistviewitem.h new file mode 100644 index 0000000..9159986 --- /dev/null +++ b/digikam/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 + +// Qt includes. + +#include <qstring.h> +#include <qlistview.h> + +// Local includes. + +#include "digikam_export.h" + +namespace Digikam +{ + +class DIGIKAM_EXPORT MetadataListViewItem : public QListViewItem +{ +public: + + MetadataListViewItem(QListViewItem *parent, const QString& key, + const QString& title, const QString& value); + ~MetadataListViewItem(); + + QString getKey(); + QString getTitle(); + QString getValue(); + +private: + + QString m_key; +}; + +} // namespace Digikam + +#endif /* METADATALISTVIEWITEM_H */ diff --git a/digikam/libs/widgets/metadata/metadatawidget.cpp b/digikam/libs/widgets/metadata/metadatawidget.cpp new file mode 100644 index 0000000..168036a --- /dev/null +++ b/digikam/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. + * + * ============================================================ */ + +// Qt includes. + +#include <qlayout.h> +#include <qmap.h> +#include <qfile.h> +#include <qmime.h> +#include <qheader.h> +#include <qwhatsthis.h> +#include <qpainter.h> +#include <qhbuttongroup.h> +#include <qpushbutton.h> +#include <qlabel.h> +#include <qdragobject.h> +#include <qclipboard.h> +#include <qsimplerichtext.h> +#include <qpaintdevicemetrics.h> +#include <qstylesheet.h> +#include <qlistview.h> +#include <qtooltip.h> + +// KDE includes. + +#include <kdialogbase.h> +#include <klocale.h> +#include <kfiledialog.h> +#include <kglobalsettings.h> +#include <kprinter.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <kapplication.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; + } + + QGridLayout *mainLayout; + + QHButtonGroup *toolButtons; + QHButtonGroup *levelButtons; + + QByteArray metadata; + + QString fileName; + + MetadataListView *view; + + SearchTextBar *searchBar; + + DMetadata::MetaDataMap metaDataMap; +}; + +MetadataWidget::MetadataWidget(QWidget* parent, const char* name) + : QWidget(parent, name) +{ + d = new MetadataWidgetPriv; + + d->mainLayout = new QGridLayout(this, 3, 4, KDialog::spacingHint(), KDialog::spacingHint()); + KIconLoader *iconLoader = KApplication::kApplication()->iconLoader(); + + d->levelButtons = new QHButtonGroup(this); + d->levelButtons->setInsideMargin( 0 ); + d->levelButtons->setExclusive(true); + d->levelButtons->setFrameShape(QFrame::NoFrame); + + QPushButton *simpleLevel = new QPushButton( d->levelButtons ); + simpleLevel->setPixmap( iconLoader->loadIcon( "ascii", (KIcon::Group)KIcon::Toolbar ) ); + simpleLevel->setToggleButton(true); + QWhatsThis::add( simpleLevel, i18n( "Switch the tags view to a simple human-readable list" ) ); + QToolTip::add( simpleLevel, i18n( "Simple list" )); + d->levelButtons->insert(simpleLevel, SIMPLE); + + QPushButton *fullLevel = new QPushButton( d->levelButtons ); + fullLevel->setPixmap( iconLoader->loadIcon( "document", (KIcon::Group)KIcon::Toolbar ) ); + fullLevel->setToggleButton(true); + QWhatsThis::add( fullLevel, i18n( "Switch the tags view to a full list" ) ); + QToolTip::add( fullLevel, i18n( "Full list" )); + d->levelButtons->insert(fullLevel, FULL); + + d->toolButtons = new QHButtonGroup(this); + d->toolButtons->setInsideMargin( 0 ); + d->toolButtons->setFrameShape(QFrame::NoFrame); + + QPushButton *saveMetadata = new QPushButton( d->toolButtons ); + saveMetadata->setPixmap( iconLoader->loadIcon( "filesave", (KIcon::Group)KIcon::Toolbar ) ); + QWhatsThis::add( saveMetadata, i18n( "Save metadata to a binary file" ) ); + QToolTip::add( saveMetadata, i18n( "Save metadata" )); + d->toolButtons->insert(saveMetadata); + + QPushButton *printMetadata = new QPushButton( d->toolButtons ); + printMetadata->setPixmap( iconLoader->loadIcon( "fileprint", (KIcon::Group)KIcon::Toolbar ) ); + QWhatsThis::add( printMetadata, i18n( "Print metadata to printer" ) ); + QToolTip::add( printMetadata, i18n( "Print metadata" )); + d->toolButtons->insert(printMetadata); + + QPushButton *copy2ClipBoard = new QPushButton( d->toolButtons ); + copy2ClipBoard->setPixmap( iconLoader->loadIcon( "editcopy", (KIcon::Group)KIcon::Toolbar ) ); + QWhatsThis::add( copy2ClipBoard, i18n( "Copy metadata to clipboard" ) ); + QToolTip::add( copy2ClipBoard, i18n( "Copy metadata to clipboard" )); + d->toolButtons->insert(copy2ClipBoard); + + d->view = new MetadataListView(this); + QString barName = QString(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, SIGNAL(released(int)), + this, SLOT(slotModeChanged(int))); + + connect(copy2ClipBoard, SIGNAL(clicked()), + this, SLOT(slotCopy2Clipboard())); + + connect(printMetadata, SIGNAL(clicked()), + this, SLOT(slotPrintMetadata())); + + connect(saveMetadata, SIGNAL(clicked()), + this, SLOT(slotSaveMetadataToFile())); + + connect(d->searchBar, SIGNAL(signalTextChanged(const QString&)), + d->view, SLOT(slotSearchTextChanged(const QString&))); + + connect(d->view, SIGNAL(signalTextFilterMatch(bool)), + d->searchBar, 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 QByteArray& 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 QByteArray& MetadataWidget::getMetadata() +{ + return d->metadata; +} + +bool MetadataWidget::storeMetadataToFile(const KURL& url) +{ + if( url.isEmpty() ) + return false; + + QFile file(url.path()); + if ( !file.open(IO_WriteOnly) ) + return false; + + QDataStream 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 QStringList& tagsFilter) +{ + d->view->setIfdList(ifds, tagsFilter); +} + +void MetadataWidget::setIfdList(const DMetadata::MetaDataMap &ifds, const QStringList& keysFilter, + const QStringList& tagsFilter) +{ + d->view->setIfdList(ifds, keysFilter, tagsFilter); +} + +void MetadataWidget::slotModeChanged(int) +{ + buildView(); +} + +void MetadataWidget::slotCopy2Clipboard() +{ + QString textmetadata = i18n("File name: %1 (%2)").arg(d->fileName).arg(getMetadataTitle()); + QListViewItemIterator 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 + { + QListViewItem *item = it.current(); + textmetadata.append(item->text(0)); + textmetadata.append(" : "); + textmetadata.append(item->text(1)); + textmetadata.append("\n"); + } + + ++it; + } + + QApplication::clipboard()->setData(new QTextDrag(textmetadata), QClipboard::Clipboard); +} + +void MetadataWidget::slotPrintMetadata() +{ + QString textmetadata = i18n("<p><big><big><b>File name: %1 (%2)</b></big></big>") + .arg(d->fileName) + .arg(getMetadataTitle()); + QListViewItemIterator 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 + { + QListViewItem *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 ) ) + { + QPainter p( &printer ); + + if ( !p.device() ) + return; + + QPaintDeviceMetrics metrics(p.device()); + int dpiy = metrics.logicalDpiY(); + int margin = (int) ( (2/2.54)*dpiy ); // 2 cm margins + QRect view( margin, margin, metrics.width() - 2*margin, metrics.height() - 2*margin ); + QFont font(KApplication::font()); + font.setPointSize( 10 ); // we define 10pt to be a nice base size for printing + QSimpleRichText richText( textmetadata, font, + QString(), + QStyleSheet::defaultSheet(), + QMimeSourceFactory::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( QString::number( page ) ), + view.bottom() + p.fontMetrics().ascent() + 5, QString::number( page ) ); + + if ( view.top() - margin >= richText.height() ) + break; + + printer.newPage(); + page++; + } + while (true); + } +} + +KURL MetadataWidget::saveMetadataToFile(const QString& caption, const QString& fileFilter) +{ + KFileDialog fileSaveDialog(KGlobalSettings::documentPath(), + QString(), + 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; +} + +QString MetadataWidget::getCurrentItemKey() const +{ + return d->view->getCurrentItemKey(); +} + +void MetadataWidget::setCurrentItemByKey(const QString& itemKey) +{ + d->view->setCurrentItemByKey(itemKey); +} + +bool MetadataWidget::loadFromData(const QString& fileName, const QByteArray& data) +{ + setFileName(fileName); + return(setMetadata(data)); +} + +QString MetadataWidget::getTagTitle(const QString&) +{ + return QString(); +} + +QString MetadataWidget::getTagDescription(const QString&) +{ + return QString(); +} + +void MetadataWidget::setFileName(const QString& fileName) +{ + d->fileName = fileName; +} + +void MetadataWidget::setUserAreaWidget(QWidget *w) +{ + QVBoxLayout *vLayout = new QVBoxLayout( 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/digikam/libs/widgets/metadata/metadatawidget.h b/digikam/libs/widgets/metadata/metadatawidget.h new file mode 100644 index 0000000..b5b96ca --- /dev/null +++ b/digikam/libs/widgets/metadata/metadatawidget.h @@ -0,0 +1,119 @@ +/* ============================================================ + * + * 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 + +// Qt includes. + +#include <qwidget.h> +#include <qstring.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 QWidget +{ + Q_OBJECT + +public: + + enum Mode + { + SIMPLE=0, + FULL + }; + +public: + + MetadataWidget(QWidget* parent, const char* name=0); + ~MetadataWidget(); + + int getMode(); + void setMode(int mode); + + QString getCurrentItemKey() const; + void setCurrentItemByKey(const QString& itemKey); + + void setUserAreaWidget(QWidget *w); + + virtual QString getTagTitle(const QString& key); + virtual QString getTagDescription(const QString& key); + + virtual bool loadFromData(const QString &fileName, const QByteArray& data=QByteArray()); + 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 QString& fileName); + MetadataListView* view(); + + bool setMetadata(const QByteArray& data=QByteArray()); + const QByteArray& getMetadata(); + + void setMetadataMap(const DMetadata::MetaDataMap& data=DMetadata::MetaDataMap()); + const DMetadata::MetaDataMap& getMetadataMap(); + + void setIfdList(const DMetadata::MetaDataMap &ifds, const QStringList& tagsFilter=QStringList()); + void setIfdList(const DMetadata::MetaDataMap &ifds, const QStringList& keysFilter, + const QStringList& tagsFilter); + + KURL saveMetadataToFile(const QString& caption, const QString& fileFilter); + bool storeMetadataToFile(const KURL& url); + + virtual void buildView(); + virtual bool decodeMetadata()=0; + virtual QString getMetadataTitle()=0; + virtual void setMetadataEmpty(); + +private: + + MetadataWidgetPriv* d; +}; + +} // namespace Digikam + +#endif /* METADATAWIDGET_H */ diff --git a/digikam/libs/widgets/metadata/worldmapwidget.cpp b/digikam/libs/widgets/metadata/worldmapwidget.cpp new file mode 100644 index 0000000..3590be9 --- /dev/null +++ b/digikam/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. + * + * ============================================================ */ + +// Qt includes. + +#include <qpainter.h> +#include <qstring.h> +#include <qpixmap.h> +#include <qlabel.h> + +// KDE includes. + +#include <kstandarddirs.h> +#include <kcursor.h> +#include <klocale.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; + + QLabel *latLonPos; + + static QPixmap *worldMap; +}; + +static KStaticDeleter<QPixmap> pixmapDeleter; + +QPixmap *WorldMapWidgetPriv::worldMap = 0; + +WorldMapWidget::WorldMapWidget(int w, int h, QWidget *parent) + : QScrollView(parent, 0, Qt::WDestructiveClose) +{ + d = new WorldMapWidgetPriv; + + setVScrollBarMode(QScrollView::AlwaysOff); + setHScrollBarMode(QScrollView::AlwaysOff); + viewport()->setMouseTracking(true); + viewport()->setPaletteBackgroundColor(colorGroup().background()); + setMinimumWidth(w); + setMaximumHeight(h); + resizeContents(worldMapPixmap().width(), worldMapPixmap().height()); + + d->latLonPos = new QLabel(viewport()); + d->latLonPos->setMaximumHeight(fontMetrics().height()); + d->latLonPos->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + d->latLonPos->setFrameStyle(QFrame::Panel | QFrame::Sunken); + addChild(d->latLonPos); +} + +WorldMapWidget::~WorldMapWidget() +{ + delete d; +} + +QPixmap &WorldMapWidget::worldMapPixmap() +{ + if (!d->worldMap) + { + KGlobal::dirs()->addResourceType("worldmap", KGlobal::dirs()->kde_default("data") + "digikam/data"); + QString directory = KGlobal::dirs()->findResourceDir("worldmap", "worldmap.jpg"); + pixmapDeleter.setObject(d->worldMap, new QPixmap(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(); + + QScrollView::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); + + QString la, lo; + d->latLonPos->setText(QString("(%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(QPainter *p, int x, int y, int w, int h) +{ + if (isEnabled()) + { + p->drawPixmap(x, y, worldMapPixmap(), x, y, w, h); + p->setPen(QPen(Qt::white, 0, Qt::SolidLine)); + p->drawLine(d->xPos, 0, d->xPos, contentsHeight()); + p->drawLine(0, d->yPos, contentsWidth(), d->yPos); + p->setPen(QPen(Qt::red, 0, Qt::DotLine)); + p->drawLine(d->xPos, 0, d->xPos, contentsHeight()); + p->drawLine(0, d->yPos, contentsWidth(), d->yPos); + p->setPen( Qt::red ); + p->setBrush( Qt::red ); + p->drawEllipse( d->xPos-2, d->yPos-2, 4, 4 ); + } + else + { + p->fillRect(x, y, w, h, palette().disabled().background()); + } +} + +void WorldMapWidget::contentsMousePressEvent ( QMouseEvent * e ) +{ + if ( e->button() == Qt::LeftButton ) + { + d->xMousePos = e->x(); + d->yMousePos = e->y(); + setCursor( KCursor::sizeAllCursor() ); + } +} + +void WorldMapWidget::contentsMouseReleaseEvent ( QMouseEvent * ) +{ + unsetCursor(); +} + +void WorldMapWidget::contentsMouseMoveEvent( QMouseEvent * e ) +{ + if ( e->state() == Qt::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/digikam/libs/widgets/metadata/worldmapwidget.h b/digikam/libs/widgets/metadata/worldmapwidget.h new file mode 100644 index 0000000..1143b02 --- /dev/null +++ b/digikam/libs/widgets/metadata/worldmapwidget.h @@ -0,0 +1,72 @@ +/* ============================================================ + * + * 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 + +// Qt includes. + +#include <qscrollview.h> + +// Local includes. + +#include "digikam_export.h" + +namespace Digikam +{ + +class WorldMapWidgetPriv; + +class DIGIKAM_EXPORT WorldMapWidget : public QScrollView +{ +Q_OBJECT + +public: + + WorldMapWidget(int w, int h, QWidget *parent); + ~WorldMapWidget(); + + void setGPSPosition(double lat, double lng); + + double getLatitude(); + double getLongitude(); + void setEnabled(bool); + +private: + + void drawContents(QPainter *p, int x, int y, int w, int h); + void contentsMousePressEvent ( QMouseEvent * e ); + void contentsMouseReleaseEvent ( QMouseEvent * e ); + void contentsMouseMoveEvent( QMouseEvent * e ); + + QPixmap &worldMapPixmap(); + +private: + + WorldMapWidgetPriv *d; + +}; + +} // namespace Digikam + +#endif /* WORLDMAPWIDGET_H */ |