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 <stdio.h>
#include <QDebug> #include <QDebug>
#include <QImageReader> #include <QImageReader>
Picture::Picture(QWidget *parent) : Picture::Picture(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::Picture){ ui(new Ui::Picture){
@ -36,41 +35,49 @@ void Picture::changeDirectory(){
if(path.isNull()==false){ if(path.isNull()==false){
directory.setPath(path); directory.setPath(path);
fillList(); fillList();
ui->log->append("Changed directory to: "+path+"/");
}else{
ui->log->append("Could not change directory");
} }
//exec("which exiv2>>/tmp/log");
} }
void Picture::fillList() { void Picture::fillList() {
ui->fileList->clear(); ui->fileList->clear();
ui->fileList->addItems(directory.entryList()); ui->fileList->addItems(directory.entryList());
} }
void Picture::on_cd_clicked(){ void Picture::on_cd_clicked(){
changeDirectory(); changeDirectory();
} }
void Picture::on_erase_clicked(){ void Picture::on_erase_clicked(){
bool ignored=false;
foreach(const QString &str,directory.entryList()){ foreach(const QString &str,directory.entryList()){
QString tmp=QString("exiv2 rm "); QString tmp=QString("exiv2 rm ");
QImageReader reader(directory.absolutePath()+"/"+str); QImageReader reader(directory.absolutePath()+"/"+str);
if(!reader.format().isEmpty()){ if(!reader.format().isEmpty()){
tmp+=directory.absolutePath()+"/"+str+">>/tmp/log"; tmp+=directory.absolutePath()+"/"+str+">>/tmp/log";
std::string tmp2=tmp.toStdString(); std::string tmp2=tmp.toStdString();
char* a=new char[tmp2.size()+1]; char* a=new char[tmp2.size()+1];
a[tmp2.size()]=0; a[tmp2.size()]=0;
memcpy(a,tmp2.c_str(),tmp2.size()); memcpy(a,tmp2.c_str(),tmp2.size());
exec(a); exec(a);
}else{ }else{
tmp="echo "+directory.absolutePath()+"/"+str+">>/tmp/log"; if(!ignored){
std::string tmp2=tmp.toStdString(); ignored=true;
char* a=new char[tmp2.size()+1]; ui->log->append("Ignored Files:");
a[tmp2.size()]=0; }
memcpy(a,tmp2.c_str(),tmp2.size()); ui->log->append(str);
exec(a);
} }
} }
ui->log->append("Done erasing metadata");
} }
void Picture::on_refresh_clicked(){ void Picture::on_refresh_clicked(){
fillList(); 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_refresh_clicked();
void on_clearLog_clicked();
void on_erase_pressed();
private: private:
Ui::Picture *ui; Ui::Picture *ui;
QDir directory; QDir directory;

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>656</width>
<height>300</height> <height>350</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -60,13 +60,39 @@
<string>Erase Metadata</string> <string>Erase Metadata</string>
</property> </property>
</widget> </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>
<widget class="QMenuBar" name="menuBar"> <widget class="QMenuBar" name="menuBar">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>656</width>
<height>21</height> <height>21</height>
</rect> </rect>
</property> </property>