From eb899a9965d8b287e310da2df145d74d06fa6fb8 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Tue, 16 May 2023 15:31:09 -0500 Subject: [PATCH] tweaks to making songs work --- TODO.org | 8 ++++++-- src/qml/presenter/SongEditor.qml | 3 ++- src/rust/song_model.rs | 21 +++++++++++++++++++-- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/TODO.org b/TODO.org index e0ff34d..bb24c4a 100644 --- a/TODO.org +++ b/TODO.org @@ -3,7 +3,7 @@ :CATEGORY: dev :END: -* Tasks [66%] [34/51] +* Tasks [67%] [35/52] ** TODO Start planning out what a 1.0 release would look like and decide how to get there :roadmap: A 1.0 release may be achievable soon as long as I can figure out what is good to have in and what isn't. Then figure out what outstanding bugs and odd workflows exist and fix them. Then figure out deploying the package to various distros, windows, and mac. @@ -79,10 +79,14 @@ This still needs ported to Rust. It'll be the hardest of the library models sinc Both PDFs and reveal.js presentations think every slide is the first one. I need a way of finding the individual components and then properly switching to the next one. Switching to the next slide in reveal.js may be tricky since I'll need to push into the WebEngineView the next reveal function and then get back how many more slides and fragments there are. -** TODO get_lyric_list method +** DONE get_lyric_list method [[file:~/dev/church-presenter/src/rust/song_model.rs::todo!();]] This is the big one. Previous implementation in cpp is here: [[file:src/cpp/songsqlmodel.cpp::QStringList SongSqlModel::getLyricList(const int &row)]] +** TODO find song on SongSelect +This function will need to include parsing through the HTML of the results page. Finding the first "song-result", then "song-result-title", and inside that tag is the name. In the URL is the CCLI number. + +Lyrics will probably be better to grab from genius lyrics. ** TODO new_song method [[file:~/dev/church-presenter/src/rust/song_model.rs::todo!();]] ** TODO Create a setting for holding static slides and audios diff --git a/src/qml/presenter/SongEditor.qml b/src/qml/presenter/SongEditor.qml index 385ee59..7d75979 100644 --- a/src/qml/presenter/SongEditor.qml +++ b/src/qml/presenter/SongEditor.qml @@ -411,7 +411,7 @@ Item { function newSong(index) { clearSlides(); - song = songProxyModel.songModel.getSong(index); + song = songProxyModel.getSong(index); console.log(song.lyrics); songIndex = song.id; @@ -438,6 +438,7 @@ Item { song = songProxyModel.getSong(index); console.log(song.lyrics); songIndex = song.id; + console.log(song.id); if (song.backgroundType == "image") { slideEditor.videoBackground = ""; diff --git a/src/rust/song_model.rs b/src/rust/song_model.rs index 3147ec5..1b565fd 100644 --- a/src/rust/song_model.rs +++ b/src/rust/song_model.rs @@ -111,7 +111,7 @@ mod song_model { self.as_mut().set_highest_id(song.id); } - let img = Song { + let song = Song { id: song.id, title: song.title, lyrics: song.lyrics.unwrap_or_default(), @@ -127,7 +127,7 @@ mod song_model { font_size: song.font_size.unwrap_or_default(), }; - self.as_mut().add_song(img); + self.as_mut().add_song(song); } println!("--------------------------------------"); println!("{:?}", self.as_mut().songs()); @@ -189,6 +189,20 @@ mod song_model { // } } + #[qinvokable] + pub fn new_song(self: Pin<&mut Self>) { + let song_id = self.rust().highest_id + 1; + let song_title = String::from("title"); + + let song = Song { + id: song_id, + title: song_title, + ..Default::default() + }; + + self.add_song(song); + } + // fn add_item( // mut self: Pin<&mut Self>, // song_id: i32, @@ -315,6 +329,9 @@ mod song_model { return QStringList::default(); } if let Some(song) = self.rust().songs.get(index as usize) { + if song.lyrics.is_empty() { + return QStringList::default(); + } let raw_lyrics = song.lyrics.clone(); println!("raw-lyrics: {:?}", raw_lyrics); let vorder: Vec<&str> = song.verse_order.split(' ').collect();