From 5672c43d2eb47c7df840ce70864eb93804e8c834 Mon Sep 17 00:00:00 2001 From: nemu Date: Wed, 13 Jul 2011 14:32:14 +0000 Subject: [PATCH] improved token handling --- src/musredit/PTextEdit.cpp | 20 ++++++++++---------- src/musrgui/PTextEdit.cpp | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/musredit/PTextEdit.cpp b/src/musredit/PTextEdit.cpp index aafb520c..dda31c42 100644 --- a/src/musredit/PTextEdit.cpp +++ b/src/musredit/PTextEdit.cpp @@ -670,7 +670,7 @@ bool PTextEdit::validRunList(const QString runList) int val; bool ok; while (!done) { - subStr = runList.section(' ', i, i); + subStr = runList.section(' ', i, i, QString::SectionSkipEmpty); if (subStr.isEmpty()) { done = true; continue; @@ -1798,7 +1798,7 @@ void PTextEdit::musrMsr2Data() break; case 1: end = 0; - while (!runList.section(' ', end, end).isEmpty()) { + while (!runList.section(' ', end, end, QString::SectionSkipEmpty).isEmpty()) { end++; } // first element @@ -1806,14 +1806,14 @@ void PTextEdit::musrMsr2Data() str = "[" + runList + "]"; cmd.append(str); } else { - str = "[" + runList.section(' ', 0, 0); + str = "[" + runList.section(' ', 0, 0, QString::SectionSkipEmpty); cmd.append(str); // middle elements for (i=1; imsrFileExtension.isEmpty()) fln += ".msr"; else @@ -1956,7 +1956,7 @@ void PTextEdit::musrMsr2Data() str = stream->readLine(); // line of text excluding '\n' str.trimmed(); if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", Qt::CaseInsensitive)) { - fln = str.section(' ', 0, 0); + fln = str.section(' ', 0, 0, QString::SectionSkipEmpty); if (fMsr2DataParam->msrFileExtension.isEmpty()) fln += ".msr"; else @@ -1983,7 +1983,7 @@ void PTextEdit::musrMsr2Data() fln = QString("%1").arg(fMsr2DataParam->firstRun) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr"); break; case 1: // run list - fln = runList.section(" ", 0, 0) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr"); + fln = runList.section(" ", 0, 0, QString::SectionSkipEmpty) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr"); break; case 2: // run list file name file = new QFile(fMsr2DataParam->runListFileName); @@ -1998,7 +1998,7 @@ void PTextEdit::musrMsr2Data() str = stream->readLine(); // line of text excluding '\n' str.trimmed(); if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", Qt::CaseInsensitive)) { - fln = str.section(' ', 0, 0); + fln = str.section(' ', 0, 0, QString::SectionSkipEmpty); break; } } diff --git a/src/musrgui/PTextEdit.cpp b/src/musrgui/PTextEdit.cpp index e87f9e9e..d325e8b7 100644 --- a/src/musrgui/PTextEdit.cpp +++ b/src/musrgui/PTextEdit.cpp @@ -499,7 +499,7 @@ bool PTextEdit::validRunList(const QString runList) int val; bool ok; while (!done) { - subStr = runList.section(' ', i, i); + subStr = runList.section(' ', i, i, QString::SectionSkipEmpty); if (subStr.isEmpty()) { done = true; continue; @@ -1525,7 +1525,7 @@ void PTextEdit::musrMsr2Data() break; case 1: end = 0; - while (!runList.section(' ', end, end).isEmpty()) { + while (!runList.section(' ', end, end, QString::SectionSkipEmpty).isEmpty()) { end++; } // first element @@ -1533,14 +1533,14 @@ void PTextEdit::musrMsr2Data() str = "[" + runList + "]"; cmd.append(str); } else { - str = "[" + runList.section(' ', 0, 0); + str = "[" + runList.section(' ', 0, 0, QString::SectionSkipEmpty); cmd.append(str); // middle elements for (i=1; imsrFileExtension.isEmpty()) fln += ".msr"; else @@ -1681,7 +1681,7 @@ void PTextEdit::musrMsr2Data() str = stream->readLine(); // line of text excluding '\n' str.stripWhiteSpace(); if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", false)) { - fln = str.section(' ', 0, 0); + fln = str.section(' ', 0, 0, QString::SectionSkipEmpty); if (fMsr2DataParam->msrFileExtension.isEmpty()) fln += ".msr"; else @@ -1707,7 +1707,7 @@ void PTextEdit::musrMsr2Data() fln = QString("%1").arg(fMsr2DataParam->firstRun) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr"); break; case 1: // run list - fln = runList.section(" ", 0, 0) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr"); + fln = runList.section(" ", 0, 0, QString::SectionSkipEmpty) + QString("+global") + fMsr2DataParam->msrFileExtension + QString(".msr"); break; case 2: // run list file name file = new QFile(fMsr2DataParam->runListFileName); @@ -1722,7 +1722,7 @@ void PTextEdit::musrMsr2Data() str = stream->readLine(); // line of text excluding '\n' str.stripWhiteSpace(); if (!str.isEmpty() && !str.startsWith("#") && !str.startsWith("run", false)) { - fln = str.section(' ', 0, 0); + fln = str.section(' ', 0, 0, QString::SectionSkipEmpty); break; } }