Commit 0fefc616 authored by Anakin's avatar Anakin

add drag and drop support

parent ae84c555
......@@ -21,6 +21,9 @@ public:
explicit OglViewerWidget(QWidget *parent = 0);
~OglViewerWidget();
signals:
void loadFile(const char*);
private:
struct {
bool left = false;
......@@ -40,6 +43,7 @@ protected:
void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE;
void dropEvent(QDropEvent * event) Q_DECL_OVERRIDE;
void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
......
......@@ -93,9 +93,18 @@ void OglViewerWidget::wheelEvent(QWheelEvent *e)
update();
}
void OglViewerWidget::dragEnterEvent(QDragEnterEvent *e)
{
if (e->mimeData()->hasUrls())
if(e->mimeData()->urls().size() == 1)
if(e->mimeData()->urls().first().toLocalFile().endsWith(".msh"))
e->acceptProposedAction();
}
void OglViewerWidget::dropEvent(QDropEvent * e)
{
std::cout << e->mimeData()->text().toStdString() << std::endl;
emit loadFile(e->mimeData()->urls().first().toLocalFile().toStdString().c_str());
}
void OglViewerWidget::keyPressEvent(QKeyEvent *e)
......@@ -127,6 +136,7 @@ void OglViewerWidget::initializeGL()
m_dataEngine = new GeometryEngine;
connect(m_dataEngine, &GeometryEngine::requestResetView, this, &OglViewerWidget::resetView);
connect(parentWidget(), SIGNAL(loadFile(const char*)), m_dataEngine, SLOT(loadFile(const char*)));
connect(this, SIGNAL(loadFile(const char*)), m_dataEngine, SLOT(loadFile(const char*)));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment