Proposed fix 1416 Drag-and-drop of automatables to Automation Editor

This commit is contained in:
Dave French
2015-01-23 02:16:30 +00:00
parent f6176921c6
commit c201a41c05
4 changed files with 39 additions and 0 deletions

View File

@@ -64,6 +64,8 @@
#include "PianoRoll.h"
#include "debug.h"
#include "MeterModel.h"
#include "StringPairDrag.h"
#include "ProjectJournal.h"
QPixmap * AutomationEditor::s_toolDraw = NULL;
@@ -239,6 +241,7 @@ void AutomationEditor::loadSettings( const QDomElement & dom_parent)
// qproperty access methods
QColor AutomationEditor::gridColor() const
@@ -2220,6 +2223,7 @@ AutomationEditorWindow::AutomationEditorWindow() :
setFocusPolicy( Qt::StrongFocus );
setFocus();
setWindowIcon( embed::getIconPixmap( "automation" ) );
setAcceptDrops( true );
}
@@ -2282,6 +2286,35 @@ 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<AutomatableModel *>(
Engine::projectJournal()->
journallingObject( val.toInt() ) );
if( mod != NULL )
{
if( m_editor->m_pattern->firstObject() )
{
m_editor->m_pattern->objectDestroyed( m_editor->m_pattern->firstObject()->id() );
}
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);

View File

@@ -127,6 +127,7 @@ void AutomationTrack::loadTrackSpecificSettings( const QDomElement & _this )
AutomationTrackView::AutomationTrackView( AutomationTrack * _at, TrackContainerView* tcv ) :
TrackView( _at, tcv )
{