Implement Drag&Drop support

This commit is contained in:
LoRd_MuldeR 2010-11-12 23:31:04 +01:00
parent 360a5a1bef
commit 43e3ea25da
3 changed files with 36 additions and 1 deletions

View File

@ -25,7 +25,7 @@
#define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 0
#define VER_LAMEXP_BUILD 11
#define VER_LAMEXP_BUILD 12
#define VER_LAMEXP_SUFFIX TechPreview
/*

View File

@ -47,6 +47,8 @@
#include <QWindowsVistaStyle>
#include <QWindowsStyle>
#include <QSysInfo>
#include <QDragEnterEvent>
#include <QWindowsMime>
//Win32 includes
#include <Windows.h>
@ -205,6 +207,9 @@ MainWindow::MainWindow(QWidget *parent)
connect(m_messageHandler, SIGNAL(killSignalReceived()), this, SLOT(close()), Qt::QueuedConnection);
connect(m_delayedFileTimer, SIGNAL(timeout()), this, SLOT(handleDelayedFiles()));
m_messageHandler->start();
//Enable Drag & Drop
this->setAcceptDrops(true);
}
////////////////////////////////////////////////////////////
@ -284,6 +289,34 @@ void MainWindow::showEvent(QShowEvent *event)
QTimer::singleShot(0, this, SLOT(windowShown()));
}
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
QStringList formats = event->mimeData()->formats();
for(int i = 0; i < formats.count(); i++)
{
if(formats[i].indexOf("FileNameW") >= 0)
{
event->acceptProposedAction();
}
}
}
void MainWindow::dropEvent(QDropEvent *event)
{
ABORT_IF_BUSY;
QStringList droppedFiles;
const QList<QUrl> urls = event->mimeData()->urls();
for(int i = 0; i < urls.count(); i++)
{
droppedFiles << QFileInfo(urls.at(i).toLocalFile()).absoluteFilePath();
}
addFiles(droppedFiles);
}
////////////////////////////////////////////////////////////
// Slots
////////////////////////////////////////////////////////////

View File

@ -71,6 +71,8 @@ private slots:
protected:
void showEvent(QShowEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
private:
void addFiles(const QStringList &files);