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