Seperating editors and making backgrounds work

This commit is contained in:
Chris Cochrun 2022-03-21 14:24:16 -05:00
parent bcdba4fea9
commit c71356cac3
8 changed files with 414 additions and 302 deletions

View file

@ -34,7 +34,11 @@ ColumnLayout {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
onDropped: { onDropped: {
serviceListModel.append({"name": dragSongTitle, "type": "song"}); appendItem(dragItemTitle,
dragItemType,
dragItemText,
dragItemBackgroundType,
dragItemBackground);
} }
keys: ["library"] keys: ["library"]
@ -106,7 +110,7 @@ ColumnLayout {
onMoveRequested: serviceListModel.move(oldIndex, newIndex, 1) onMoveRequested: serviceListModel.move(oldIndex, newIndex, 1)
onClicked: { onClicked: {
serviceItemList.currentIndex = index; serviceItemList.currentIndex = index;
showPassiveNotification(serviceItemList.currentIndex); /* showPassiveNotification(serviceItemList.currentIndex); */
changeSlideBackground(background, backgroundType); changeSlideBackground(background, backgroundType);
changeSlideText(text); changeSlideText(text);
changeSlideType(type); changeSlideType(type);
@ -117,8 +121,12 @@ ColumnLayout {
id: serviceDrop id: serviceDrop
anchors.fill: parent anchors.fill: parent
onDropped: { onDropped: {
serviceListModel.insert(index, {"name": dragSongTitle, "type": "song"}); addItem(index,
showPassiveNotification(index); dragItemTitle,
dragItemType,
dragItemText,
dragItemBackgroundType,
dragItemBackground);
} }
keys: ["library"] keys: ["library"]
} }
@ -161,33 +169,26 @@ ColumnLayout {
backgroundType: "video" backgroundType: "video"
background: "file:/home/chris/nextcloud/tfc/openlp/videos/test.mp4" background: "file:/home/chris/nextcloud/tfc/openlp/videos/test.mp4"
} }
ListElement {
name: "facebook"
type: "video"
text: ""
backgroundType: "video"
background: "file:/home/chris/nextcloud/tfc/videos/facebook-ukraine-vid.mkv"
} }
ListElement {
name: "10,000 Reason"
type: "song"
}
ListElement {
name: "Marvelous Light"
type: "song"
}
ListElement {
name: "10,000 Reason"
type: "song"
}
ListElement {
name: "Marvelous Light"
type: "song"
} }
} }
function addItem(index, name, type, text, backgroundType, background) {
serviceListModel.insert(index, {
"name": name,
"type": type,
"text": text,
"backgroundType": backgroundType,
"background": background})
} }
function appendItem(name, type, text, backgroundType, background) {
serviceListModel.append({
"name": name,
"type": type,
"text": text,
"backgroundType": backgroundType,
"background": background})
} }
} }

View file

