Dropping a file onto a main window now opens that file.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@1861 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2012-05-24 17:27:15 +00:00
parent 9100578e9d
commit 515311db04
4 changed files with 66 additions and 0 deletions

View File

@@ -29,6 +29,8 @@ QETMainWindow::QETMainWindow(QWidget *widget, Qt::WindowFlags flags) :
{
initCommonActions();
initCommonMenus();
setAcceptDrops(true);
}
/**
@@ -162,3 +164,31 @@ bool QETMainWindow::event(QEvent *e) {
*/
void QETMainWindow::firstActivation(QEvent *) {
}
/**
Accept or refuse drag'n drop events depending on the dropped mime type;
especially, accepts only URLs to local files that we could open.
@param e le QDragEnterEvent correspondant au drag'n drop tente
*/
void QETMainWindow::dragEnterEvent(QDragEnterEvent *e) {
if (e -> mimeData() -> hasUrls()) {
if (QETApp::handledFiles(e -> mimeData() -> urls()).count()) {
e -> acceptProposedAction();
}
}
}
/**
Handle drops accepted on main windows; more specifically, open dropped files
as long as they are handled by QElectrotech.
@param e the QDropEvent describing the current drag'n drop
*/
void QETMainWindow::dropEvent(QDropEvent *e) {
if (e -> mimeData() -> hasUrls()) {
QStringList filepaths = QETApp::handledFiles(e -> mimeData() -> urls());
if (filepaths.count()) {
QETApp::instance() -> openFiles(QETArguments(filepaths));
}
}
}