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