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

« back to all changes in this revision

Viewing changes to libs/widgets/metadata/exifwidget.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer, Rohan Garg, Philip Muškovac, Felix Geyer
  • Date: 2011-09-23 18:18:55 UTC
  • mfrom: (1.2.36 upstream)
  • Revision ID: package-import@ubuntu.com-20110923181855-ifs67wxkugshev9k
Tags: 2:2.1.1-0ubuntu1
[ Rohan Garg ]
* New upstream release (LP: #834190)
  - debian/control
    + Build with libqtwebkit-dev
 - debian/kipi-plugins-common
    + Install libkvkontakte required by kipi-plugins
 - debian/digikam
    + Install panoramagui

[ Philip Muškovac ]
* New upstream release
  - debian/control:
    + Add libcv-dev, libcvaux-dev, libhighgui-dev, libboost-graph1.46-dev,
      libksane-dev, libxml2-dev, libxslt-dev, libqt4-opengl-dev, libqjson-dev,
      libgpod-dev and libqca2-dev to build-deps
    + Add packages for kipi-plugins, libmediawiki, libkface, libkgeomap and
      libkvkontakte
  - debian/rules:
    + Don't build with gphoto2 since it doesn't build with it.
  - Add kubuntu_fix_test_linking.diff to fix linking of the dngconverter test
  - update install files
  - update kubuntu_01_mysqld_executable_name.diff for new cmake layout
    and rename to kubuntu_mysqld_executable_name.diff
* Fix typo in digikam-data description (LP: #804894)
* Fix Vcs links

[ Felix Geyer ]
* Move library data files to the new packages libkface-data, libkgeomap-data
  and libkvkontakte-data.
* Override version of the embedded library packages to 1.0~digikam<version>.
* Exclude the library packages from digikam-dbg to prevent file conflicts in
  the future.
* Call dh_install with --list-missing.

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        : 2006-02-20
7
 
 * Description : a widget to display Standard Exif metadata
8
 
 *
9
 
 * Copyright (C) 2006-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 "exifwidget.moc"
25
 
 
26
 
// Qt includes
27
 
 
28
 
#include <QMap>
29
 
#include <QFile>
30
 
 
31
 
// KDE includes
32
 
 
33
 
 
34
 
#include <klocale.h>
35
 
 
36
 
// Local includes
37
 
 
38
 
#include "dmetadata.h"
39
 
#include "metadatalistview.h"
40
 
 
41
 
namespace Digikam
42
 
{
43
 
 
44
 
// Standard Exif Entry list from to less important to the most important for photograph.
45
 
static const char* StandardExifEntryList[] =
46
 
{
47
 
    "Iop",
48
 
    "Thumbnail",
49
 
    "SubImage1",
50
 
    "SubImage2",
51
 
    "Image",
52
 
    "Photo",
53
 
    "GPSInfo",
54
 
    "-1"
55
 
};
56
 
 
57
 
ExifWidget::ExifWidget(QWidget* parent, const char* name)
58
 
    : MetadataWidget(parent, name)
59
 
{
60
 
    view()->setSortingEnabled(false);
61
 
 
62
 
    for (int i=0 ; QString(StandardExifEntryList[i]) != QString("-1") ; ++i)
63
 
    {
64
 
        m_keysFilter << StandardExifEntryList[i];
65
 
    }
66
 
}
67
 
 
68
 
ExifWidget::~ExifWidget()
69
 
{
70
 
}
71
 
 
72
 
QString ExifWidget::getMetadataTitle()
73
 
{
74
 
    return i18n("Standard EXIF Tags");
75
 
}
76
 
 
77
 
bool ExifWidget::loadFromURL(const KUrl& url)
78
 
{
79
 
    setFileName(url.toLocalFile());
80
 
 
81
 
    if (url.isEmpty())
82
 
    {
83
 
        setMetadata();
84
 
        return false;
85
 
    }
86
 
    else
87
 
    {
88
 
        DMetadata metadata(url.toLocalFile());
89
 
 
90
 
        if (!metadata.hasExif())
91
 
        {
92
 
            setMetadata();
93
 
            return false;
94
 
        }
95
 
        else
96
 
        {
97
 
            setMetadata(metadata);
98
 
        }
99
 
    }
100
 
 
101
 
    return true;
102
 
}
103
 
 
104
 
bool ExifWidget::decodeMetadata()
105
 
{
106
 
    DMetadata data = getMetadata();
107
 
 
108
 
    if (!data.hasExif())
109
 
    {
110
 
        return false;
111
 
    }
112
 
 
113
 
    // Update all metadata contents.
114
 
    setMetadataMap(data.getExifTagsDataList(m_keysFilter));
115
 
    return true;
116
 
}
117
 
 
118
 
void ExifWidget::buildView()
119
 
{
120
 
    if (getMode() == CUSTOM)
121
 
    {
122
 
        setIfdList(getMetadataMap(), m_keysFilter, getTagsFilter());
123
 
    }
124
 
    else
125
 
    {
126
 
        setIfdList(getMetadataMap(), m_keysFilter, QStringList() << QString("FULL"));
127
 
    }
128
 
 
129
 
    MetadataWidget::buildView();
130
 
}
131
 
 
132
 
QString ExifWidget::getTagTitle(const QString& key)
133
 
{
134
 
    DMetadata metadataIface;
135
 
    QString title = metadataIface.getExifTagTitle(key.toAscii());
136
 
 
137
 
    if (title.isEmpty())
138
 
    {
139
 
        return key.section('.', -1);
140
 
    }
141
 
 
142
 
    return title;
143
 
}
144
 
 
145
 
QString ExifWidget::getTagDescription(const QString& key)
146
 
{
147
 
    DMetadata metadataIface;
148
 
    QString desc = metadataIface.getExifTagDescription(key.toAscii());
149
 
 
150
 
    if (desc.isEmpty())
151
 
    {
152
 
        return i18n("No description available");
153
 
    }
154
 
 
155
 
    return desc;
156
 
}
157
 
 
158
 
void ExifWidget::slotSaveMetadataToFile()
159
 
{
160
 
    KUrl url = saveMetadataToFile(i18n("EXIF File to Save"),
161
 
                                  QString("*.exif|"+i18n("EXIF binary Files (*.exif)")));
162
 
 
163
 
#if KEXIV2_VERSION >= 0x010000
164
 
    storeMetadataToFile(url, getMetadata().getExifEncoded());
165
 
#else
166
 
    storeMetadataToFile(url, getMetadata().getExif());
167
 
#endif
168
 
}
169
 
 
170
 
}  // namespace Digikam