@ -164,36 +164,26 @@ Item {
backgroundColor: { backgroundColor: {
if (parent.ListView.isCurrentItem) { if (parent.ListView.isCurrentItem) {
Kirigami.Theme.highlightColor; Kirigami.Theme.highlightColor;
} else if (dragHandler.containsMouse){ } else if (songDragHandler.containsMouse){
Kirigami.Theme.highlightColor; Kirigami.Theme.highlightColor;
} else { } else {
Kirigami.Theme.backgroundColor; Kirigami.Theme.backgroundColor;
} }
} }
textColor: { textColor: {
if (parent.ListView.isCurrentItem || dragHandler.containsMouse) if (parent.ListView.isCurrentItem || songDragHandler.containsMouse)
activeTextColor; activeTextColor;
else else
Kirigami.Theme.textColor; Kirigami.Theme.textColor;
} }
/* onAdd: { */
/* showPassiveNotification(title, 3000) */
/* songLibraryList.currentIndex = index */
/* song = index */
/* songTitle = title */
/* songLyrics = lyrics */
/* songAuthor = author */
/* songVorder = vorder */
/* } */
Behavior on height { Behavior on height {
NumberAnimation { NumberAnimation {
easing.type: Easing.OutCubic easing.type: Easing.OutCubic
duration: 300 duration: 300
} }
} }
Drag.active: dragHandler.drag.active Drag.active: songDragHandler.drag.active
Drag.hotSpot.x: width / 2 Drag.hotSpot.x: width / 2
Drag.hotSpot.y: height / 2 Drag.hotSpot.y: height / 2
Drag.keys: [ "library" ] Drag.keys: [ "library" ]
@ -211,15 +201,18 @@ Item {
} }
MouseArea { MouseArea {
id: dragHandler id: songDragHandler
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
drag { drag {
target: songListItem target: songListItem
onActiveChanged: { onActiveChanged: {
if (dragHandler.drag.active) { if (songDragHandler.drag.active) {
dragSongTitle = title dragItemTitle = title;
showPassiveNotification(dragSongTitle) dragItemType = "song";
dragItemBackgroundType = "image";
dragItemBackground = "";
/* showPassiveNotification(dragSongTitle) */
} else { } else {
songListItem.Drag.drop() songListItem.Drag.drop()
} }
@ -228,7 +221,7 @@ Item {
threshold: 10 threshold: 10
} }
MouseArea { MouseArea {
id: clickHandler id: songClickHandler
anchors.fill: parent anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: { onClicked: {
@ -237,11 +230,10 @@ Item {
else{ else{
showPassiveNotification(title, 3000) showPassiveNotification(title, 3000)
songLibraryList.currentIndex = index songLibraryList.currentIndex = index
song = index if (!editMode)
songTitle = title editMode = true;
songLyrics = lyrics editType = "song";
songAuthor = author editSwitch(index);
songVorder = vorder
} }
} }
@ -249,8 +241,8 @@ Item {
} }
Controls.Menu { Controls.Menu {
id: rightClickSongMenu id: rightClickSongMenu
x: clickHandler.mouseX x: songClickHandler.mouseX
y: clickHandler.mouseY + 10 y: songClickHandler.mouseY + 10
Kirigami.Action { Kirigami.Action {
text: "delete" text: "delete"
onTriggered: songsqlmodel.deleteSong(index) onTriggered: songsqlmodel.deleteSong(index)
@ -274,15 +266,11 @@ Item {
function newSong() { function newSong() {
songsqlmodel.newSong(); songsqlmodel.newSong();
songLibraryList.currentIndex = songsqlmodel.rowCount(); songLibraryList.currentIndex = songsqlmodel.rowCount() - 1;
if (!editMode) if (!editMode)
toggleEditMode(); editMode = true;
song = songLibraryList.currentItem editType = "song";
songTitle = songLibraryList.currentItem.title editSwitch(songLibraryList.currentIndex);
songLyrics = songLibraryList.currentItem.lyrics
songAuthor = songLibraryList.currentItem.author
songVorder = songLibraryList.currentItem.vorder
showPassiveNotification("newest song index: " + songLibraryList.currentIndex)
} }
} }
@ -436,8 +424,11 @@ Item {
target: videoListItem target: videoListItem
onActiveChanged: { onActiveChanged: {
if (videoDragHandler.drag.active) { if (videoDragHandler.drag.active) {
dragVideoTitle = title dragItemTitle = title;
showPassiveNotification(dragVideoTitle) dragItemType = "video";
dragItemText = "";
dragItemBackgroundType = "video";
dragItemBackground = filePath;
} else { } else {
videoListItem.Drag.drop() videoListItem.Drag.drop()
} }
@ -457,7 +448,8 @@ Item {
const video = videosqlmodel.getVideo(videoLibraryList.currentIndex); const video = videosqlmodel.getVideo(videoLibraryList.currentIndex);
if (!editMode) if (!editMode)
editMode = true; editMode = true;
editSwitch("video", video); editType = "video";
editSwitch(video);
} }
} }
@ -531,8 +523,8 @@ Item {
duration: 300 duration: 300
} }
} }
} }
Rectangle { Rectangle {
id: presentationLibraryPanel id: presentationLibraryPanel
Layout.preferredHeight: 40 Layout.preferredHeight: 40
@ -588,8 +580,8 @@ Item {
duration: 300 duration: 300
} }
} }
} }
Rectangle { Rectangle {
id: slideLibraryPanel id: slideLibraryPanel
Layout.preferredHeight: 40 Layout.preferredHeight: 40
@ -645,9 +637,9 @@ Item {
duration: 300 duration: 300
} }
} }
}
}
}
}
DropArea { DropArea {
id: fileDropArea id: fileDropArea
anchors.fill: parent anchors.fill: parent

View file

@ -14,15 +14,15 @@ Controls.Page {
// properties passed around for the slides // properties passed around for the slides
property url imageBackground: "" property url imageBackground: ""
property url videoBackground: "" property url videoBackground: ""
property string songTitle: ""
property string songLyrics: ""
property string songAuthor: ""
property string songVorder: ""
property int blurRadius: 0 property int blurRadius: 0
/* property var video */ /* property var video */
property string dragSongTitle: "" property string dragItemTitle: ""
property string dragItemType: ""
property string dragItemText: ""
property string dragItemBackgroundType: ""
property string dragItemBackground: ""
property bool editing: true property bool editing: true
@ -30,7 +30,7 @@ Controls.Page {
property var song property var song
property var draggedLibraryItem property var draggedLibraryItem
property Item editStackItem property string editType
Item { Item {
id: mainItem id: mainItem
@ -124,41 +124,6 @@ Controls.Page {
} }
} }
FileDialog {
id: videoFileDialog
title: "Please choose a background"
folder: shortcuts.home
selectMultiple: false
nameFilters: ["Video files (*.mp4 *.mkv *.mov *.wmv *.avi *.MP4 *.MOV *.MKV)"]
onAccepted: {
imageBackground = ""
videoBackground = videoFileDialog.fileUrls[0]
print("video background = " + videoFileDialog.fileUrl)
}
onRejected: {
print("Canceled")
/* Qt.quit() */
}
}
FileDialog {
id: imageFileDialog
title: "Please choose a background"
folder: shortcuts.home
selectMultiple: false
nameFilters: ["Image files (*.jpg *.jpeg *.png *.JPG *.JPEG *.PNG)"]
onAccepted: {
videoBackground = ""
imageBackground = imageFileDialog.fileUrls[0]
}
onRejected: {
print("Canceled")
/* Qt.quit() */
}
}
SongSqlModel { SongSqlModel {
id: songsqlmodel id: songsqlmodel
} }
@ -168,21 +133,15 @@ Controls.Page {
} }
function changeSlideType(type) { function changeSlideType(type) {
/* showPassiveNotification("used to be: " + presentation.text); */
presentation.itemType = type; presentation.itemType = type;
/* showPassiveNotification("next"); */
if (slideItem) if (slideItem)
slideItem.itemType = type; slideItem.itemType = type;
/* showPassiveNotification("last"); */
} }
function changeSlideText(text) { function changeSlideText(text) {
/* showPassiveNotification("used to be: " + presentation.text); */
presentation.text = text; presentation.text = text;
/* showPassiveNotification("next"); */
if (slideItem) if (slideItem)
slideItem.text = text; slideItem.text = text;
/* showPassiveNotification("last"); */
} }
function changeSlideBackground(background, type) { function changeSlideBackground(background, type) {
@ -217,28 +176,37 @@ Controls.Page {
showPassiveNotification("previous slide please") showPassiveNotification("previous slide please")
} }
function editSwitch(editType, item) { function editSwitch(item) {
if (editMode) { if (editMode) {
switch (editType) { switch (editType) {
case "song" : case "song" :
presentation.visible = false; presentation.visible = false;
videoEditor.visible = false; videoEditor.visible = false;
videoEditor.stop();
songEditor.visible = true; songEditor.visible = true;
songEditor.changeSong(item);
break; break;
case "video" : case "video" :
presentation.visible = false; presentation.visible = false;
songEditor.visible = false; songEditor.visible = false;
videoEditor.visible = true; videoEditor.visible = true;
videoEditor.changeVideo(item);
break; break;
case "image" : case "image" :
mainPageArea.pop(Controls.StackView.Immediate); mainPageArea.pop(Controls.StackView.Immediate);
mainPageArea.push(imageEditorComp, Controls.StackView.Immediate); mainPageArea.push(imageEditorComp, Controls.StackView.Immediate);
videoEditor.stop();
break; break;
default: default:
videoEditor videoEditor.visible = false;
videoEditor.stop();
songEditor.visible = false;
presentation.visible = true;
editMode = false;
} }
} else { } else {
videoEditor.visible = false; videoEditor.visible = false;
videoEditor.stop();
songEditor.visible = false; songEditor.visible = false;
presentation.visible = true; presentation.visible = true;
editMode = false; editMode = false;
@ -251,28 +219,4 @@ videoEditor
else else
presentationWindow.close(); presentationWindow.close();
} }
function updateLyrics(lyrics) {
songsqlmodel.updateLyrics(song, lyrics);
}
function updateTitle(title) {
songsqlmodel.updateTitle(song, title)
}
function updateAuthor(author) {
songsqlmodel.updateAuthor(song, author)
}
function updateAudio(audio) {
songsqlmodel.updateAudio(song, audio)
}
function updateCcli(ccli) {
songsqlmodel.updateCcli(song, ccli)
}
function updateVerseOrder(vorder) {
songsqlmodel.updateVerseOrder(song, vorder)
}
} }

View file

@ -11,10 +11,15 @@ import "./" as Presenter
Item { Item {
id: root id: root
property string imageBackground
property string videoBackground
Presenter.Slide { Presenter.Slide {
id: representation id: representation
anchors.fill: parent anchors.fill: parent
textSize: width / 15 textSize: width / 15
editMode: true editMode: true
imageSource: imageBackground
videoSource: videoBackground
} }
} }

View file

@ -8,6 +8,16 @@ import "./" as Presenter
Item { Item {
id: root id: root
property int songIndex
property string songTitle
property string songLyrics
property string songAuthor
property string songCcli
property string songAudio
property string songVorder
property string songBackground
property string songBackgroundType
GridLayout { GridLayout {
id: mainLayout id: mainLayout
anchors.fill: parent anchors.fill: parent
@ -66,11 +76,11 @@ Item {
text: "Background" text: "Background"
icon.name: "fileopen" icon.name: "fileopen"
hoverEnabled: true hoverEnabled: true
onClicked: backgroundType.open() onClicked: backgroundTypePopup.open()
} }
Controls.Popup { Controls.Popup {
id: backgroundType id: backgroundTypePopup
x: backgroundButton.x x: backgroundButton.x
y: backgroundButton.y + backgroundButton.height + 20 y: backgroundButton.y + backgroundButton.height + 20
modal: true modal: true
@ -83,7 +93,7 @@ Item {
border.color: Kirigami.Theme.activeBackgroundColor border.color: Kirigami.Theme.activeBackgroundColor
border.width: 2 border.width: 2
} }
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent closePolicy: Controls.Popup.CloseOnEscape | Controls.Popup.CloseOnPressOutsideParent
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
Controls.ToolButton { Controls.ToolButton {
@ -91,14 +101,14 @@ Item {
Layout.fillWidth: true Layout.fillWidth: true
text: "Video" text: "Video"
icon.name: "emblem-videos-symbolic" icon.name: "emblem-videos-symbolic"
onClicked: videoFileDialog.open() & backgroundType.close() onClicked: videoFileDialog.open() & backgroundTypePopup.close()
} }
Controls.ToolButton { Controls.ToolButton {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
text: "Image" text: "Image"
icon.name: "folder-pictures-symbolic" icon.name: "folder-pictures-symbolic"
onClicked: imageFileDialog.open() & backgroundType.close() onClicked: imageFileDialog.open() & backgroundTypePopup.close()
} }
} }
} }
@ -196,15 +206,15 @@ Item {
Controls.SplitView.preferredWidth: 700 Controls.SplitView.preferredWidth: 700
Controls.SplitView.minimumWidth: 300 Controls.SplitView.minimumWidth: 300
Rectangle { /* Rectangle { */
id: slideBar /* id: slideBar */
color: Kirigami.Theme.highlightColor /* color: Kirigami.Theme.highlightColor */
Layout.preferredWidth: 500 /* Layout.preferredWidth: 500 */
Layout.preferredHeight: songTitleField.height /* Layout.preferredHeight: songTitleField.height */
Layout.rightMargin: 20 /* Layout.rightMargin: 20 */
Layout.leftMargin: 20 /* Layout.leftMargin: 20 */
} /* } */
Presenter.SlideEditor { Presenter.SlideEditor {
id: slideEditor id: slideEditor
@ -215,11 +225,10 @@ Item {
Layout.rightMargin: 20 Layout.rightMargin: 20
Layout.leftMargin: 20 Layout.leftMargin: 20
} }
}
} }
} }
}
Timer { Timer {
id: editorTimer id: editorTimer
interval: 1000 interval: 1000
@ -227,4 +236,87 @@ Item {
running: false running: false
onTriggered: updateLyrics(lyricsEditor.text) onTriggered: updateLyrics(lyricsEditor.text)
} }
FileDialog {
id: videoFileDialog
title: "Please choose a background"
folder: shortcuts.home
selectMultiple: false
nameFilters: ["Video files (*.mp4 *.mkv *.mov *.wmv *.avi *.MP4 *.MOV *.MKV)"]
onAccepted: {
updateBackground(videoFileDialog.fileUrls[0], "video");
print("video background = " + videoFileDialog.fileUrls[0]);
}
onRejected: {
print("Canceled")
}
}
FileDialog {
id: imageFileDialog
title: "Please choose a background"
folder: shortcuts.home
selectMultiple: false
nameFilters: ["Image files (*.jpg *.jpeg *.png *.JPG *.JPEG *.PNG)"]
onAccepted: {
updateBackground(imageFileDialog.fileUrls[0], "image");
print("image background = " + imageFileDialog.fileUrls[0]);
}
onRejected: {
print("Canceled")
}
}
function changeSong(index) {
const song = songsqlmodel.getSong(index);
songIndex = index;
songTitle = song[0];
songLyrics = song[1];
songAuthor = song[2];
songCcli = song[3];
songAudio = song[4];
songVorder = song[5];
songBackground = song[6];
songBackgroundType = song[7];
if (songBackgroundType == "image") {
slideEditor.videoBackground = "";
slideEditor.imageBackground = songBackground;
} else {
slideEditor.imageBackground = "";
slideEditor.videoBackground = songBackground;
}
print(song);
}
function updateLyrics(lyrics) {
songsqlmodel.updateLyrics(songIndex, lyrics);
}
function updateTitle(title) {
songsqlmodel.updateTitle(songIndex, title)
}
function updateAuthor(author) {
songsqlmodel.updateAuthor(songIndex, author)
}
function updateAudio(audio) {
songsqlmodel.updateAudio(songIndex, audio)
}
function updateCcli(ccli) {
songsqlmodel.updateCcli(songIndex, ccli)
}
function updateVerseOrder(vorder) {
songsqlmodel.updateVerseOrder(songIndex, vorder)
}
function updateBackground(background, backgroundType) {
songsqlmodel.updateBackground(songIndex, background);
songsqlmodel.updateBackgroundType(songIndex, backgroundType);
print("changed background");
}
} }

