From 5e400c5d51d97f9da7446c09606274eed0b495ed Mon Sep 17 00:00:00 2001 From: Austen Date: Fri, 20 Jun 2014 13:39:10 -0400 Subject: [PATCH] Fixes directory problem with drag and rop --- Picture.pro | 3 +-- Picture.pro.user | 2 +- picture.cpp | 46 +++++++++++++-------------------- picture.ui | 6 ++--- preview.ui | 66 ------------------------------------------------ 5 files changed, 22 insertions(+), 101 deletions(-) delete mode 100644 preview.ui diff --git a/Picture.pro b/Picture.pro index 9e8b806..8de8f4f 100644 --- a/Picture.pro +++ b/Picture.pro @@ -17,8 +17,7 @@ SOURCES += main.cpp\ HEADERS += picture.h -FORMS += picture.ui \ - preview.ui +FORMS += picture.ui unix: CONFIG += link_pkgconfig unix: PKGCONFIG += exiv2 diff --git a/Picture.pro.user b/Picture.pro.user index 259c700..6bb30be 100644 --- a/Picture.pro.user +++ b/Picture.pro.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/picture.cpp b/picture.cpp index 0f3d712..2bf85b6 100644 --- a/picture.cpp +++ b/picture.cpp @@ -16,22 +16,20 @@ Picture::~Picture(){ delete ui; } void Picture::dragEnterEvent(QDragEnterEvent *event){ - if(event->mimeData()->hasUrls()){ - event->acceptProposedAction(); - - } + if(event->mimeData()->hasUrls()){ + event->acceptProposedAction(); + } } void Picture::dropEvent(QDropEvent *event){ - foreach (const QUrl &url, event->mimeData()->urls()) { - const QString &fileName = url.toLocalFile(); - - //if(fileName.contains(QRegExp("\.(?i)(jpe?g|png|gif)$"))){ - ui->fileList->addItem(fileName); - //}else{ - // qDebug()<mimeData()->urls()) { + const QString &fileName = url.toLocalFile(); + //if(fileName.contains(QRegExp("\.(?i)(jpe?g|png|gif)$"))){ + ui->fileList->addItem(fileName); + //}else{ + // qDebug()<fileList->count(); ++i) - myStringList.append(ui->fileList->item(i)->text()); - qDebug() << myStringList; + 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){ - QString tmp=QString("exiv2 rm "); - QImageReader reader(directory.absolutePath()+"/"+str); + QImageReader reader(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); - //ui->log->append(str); - QString fullPath=directory.absolutePath()+"/"+str; + QString fullPath=str; Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fullPath.toStdString()); assert (image.get() != 0); image->readMetadata(); diff --git a/picture.ui b/picture.ui index a118bd9..25dae5b 100644 --- a/picture.ui +++ b/picture.ui @@ -19,8 +19,8 @@ 0 0 - 393 - 279 + 521 + 411 @@ -75,8 +75,6 @@ - layoutWidget - layoutWidget diff --git a/preview.ui b/preview.ui deleted file mode 100644 index 92cccb3..0000000 --- a/preview.ui +++ /dev/null @@ -1,66 +0,0 @@ - - - Dialog - - - - 0 - 0 - 432 - 334 - - - - Dialog - - - - - 1 - 1 - 120 - 16 - - - - Process this picture? - - - - - - 1 - 22 - 431 - 311 - - - - - - - - - - No (n) - - - - - - - Yes (y) - - - - - - buttonBox - image - buttonBox - noButton - yesButton - - - -