Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Album::createScore now tries to append all excerpts (parts) for each score. #2138

Merged
merged 3 commits into from
Aug 6, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions mscore/album.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "globals.h"
#include "libmscore/score.h"
#include "libmscore/page.h"
#include "libmscore/excerpt.h"
#include "preferences.h"
#include "libmscore/mscore.h"
#include "libmscore/xml.h"
Expand Down Expand Up @@ -127,16 +128,61 @@ bool Album::createScore(const QString& fn)
loadScores();

Score* firstScore = _scores[0]->score;
if (!firstScore)
if (!firstScore) {
qDebug("First score is NULL. Will not attempt to join scores.");
return false;
}

// do layout for first score's root and excerpt scores
firstScore->doLayout();
for (int i = 0; i < firstScore->excerpts().count(); i++) {
if (firstScore->excerpts().at(i)->partScore()) {
firstScore->excerpts().at(i)->partScore()->doLayout();
}
else {
qDebug("First score has excerpts, but excerpt %d is NULL. Will not attempt to join scores.", i);
return false;
}
}

Score* score = firstScore->clone();

foreach (AlbumItem* item, _scores) {

if (item->score == 0 || item->score == firstScore)
continue;

// try to append root score
item->score->doLayout();
if (!score->appendScore(item->score)) {
qDebug("cannot append score");
qDebug("Cannot append root score of album item \"%s\".", qPrintable(item->name));
delete score;
return false;
}

// try to append each excerpt
if (item->score->excerpts().count() == score->excerpts().count()) {
for (int i = 0; i < score->excerpts().count(); i++) {
Score* currentScoreExcerpt = item->score->excerpts().at(i)->partScore();
if (currentScoreExcerpt) {
currentScoreExcerpt->doLayout();
if (!score->excerpts().at(i)->partScore()->appendScore(currentScoreExcerpt)) {
qDebug("Cannot append excerpt %d of album item \"%s\".", i, qPrintable(item->name));
delete score;
return false;
}
}
else {
qDebug("First score has excerpts, but excerpt %d of album item \"%s\" is NULL. Will not attempt to join scores.",
i, qPrintable(item->name));
delete score;
return false;
}
}
}
else {
qDebug("Will not append album item \"%s\". Mismatch between number of excerpts with first album item \"%s\"",
qPrintable(item->name), qPrintable(_scores[0]->name));
delete score;
return false;
}
Expand Down