diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 64cfeb718..eca52d2c6 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -262,6 +262,9 @@ public: void setCurrentPattern(AutomationPattern* pattern); const AutomationPattern* currentPattern(); + virtual void dropEvent( QDropEvent * _de ); + virtual void dragEnterEvent( QDragEnterEvent * _dee ); + void open(AutomationPattern* pattern); AutomationEditor* m_editor; diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index f839eb5a6..bde69e950 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -64,6 +64,8 @@ #include "PianoRoll.h" #include "debug.h" #include "MeterModel.h" +#include "StringPairDrag.h" +#include "ProjectJournal.h" QPixmap * AutomationEditor::s_toolDraw = NULL; @@ -2220,6 +2222,8 @@ AutomationEditorWindow::AutomationEditorWindow() : setFocusPolicy( Qt::StrongFocus ); setFocus(); setWindowIcon( embed::getIconPixmap( "automation" ) ); + setAcceptDrops( true ); + m_toolBar->setAcceptDrops( true ); } @@ -2282,6 +2286,30 @@ const AutomationPattern* AutomationEditorWindow::currentPattern() return m_editor->currentPattern(); } +void AutomationEditorWindow::dropEvent( QDropEvent *_de ) +{ + QString type = StringPairDrag::decodeKey( _de ); + QString val = StringPairDrag::decodeValue( _de ); + if( type == "automatable_model" ) + { + AutomatableModel * mod = dynamic_cast( + Engine::projectJournal()-> + journallingObject( val.toInt() ) ); + if( mod != NULL ) + { + m_editor->m_pattern->addObject( mod ); + setCurrentPattern( m_editor->m_pattern ); + } + } + + update(); +} + +void AutomationEditorWindow::dragEnterEvent( QDragEnterEvent *_dee ) +{ + StringPairDrag::processDragEnterEvent( _dee, "automatable_model" ); +} + void AutomationEditorWindow::open(AutomationPattern* pattern) { setCurrentPattern(pattern);