From db18fa61fe3483191249e115ac58eba44950a916 Mon Sep 17 00:00:00 2001 From: Colin Wallace Date: Sun, 6 Sep 2015 15:33:13 -0700 Subject: [PATCH] have getSelectedNotes() return the selected notes, rather than appending them to a write-back parameter --- include/PianoRoll.h | 2 +- src/gui/editors/PianoRoll.cpp | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/include/PianoRoll.h b/include/PianoRoll.h index eaff75fb8..e4821ab01 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -129,7 +129,7 @@ protected: int width, const Note * n, const QColor & noteCol ); void removeSelection(); void selectAll(); - void getSelectedNotes( NoteVector & selected_notes ); + NoteVector getSelectedNotes(); // for entering values with dblclick in the vol/pan bars void enterValue( NoteVector* nv ); diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 104bbc841..e74e3c602 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -3480,20 +3480,21 @@ void PianoRoll::selectAll() // returns vector with pointers to all selected notes -void PianoRoll::getSelectedNotes(NoteVector & selected_notes ) +NoteVector PianoRoll::getSelectedNotes() { - if( ! hasValidPattern() ) - { - return; - } + NoteVector selectedNotes; - for( Note *note : m_pattern->notes() ) + if (hasValidPattern()) { - if( note->selected() ) + for( Note *note : m_pattern->notes() ) { - selected_notes.push_back( note ); + if( note->selected() ) + { + selectedNotes.push_back( note ); + } } } + return selectedNotes; } @@ -3567,8 +3568,7 @@ void PianoRoll::copyToClipboard( const NoteVector & notes ) const void PianoRoll::copySelectedNotes() { - NoteVector selected_notes; - getSelectedNotes( selected_notes ); + NoteVector selected_notes = getSelectedNotes(); if( ! selected_notes.empty() ) { @@ -3586,8 +3586,7 @@ void PianoRoll::cutSelectedNotes() return; } - NoteVector selected_notes; - getSelectedNotes( selected_notes ); + NoteVector selected_notes = getSelectedNotes(); if( ! selected_notes.empty() ) {