Skip to content

Commit

Permalink
fix #123536 Multi-select is not working as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Sep 8, 2016
1 parent 20fdab9 commit 82a79cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
22 changes: 15 additions & 7 deletions libmscore/score.cpp
Expand Up @@ -2628,6 +2628,7 @@ void Score::deselect(Element* el)
addRefresh(el->abbox());
_selection.remove(el);
setSelectionChanged(true);
update();
}

//---------------------------------------------------------
Expand All @@ -2637,9 +2638,9 @@ void Score::deselect(Element* el)

void Score::select(Element* e, SelectType type, int staffIdx)
{
if (e && (e->type() == Element::Type::NOTE || e->type() == Element::Type::REST)) {
if (e && (e->isNote() || e->isRest())) {
Element* ee = e;
if (ee->type() == Element::Type::NOTE)
if (ee->isNote())
ee = ee->parent();
int tick = toChordRest(ee)->segment()->tick();
if (playPos() != tick)
Expand All @@ -2650,10 +2651,17 @@ void Score::select(Element* e, SelectType type, int staffIdx)
e ? e->name() : "", int(type), int(selection().state()), e ? e->staffIdx() : -1);

switch (type) {
case SelectType::SINGLE: return selectSingle(e, staffIdx);
case SelectType::ADD: return selectAdd(e);
case SelectType::RANGE: return selectRange(e, staffIdx);
case SelectType::SINGLE:
selectSingle(e, staffIdx);
break;
case SelectType::ADD:
selectAdd(e);
break;
case SelectType::RANGE:
selectRange(e, staffIdx);
break;
}
update();
}

//---------------------------------------------------------
Expand Down Expand Up @@ -2705,7 +2713,7 @@ void Score::selectAdd(Element* e)
return;
}

if (e->type() == Element::Type::MEASURE) {
if (e->isMeasure()) {
Measure* m = toMeasure(e);
int tick = m->tick();
if (_selection.isNone()) {
Expand All @@ -2727,8 +2735,8 @@ void Score::selectAdd(Element* e)
if (_selection.elements().contains(e))
_selection.remove(e);
else {
_selection.add(e);
selState = SelState::LIST;
_selection.add(e);
}
}
_selection.setState(selState);
Expand Down
9 changes: 3 additions & 6 deletions mscore/scoreview.cpp
Expand Up @@ -3743,17 +3743,14 @@ void ScoreView::select(QMouseEvent* ev)
}
else if (ev->type() == QEvent::MouseButtonRelease) {
score()->deselect(curElement);
_score->setUpdateAll(); //DEBUG
mscore->endCmd();
}
return;
}
addSelect = true;
st = SelectType::ADD;
}
if (curElement && curElement->type() == Element::Type::KEYSIG
&& (keyState != Qt::ControlModifier)
&& st == SelectType::SINGLE) {
if (curElement && curElement->isKeySig() && (keyState != Qt::ControlModifier) && st == SelectType::SINGLE) {
// special case: select for all staves
Segment* s = static_cast<Segment*>(curElement->parent());
bool first = true;
Expand All @@ -3768,8 +3765,8 @@ void ScoreView::select(QMouseEvent* ev)
}
else
_score->select(curElement, st, dragStaffIdx);
if (curElement && curElement->type() == Element::Type::NOTE && ev->type() == QEvent::MouseButtonPress) {
Note* note = static_cast<Note*>(curElement);
if (curElement && curElement->isNote() && ev->type() == QEvent::MouseButtonPress) {
Note* note = toNote(curElement);
int pitch = note->ppitch();
mscore->play(note, pitch);
}
Expand Down

0 comments on commit 82a79cb

Please sign in to comment.