[Digikam-devel] extragear/libs/kipi-plugins/metadataedit
Gilles Caulier
caulier.gilles at free.fr
Mon Nov 20 12:35:51 GMT 2006
SVN commit 606424 by cgilles:
kipi-plugins from trunk : MetadataEdit : new option to remove Comments to a group of pictures. This tool will remove comments from all selected pictures selected on host application. You can remove IPTC/EXIF/JFIF comments at the same time.
CCMAIL: digikam-devel at kde.org, kde-imaging at kde.org
M +1 -1 Makefile.am
M +3 -4 commenteditdialog.cpp
M +2 -3 commenteditdialog.h
A commentremovedialog.cpp [License: GPL]
A commentremovedialog.h [License: GPL]
M +78 -5 plugin_metadataedit.cpp
M +1 -0 plugin_metadataedit.h
--- trunk/extragear/libs/kipi-plugins/metadataedit/Makefile.am #606423:606424
@@ -16,7 +16,7 @@
iptceditdialog.cpp iptccaption.cpp iptcsubjects.cpp \
iptccredits.cpp iptcstatus.cpp iptcorigin.cpp \
iptcdatetime.cpp iptckeywords.cpp iptccategories.cpp \
- commenteditdialog.cpp
+ commenteditdialog.cpp commentremovedialog.cpp
# Libs needed by the plugin
kipiplugin_metadataedit_la_LIBADD = $(top_builddir)/kipi-plugins/common/exiv2iface/libexiv2iface.la \
--- trunk/extragear/libs/kipi-plugins/metadataedit/commenteditdialog.cpp #606423:606424
@@ -42,8 +42,6 @@
// Local includes.
#include "kpaboutdata.h"
-#include "pluginsversion.h"
-#include "exiv2iface.h"
#include "commenteditdialog.h"
#include "commenteditdialog.moc"
@@ -69,6 +67,7 @@
QCheckBox *syncIPTCCaptionCheck;
KTextEdit *userCommentEdit;
+
KIPIPlugins::KPAboutData *about;
};
@@ -159,7 +158,7 @@
config.setGroup("Comments Edit Settings");
setCheckedSyncJFIFComment(config.readBoolEntry("Sync JFIF Comment", true));
setCheckedSyncEXIFComment(config.readBoolEntry("Sync EXIF Comment", true));
- setCheckedIPTCCaption(config.readBoolEntry("Sync IPTC Caption", true));
+ setCheckedSyncIPTCCaption(config.readBoolEntry("Sync IPTC Caption", true));
resize(configDialogSize(config, QString("Comments Edit Dialog")));
}
@@ -210,7 +209,7 @@
d->syncEXIFCommentCheck->setChecked(c);
}
-void CommentEditDialog::setCheckedIPTCCaption(bool c)
+void CommentEditDialog::setCheckedSyncIPTCCaption(bool c)
{
d->syncIPTCCaptionCheck->setChecked(c);
}
--- trunk/extragear/libs/kipi-plugins/metadataedit/commenteditdialog.h #606423:606424
@@ -23,12 +23,11 @@
// Qt includes.
-#include <qcstring.h>
+#include <qstring.h>
// KDE includes.
#include <kdialogbase.h>
-#include <kurl.h>
namespace KIPIMetadataEditPlugin
{
@@ -50,7 +49,7 @@
void setCheckedSyncJFIFComment(bool c);
void setCheckedSyncEXIFComment(bool c);
- void setCheckedIPTCCaption(bool c);
+ void setCheckedSyncIPTCCaption(bool c);
QString getComments();
--- trunk/extragear/libs/kipi-plugins/metadataedit/plugin_metadataedit.cpp #606423:606424
@@ -42,6 +42,7 @@
#include "exifeditdialog.h"
#include "iptceditdialog.h"
#include "commenteditdialog.h"
+#include "commentremovedialog.h"
#include "plugin_metadataedit.h"
#include "plugin_metadataedit.moc"
@@ -124,6 +125,14 @@
actionCollection(),
"editcomments"));
+ m_actionMetadataEdit->insert(new KAction (i18n("Remove Comments..."),
+ 0,
+ 0,
+ this,
+ SLOT(slotRemoveComments()),
+ actionCollection(),
+ "removecomments"));
+
addAction( m_actionMetadataEdit );
m_interface = dynamic_cast< KIPI::Interface* >( parent() );
@@ -489,14 +498,78 @@
if (!errorURLs.isEmpty())
{
- KMessageBox::errorList(
- kapp->activeWindow(),
- i18n("Unable to set comments like picture metadata from:"),
- errorURLs.toStringList(),
- i18n("Edit Pictures Comments"));
+ KMessageBox::informationList(
+ kapp->activeWindow(),
+ i18n("Unable to set comments like picture metadata from:"),
+ errorURLs.toStringList(),
+ i18n("Edit Pictures Comments"));
}
}
+void Plugin_MetadataEdit::slotRemoveComments()
+{
+ KIPI::ImageCollection images = m_interface->currentSelection();
+
+ if ( !images.isValid() || images.images().isEmpty() )
+ return;
+
+ KIPIMetadataEditPlugin::CommentRemoveDialog dlg(kapp->activeWindow());
+
+ if (dlg.exec() != KMessageBox::Ok)
+ return;
+
+ KURL::List imageURLs = images.images();
+ KURL::List updatedURLs;
+ KURL::List errorURLs;
+
+ for( KURL::List::iterator it = imageURLs.begin() ;
+ it != imageURLs.end(); ++it)
+ {
+ KURL url = *it;
+ bool ret = false;
+
+ KIPI::ImageInfo info = m_interface->info(url);
+ info.setDescription(QString::null);
+
+ if (!KIPIPlugins::Exiv2Iface::isReadOnly(url.path()))
+ {
+ ret = true;
+ KIPIPlugins::Exiv2Iface exiv2Iface;
+ ret &= exiv2Iface.load(url.path());
+
+ if (dlg.removeEXIFCommentIsChecked())
+ ret &= exiv2Iface.removeExifTag("Exif.Photo.UserComment");
+
+ if (dlg.removeJFIFCommentIsChecked())
+ ret &= exiv2Iface.setComments(QByteArray());
+
+ if (dlg.removeIPTCCaptionIsChecked())
+ ret &= exiv2Iface.removeIptcTag("Iptc.Application2.Caption");
+
+ ret &= exiv2Iface.save(url.path());
+ }
+
+ if (!ret)
+ errorURLs.append(url);
+ else
+ updatedURLs.append(url);
+ }
+
+ // We use kipi interface refreshImages() method to tell to host than
+ // metadata from pictures have changed and need to be re-read.
+
+ m_interface->refreshImages(updatedURLs);
+
+ if (!errorURLs.isEmpty())
+ {
+ KMessageBox::informationList(
+ kapp->activeWindow(),
+ i18n("Unable to remove Comments like picture metadata from:"),
+ errorURLs.toStringList(),
+ i18n("Remove Pictures Comments"));
+ }
+}
+
KIPI::Category Plugin_MetadataEdit::category( KAction* action ) const
{
if ( action == m_actionMetadataEdit )
--- trunk/extragear/libs/kipi-plugins/metadataedit/plugin_metadataedit.h #606423:606424
@@ -49,6 +49,7 @@
void slotImportIptc();
void slotEditComments();
+ void slotRemoveComments();
private:
More information about the Digikam-devel
mailing list