Now succesfully adds files from drag and drop
This commit is contained in:
commit
f7085cc49a
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
|
||||||
|
86
picture.ui
86
picture.ui
@ -6,8 +6,13 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
|
<<<<<<< HEAD
|
||||||
<width>658</width>
|
<width>658</width>
|
||||||
<height>434</height>
|
<height>434</height>
|
||||||
|
=======
|
||||||
|
<width>656</width>
|
||||||
|
<height>463</height>
|
||||||
|
>>>>>>> tmp
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -19,8 +24,13 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
|
<<<<<<< HEAD
|
||||||
<width>411</width>
|
<width>411</width>
|
||||||
<height>341</height>
|
<height>341</height>
|
||||||
|
=======
|
||||||
|
<width>393</width>
|
||||||
|
<height>279</height>
|
||||||
|
>>>>>>> tmp
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
@ -30,6 +40,7 @@
|
|||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Commands</string>
|
<string>Commands</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<<<<<<< HEAD
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
@ -175,37 +186,80 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
=======
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="fileList"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="cd">
|
||||||
|
<property name="text">
|
||||||
|
<string>Change Directory</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="refresh">
|
||||||
|
<property name="text">
|
||||||
|
<string>Clear File List</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="erase">
|
||||||
|
<property name="text">
|
||||||
|
<string>Erase Metadata</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Label</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
<zorder>layoutWidget</zorder>
|
||||||
|
<zorder>layoutWidget</zorder>
|
||||||
|
>>>>>>> tmp
|
||||||
</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