"Erase Other Metadata" checkbox added and works correctly

This commit is contained in:
Austen Adler 2014-06-22 19:51:33 -04:00
parent 8d5e2e4e81
commit e722dea0dc
3 changed files with 60 additions and 34 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.0.1, 2014-06-20T13:04:41. -->
<!-- Written by QtCreator 3.0.1, 2014-06-22T19:25:12. -->
<qtcreator>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>

View File

@ -113,38 +113,40 @@ void Picture::on_processButton_pressed(){
on_processButton_clicked();
}
void Picture::on_processButton_clicked(){
bool ignored=false;
QStringList myStringList;
for (int i = 0; i < ui->fileList->count(); ++i)
myStringList.append(ui->fileList->item(i)->text());
qDebug() << myStringList;
//foreach(const QString &str,directory.entryList()){
foreach(const QString &str,myStringList){
QImageReader reader(str);
if(!reader.format().isEmpty()){
QString fullPath=str;
try{
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString());
assert (image.get() != 0);
image->readMetadata();
Exiv2::ExifData &exifData = image->exifData();
exifData["Exif.Photo.UserComment"] = "charset=Ascii "+ui->labelText->text().toStdString();
image->writeMetadata();
}catch(Exiv2::AnyError& e){
QMessageBox msgBox;
msgBox.setInformativeText("The program could not process the file: "+fullPath);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
int ret=msgBox.exec();
bool ignored=false;
QStringList myStringList;
for (int i=0;i<ui->fileList->count();++i){
myStringList.append(ui->fileList->item(i)->text());
}
qDebug()<<myStringList;
foreach(const QString &str,myStringList){
QImageReader reader(str);
if(!reader.format().isEmpty()){
QString fullPath=str;
try{
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString());
assert (image.get() != 0);
image->readMetadata();
if(ui->eraseOtherMetadata->isChecked()){
image->clearMetadata();
}
}else{
if(!ignored){
ignored=true;
ui->log->append("Ignored Files:");
}
ui->log->append(str);
Exiv2::ExifData &exifData=image->exifData();
exifData["Exif.Photo.UserComment"] = "charset=Ascii "+ui->labelText->text().toStdString();
image->writeMetadata();
}catch(Exiv2::AnyError& e){
QMessageBox msgBox;
msgBox.setInformativeText("The program could not process the file: "+fullPath);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}else{
if(!ignored){
ignored=true;
ui->log->append("Ignored Files:");
}
ui->log->append(str);
}
ui->log->append("Done erasing metadata");
}
ui->log->append("Done erasing metadata");
}

View File

@ -61,7 +61,7 @@
<item>
<widget class="QPushButton" name="erase">
<property name="text">
<string>Erase Metadata</string>
<string>Erase All Metadata</string>
</property>
</widget>
</item>
@ -88,6 +88,13 @@
<item>
<widget class="QLineEdit" name="labelText"/>
</item>
<item>
<widget class="QCheckBox" name="eraseOtherMetadata">
<property name="text">
<string>Erase Other Metadata</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="eraseGpsData">
<property name="text">
@ -167,5 +174,22 @@
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
<connections>
<connection>
<sender>eraseOtherMetadata</sender>
<signal>toggled(bool)</signal>
<receiver>eraseGpsData</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>428</x>
<y>367</y>
</hint>
<hint type="destinationlabel">
<x>432</x>
<y>387</y>
</hint>
</hints>
</connection>
</connections>
</ui>