~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to utilities/queuemanager/basetools/metadata/removemetadata.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-24 00:20:43 UTC
  • mfrom: (1.2.31 upstream)
  • Revision ID: james.westby@ubuntu.com-20101024002043-y7y9fg4rvxy0obcc
Tags: 2:1.5.0-0ubuntu1
* New upstream release
  - Bump build-dependencies
  - Build against libkipi-dev 1.5.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 *
 
3
 * This file is a part of digiKam project
 
4
 * http://www.digikam.org
 
5
 *
 
6
 * Date        : 2010-09-14
 
7
 * Description : remove metadata batch tool.
 
8
 *
 
9
 * Copyright (C) 2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
10
 *
 
11
 * This program is free software; you can redistribute it
 
12
 * and/or modify it under the terms of the GNU General
 
13
 * Public License as published by the Free Software Foundation;
 
14
 * either version 2, or (at your option)
 
15
 * any later version.
 
16
 *
 
17
 * This program is distributed in the hope that it will be useful,
 
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
 * GNU General Public License for more details.
 
21
 *
 
22
 * ============================================================ */
 
23
 
 
24
#include "removemetadata.moc"
 
25
 
 
26
// Qt includes
 
27
 
 
28
#include <QCheckBox>
 
29
#include <QWidget>
 
30
#include <QLabel>
 
31
 
 
32
// KDE includes
 
33
 
 
34
#include <kiconloader.h>
 
35
#include <klocale.h>
 
36
#include <kvbox.h>
 
37
 
 
38
// Local includes
 
39
 
 
40
#include "dimg.h"
 
41
#include "dmetadata.h"
 
42
 
 
43
namespace Digikam
 
44
{
 
45
 
 
46
RemoveMetadata::RemoveMetadata(QObject* parent)
 
47
              : BatchTool("RemoveMetadata", MetadataTool, parent)
 
48
{
 
49
    setToolTitle(i18n("Remove Metadata"));
 
50
    setToolDescription(i18n("A tool to remove Exif, Iptc, or Xmp metadata from images."));
 
51
    setToolIcon(KIcon(SmallIcon("exifinfo")));
 
52
 
 
53
    KVBox* vbox  = new KVBox;
 
54
    m_removeExif = new QCheckBox(i18n("Remove Exif"), vbox);
 
55
    m_removeIptc = new QCheckBox(i18n("Remove Iptc"), vbox);
 
56
    m_removeXmp  = new QCheckBox(i18n("Remove Xmp"), vbox);
 
57
 
 
58
    QLabel* space = new QLabel(vbox);
 
59
    vbox->setStretchFactor(space, 10);
 
60
 
 
61
    setSettingsWidget(vbox);
 
62
 
 
63
    connect(m_removeExif, SIGNAL(toggled(bool)),
 
64
            this, SLOT(slotSettingsChanged()));
 
65
 
 
66
    connect(m_removeIptc, SIGNAL(toggled(bool)),
 
67
            this, SLOT(slotSettingsChanged()));
 
68
 
 
69
    connect(m_removeXmp, SIGNAL(toggled(bool)),
 
70
            this, SLOT(slotSettingsChanged()));
 
71
}
 
72
 
 
73
RemoveMetadata::~RemoveMetadata()
 
74
{
 
75
}
 
76
 
 
77
BatchToolSettings RemoveMetadata::defaultSettings()
 
78
{
 
79
    BatchToolSettings settings;
 
80
    settings.insert("RemoveExif", false);
 
81
    settings.insert("RemoveIptc", false);
 
82
    settings.insert("RemoveXmp",  false);
 
83
    return settings;
 
84
}
 
85
 
 
86
void RemoveMetadata::slotAssignSettings2Widget()
 
87
{
 
88
    m_removeExif->setChecked(settings()["RemoveExif"].toBool());
 
89
    m_removeIptc->setChecked(settings()["RemoveIptc"].toBool());
 
90
    m_removeXmp->setChecked(settings()["RemoveXmp"].toBool());
 
91
}
 
92
 
 
93
void RemoveMetadata::slotSettingsChanged()
 
94
{
 
95
    BatchToolSettings settings;
 
96
    settings.insert("RemoveExif", m_removeExif->isChecked());
 
97
    settings.insert("RemoveIptc", m_removeIptc->isChecked());
 
98
    settings.insert("RemoveXmp",  m_removeXmp->isChecked());
 
99
    BatchTool::slotSettingsChanged(settings);
 
100
}
 
101
 
 
102
bool RemoveMetadata::toolOperations()
 
103
{
 
104
    bool removeExif = settings()["RemoveExif"].toBool();
 
105
    bool removeIptc = settings()["RemoveIptc"].toBool();
 
106
    bool removeXmp  = settings()["RemoveXmp"].toBool();
 
107
 
 
108
    if (!loadToDImg()) return false;
 
109
 
 
110
    DMetadata meta(image().getMetadata());
 
111
 
 
112
    if (removeExif) meta.clearExif();
 
113
 
 
114
    if (removeIptc) meta.clearIptc();
 
115
 
 
116
    if (removeXmp) meta.clearXmp();
 
117
 
 
118
    image().setMetadata(meta.data());
 
119
 
 
120
    return (savefromDImg());
 
121
}
 
122
 
 
123
}  // namespace Digikam