fix #11261: improved logic for inserting measures
This commit is contained in:
parent
958449d646
commit
3ccfc359f4
6 changed files with 70 additions and 10 deletions
|
@ -1559,6 +1559,34 @@ bool Element::isText() const
|
|||
|| type() == TEMPO_TEXT;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// parentChordRest
|
||||
//---------------------------------------------------------
|
||||
|
||||
Element* Element::parentChordRest()
|
||||
{
|
||||
if (isChordRest())
|
||||
return this;
|
||||
else if (_parent)
|
||||
return _parent->parentChordRest();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// parentChordRest
|
||||
//---------------------------------------------------------
|
||||
|
||||
Element* Element::findMeasure()
|
||||
{
|
||||
if (type() == MEASURE)
|
||||
return this;
|
||||
else if (_parent)
|
||||
return _parent->findMeasure();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// undoSetColor
|
||||
//---------------------------------------------------------
|
||||
|
|
|
@ -314,6 +314,8 @@ class Element : public QObject {
|
|||
virtual void setScore(Score* s) { _score = s; }
|
||||
Element* parent() const { return _parent; }
|
||||
void setParent(Element* e) { _parent = e; }
|
||||
Element* parentChordRest();
|
||||
Element* findMeasure();
|
||||
|
||||
qreal spatium() const;
|
||||
|
||||
|
|
|
@ -182,6 +182,21 @@ ChordRest* Selection::lastChordRest(int track) const
|
|||
return cr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// findMeasure
|
||||
//---------------------------------------------------------
|
||||
|
||||
|
||||
Measure* Selection::findMeasure() const
|
||||
{
|
||||
Measure *m = 0;
|
||||
if (_el.size() >= 1) {
|
||||
Element* el = _el[0];
|
||||
m = static_cast<Measure*>(el->findMeasure());
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// deselectAll
|
||||
//---------------------------------------------------------
|
||||
|
|
|
@ -86,6 +86,7 @@ class Selection {
|
|||
Element* element() const;
|
||||
ChordRest* firstChordRest(int track = -1) const;
|
||||
ChordRest* lastChordRest(int track = -1) const;
|
||||
Measure* findMeasure() const;
|
||||
void update();
|
||||
void updateState();
|
||||
void dump();
|
||||
|
|
|
@ -143,10 +143,16 @@ extern void qt_mac_set_menubar_icons(bool b);
|
|||
|
||||
void MuseScore::cmdInsertMeasures()
|
||||
{
|
||||
if (cs) {
|
||||
insertMeasuresDialog = new InsertMeasuresDialog;
|
||||
insertMeasuresDialog->show();
|
||||
if (cs) {
|
||||
if (cs->selection().state() == SEL_NONE && !cs->selection().findMeasure()) {
|
||||
QMessageBox::warning(0, "MuseScore",
|
||||
tr("No measure selected:\n" "Please select a measure and try again"));
|
||||
}
|
||||
else {
|
||||
insertMeasuresDialog = new InsertMeasuresDialog;
|
||||
insertMeasuresDialog->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
|
|
@ -4858,17 +4858,23 @@ void ScoreView::appendMeasures(int n, Element::ElementType type)
|
|||
|
||||
MeasureBase* ScoreView::checkSelectionStateForInsertMeasure()
|
||||
{
|
||||
if (_score->selection().state() == SEL_RANGE) {
|
||||
MeasureBase* mb = _score->selection().startSegment()->measure();
|
||||
MeasureBase* mb = 0;
|
||||
if (_score->selection().state() == SEL_RANGE) {
|
||||
mb = _score->selection().startSegment()->measure();
|
||||
return mb;
|
||||
}
|
||||
|
||||
mb = _score->selection().findMeasure();
|
||||
if (mb)
|
||||
return static_cast<MeasureBase*>(mb);
|
||||
|
||||
Element* e = _score->selection().element();
|
||||
if (e) {
|
||||
if (e->type() == Element::VBOX || e->type() == Element::TBOX)
|
||||
return static_cast<MeasureBase*>(e);
|
||||
}
|
||||
QMessageBox::warning(0, "MuseScore",
|
||||
tr("No Measure selected:\n" "please select a measure and try again"));
|
||||
QMessageBox::warning(0, "MuseScore",
|
||||
tr("No measure selected:\n" "Please select a measure and try again"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -4882,9 +4888,10 @@ void ScoreView::cmdInsertMeasures(int n, Element::ElementType type)
|
|||
if (!mb)
|
||||
return;
|
||||
_score->startCmd();
|
||||
for (int i = 0; i < n; ++i)
|
||||
for (int i = 0; i < n; ++i)
|
||||
mb = _score->insertMeasure(type, mb);
|
||||
_score->select(0, SELECT_SINGLE, 0);
|
||||
if (mb)
|
||||
_score->select(mb, SELECT_SINGLE, 0);
|
||||
_score->endCmd();
|
||||
}
|
||||
|
||||
|
@ -4907,7 +4914,8 @@ void ScoreView::cmdInsertMeasure(Element::ElementType type)
|
|||
startEdit(s);
|
||||
return;
|
||||
}
|
||||
_score->select(0, SELECT_SINGLE, 0);
|
||||
if (mb)
|
||||
_score->select(mb, SELECT_SINGLE, 0);
|
||||
_score->endCmd();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue