Skip to content

Commit

Permalink
speed up some commands; cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Jun 3, 2016
1 parent 41b89ae commit 8de3e55
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 139 deletions.
33 changes: 15 additions & 18 deletions libmscore/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,8 @@ namespace Ms {

void CmdState::reset()
{
// refresh = QRectF(); ///< area to update, canvas coordinates
layoutFlags = LayoutFlag::NO_FLAGS;
_updateMode = UpdateMode::DoNothing;
// _playNote = false; ///< play selected note after command
// _playChord = false; ///< play whole chord for the selected note
// _excerptsChanged = false;
// _instrumentsChanged = false;
// _selectionChanged = false;
_startTick = -1;
_endTick = -1;
}
Expand Down Expand Up @@ -144,6 +138,21 @@ void Score::startCmd()
undo(new SaveState(this));
}

//---------------------------------------------------------
// undoRedo
//---------------------------------------------------------

void Score::undoRedo(bool undo)
{
cmdState().reset();
if (undo)
undoStack()->undo();
else
undoStack()->redo();
update();
updateSelection();
}

//---------------------------------------------------------
// endCmd
/// End a GUI command by (if \a undo) ending a user-visble undo
Expand Down Expand Up @@ -222,17 +231,6 @@ void Score::update()
}
}

//---------------------------------------------------------
// endUndoRedo
/// Common handling for ending undo or redo
//---------------------------------------------------------

void Score::endUndoRedo()
{
update();
updateSelection();
}

//---------------------------------------------------------
// cmdAddSpanner
// drop VOLTA, OTTAVA, TRILL, PEDAL, DYNAMIC
Expand Down Expand Up @@ -272,7 +270,6 @@ void Score::cmdAddSpanner(Spanner* spanner, const QPointF& pos)
spanner->setTick(m->tick());
spanner->setTick2(m->endTick());
}

undoAddElement(spanner);
select(spanner, SelectType::SINGLE, 0);
}
Expand Down
7 changes: 6 additions & 1 deletion libmscore/element.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class Spacer;
class StaffLines;
class Ambitus;
class Bracket;
class InstrumentChange;
class Text;

enum class SymId;

Expand Down Expand Up @@ -673,6 +675,7 @@ class Element : public QObject, public ScoreElement {
CONVERT(StaffLines, STAFF_LINES)
CONVERT(Ambitus, AMBITUS)
CONVERT(Bracket, BRACKET)
CONVERT(InstrumentChange, INSTRUMENT_CHANGE)
#undef CONVERT
};

Expand All @@ -696,7 +699,7 @@ static inline const ChordRest* toChordRest(const Element* e) {
}

#define CONVERT(a,b) \
static inline a* to##a(Element* e) { Q_ASSERT(e == 0 || e->type() == Element::Type::b); return (a*)e; } \
static inline a* to##a(Element* e) { Q_ASSERT(e == 0 || e->type() == Element::Type::b); return (a*)e; } \
static inline const a* to##a(const Element* e) { Q_ASSERT(e == 0 || e->type() == Element::Type::b); return (const a*)e; }

CONVERT(Note, NOTE)
Expand Down Expand Up @@ -739,6 +742,8 @@ static inline const a* to##a(const Element* e) { Q_ASSERT(e == 0 || e->type() ==
CONVERT(StaffLines, STAFF_LINES)
CONVERT(Ambitus, AMBITUS)
CONVERT(Bracket, BRACKET)
CONVERT(InstrumentChange, INSTRUMENT_CHANGE)
CONVERT(Text, TEXT)

This comment has been minimized.

Copy link
@Jojo-Schmitz

Jojo-Schmitz Jun 3, 2016

Contributor

not in 'is##a()` too?

This comment has been minimized.

Copy link
@wschweer

wschweer Jun 3, 2016

Author Contributor

class Text is special. It can be instantiated as a TEXT element but also has derived types like TempoText() (TEMPO_TEXT). Its expected that for TempoText isText() will return true but the is##a() macro does check the type and will return false.

This comment has been minimized.

Copy link
@Jojo-Schmitz

Jojo-Schmitz Jun 3, 2016

Contributor

might be worth a comment at that spot?
// no CONVERT(Text,TEXT), because...

#undef CONVERT

//---------------------------------------------------------
Expand Down
4 changes: 1 addition & 3 deletions libmscore/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2293,9 +2293,7 @@ void Measure::setStartRepeatBarLine()
score()->undoAddElement(bl);
}
else if (bl && !val) {
// barline were we do not need one:
if (!score()->undoRedo()) // DEBUG
score()->undoRemoveElement(bl);
score()->undoRemoveElement(bl); // barline were we do not need one
}
if (bl && val && span) {
bl->setSpan(span);
Expand Down
2 changes: 1 addition & 1 deletion libmscore/note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2283,7 +2283,7 @@ bool Note::setProperty(P_ID propertyId, const QVariant& v)
return false;
break;
}
score()->setLayoutAll();
score()->setLayout(tick());
return true;
}

Expand Down
Loading

0 comments on commit 8de3e55

Please sign in to comment.