From fe32ccc3bb5ebec8a060121136bd39e623a54622 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Fri, 25 Mar 2022 16:43:37 -0500 Subject: [PATCH] adding keywords to try to base finding place off that --- src/songsqlmodel.cpp | 79 +++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/src/songsqlmodel.cpp b/src/songsqlmodel.cpp index d055ace..ccba9c9 100644 --- a/src/songsqlmodel.cpp +++ b/src/songsqlmodel.cpp @@ -145,47 +145,58 @@ QStringList SongSqlModel::getLyricList(const int &row) { qDebug() << rawLyrics; QStringList lyrics; - qDebug() << lyrics; + // qDebug() << lyrics; QStringList vorder = recordData.value("vorder").toString().split(" "); qDebug() << vorder; - int startIndex; int endIndex; QString line; - QString verse; - qDebug() << vorder.contains("C1"); - qDebug() << vorder.indexOf("C1"); - foreach (QString vstr, vorder) { - foreach (line, rawLyrics) { - if (line.startsWith(vstr.at(0)) && line.endsWith(vstr.at(1))) { - qDebug() << line; - startIndex = rawLyrics.indexOf(line); - } - if (rawLyrics.indexOf(line) > startIndex) - verse.append(line + "\n"); - } - } - foreach (line, rawLyrics) { - if (line.trimmed() == "Chorus 1") { - startIndex = rawLyrics.indexOf(line) + 1; - // qDebug() << line; - // qDebug() << startIndex; - } - if (line.trimmed() == "Verse 1") { - endIndex = rawLyrics.indexOf(line); - // qDebug() << endIndex; - break; - } - if (rawLyrics.indexOf(line) == startIndex - 1) { - continue; - } - verse.append(line + "\n"); - // qDebug() << verse; - } + QStringList keywords = {"Verse 1", "Verse 2", "Verse 3", "Verse 4", + "Verse 5", "Verse 6", "Verse 7", "Verse 8", + "Chorus 1", "Chorus 2", "Chorus 3", "Chorus 4", + "Bridge 1", "Bridge 2", "Bridge 3", "Bridge 4", + "Intro 1", "Outro 2", "Ending 1", "Other 1"}; + + foreach (const QString &vstr, vorder) { + int startIndex; + QString verse; + qDebug() << vstr; + foreach (line, rawLyrics) { + if (keywords.contains(line)) { + if (line.startsWith(vstr.at(0)) && line.endsWith(vstr.at(1))) { + qDebug() << vstr << line; + startIndex = rawLyrics.indexOf(line); + continue; + } + qDebug() << "Break out"; + break; + } + qDebug() << line; + // verse.append(line + "\n"); + // qDebug() << verse; + } + // lyrics.append(verse); + // qDebug() << verse; + } + // foreach (line, rawLyrics) { + // if (line.trimmed() == "Chorus 1") { + // startIndex = rawLyrics.indexOf(line) + 1; + // // qDebug() << line; + // // qDebug() << startIndex; + // } + // if (line.trimmed() == "Verse 1") { + // endIndex = rawLyrics.indexOf(line); + // // qDebug() << endIndex; + // break; + // } + // if (rawLyrics.indexOf(line) == startIndex - 1) { + // continue; + // } + // verse.append(line + "\n"); + // // qDebug() << verse; + // } - lyrics.append(verse); - qDebug() << lyrics; return lyrics; }