Fixes directory problem with drag and rop

This commit is contained in:
Austen Adler 2014-06-20 13:39:10 -04:00
parent dd1400e35d
commit 5e400c5d51
5 changed files with 22 additions and 101 deletions

View File

@ -17,8 +17,7 @@ SOURCES += main.cpp\
HEADERS += picture.h HEADERS += picture.h
FORMS += picture.ui \ FORMS += picture.ui
preview.ui
unix: CONFIG += link_pkgconfig unix: CONFIG += link_pkgconfig
unix: PKGCONFIG += exiv2 unix: PKGCONFIG += exiv2

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.0.1, 2014-06-18T20:10:29. --> <!-- Written by QtCreator 3.0.1, 2014-06-20T13:04:41. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>ProjectExplorer.Project.ActiveTarget</variable> <variable>ProjectExplorer.Project.ActiveTarget</variable>

View File

@ -18,13 +18,11 @@ Picture::~Picture(){
void Picture::dragEnterEvent(QDragEnterEvent *event){ void Picture::dragEnterEvent(QDragEnterEvent *event){
if(event->mimeData()->hasUrls()){ if(event->mimeData()->hasUrls()){
event->acceptProposedAction(); event->acceptProposedAction();
} }
} }
void Picture::dropEvent(QDropEvent *event){ void Picture::dropEvent(QDropEvent *event){
foreach (const QUrl &url, event->mimeData()->urls()) { foreach (const QUrl &url, event->mimeData()->urls()) {
const QString &fileName = url.toLocalFile(); const QString &fileName = url.toLocalFile();
//if(fileName.contains(QRegExp("\.(?i)(jpe?g|png|gif)$"))){ //if(fileName.contains(QRegExp("\.(?i)(jpe?g|png|gif)$"))){
ui->fileList->addItem(fileName); ui->fileList->addItem(fileName);
//}else{ //}else{
@ -68,17 +66,9 @@ void Picture::on_erase_clicked(){
qDebug() << myStringList; qDebug() << myStringList;
//foreach(const QString &str,directory.entryList()){ //foreach(const QString &str,directory.entryList()){
foreach(const QString &str,myStringList){ foreach(const QString &str,myStringList){
QString tmp=QString("exiv2 rm "); QImageReader reader(str);
QImageReader reader(directory.absolutePath()+"/"+str);
if(!reader.format().isEmpty()){ if(!reader.format().isEmpty()){
tmp+=directory.absolutePath()+"/"+str+">>/tmp/log"; QString fullPath=str;
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;
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();

View File

@ -19,8 +19,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>393</width> <width>521</width>
<height>279</height> <height>411</height>
</rect> </rect>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
@ -75,8 +75,6 @@
</layout> </layout>
</item> </item>
</layout> </layout>
<zorder>layoutWidget</zorder>
<zorder>layoutWidget</zorder>
</widget> </widget>
<widget class="QWidget" name="tab_2"> <widget class="QWidget" name="tab_2">
<attribute name="title"> <attribute name="title">

View File

@ -1,66 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>334</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>1</x>
<y>1</y>
<width>120</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Process this picture?</string>
</property>
</widget>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>1</x>
<y>22</y>
<width>431</width>
<height>311</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QGraphicsView" name="image"/>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="noButton">
<property name="text">
<string>No (n)</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="yesButton">
<property name="text">
<string>Yes (y)</string>
</property>
</widget>
</item>
</layout>
</widget>
<zorder>buttonBox</zorder>
<zorder>image</zorder>
<zorder>buttonBox</zorder>
<zorder>noButton</zorder>
<zorder>yesButton</zorder>
</widget>
<resources/>
<connections/>
</ui>