From ad2ed98968d4d5dd95c5ce70827c481f8254526a Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Thu, 18 May 2023 06:39:22 -0500 Subject: [PATCH] using more innerModels since they are already loaded --- src/qml/presenter/Library.qml | 6 +++--- src/rust/song_model.rs | 17 ----------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/qml/presenter/Library.qml b/src/qml/presenter/Library.qml index 0fa611d..f05239f 100644 --- a/src/qml/presenter/Library.qml +++ b/src/qml/presenter/Library.qml @@ -40,11 +40,11 @@ Item { headerLabel: "Songs" itemIcon: "folder-music-symbolic" /* itemSubtitle: model.author */ - count: innerModel.rowCount() + count: innerModel.count() newItemFunction: (function() { songProxyModel.setFilterRegularExpression(""); - songProxyModel.songModel.newSong(); - libraryList.currentIndex = songProxyModel.songModel.count() - 1; + innerModel.newSong(); + libraryList.currentIndex = innerModel.count() - 1; if (!editMode) editMode = true; editSwitch(libraryList.currentIndex, "song"); diff --git a/src/rust/song_model.rs b/src/rust/song_model.rs index f37e050..9d6c87b 100644 --- a/src/rust/song_model.rs +++ b/src/rust/song_model.rs @@ -172,23 +172,6 @@ mod song_model { // self.rust().db = db; } - #[qinvokable] - pub fn new_item(mut self: Pin<&mut Self>, url: QUrl) { - println!("LETS INSERT THIS SUCKER!"); - let file_path = PathBuf::from(url.path().to_string()); - let name = file_path.file_stem().unwrap().to_str().unwrap(); - let song_id = self.rust().highest_id + 1; - let song_title = QString::from(name); - let song_path = url.to_qstring(); - - // if self.as_mut().add_item(song_id, song_title, song_path) { - // println!("filename: {:?}", name); - // self.as_mut().set_highest_id(song_id); - // } else { - // println!("Error in inserting item"); - // } - } - #[qinvokable] pub fn new_song(mut self: Pin<&mut Self>) -> bool { let song_id = self.rust().highest_id + 1;