Now successfully changes directories and removes metadata. Added logging feature

This commit is contained in:
Austen Adler 2014-06-18 16:00:39 -04:00
parent 28608056cb
commit 8f9d74199b
3 changed files with 58 additions and 21 deletions

View File

@ -6,7 +6,6 @@
#include <stdio.h>
#include <QDebug>
#include <QImageReader>
Picture::Picture(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Picture){
@ -36,41 +35,49 @@ void Picture::changeDirectory(){
if(path.isNull()==false){
directory.setPath(path);
fillList();
ui->log->append("Changed directory to: "+path+"/");
}else{
ui->log->append("Could not change directory");
}
//exec("which exiv2>>/tmp/log");
}
void Picture::fillList() {
ui->fileList->clear();
ui->fileList->addItems(directory.entryList());
}
void Picture::on_cd_clicked(){
changeDirectory();
}
void Picture::on_erase_clicked(){
bool ignored=false;
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);
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);
if(!ignored){
ignored=true;
ui->log->append("Ignored Files:");
}
ui->log->append(str);
}
}
ui->log->append("Done erasing metadata");
}
void Picture::on_refresh_clicked(){
fillList();
}
void Picture::on_clearLog_clicked(){
ui->log->setText("");
}
void Picture::on_erase_pressed()
{
ui->log->append("Erasing metadata from images...");
}

View File

@ -27,6 +27,10 @@ private slots:
void on_refresh_clicked();
void on_clearLog_clicked();
void on_erase_pressed();
private:
Ui::Picture *ui;
QDir directory;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>656</width>
<height>350</height>
</rect>
</property>
<property name="windowTitle">
@ -60,13 +60,39 @@
<string>Erase Metadata</string>
</property>
</widget>
<widget class="QTextEdit" name="log">
<property name="geometry">
<rect>
<x>310</x>
<y>60</y>
<width>301</width>
<height>191</height>
</rect>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="clearLog">
<property name="geometry">
<rect>
<x>561</x>
<y>222</y>
<width>51</width>
<height>30</height>
</rect>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<width>656</width>
<height>21</height>
</rect>
</property>