Fixed small issues and added markers

This commit is contained in:
Austen Adler 2014-06-24 00:07:14 -04:00
parent b346ed838b
commit ab3fe277b5

View File

@ -1,4 +1,7 @@
//Includes{{{
#include "picture.h" #include "picture.h"
//}}}
//Decleration{{{
Picture::Picture(QWidget *parent) : Picture::Picture(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::Picture){ ui(new Ui::Picture){
@ -11,6 +14,8 @@ Picture::Picture(QWidget *parent) :
Picture::~Picture(){ Picture::~Picture(){
delete ui; delete ui;
} }
//}}}
//Drag and Drop{{{
void Picture::dragEnterEvent(QDragEnterEvent *event){ void Picture::dragEnterEvent(QDragEnterEvent *event){
if(event->mimeData()->hasUrls()){ if(event->mimeData()->hasUrls()){
ui->tabField->setCurrentIndex(0); ui->tabField->setCurrentIndex(0);
@ -23,6 +28,23 @@ void Picture::dropEvent(QDropEvent *event){
ui->fileList->addItem(fileName); ui->fileList->addItem(fileName);
} }
} }
//}}}
//Fill List{{{
void Picture::fillList() {
ui->fileList->clear();
foreach(const QString &str,directory.entryList()){
QImageReader reader(directory.absolutePath()+"/"+str);
if(!reader.format().isEmpty()){
QString itemString=directory.path()+"/"+str;
ui->fileList->addItem(itemString);
}
}
}
//}}}
//Change Directory{{{
void Picture::on_cd_clicked(){
changeDirectory();
}
void Picture::changeDirectory(){ void Picture::changeDirectory(){
QString path=QFileDialog::getExistingDirectory(this,tr("Directory"),directory.path()); QString path=QFileDialog::getExistingDirectory(this,tr("Directory"),directory.path());
if(path.isNull()==false){ if(path.isNull()==false){
@ -33,48 +55,41 @@ void Picture::changeDirectory(){
ui->log->append("Could not change directory"); ui->log->append("Could not change directory");
} }
} }
void Picture::fillList() { //}}}
ui->fileList->clear(); //Clear File List{{{
//ui->fileList->addItems(directory.entryList());
foreach(const QString &str,directory.entryList()){
QImageReader reader(directory.absolutePath()+"/"+str);
if(!reader.format().isEmpty()){
QString itemString=directory.path()+"/"+str;
ui->fileList->addItem(itemString);
}
}
if(ui->fileList->count()==0){
//ui->fileList->addItem("<NO PICTURES>");
}
}
void Picture::on_cd_clicked(){
changeDirectory();
}
void Picture::on_refresh_clicked(){ void Picture::on_refresh_clicked(){
//fillList();
ui->fileList->clear(); ui->fileList->clear();
ui->log->append("Cleared File List"); ui->log->append("Cleared File List");
} }
//}}}
//Clear Log{{{
void Picture::on_clearLog_clicked(){ void Picture::on_clearLog_clicked(){
ui->log->setText(""); ui->log->setText("");
ui->tabField->setCurrentIndex(0); ui->tabField->setCurrentIndex(0);
} }
//}}}
//Process Images{{{
//Switch Tab{{{
void Picture::on_processButton_pressed(){ void Picture::on_processButton_pressed(){
ui->log->append("Processing images..."); ui->log->append("Processing images...");
ui->tabField->setCurrentIndex(1); ui->tabField->setCurrentIndex(1);
on_processButton_clicked(); on_processButton_clicked();
} }
//}}}
void Picture::on_processButton_clicked(){ void Picture::on_processButton_clicked(){
bool ignored=false; bool ignored=false;
//Populate File List{{{
QStringList myStringList; QStringList myStringList;
for (int i=0;i<ui->fileList->count();++i){ for(int i=0;i<ui->fileList->count();++i){
myStringList.append(ui->fileList->item(i)->text()); myStringList.append(ui->fileList->item(i)->text());
} }
//}}}
foreach(const QString &str,myStringList){ foreach(const QString &str,myStringList){
QImageReader reader(str); QImageReader reader(str);
if(!reader.format().isEmpty()){ if(!reader.format().isEmpty()){
QString fullPath=str; QString fullPath=str;
try{ try{
//Label Images{{{
if(ui->labelImagesRadio->isChecked()){ if(ui->labelImagesRadio->isChecked()){
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString());
assert (image.get() != 0); assert (image.get() != 0);
@ -85,13 +100,17 @@ void Picture::on_processButton_clicked(){
Exiv2::ExifData &exifData=image->exifData(); Exiv2::ExifData &exifData=image->exifData();
exifData["Exif.Photo.UserComment"] = "charset=Ascii "+ui->labelText->text().toStdString(); exifData["Exif.Photo.UserComment"] = "charset=Ascii "+ui->labelText->text().toStdString();
image->writeMetadata(); image->writeMetadata();
//}}}
//Erase Metadata{{{
}else{ }else{
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString());
assert (image.get() != 0); assert(image.get()!=0);
image->readMetadata(); image->readMetadata();
image->clearMetadata(); image->clearMetadata();
image->writeMetadata(); image->writeMetadata();
} }
//}}}
//Catch{{{
}catch(Exiv2::AnyError& e){ }catch(Exiv2::AnyError& e){
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setInformativeText("The program could not process the file: "+fullPath); msgBox.setInformativeText("The program could not process the file: "+fullPath);
@ -99,6 +118,8 @@ void Picture::on_processButton_clicked(){
msgBox.setDefaultButton(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec(); msgBox.exec();
} }
//}}}
//List Ignored Files{{{
}else{ }else{
if(!ignored){ if(!ignored){
ignored=true; ignored=true;
@ -106,6 +127,8 @@ void Picture::on_processButton_clicked(){
} }
ui->log->append(str); ui->log->append(str);
} }
//}}}
} }
ui->log->append("Done erasing metadata"); ui->log->append("Done processing metadata");
} }
//}}}