View file

@ -230,13 +230,9 @@ Item {
mpvLoadingTimer.restart(); mpvLoadingTimer.restart();
} }
function prePop() { function stop() {
print("stopping video"); print("stopping video");
videoSlider.to = 0; videoPreview.pause();
/* videoSlider.position = 0; */
/* videoSlider.onMoved = null; */
videoPreview.quit();
print("quit mpv"); print("quit mpv");
} }
} }

View file

@ -29,6 +29,8 @@ static void createTable()
" 'ccli' TEXT," " 'ccli' TEXT,"
" 'audio' TEXT," " 'audio' TEXT,"
" 'vorder' TEXT," " 'vorder' TEXT,"
" 'background' TEXT,"
" 'backgroundType' TEXT,"
" PRIMARY KEY(id))")) { " PRIMARY KEY(id))")) {
qFatal("Failed to query database: %s", qFatal("Failed to query database: %s",
qPrintable(query.lastError().text())); qPrintable(query.lastError().text()));
@ -36,11 +38,11 @@ static void createTable()
qDebug() << query.lastQuery(); qDebug() << query.lastQuery();
qDebug() << "inserting into songs"; qDebug() << "inserting into songs";
query.exec("INSERT INTO songs (title, lyrics, author, ccli, audio, vorder) VALUES ('10,000 Reasons', '10,000 reasons for my heart to sing', 'Matt Redman', '13470183', '', '')"); query.exec("INSERT INTO songs (title, lyrics, author, ccli, audio, vorder, background, backgroundType) VALUES ('10,000 Reasons', '10,000 reasons for my heart to sing', 'Matt Redman', '13470183', '', '', '', '')");
qDebug() << query.lastQuery(); qDebug() << query.lastQuery();
query.exec("INSERT INTO songs (title, lyrics, author, ccli, audio, vorder) VALUES ('River', 'Im going down to the river', 'Jordan Feliz', '13470183', '', '')"); query.exec("INSERT INTO songs (title, lyrics, author, ccli, audio, vorder, background, backgroundType) VALUES ('River', 'Im going down to the river', 'Jordan Feliz', '13470183', '', '', '', '')");
query.exec("INSERT INTO songs (title, lyrics, author, ccli, audio, vorder) VALUES ('Marvelous Light', 'Into marvelous " query.exec("INSERT INTO songs (title, lyrics, author, ccli, audio, vorder, background, backgroundType) VALUES ('Marvelous Light', 'Into marvelous "
"light Im running', 'Chris Tomlin', '13470183', '', '')"); "light Im running', 'Chris Tomlin', '13470183', '', '', '', '')");
query.exec("select * from songs"); query.exec("select * from songs");
qDebug() << query.lastQuery(); qDebug() << query.lastQuery();
@ -78,6 +80,8 @@ QHash<int, QByteArray> SongSqlModel::roleNames() const
names[Qt::UserRole + 4] = "ccli"; names[Qt::UserRole + 4] = "ccli";
names[Qt::UserRole + 5] = "audio"; names[Qt::UserRole + 5] = "audio";
names[Qt::UserRole + 6] = "vorder"; names[Qt::UserRole + 6] = "vorder";
names[Qt::UserRole + 7] = "background";
names[Qt::UserRole + 8] = "backgroundType";
return names; return names;
} }
@ -106,6 +110,27 @@ void SongSqlModel::deleteSong(const int &row) {
submitAll(); submitAll();
} }
QVariantList SongSqlModel::getSong(const int &row) {
QSqlRecord recordData = record(row);
if (recordData.isEmpty()) {
qDebug() << "this is not a song";
QVariantList empty;
return empty;
}
QVariantList song;
song.append(recordData.value("title"));
song.append(recordData.value("lyrics"));
song.append(recordData.value("author"));
song.append(recordData.value("ccli"));
song.append(recordData.value("audio"));
song.append(recordData.value("vorder"));
song.append(recordData.value("background"));
song.append(recordData.value("backgroundType"));
return song;
}
int SongSqlModel::id() const { int SongSqlModel::id() const {
return m_id; return m_id;
} }
@ -253,3 +278,47 @@ void SongSqlModel::updateVerseOrder(const int &row, const QString &vorder) {
submitAll(); submitAll();
emit vorderChanged(); emit vorderChanged();
} }
QString SongSqlModel::background() const { return m_background; }
void SongSqlModel::setBackground(const QString &background) {
if (background == m_background)
return;
m_background = background;
select();
emit backgroundChanged();
}
// This function is for updating the lyrics from outside the delegate
void SongSqlModel::updateBackground(const int &row, const QString &background) {
qDebug() << "Row is " << row;
QSqlRecord rowdata = record(row);
rowdata.setValue("background", background);
setRecord(row, rowdata);
submitAll();
emit backgroundChanged();
}
QString SongSqlModel::backgroundType() const { return m_backgroundType; }
void SongSqlModel::setBackgroundType(const QString &backgroundType) {
if (backgroundType == m_backgroundType)
return;
m_backgroundType = backgroundType;
select();
emit backgroundTypeChanged();
}
// This function is for updating the lyrics from outside the delegate
void SongSqlModel::updateBackgroundType(const int &row, const QString &backgroundType) {
qDebug() << "Row is " << row;
QSqlRecord rowdata = record(row);
rowdata.setValue("backgroundType", backgroundType);
setRecord(row, rowdata);
submitAll();
emit backgroundTypeChanged();
}

