Fixed the song textarea from removing blank lines
This commit is contained in:
parent
7f69726c47
commit
93c94e19db
7 changed files with 51 additions and 8 deletions
1
TODO.org
1
TODO.org
|
@ -4,5 +4,6 @@
|
||||||
|
|
||||||
[[file:~/dev/church-presenter/src/qml/presenter/LeftDock.qml::/* showPassiveNotification(serviceItemList.currentIndex); */]]
|
[[file:~/dev/church-presenter/src/qml/presenter/LeftDock.qml::/* showPassiveNotification(serviceItemList.currentIndex); */]]
|
||||||
** TODO Parse Lyrics to create a list of strings for slides
|
** TODO Parse Lyrics to create a list of strings for slides
|
||||||
|
SCHEDULED: <2022-03-23 Wed 10:00>
|
||||||
|
|
||||||
[[file:~/dev/church-presenter/src/qml/presenter/LeftDock.qml::/* showPassiveNotification(serviceItemList.currentIndex); */]]
|
[[file:~/dev/church-presenter/src/qml/presenter/LeftDock.qml::/* showPassiveNotification(serviceItemList.currentIndex); */]]
|
||||||
|
|
|
@ -38,7 +38,8 @@ ColumnLayout {
|
||||||
dragItemType,
|
dragItemType,
|
||||||
dragItemText,
|
dragItemText,
|
||||||
dragItemBackgroundType,
|
dragItemBackgroundType,
|
||||||
dragItemBackground);
|
dragItemBackground,
|
||||||
|
dragItemIndex);
|
||||||
}
|
}
|
||||||
keys: ["library"]
|
keys: ["library"]
|
||||||
|
|
||||||
|
@ -126,7 +127,8 @@ ColumnLayout {
|
||||||
dragItemType,
|
dragItemType,
|
||||||
dragItemText,
|
dragItemText,
|
||||||
dragItemBackgroundType,
|
dragItemBackgroundType,
|
||||||
dragItemBackground);
|
dragItemBackground,
|
||||||
|
dragItemIndex);
|
||||||
}
|
}
|
||||||
keys: ["library"]
|
keys: ["library"]
|
||||||
}
|
}
|
||||||
|
@ -173,7 +175,7 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addItem(index, name, type, text, backgroundType, background) {
|
function addItem(index, name, type, text, backgroundType, background, itemID) {
|
||||||
serviceListModel.insert(index, {
|
serviceListModel.insert(index, {
|
||||||
"name": name,
|
"name": name,
|
||||||
"type": type,
|
"type": type,
|
||||||
|
@ -182,13 +184,19 @@ ColumnLayout {
|
||||||
"background": background})
|
"background": background})
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendItem(name, type, text, backgroundType, background) {
|
function appendItem(name, type, text, backgroundType, background, itemID) {
|
||||||
serviceListModel.append({
|
serviceListModel.append({
|
||||||
"name": name,
|
"name": name,
|
||||||
"type": type,
|
"type": type,
|
||||||
"text": text,
|
"text": text,
|
||||||
"backgroundType": backgroundType,
|
"backgroundType": backgroundType,
|
||||||
"background": background})
|
"background": background});
|
||||||
|
|
||||||
|
if (type == "song") {
|
||||||
|
const lyrics = songsqlmodel.getLyricList(itemID);
|
||||||
|
print(lyrics);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,6 +208,7 @@ Item {
|
||||||
target: songListItem
|
target: songListItem
|
||||||
onActiveChanged: {
|
onActiveChanged: {
|
||||||
if (songDragHandler.drag.active) {
|
if (songDragHandler.drag.active) {
|
||||||
|
dragItemIndex = index;
|
||||||
dragItemTitle = title;
|
dragItemTitle = title;
|
||||||
dragItemType = "song";
|
dragItemType = "song";
|
||||||
dragItemBackgroundType = backgroundType;
|
dragItemBackgroundType = backgroundType;
|
||||||
|
|
|
@ -18,6 +18,7 @@ Controls.Page {
|
||||||
|
|
||||||
/* property var video */
|
/* property var video */
|
||||||
|
|
||||||
|
property int dragItemIndex
|
||||||
property string dragItemTitle: ""
|
property string dragItemTitle: ""
|
||||||
property string dragItemType: ""
|
property string dragItemType: ""
|
||||||
property string dragItemText: ""
|
property string dragItemText: ""
|
||||||
|
|
|
@ -177,13 +177,14 @@ Item {
|
||||||
placeholderText: "Put lyrics here..."
|
placeholderText: "Put lyrics here..."
|
||||||
persistentSelection: true
|
persistentSelection: true
|
||||||
text: songLyrics
|
text: songLyrics
|
||||||
textFormat: TextEdit.MarkdownText
|
textFormat: TextEdit.PlainText
|
||||||
padding: 10
|
padding: 10
|
||||||
onEditingFinished: {
|
onEditingFinished: {
|
||||||
updateLyrics(text);
|
updateLyrics(lyricsEditor.getText(0,lyricsEditor.length));
|
||||||
editorTimer.running = false;
|
editorTimer.running = false;
|
||||||
}
|
}
|
||||||
onPressed: editorTimer.running = true
|
onPressed: editorTimer.running = true
|
||||||
|
/* Component.onCompleted: text = songsqlmodel.getLyrics(songIndex); */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Controls.TextField {
|
Controls.TextField {
|
||||||
|
@ -215,6 +216,12 @@ Item {
|
||||||
Layout.rightMargin: 20
|
Layout.rightMargin: 20
|
||||||
Layout.leftMargin: 20
|
Layout.leftMargin: 20
|
||||||
}
|
}
|
||||||
|
Controls.Button {
|
||||||
|
text: "update lyrics"
|
||||||
|
onClicked: {
|
||||||
|
print(lyricsEditor.getText(0,lyricsEditor.length));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,7 +231,9 @@ Item {
|
||||||
interval: 1000
|
interval: 1000
|
||||||
repeat: true
|
repeat: true
|
||||||
running: false
|
running: false
|
||||||
onTriggered: updateLyrics(lyricsEditor.text)
|
onTriggered: {
|
||||||
|
updateLyrics(lyricsEditor.getText(0,lyricsEditor.length));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileDialog {
|
FileDialog {
|
||||||
|
@ -282,6 +291,7 @@ Item {
|
||||||
|
|
||||||
function updateLyrics(lyrics) {
|
function updateLyrics(lyrics) {
|
||||||
songsqlmodel.updateLyrics(songIndex, lyrics);
|
songsqlmodel.updateLyrics(songIndex, lyrics);
|
||||||
|
print(lyrics);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTitle(title) {
|
function updateTitle(title) {
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
#include <qabstractitemmodel.h>
|
#include <qabstractitemmodel.h>
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
|
#include <qglobal.h>
|
||||||
#include <qobjectdefs.h>
|
#include <qobjectdefs.h>
|
||||||
|
#include <qsqlquery.h>
|
||||||
#include <qsqlrecord.h>
|
#include <qsqlrecord.h>
|
||||||
|
|
||||||
static const char *songsTableName = "songs";
|
static const char *songsTableName = "songs";
|
||||||
|
@ -131,6 +133,23 @@ QVariantList SongSqlModel::getSong(const int &row) {
|
||||||
return song;
|
return song;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList SongSqlModel::getLyricList(const int &row) {
|
||||||
|
QSqlRecord recordData = record(row);
|
||||||
|
if (recordData.isEmpty()) {
|
||||||
|
qDebug() << "this is not a song";
|
||||||
|
QStringList empty;
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString rawLyrics = recordData.value("lyrics").toString();
|
||||||
|
qDebug() << rawLyrics;
|
||||||
|
|
||||||
|
QStringList lyrics = rawLyrics.split("\n");
|
||||||
|
qDebug() << lyrics;
|
||||||
|
|
||||||
|
return lyrics;
|
||||||
|
}
|
||||||
|
|
||||||
int SongSqlModel::id() const {
|
int SongSqlModel::id() const {
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
@ -203,7 +222,9 @@ void SongSqlModel::setLyrics(const QString &lyrics) {
|
||||||
void SongSqlModel::updateLyrics(const int &row, const QString &lyrics) {
|
void SongSqlModel::updateLyrics(const int &row, const QString &lyrics) {
|
||||||
qDebug() << "Row is " << row;
|
qDebug() << "Row is " << row;
|
||||||
QSqlRecord rowdata = record(row);
|
QSqlRecord rowdata = record(row);
|
||||||
|
qDebug() << lyrics;
|
||||||
rowdata.setValue("lyrics", lyrics);
|
rowdata.setValue("lyrics", lyrics);
|
||||||
|
qDebug() << rowdata.value("lyrics");
|
||||||
setRecord(row, rowdata);
|
setRecord(row, rowdata);
|
||||||
submitAll();
|
submitAll();
|
||||||
emit lyricsChanged();
|
emit lyricsChanged();
|
||||||
|
|
|
@ -54,6 +54,7 @@ public:
|
||||||
Q_INVOKABLE void newSong();
|
Q_INVOKABLE void newSong();
|
||||||
Q_INVOKABLE void deleteSong(const int &row);
|
Q_INVOKABLE void deleteSong(const int &row);
|
||||||
Q_INVOKABLE QVariantList getSong(const int &row);
|
Q_INVOKABLE QVariantList getSong(const int &row);
|
||||||
|
Q_INVOKABLE QStringList getLyricList(const int &row);
|
||||||
|
|
||||||
QVariant data(const QModelIndex &index, int role) const override;
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
QHash<int, QByteArray> roleNames() const override;
|
QHash<int, QByteArray> roleNames() const override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue