From 28608056cb8c497d65dd7ee03206a790f0b56cdf Mon Sep 17 00:00:00 2001 From: Austen Date: Wed, 18 Jun 2014 15:23:12 -0400 Subject: [PATCH] Now successfully removes metadata --- Picture.pro.user | 2 +- picture.cpp | 69 +++++++++++++++++++++++++++++------------------- picture.h | 2 ++ picture.ui | 17 ++++++++++-- 4 files changed, 60 insertions(+), 30 deletions(-) diff --git a/Picture.pro.user b/Picture.pro.user index df5b813..04ea3a6 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 cf6a93b..7e690b6 100644 --- a/picture.cpp +++ b/picture.cpp @@ -5,57 +5,72 @@ #include #include #include +#include Picture::Picture(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::Picture){ + QMainWindow(parent), + ui(new Ui::Picture){ ui->setupUi(this); connect(ui->actionOpen_Files,SIGNAL(triggered()),this,SLOT(changeDirectory())); - changeDirectory(); + //changeDirectory(); fillList(); -} + } std::string exec(char* cmd) { - FILE* pipe = popen(cmd, "r"); - if (!pipe) return "ERROR"; - char buffer[128]; - std::string result = ""; - while(!feof(pipe)) { - if(fgets(buffer, 128, pipe) != NULL){ - result += buffer; - } + FILE* pipe = popen(cmd, "r"); + if (!pipe) return "ERROR"; + char buffer[128]; + std::string result = ""; + while(!feof(pipe)) { + if(fgets(buffer, 128, pipe) != NULL){ + result += buffer; } - pclose(pipe); - return result; + } + pclose(pipe); + return result; } Picture::~Picture(){ - delete ui; + delete ui; } void Picture::changeDirectory(){ - QString path=QFileDialog::getExistingDirectory(this,tr("Directory"),directory.path()); - if(path.isNull()==false){ - directory.setPath(path); - fillList(); - } - //exec("which exiv2>>/tmp/log"); + QString path=QFileDialog::getExistingDirectory(this,tr("Directory"),directory.path()); + if(path.isNull()==false){ + directory.setPath(path); + fillList(); + } + //exec("which exiv2>>/tmp/log"); } void Picture::fillList() { - ui->fileList->clear(); - ui->fileList->addItems(directory.entryList()); + ui->fileList->clear(); + ui->fileList->addItems(directory.entryList()); } void Picture::on_cd_clicked(){ - changeDirectory(); + changeDirectory(); } void Picture::on_erase_clicked(){ - foreach(const QString &str,directory.entryList()){ - QString tmp=QString("echo "); - tmp+=str+">>/tmp/log"; + foreach(const QString &str,directory.entryList()){ + QString tmp=QString("exiv2 rm "); + QImageReader reader(directory.absolutePath()+"/"+str); + if(!reader.format().isEmpty()){ + tmp+=directory.absolutePath()+"/"+str+">>/tmp/log"; + std::string tmp2=tmp.toStdString(); + char* a=new char[tmp2.size()+1]; + a[tmp2.size()]=0; + memcpy(a,tmp2.c_str(),tmp2.size()); + exec(a); + }else{ + tmp="echo "+directory.absolutePath()+"/"+str+">>/tmp/log"; std::string tmp2=tmp.toStdString(); char* a=new char[tmp2.size()+1]; a[tmp2.size()]=0; memcpy(a,tmp2.c_str(),tmp2.size()); exec(a); } + } +} + +void Picture::on_refresh_clicked(){ + fillList(); } diff --git a/picture.h b/picture.h index 735f14e..2ac99f1 100644 --- a/picture.h +++ b/picture.h @@ -25,6 +25,8 @@ private slots: void on_erase_clicked(); + void on_refresh_clicked(); + private: Ui::Picture *ui; QDir directory; diff --git a/picture.ui b/picture.ui index 06fb3be..f28cb45 100644 --- a/picture.ui +++ b/picture.ui @@ -37,9 +37,9 @@ - + - Erase Metadata + Refresh Directory @@ -47,6 +47,19 @@ + + + + 270 + 10 + 124 + 27 + + + + Erase Metadata + +