Skip to content

Commit

Permalink
fix 40241: Recent scores menu doesn't show imported files
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Dec 8, 2014
1 parent e835aa5 commit c87cfae
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion libmscore/page.cpp
Expand Up @@ -550,7 +550,7 @@ QString Page::replaceTextMacros(const QString& s) const
d += _score->rootScore()->name();
break;
case 'F':
d += _score->rootScore()->absoluteFilePath();
d += _score->rootScore()->fileInfo()->absoluteFilePath();
break;
case 'd':
d += QDate::currentDate().toString(Qt::DefaultLocaleShortDate);
Expand Down
3 changes: 0 additions & 3 deletions libmscore/score.h
Expand Up @@ -666,10 +666,7 @@ class Score : public QObject {
int fileDivision(int t) const { return (t * MScore::division + _fileDivision/2) / _fileDivision; }
bool saveFile();

QString filePath() const { return info.filePath(); }
QString absoluteFilePath() const { return info.absoluteFilePath(); }
QFileInfo* fileInfo() { return &info; }

QString name() const { return info.completeBaseName(); }
void setName(QString s);

Expand Down
6 changes: 3 additions & 3 deletions libmscore/scorefile.cpp
Expand Up @@ -1244,7 +1244,7 @@ void Score::print(QPainter* painter, int pageNo)

QByteArray Score::readCompressedToBuffer()
{
MQZipReader uz(filePath());
MQZipReader uz(info.filePath());
if (!uz.exists()) {
qDebug("Score::readCompressedToBuffer: cannot read zip file");
return QByteArray();
Expand All @@ -1261,7 +1261,7 @@ QByteArray Score::readCompressedToBuffer()
}

if (rootfile.isEmpty()) {
qDebug("=can't find rootfile in: %s", qPrintable(filePath()));
qDebug("=can't find rootfile in: %s", qPrintable(info.filePath()));
return QByteArray();
}
return uz.fileData(rootfile);
Expand All @@ -1280,7 +1280,7 @@ QByteArray Score::readToBuffer()
ba = readCompressedToBuffer();
}
if (cs.toLower() == "msc" || cs.toLower() == "mscx") {
QFile f(filePath());
QFile f(info.filePath());
if (f.open(QIODevice::ReadOnly)) {
ba = f.readAll();
f.close();
Expand Down
8 changes: 4 additions & 4 deletions mscore/file.cpp
Expand Up @@ -294,7 +294,6 @@ Score* MuseScore::openScore(const QString& fn)
Score* score = readScore(fn);
if (score) {
setCurrentScoreView(appendScore(score));
updateRecentScores(score);
writeSessionFile(false);
}
return score;
Expand Down Expand Up @@ -329,6 +328,7 @@ Score* MuseScore::readScore(const QString& name)
score = 0;
}
allowShowMidiPanel(name);
addRecentScore(score);
return score;
}

Expand Down Expand Up @@ -391,7 +391,7 @@ bool MuseScore::saveFile(Score* score)
QMessageBox::critical(mscore, tr("MuseScore: Save File"), MScore::lastError);
return false;
}
updateRecentScores(score);
addRecentScore(score);
score->setCreated(false);
writeSessionFile(false);
}
Expand Down Expand Up @@ -1726,7 +1726,7 @@ bool MuseScore::saveAs(Score* cs, bool saveCopy, const QString& path, const QStr
rv = true;
// store new file and path into score fileInfo
// to have it accessible to resources
QString originalScoreFName(cs->absoluteFilePath());
QString originalScoreFName(cs->fileInfo()->canonicalFilePath());
cs->fileInfo()->setFile(fn);
try {
if (ext == "mscz")
Expand All @@ -1746,7 +1746,7 @@ bool MuseScore::saveAs(Score* cs, bool saveCopy, const QString& path, const QStr
cs->undo()->setClean();
dirtyChanged(cs);
cs->setCreated(false);
updateRecentScores(cs);
addRecentScore(cs);
writeSessionFile(false);
}
}
Expand Down
29 changes: 14 additions & 15 deletions mscore/musescore.cpp
Expand Up @@ -1106,10 +1106,10 @@ void MuseScore::selectScore(QAction* action)
_recentScores.clear();
}
else {
Score* score = readScore(a);
Score* score = readScore(a);
if (score) {
setCurrentScoreView(appendScore(score));
updateRecentScores(score);
addRecentScore(score);
writeSessionFile(false);
}
}
Expand Down Expand Up @@ -1165,7 +1165,7 @@ int MuseScore::appendScore(Score* score)
for (int i = 0; i < scoreList.size(); ++i) {
if ((!score->importedFilePath().isEmpty()
&& scoreList[i]->importedFilePath() == score->importedFilePath())
|| (scoreList[i]->filePath() == score->filePath() && score->fileInfo()->exists())) {
|| (scoreList[i]->fileInfo()->canonicalFilePath() == score->fileInfo()->canonicalFilePath() && score->fileInfo()->exists())) {
removeTab(i);
index = i;
break;
Expand All @@ -1185,30 +1185,27 @@ int MuseScore::appendScore(Score* score)
}

//---------------------------------------------------------
// updateRecentScores
// addRecentScore
//---------------------------------------------------------

void MuseScore::updateRecentScores(Score* score)
void MuseScore::addRecentScore(Score* score)
{
QString path = score->importedFilePath(); // defined for scores imported from e.g. MIDI files
addRecentScore(path);
path = score->fileInfo()->canonicalFilePath();
addRecentScore(path);
if (startcenter)
startcenter->updateRecentScores();
}

//---------------------------------------------------------
// addRecentScore
//---------------------------------------------------------
void MuseScore::addRecentScore(const QString& scorePath)
{
if (scorePath.isEmpty() || _recentScores.first() == scorePath)
if (scorePath.isEmpty())
return;
_recentScores.removeAll(scorePath);
_recentScores.prepend(scorePath);
if (_recentScores.size() > RECENT_LIST_SIZE)
_recentScores.removeLast();
if (startcenter)
startcenter->updateRecentScores();
}

//---------------------------------------------------------
Expand Down Expand Up @@ -1542,7 +1539,7 @@ void MuseScore::dropEvent(QDropEvent* event)
Score* score = readScore(file);
if (score) {
view = appendScore(score);
updateRecentScores(score);
addRecentScore(score);
}
}
}
Expand Down Expand Up @@ -2038,7 +2035,7 @@ static void loadScores(const QStringList& argv)
mscore->appendScore(score);
scoresOnCommandline = true;
if(!MScore::noGui) {
mscore->updateRecentScores(score);
mscore->addRecentScore(score);
mscore->writeSessionFile(false);
}
}
Expand Down Expand Up @@ -3018,7 +3015,7 @@ void MuseScore::handleMessage(const QString& message)
Score* score = readScore(message);
if (score) {
setCurrentScoreView(appendScore(score));
updateRecentScores(score);
addRecentScore(score);
writeSessionFile(false);
}
}
Expand Down Expand Up @@ -4465,6 +4462,8 @@ QQmlEngine* MuseScore::qml() { return 0; }

//---------------------------------------------------------
// recentScores
// return a list of recent scores
// omit loaded scores
//---------------------------------------------------------

QFileInfoList MuseScore::recentScores() const
Expand All @@ -4478,7 +4477,7 @@ QFileInfoList MuseScore::recentScores() const
bool alreadyLoaded = false;
QString fp = fi.canonicalFilePath();
for (Score* s : mscore->scores()) {
if (s->fileInfo()->canonicalFilePath() == fp) {
if ((s->fileInfo()->canonicalFilePath() == fp) || (s->importedFilePath() == fp)) {
alreadyLoaded = true;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion mscore/musescore.h
Expand Up @@ -521,7 +521,7 @@ class MuseScore : public QMainWindow, public MuseScoreCore {
void updateTabNames();
QProgressBar* showProgressBar();
void hideProgressBar();
void updateRecentScores(Score*);
void addRecentScore(Score*);
QFileDialog* saveAsDialog();
QFileDialog* saveCopyDialog();

Expand Down

0 comments on commit c87cfae

Please sign in to comment.