add drag and drop support
This commit is contained in:
parent
ae84c55559
commit
0fefc6168b
|
@ -21,6 +21,9 @@ public:
|
||||||
explicit OglViewerWidget(QWidget *parent = 0);
|
explicit OglViewerWidget(QWidget *parent = 0);
|
||||||
~OglViewerWidget();
|
~OglViewerWidget();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void loadFile(const char*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct {
|
struct {
|
||||||
bool left = false;
|
bool left = false;
|
||||||
|
@ -40,6 +43,7 @@ protected:
|
||||||
void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
||||||
void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
|
||||||
void wheelEvent(QWheelEvent *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 dropEvent(QDropEvent * event) Q_DECL_OVERRIDE;
|
||||||
void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
|
void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
|
|
@ -93,9 +93,18 @@ void OglViewerWidget::wheelEvent(QWheelEvent *e)
|
||||||
update();
|
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)
|
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)
|
void OglViewerWidget::keyPressEvent(QKeyEvent *e)
|
||||||
|
@ -127,6 +136,7 @@ void OglViewerWidget::initializeGL()
|
||||||
m_dataEngine = new GeometryEngine;
|
m_dataEngine = new GeometryEngine;
|
||||||
connect(m_dataEngine, &GeometryEngine::requestResetView, this, &OglViewerWidget::resetView);
|
connect(m_dataEngine, &GeometryEngine::requestResetView, this, &OglViewerWidget::resetView);
|
||||||
connect(parentWidget(), SIGNAL(loadFile(const char*)), m_dataEngine, SLOT(loadFile(const char*)));
|
connect(parentWidget(), SIGNAL(loadFile(const char*)), m_dataEngine, SLOT(loadFile(const char*)));
|
||||||
|
connect(this, SIGNAL(loadFile(const char*)), m_dataEngine, SLOT(loadFile(const char*)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue