Added label functionality. Erase and label functionality now works 100picture.cpp. Starting to work on "Erase GPS data" checkbox now...

This commit is contained in:
Austen Adler 2014-06-21 17:17:00 -04:00
parent fdfdffc9b0
commit 8d5e2e4e81
3 changed files with 79 additions and 4 deletions

View File

@ -18,6 +18,7 @@ Picture::~Picture(){
} }
void Picture::dragEnterEvent(QDragEnterEvent *event){ void Picture::dragEnterEvent(QDragEnterEvent *event){
if(event->mimeData()->hasUrls()){ if(event->mimeData()->hasUrls()){
ui->tabField->setCurrentIndex(0);
event->acceptProposedAction(); event->acceptProposedAction();
} }
} }
@ -73,8 +74,7 @@ void Picture::on_erase_clicked(){
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();
Exiv2::ExifData &exifData = image->exifData(); image->clearMetadata();
exifData["Exif.Photo.UserComment"] = "charset=Ascii An ASCII Exif comment added with Exiv2";
image->writeMetadata(); image->writeMetadata();
}catch(Exiv2::AnyError& e){ }catch(Exiv2::AnyError& e){
QMessageBox msgBox; QMessageBox msgBox;
@ -107,3 +107,44 @@ void Picture::on_erase_pressed(){
ui->tabField->setCurrentIndex(1); ui->tabField->setCurrentIndex(1);
on_erase_clicked(); on_erase_clicked();
} }
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;
QStringList myStringList;
for (int i = 0; i < ui->fileList->count(); ++i)
myStringList.append(ui->fileList->item(i)->text());
qDebug() << myStringList;
//foreach(const QString &str,directory.entryList()){
foreach(const QString &str,myStringList){
QImageReader reader(str);
if(!reader.format().isEmpty()){
QString fullPath=str;
try{
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString());
assert (image.get() != 0);
image->readMetadata();
Exiv2::ExifData &exifData = image->exifData();
exifData["Exif.Photo.UserComment"] = "charset=Ascii "+ui->labelText->text().toStdString();
image->writeMetadata();
}catch(Exiv2::AnyError& e){
QMessageBox msgBox;
msgBox.setInformativeText("The program could not process the file: "+fullPath);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
int ret=msgBox.exec();
}
}else{
if(!ignored){
ignored=true;
ui->log->append("Ignored Files:");
}
ui->log->append(str);
}
}
ui->log->append("Done erasing metadata");
}

View File

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

View File

@ -19,7 +19,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>521</width> <width>651</width>
<height>411</height> <height>411</height>
</rect> </rect>
</property> </property>
@ -66,12 +66,42 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton"> <spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="labelLabel">
<property name="text"> <property name="text">
<string>Label</string> <string>Label</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QLineEdit" name="labelText"/>
</item>
<item>
<widget class="QCheckBox" name="eraseGpsData">
<property name="text">
<string>Erase GPS Data</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="processButton">
<property name="text">
<string>Process</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>