From e722dea0dce045513b18de5fa4c7a5896dc5121c Mon Sep 17 00:00:00 2001 From: Austen Date: Sun, 22 Jun 2014 19:51:33 -0400 Subject: [PATCH] "Erase Other Metadata" checkbox added and works correctly --- Picture.pro.user | 2 +- picture.cpp | 64 +++++++++++++++++++++++++----------------------- picture.ui | 28 +++++++++++++++++++-- 3 files changed, 60 insertions(+), 34 deletions(-) diff --git a/Picture.pro.user b/Picture.pro.user index 6bb30be..4b7332a 100644 --- a/Picture.pro.user +++ b/Picture.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/picture.cpp b/picture.cpp index c26cb08..0e6caef 100644 --- a/picture.cpp +++ b/picture.cpp @@ -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;ifileList->count();++i){ + myStringList.append(ui->fileList->item(i)->text()); + } + qDebug()<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"); } - diff --git a/picture.ui b/picture.ui index a9b7df2..ea002ac 100644 --- a/picture.ui +++ b/picture.ui @@ -61,7 +61,7 @@ - Erase Metadata + Erase All Metadata @@ -88,6 +88,13 @@ + + + + Erase Other Metadata + + + @@ -167,5 +174,22 @@ - + + + eraseOtherMetadata + toggled(bool) + eraseGpsData + setDisabled(bool) + + + 428 + 367 + + + 432 + 387 + + + +