View file

@ -16,6 +16,8 @@ class SongSqlModel : public QSqlTableModel
Q_PROPERTY(QString ccli READ ccli WRITE setCcli NOTIFY ccliChanged) Q_PROPERTY(QString ccli READ ccli WRITE setCcli NOTIFY ccliChanged)
Q_PROPERTY(QString audio READ audio WRITE setAudio NOTIFY audioChanged) Q_PROPERTY(QString audio READ audio WRITE setAudio NOTIFY audioChanged)
Q_PROPERTY(QString vorder READ vorder WRITE setVerseOrder NOTIFY vorderChanged) Q_PROPERTY(QString vorder READ vorder WRITE setVerseOrder NOTIFY vorderChanged)
Q_PROPERTY(QString background READ background WRITE setBackground NOTIFY backgroundChanged)
Q_PROPERTY(QString backgroundType READ backgroundType WRITE setBackgroundType NOTIFY backgroundTypeChanged)
QML_ELEMENT QML_ELEMENT
public: public:
@ -28,6 +30,8 @@ public:
QString ccli() const; QString ccli() const;
QString audio() const; QString audio() const;
QString vorder() const; QString vorder() const;
QString background() const;
QString backgroundType() const;
void setTitle(const QString &title); void setTitle(const QString &title);
void setLyrics(const QString &lyrics); void setLyrics(const QString &lyrics);
@ -35,6 +39,8 @@ public:
void setCcli(const QString &ccli); void setCcli(const QString &ccli);
void setAudio(const QString &audio); void setAudio(const QString &audio);
void setVerseOrder(const QString &vorder); void setVerseOrder(const QString &vorder);
void setBackground(const QString &background);
void setBackgroundType(const QString &backgroundType);
Q_INVOKABLE void updateTitle(const int &row, const QString &title); Q_INVOKABLE void updateTitle(const int &row, const QString &title);
Q_INVOKABLE void updateLyrics(const int &row, const QString &lyrics); Q_INVOKABLE void updateLyrics(const int &row, const QString &lyrics);
@ -42,9 +48,12 @@ public:
Q_INVOKABLE void updateCcli(const int &row, const QString &ccli); Q_INVOKABLE void updateCcli(const int &row, const QString &ccli);
Q_INVOKABLE void updateAudio(const int &row, const QString &audio); Q_INVOKABLE void updateAudio(const int &row, const QString &audio);
Q_INVOKABLE void updateVerseOrder(const int &row, const QString &vorder); Q_INVOKABLE void updateVerseOrder(const int &row, const QString &vorder);
Q_INVOKABLE void updateBackground(const int &row, const QString &background);
Q_INVOKABLE void updateBackgroundType(const int &row, const QString &backgroundType);
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);
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;
@ -56,6 +65,8 @@ signals:
void ccliChanged(); void ccliChanged();
void audioChanged(); void audioChanged();
void vorderChanged(); void vorderChanged();
void backgroundChanged();
void backgroundTypeChanged();
private: private:
int m_id; int m_id;
@ -65,6 +76,8 @@ private:
QString m_ccli; QString m_ccli;
QString m_audio; QString m_audio;
QString m_vorder; QString m_vorder;
QString m_background;
QString m_backgroundType;
}; };
#endif //SONGSQLMODEL_H #endif //SONGSQLMODEL_H