Commit 239a54c9 authored by Jan Möbius's avatar Jan Möbius
Browse files

Update Drag and drop functions to support multiview

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4295 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 31cdda26
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "CoreWidget.hh" #include "CoreWidget.hh"
#include <OpenFlipper/BasePlugin/PluginFunctions.hh> #include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
...@@ -57,6 +58,25 @@ static const char VIEW_MAGIC[] = "ACG::QtWidgets::QGLViewerWidget encoded view"; ...@@ -57,6 +58,25 @@ static const char VIEW_MAGIC[] = "ACG::QtWidgets::QGLViewerWidget encoded view";
void CoreWidget::startDrag ( QMouseEvent* _event ) void CoreWidget::startDrag ( QMouseEvent* _event )
{ {
QObject* senderPointer = sender();
int examinerId = -1;
if ( senderPointer != 0 ) {
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) {
if ( senderPointer == examiner_widgets_[i] ) {
examinerId = i;
break;
}
}
}
if ( examinerId == -1 ) {
std::cerr << "startDrag in Core called by non examiner, stopping here" << std::endl;
return;
}
PluginFunctions::setActiveExaminer(examinerId);
// Get the correct position in the widget // Get the correct position in the widget
QPoint position = _event->pos(); QPoint position = _event->pos();
...@@ -83,19 +103,22 @@ void CoreWidget::startDrag ( QMouseEvent* _event ) ...@@ -83,19 +103,22 @@ void CoreWidget::startDrag ( QMouseEvent* _event )
} }
QString view; QString view;
examiner_widget_->encodeView ( view ); examiner_widgets_[PluginFunctions::activeExaminer()]->encodeView ( view );
QDrag * drag = new QDrag ( examiner_widget_ ); QDrag * drag = new QDrag ( examiner_widgets_[PluginFunctions::activeExaminer()] );
QMimeData * mime_data = new QMimeData; QMimeData * mime_data = new QMimeData;
mime_data->setText ( view ); mime_data->setText ( view );
drag->setMimeData ( mime_data ); drag->setMimeData ( mime_data );
drag->start(); drag->start();
} }
void CoreWidget::dragEnterEvent ( QDragEnterEvent* _event ) {
void CoreWidget::dragEnterEvent ( QDragEnterEvent* _event ) {
if ( _event->mimeData()->hasFormat ( "text/plain" ) ) { if ( _event->mimeData()->hasFormat ( "text/plain" ) ) {
QString view ( _event->mimeData()->text() ); QString view ( _event->mimeData()->text() );
...@@ -105,10 +128,28 @@ void CoreWidget::startDrag ( QMouseEvent* _event ) ...@@ -105,10 +128,28 @@ void CoreWidget::startDrag ( QMouseEvent* _event )
} }
} }
}
void CoreWidget::dropEvent ( QDropEvent* _event ) {
QObject* senderPointer = sender();
int examinerId = -1;
if ( senderPointer != 0 ) {
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) {
if ( senderPointer == examiner_widgets_[i] ) {
examinerId = i;
break;
}
}
} }
void CoreWidget::dropEvent ( QDropEvent* _event ) { if ( examinerId == -1 ) {
std::cerr << "dropEvent in Core called by non examiner, stopping here" << std::endl;
return;
}
PluginFunctions::setActiveExaminer(examinerId);
if ( _event->mimeData()->hasFormat ( "text/plain" ) ) { if ( _event->mimeData()->hasFormat ( "text/plain" ) ) {
...@@ -116,7 +157,7 @@ void CoreWidget::startDrag ( QMouseEvent* _event ) ...@@ -116,7 +157,7 @@ void CoreWidget::startDrag ( QMouseEvent* _event )
// Dropped view information // Dropped view information
if ( view.left ( sizeof ( VIEW_MAGIC ) - 1 ) == QString ( VIEW_MAGIC ) ) { if ( view.left ( sizeof ( VIEW_MAGIC ) - 1 ) == QString ( VIEW_MAGIC ) ) {
examiner_widget_->decodeView ( view ); examiner_widgets_[PluginFunctions::activeExaminer()]->decodeView ( view );
_event->acceptProposedAction(); _event->acceptProposedAction();
return; return;
} }
...@@ -124,6 +165,6 @@ void CoreWidget::startDrag ( QMouseEvent* _event ) ...@@ -124,6 +165,6 @@ void CoreWidget::startDrag ( QMouseEvent* _event )
} }
} }
//============================================================================= //=============================================================================
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