Skip to content

Commit

Permalink
automatic to create unique rehearsal marks
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Nov 15, 2014
1 parent d8e1c74 commit c511c86
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 24 deletions.
Binary file modified demos/Triumph.mscz
Binary file not shown.
2 changes: 2 additions & 0 deletions libmscore/chordrest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,8 @@ Element* ChordRest::drop(const DropData& data)
TextStyleType st = f->textStyleType();
if (st >= TextStyleType::DEFAULT)
f->setTextStyleType(st);
if (e->type() == Element::Type::REHEARSAL_MARK)
f->setText(score()->createRehearsalmarkText(segment()->tick()));
}
score()->undoAddElement(e);
return e;
Expand Down
41 changes: 41 additions & 0 deletions libmscore/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include "instrtemplate.h"
#include "cursor.h"
#include "sym.h"
#include "rehearsalmark.h"

namespace Ms {

Expand Down Expand Up @@ -3587,5 +3588,45 @@ QString Score::title()
return fn.simplified();
}

//---------------------------------------------------------
// createRehearsalmarkText
//---------------------------------------------------------

QString Score::createRehearsalmarkText(int tick) const
{
RehearsalMark* before = 0;
RehearsalMark* after = 0;
for (Segment* s = firstSegment(); s; s = s->next1()) {
for (Element* e : s->annotations()) {
if (e && e->type() == Element::Type::REHEARSAL_MARK) {
if (s->tick() < tick)
before = static_cast<RehearsalMark*>(e);
else if (s->tick() > tick) {
after = static_cast<RehearsalMark*>(e);
break;
}
}
}
if (after)
break;
}
QString s = "A";
QString s1 = before ? before->text() : "";
QString s2 = after ? after->text() : "";
// qDebug("createRehearsalMark <%s> xx <%s>", qPrintable(s1), qPrintable(s2));
if (s1.isEmpty())
return s;
if (!s2.isEmpty()) {
s = s1[0];
if (s1.size() > 1)
s += QChar::fromLatin1(s1[1].toLatin1() + 1);
else
s += QChar::fromLatin1('1');
}
else
s = QChar::fromLatin1(s1[0].toLatin1() + 1);
return s;
}

}

1 change: 1 addition & 0 deletions libmscore/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,7 @@ class Score : public QObject {
QString accessibleInfo() { return accInfo; }

QImage createThumbnail();
QString createRehearsalmarkText(int tick) const;

friend class ChangeSynthesizerState;
friend class Chord;
Expand Down
44 changes: 22 additions & 22 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2980,28 +2980,6 @@ void MuseScore::hideProgressBar()
_statusBar->removeWidget(_progressBar);
}

//---------------------------------------------------------
// searchTextChanged
//---------------------------------------------------------

void MuseScore::searchTextChanged(const QString& s)
{
if (cv == 0)
return;
cv->search(s);
}

//---------------------------------------------------------
// endSearch
//---------------------------------------------------------

void MuseScore::endSearch()
{
_searchDialog->hide();
if (cv)
cv->setFocus();
}

//---------------------------------------------------------
// handleMessage
//---------------------------------------------------------
Expand Down Expand Up @@ -4360,6 +4338,28 @@ void MuseScore::updateDrumTools()
_drumTools->updateDrumset();
}

//---------------------------------------------------------
// searchTextChanged
//---------------------------------------------------------

void MuseScore::searchTextChanged(const QString& s)
{
if (cv == 0)
return;
cv->search(s);
}

//---------------------------------------------------------
// endSearch
//---------------------------------------------------------

void MuseScore::endSearch()
{
_searchDialog->hide();
if (cv)
cv->setFocus();
}

//---------------------------------------------------------
// showSearchDialog
//---------------------------------------------------------
Expand Down
9 changes: 7 additions & 2 deletions mscore/scoreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5261,17 +5261,22 @@ void ScoreView::search(const QString& s)
}
else {
//search rehearsal marks
QString ss = s.toLower();
bool found = false;
for (Segment* seg = score()->firstSegment(); seg; seg = seg->next1(Segment::Type::ChordRest)) {
for (Element* e : seg->annotations()){
if (e->type() == Element::Type::REHEARSAL_MARK) {
RehearsalMark* rm = static_cast<RehearsalMark*>(e);
QString rms = rm->text();
if (rms.contains(s)) {
QString rms = rm->text().toLower();
if (rms.startsWith(ss)) {
gotoMeasure(seg->measure());
found = true;
break;
}
}
}
if (found)
break;
}
}
}
Expand Down

0 comments on commit c511c86

Please sign in to comment.