|
From: Tapio V. <aa...@us...> - 2011-01-07 10:34:23
|
Module: editor
Branch: master
Commit: 3ffa0b6a1a9235de8a9b61fcb3b31eccd927d773
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 7 09:33:21 2011 +0200
No more loading lyrics from a predefined resource file.
---
editor.qrc | 6 +-----
editorapp.cc | 5 +++--
notegraphwidget.cc | 22 ++++++++++------------
notegraphwidget.hh | 1 +
4 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/editor.qrc b/editor.qrc
index b72217d..7646d2b 100644
--- a/editor.qrc
+++ b/editor.qrc
@@ -1,5 +1 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/dictionary">
- <file>words.txt</file>
-</qresource>
-</RCC>
+<RCC/>
diff --git a/editorapp.cc b/editorapp.cc
index b72876a..4b74e6c 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -6,8 +6,9 @@
EditorApp::EditorApp(QWidget *parent): QMainWindow(parent)
{
ui.setupUi(this);
- // Now adjust the NoteGraph's width according to the content
- ui.noteGraph->updateWidth();
+ // FIXME: Should not set any lyrics here
+ ui.noteGraph->setLyrics("Young man, there's no need to feel down. "
+ "I said, young man, pick yourself off the ground.");
}
void EditorApp::on_actionAbout_triggered()
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index b63cd04..3fe99ea 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -7,27 +7,25 @@
NoteGraphWidget::NoteGraphWidget(QWidget *parent)
: QWidget(parent)
{
- QFile dictionaryFile(":/dictionary/words.txt");
- dictionaryFile.open(QFile::ReadOnly);
- QTextStream inputStream(&dictionaryFile);
+ setAcceptDrops(true);
+}
- int x = 5;
- int y = 5;
+void NoteGraphWidget::setLyrics(QString lyrics)
+{
+ QTextStream ts(&lyrics, QIODevice::ReadOnly);
+ int x = 5, y = 5;
- while (!inputStream.atEnd()) {
+ while (!ts.atEnd()) {
QString word;
- inputStream >> word;
+ ts >> word;
if (!word.isEmpty()) {
- NoteLabel *wordLabel = new NoteLabel(word, this);
- wordLabel->move(x, y);
- wordLabel->show();
- wordLabel->setAttribute(Qt::WA_DeleteOnClose);
+ NoteLabel *wordLabel = new NoteLabel(word, this, QPoint(x, y));
x += wordLabel->width() + 2;
}
}
requiredWidth = x + 3;
- setAcceptDrops(true);
+ updateWidth();
}
void NoteGraphWidget::updateWidth()
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index 1f52420..38dfbb3 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -7,6 +7,7 @@ class NoteGraphWidget: public QWidget
public:
NoteGraphWidget(QWidget *parent = 0);
+ void setLyrics(QString lyrics);
void updateWidth();
protected:
|