-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexivbackend.cpp
175 lines (160 loc) · 6.52 KB
/
exivbackend.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#include "exivbackend.h"
exivBackend::exivBackend(QObject *parent) : QObject(parent),_signalOutput(new QWidget)
{
}
void exivBackend::newImage(QString path)
{
_scroller= new QScrollArea();
_signalOutput=new QWidget(_scroller);
QGridLayout *frame=new QGridLayout(_signalOutput);
try{
ex2::Image::UniquePtr image=ex2::ImageFactory::open(path.toStdString());
if(image.get() == nullptr)
return;
image->readMetadata();
_exifD = image->exifData();
_xmpD = image->xmpData();
_iptcD = image->iptcData();
if (!_exifD.empty()) {
int count=0;
qDebug()<<"Exif Scope\n";
ex2::ExifData::const_iterator end=_exifD.end();
for (ex2::ExifData::const_iterator i= _exifD.begin(); i != end; ++i) {
if(i->tagLabel()!=""){
/*
std::cout<<i->tagLabel()<<"\t"
<< "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << i->tag() << std::dec << "\t"
<< i->groupName() << "\t"
<< i->typeName() << "\t"
<< i->count() << "\t"
<< i->print(&_exifD)
<< "\n";
*/
QLabel *lbl=new QLabel(QString(i->tagLabel().c_str()));
frame->addWidget(lbl,count,0,Qt::AlignLeft);
}
else {
QLabel *lbl=new QLabel(QString("0x")+QString::number(i->tag(),16));
frame->addWidget(lbl,count,0,Qt::AlignLeft);
}
QLabel *ltag=new QLabel(QString::fromStdString(i->print()).trimmed());
if(ltag->text().size()>40){
// ltag->text().chop(ltag->text().size()-40);
ltag->setText(ltag->text().remove(40,ltag->text().size()-40));
ltag->setWordWrap(true);
}
frame->addWidget(ltag,count,1,Qt::AlignLeft);
///TODO add stuff for other types
QtMaterialFlatButton *btn=new QtMaterialFlatButton("...");
btn->setFontSize(16);
btn->setHaloVisible(false);
btn->setForegroundColor(QColor(255,255,255));
///TODO add Button Signals connections
frame->addWidget(btn,count,2,Qt::AlignRight);
count++;
}
_scroller->setWidget(_signalOutput);
emit MetaTypeDone(_scroller,1);
}
else{
QLabel *nf= new QLabel();
nf->setText("No Exif Record Found"); //TODO change Fonts and stuff
_scroller->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
frame->addWidget(nf,0,0, Qt::AlignHCenter | Qt::AlignVCenter);
// frame->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
_scroller->setWidget(_signalOutput);
emit MetaTypeDone(_scroller,1);
}
//reInitilize for next use
_scroller= new QScrollArea();
_signalOutput=new QWidget(_scroller);
frame=new QGridLayout(_signalOutput);
if(!_xmpD.empty()){
int count=0;
qDebug()<<"XMP Scope\n";
ex2::XmpData::const_iterator end=_xmpD.end();
for (ex2::XmpData::const_iterator i= _xmpD.begin(); i != end; ++i) {
//std::cout << i->key() << "\t" << i->typeName() << "\t" << i->count() << "\t" << "\n";
if(i->tagLabel()!=""){
QLabel *lbl=new QLabel(QString(i->tagLabel().c_str()));
frame->addWidget(lbl,count,0,Qt::AlignLeft);
}
else{
QLabel *lbl=new QLabel(QString("0x")+QString::number(i->tag(),16));
frame->addWidget(lbl,count,0,Qt::AlignLeft);
}
QLabel *ltag=new QLabel(QString::fromStdString(i->print()).trimmed());
if(ltag->text().size()>40){
ltag->setText(ltag->text().remove(40,ltag->text().size()-40));
ltag->setWordWrap(true);
}
frame->addWidget(ltag,count,1,Qt::AlignLeft);
QtMaterialFlatButton *btn=new QtMaterialFlatButton("...");
btn->setFontSize(16);
btn->setHaloVisible(false);
btn->setForegroundColor(QColor(255,255,255));
///TODO add Button Signals connections
frame->addWidget(btn,count,2,Qt::AlignRight);
count++;
}
_scroller->setWidget(_signalOutput);
emit MetaTypeDone(_scroller,2);
}
else {
QLabel *nf= new QLabel();
nf->setText("No XMP Record Found");
_scroller->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
frame->addWidget(nf,0,0, Qt::AlignHCenter | Qt::AlignVCenter);
_scroller->setWidget(_signalOutput);
emit MetaTypeDone(_scroller,2);
}
_scroller= new QScrollArea();
_signalOutput=new QWidget(_scroller);
frame=new QGridLayout(_signalOutput);
if(!_iptcD.empty()){
int count =0 ;
qDebug()<<"IPTC Scope\n";
ex2::IptcData::const_iterator end=_iptcD.end();
for (ex2::IptcData::const_iterator i= _iptcD.begin(); i != end; ++i) {
// std::cout << i->key() << "\n";
if(i->tagLabel()!=""){
QLabel *lbl=new QLabel(QString(i->tagLabel().c_str()));
frame->addWidget(lbl,count,0,Qt::AlignLeft);
}
else{
QLabel *lbl=new QLabel(QString("0x")+QString::number(i->tag(),16));
frame->addWidget(lbl,count,0,Qt::AlignLeft);
}
QLabel *ltag=new QLabel(QString::fromStdString(i->print()).trimmed());
if(ltag->text().size()>40){
ltag->setText(ltag->text().remove(40,ltag->text().size()-40));
ltag->setWordWrap(true);
}
frame->addWidget(ltag,count,1,Qt::AlignLeft);
QtMaterialFlatButton *btn=new QtMaterialFlatButton("...");
btn->setFontSize(16);
btn->setHaloVisible(false);
btn->setForegroundColor(QColor(255,255,255));
///TODO add Button Signals connections
frame->addWidget(btn,count,2,Qt::AlignRight);
count++;
}
_scroller->setWidget(_signalOutput);
emit MetaTypeDone(_scroller,3);
}
else{
QLabel *nf= new QLabel();
nf->setText("No IPTC Record Found");
_scroller->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
frame->addWidget(nf,0,0, Qt::AlignHCenter | Qt::AlignVCenter);
_scroller->setWidget(_signalOutput);
emit MetaTypeDone(_scroller,3);
}
}
catch(ex2::AnyError& e)
{
std::cout << "Caught Exiv2 exception '" << e << "'\n";
}
return;
}