-
Notifications
You must be signed in to change notification settings - Fork 4
/
qmlexif.cpp
95 lines (76 loc) · 1.89 KB
/
qmlexif.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "qmlexif.h"
#include <libexif/exif-entry.h>
#include <libexif/exif-content.h>
QMLExif::QMLExif(QQuickItem *parent):
QQuickItem(parent)
, m_data(NULL)
{
// By default, QQuickItem does not draw anything. If you subclass
// QQuickItem to create a visual item, you will need to uncomment the
// following line and re-implement updatePaintNode()
// setFlag(ItemHasContents, true);
}
QMLExif::~QMLExif()
{
}
QString QMLExif::source() const
{
return m_source;
}
QString QMLExif::getTagName(QMLExif::QMLExifTag tag)
{
return QString(exif_tag_get_name_in_ifd((ExifTag)tag, (ExifIfd)m_ifd));
}
QString QMLExif::getTagTitle(QMLExif::QMLExifTag tag)
{
return QString(exif_tag_get_title_in_ifd((ExifTag)tag, (ExifIfd)m_ifd));
}
QString QMLExif::getTagDescription(QMLExif::QMLExifTag tag)
{
return QString(exif_tag_get_description_in_ifd((ExifTag)tag, (ExifIfd)m_ifd));
}
QString QMLExif::getTagValue(QMLExifTag tag)
{
if (! m_data)
return QString();
ExifEntry *entry = exif_content_get_entry(m_data->ifd[(ExifIfd)m_ifd], (ExifTag)tag);
if (entry){
char buf[1024];
exif_entry_get_value(entry, buf, sizeof(buf));
if (*buf) {
return QString(buf).trimmed();
}
}
return QString();
}
//QString QMLExif::getGPSValue(ExifTag tag)
//{
// Q_UNUSED (tag)
// return QString();
//}
QMap<QString, QString> QMLExif::getMakerNotes()
{
QMap<QString, QString> m;
return m;
}
QMLExif::QMLExifIfd QMLExif::ifd() const
{
return m_ifd;
}
void QMLExif::setSource(QString source)
{
if (source.isEmpty() || m_source == source)
return;
m_source = source;
m_data = exif_data_new_from_file(source.toUtf8().data());
if (! m_data)
return;
emit sourceChanged(source);
}
void QMLExif::setIfd(QMLExifIfd ifd)
{
if (m_ifd == ifd)
return;
m_ifd = ifd;
emit ifdChanged(ifd);
}