From 4af91b494225571e41ca7f762734eb59de8e0210 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Mon, 7 Jul 2025 10:02:14 +0200 Subject: [PATCH] improved reload of msr-files in musredit after a msr2data command. --- src/musredit_qt5/musredit/PTextEdit.cpp | 34 ++++++++++++++++++++++++- src/musredit_qt6/musredit/PTextEdit.cpp | 34 ++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/src/musredit_qt5/musredit/PTextEdit.cpp b/src/musredit_qt5/musredit/PTextEdit.cpp index 615d6a5f..4f52756d 100644 --- a/src/musredit_qt5/musredit/PTextEdit.cpp +++ b/src/musredit_qt5/musredit/PTextEdit.cpp @@ -3522,7 +3522,8 @@ void PTextEdit::fillRecentFiles() //---------------------------------------------------------------------------------------------------- /** - *

run list is split (space separated) and expanded (start-end -> start, start+1, ..., end) to a list + *

run list is split (space separated), expanded (start-end -> start, start+1, ..., end) or + * (start:end:step -> start, start+step, ..., end) to a list. * * \param runListStr list to be split and expanded * \param ok true if everything is fine; false if an error has been encountered @@ -3572,6 +3573,37 @@ QStringList PTextEdit::getRunList(QString runListStr, bool &ok) str = QString("%1").arg(i); result << str; } + } else if (tok[i].contains(':')) { // list given, hence need to expand + QStringList runListTok = tok[i].split(':', Qt::SkipEmptyParts); + int start{0}, end{0}, step{0}; + if (runListTok.size() != 3) { // error + ok = false; + result.clear(); + return result; + } + start = runListTok[0].toInt(&isInt); + if (!isInt) { + ok = false; + result.clear(); + return result; + } + end = runListTok[1].toInt(&isInt); + if (!isInt) { + ok = false; + result.clear(); + return result; + } + step = runListTok[2].toInt(&isInt); + if (!isInt) { + ok = false; + result.clear(); + return result; + } + do { + str = QString("%1").arg(start); + result << str; + start += step; + } while (start <= end); } else { // keep it result << tok[i]; } diff --git a/src/musredit_qt6/musredit/PTextEdit.cpp b/src/musredit_qt6/musredit/PTextEdit.cpp index 3c28f837..891ab867 100644 --- a/src/musredit_qt6/musredit/PTextEdit.cpp +++ b/src/musredit_qt6/musredit/PTextEdit.cpp @@ -3487,7 +3487,8 @@ void PTextEdit::fillRecentFiles() //---------------------------------------------------------------------------------------------------- /** - *

run list is split (space separated) and expanded (start-end -> start, start+1, ..., end) to a list + *

run list is split (space separated), expanded (start-end -> start, start+1, ..., end) or + * (start:end:step -> start, start+step, ..., end) to a list. * * \param runListStr list to be split and expanded * \param ok true if everything is fine; false if an error has been encountered @@ -3529,6 +3530,37 @@ QStringList PTextEdit::getRunList(QString runListStr, bool &ok) str = QString("%1").arg(i); result << str; } + } else if (tok[i].contains(':')) { // list given, hence need to expand + QStringList runListTok = tok[i].split(':', Qt::SkipEmptyParts); + int start{0}, end{0}, step{0}; + if (runListTok.size() != 3) { // error + ok = false; + result.clear(); + return result; + } + start = runListTok[0].toInt(&isInt); + if (!isInt) { + ok = false; + result.clear(); + return result; + } + end = runListTok[1].toInt(&isInt); + if (!isInt) { + ok = false; + result.clear(); + return result; + } + step = runListTok[2].toInt(&isInt); + if (!isInt) { + ok = false; + result.clear(); + return result; + } + do { + str = QString("%1").arg(start); + result << str; + start += step; + } while (start <= end); } else { // keep it result << tok[i]; }