From 899c0a6543507409db192a21a9aa0e0f2e3082f1 Mon Sep 17 00:00:00 2001 From: Austen Date: Thu, 19 Jun 2014 11:39:37 -0400 Subject: [PATCH] Working though issue 1 --- picture.cpp | 32 +++++++------------------------- picture.h | 4 ++-- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/picture.cpp b/picture.cpp index f269c82..3dc6223 100644 --- a/picture.cpp +++ b/picture.cpp @@ -3,34 +3,10 @@ Picture::Picture(QWidget *parent) : QMainWindow(parent), ui(new Ui::Picture){ ui->setupUi(this); - connect(&commandProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(log())); - connect(&commandProcess,SIGNAL(readyReadStandardError()),this,SLOT(log())); connect(ui->actionOpen_Files,SIGNAL(triggered()),this,SLOT(changeDirectory())); //changeDirectory(); fillList(); } -void Picture::log(){ - QByteArray cmdoutput = commandProcess.readAllStandardOutput(); - QString txtoutput = cmdoutput; - ui->log->append(txtoutput); - cmdoutput = commandProcess.readAllStandardError(); - txtoutput = cmdoutput; - ui->log->append(txtoutput); -} - -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; - } - } - pclose(pipe); - return result; -} Picture::~Picture(){ delete ui; } @@ -72,7 +48,13 @@ void Picture::on_erase_clicked(){ a[tmp2.size()]=0; memcpy(a,tmp2.c_str(),tmp2.size()); //exec(a); - commandProcess.start(a); + ui->log->append(str); + Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(str.toStdString()); + assert (image.get() != 0); + image->readMetadata(); + Exiv2::ExifData &exifData = image->exifData(); + exifData["Exif.Photo.UserComment"] = "charset=Ascii An ASCII Exif comment added with Exiv2"; + image->writeMetadata(); }else{ if(!ignored){ ignored=true; diff --git a/picture.h b/picture.h index ed733cf..807861f 100644 --- a/picture.h +++ b/picture.h @@ -14,6 +14,8 @@ #include #include #include +#include +#include namespace Ui { class Picture; @@ -35,10 +37,8 @@ private slots: void on_refresh_clicked(); void on_clearLog_clicked(); void on_erase_pressed(); - void log(); private: Ui::Picture *ui; QDir directory; - QProcess commandProcess; }; #endif // PICTURE_H