Now succesfully adds files from drag and drop
This commit is contained in:
parent
e8448b97bd
commit
bc51ea6a3c
38
picture.cpp
38
picture.cpp
@ -1,15 +1,39 @@
|
||||
#include "picture.h"
|
||||
#include <QDrag>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QMimeData>
|
||||
#include <QRegExp>
|
||||
Picture::Picture(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::Picture){
|
||||
ui->setupUi(this);
|
||||
connect(ui->actionOpen_Files,SIGNAL(triggered()),this,SLOT(changeDirectory()));
|
||||
setAcceptDrops(true);
|
||||
//changeDirectory();
|
||||
fillList();
|
||||
}
|
||||
Picture::~Picture(){
|
||||
delete ui;
|
||||
}
|
||||
void Picture::dragEnterEvent(QDragEnterEvent *event){
|
||||
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()<<fileName;
|
||||
//}
|
||||
//qDebug() << "Dropped file:" << fileName;
|
||||
}
|
||||
}
|
||||
|
||||
void Picture::changeDirectory(){
|
||||
QString path=QFileDialog::getExistingDirectory(this,tr("Directory"),directory.path());
|
||||
if(path.isNull()==false){
|
||||
@ -30,7 +54,7 @@ void Picture::fillList() {
|
||||
}
|
||||
}
|
||||
if(ui->fileList->count()==0){
|
||||
ui->fileList->addItem("<NO PICTURES>");
|
||||
//ui->fileList->addItem("<NO PICTURES>");
|
||||
}
|
||||
}
|
||||
void Picture::on_cd_clicked(){
|
||||
@ -38,7 +62,12 @@ void Picture::on_cd_clicked(){
|
||||
}
|
||||
void Picture::on_erase_clicked(){
|
||||
bool ignored=false;
|
||||
foreach(const QString &str,directory.entryList()){
|
||||
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);
|
||||
if(!reader.format().isEmpty()){
|
||||
@ -67,8 +96,9 @@ void Picture::on_erase_clicked(){
|
||||
ui->log->append("Done erasing metadata");
|
||||
}
|
||||
void Picture::on_refresh_clicked(){
|
||||
fillList();
|
||||
ui->log->append("Refreshed directory");
|
||||
//fillList();
|
||||
ui->fileList->clear();
|
||||
ui->log->append("Cleared File List");
|
||||
}
|
||||
void Picture::on_clearLog_clicked(){
|
||||
ui->log->setText("");
|
||||
|
@ -40,5 +40,8 @@ private slots:
|
||||
private:
|
||||
Ui::Picture *ui;
|
||||
QDir directory;
|
||||
protected:
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dropEvent(QDropEvent *event);
|
||||
};
|
||||
#endif // PICTURE_H
|
||||
|
65
picture.ui
65
picture.ui
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>656</width>
|
||||
<height>350</height>
|
||||
<height>463</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -19,8 +19,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>471</width>
|
||||
<height>301</height>
|
||||
<width>393</width>
|
||||
<height>279</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
@ -30,15 +30,8 @@
|
||||
<attribute name="title">
|
||||
<string>Commands</string>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>258</width>
|
||||
<height>229</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="fileList"/>
|
||||
@ -55,23 +48,15 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="refresh">
|
||||
<property name="text">
|
||||
<string>Refresh Directory</string>
|
||||
<string>Clear File List</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>60</y>
|
||||
<width>107</width>
|
||||
<height>62</height>
|
||||
</rect>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="erase">
|
||||
@ -88,43 +73,35 @@
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<zorder>fileList</zorder>
|
||||
<zorder>fileList</zorder>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>layoutWidget</zorder>
|
||||
<zorder>layoutWidget</zorder>
|
||||
<zorder>erase</zorder>
|
||||
<zorder>pushButton</zorder>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Log</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="log">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>381</width>
|
||||
<height>192</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="clearLog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>220</y>
|
||||
<width>51</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
|
Loading…
Reference in New Issue
Block a user