Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Jan 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/AutomationEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ class AutomationEditorWindow : public Editor
void setCurrentPattern(AutomationPattern* pattern);
const AutomationPattern* currentPattern();

virtual void dropEvent( QDropEvent * _de );
virtual void dragEnterEvent( QDragEnterEvent * _dee );

void open(AutomationPattern* pattern);

AutomationEditor* m_editor;
Expand Down
28 changes: 28 additions & 0 deletions src/gui/editors/AutomationEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
#include "PianoRoll.h"
#include "debug.h"
#include "MeterModel.h"
#include "StringPairDrag.h"
#include "ProjectJournal.h"


QPixmap * AutomationEditor::s_toolDraw = NULL;
Expand Down Expand Up @@ -2220,6 +2222,8 @@ AutomationEditorWindow::AutomationEditorWindow() :
setFocusPolicy( Qt::StrongFocus );
setFocus();
setWindowIcon( embed::getIconPixmap( "automation" ) );
setAcceptDrops( true );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking here... it appears we generally link the toolbar as well per BBEditor.cpp#L56

m_toolBar->setAcceptDrops( true );
}


Expand Down Expand Up @@ -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<AutomatableModel *>(
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);
Expand Down