|
From: Tapio V. <aa...@us...> - 2011-01-27 13:58:47
|
Module: editor
Branch: master
Commit: ac9fb5f53707edd51e0cebedaa6a271f4e733e5e
Author: Tapio Vierros <tap...@gm...>
Date: Thu Jan 27 15:58:07 2011 +0200
Line breaks are now inserted when importing plain text lyrics.
---
editorapp.cc | 10 ++--------
notegraphwidget.cc | 18 ++++++++++++------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index 3d7f839..cb09dd9 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -427,14 +427,8 @@ void EditorApp::on_actionLyricsFromFile_triggered()
return;
QTextStream in(&file);
- QString text = "";
- while (!in.atEnd()) {
- text += in.readLine();
- if (!in.atEnd()) text += " "; // TODO: Some kind of line separator here
- }
-
- if (text != "")
- noteGraph->setLyrics(text);
+ QString text = in.readAll();
+ if (text != "") noteGraph->setLyrics(text);
}
}
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index f5026cd..1287f82 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -77,13 +77,19 @@ void NoteGraphWidget::setLyrics(QString lyrics)
clearNotes();
bool first = true;
while (!ts.atEnd()) {
- QString word;
- ts >> word;
- if (!word.isEmpty()) {
- m_notes.push_back(new NoteLabel(Note(word), this, QPoint(0, n2px(24)), QSize(), !first));
- doOperation(opFromNote(*m_notes.back(), m_notes.size()-1), Operation::NO_EXEC);
- first = false;
+ // We want to loop one line at the time to insert line breaks
+ QString sentence = ts.readLine();
+ QTextStream ts2(&sentence, QIODevice::ReadOnly);
+ while (!ts2.atEnd()) {
+ QString word;
+ ts2 >> word;
+ if (!word.isEmpty()) {
+ m_notes.push_back(new NoteLabel(Note(word), this, QPoint(0, n2px(24)), QSize(), !first));
+ doOperation(opFromNote(*m_notes.back(), m_notes.size()-1), Operation::NO_EXEC);
+ first = false;
+ }
}
+ if (!m_notes.isEmpty()) setLineBreak(m_notes.back(), true);
}
finalizeNewLyrics();
|