Avoid update if nothing has changed
This commit is contained in:
@@ -250,7 +250,7 @@ class NoteVector: public QVector<Note*>
|
||||
{
|
||||
public:
|
||||
bool getBounds(TimePos& start, TimePos& end, int& lower, int& upper) const;
|
||||
void transpose(int semitones) const;
|
||||
bool transpose(int semitones) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -278,13 +278,15 @@ bool NoteVector::getBounds(TimePos& start, TimePos& end, int& lower, int& upper)
|
||||
* Notes will be hard-clipped to the MIDI note range. To prevent this use getBounds() prior to transposing.
|
||||
*
|
||||
* \param semitones Semitones to transpose
|
||||
* \return bool True if notes were transposed
|
||||
*/
|
||||
void NoteVector::transpose(int semitones) const
|
||||
bool NoteVector::transpose(int semitones) const
|
||||
{
|
||||
if (empty() || !semitones) { return; }
|
||||
if (empty() || !semitones) { return false; }
|
||||
|
||||
for (Note* note: *this)
|
||||
{
|
||||
note->setKey(note->key() + semitones);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ void MidiClipView::transposeSelection()
|
||||
// Engine::getSong()->addJournalCheckPoint();
|
||||
|
||||
QSet<Track*> m_changedTracks;
|
||||
for (ClipView* clipview: getClickedClips())
|
||||
for (ClipView* clipview: selection)
|
||||
{
|
||||
if (auto mcv = dynamic_cast<MidiClipView*>(clipview))
|
||||
{
|
||||
@@ -183,10 +183,13 @@ void MidiClipView::transposeSelection()
|
||||
m_changedTracks.insert(track);
|
||||
}
|
||||
auto clip = mcv->getMidiClip();
|
||||
clip->notes().transpose(semitones);
|
||||
emit clip->dataChanged();
|
||||
if (clip->notes().transpose(semitones))
|
||||
{
|
||||
emit clip->dataChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
// At least one clip must have notes to show the transpose dialog, so something *has* changed
|
||||
Engine::getSong()->setModified();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user