adding selecting multiple items. Still needs work

This commit is contained in:
Chris Cochrun 2023-09-27 09:45:41 -05:00
parent bef09ed805
commit 83d7249a8b
3 changed files with 55 additions and 3 deletions

View file

@ -675,6 +675,6 @@ Item {
console.log("Select all these here items..." + arr); console.log("Select all these here items..." + arr);
} }
} }
ServiceItemModel.selectItems(arr); ServiceItemModel.selectItems(index);
} }
} }

View file

@ -145,6 +145,7 @@ mod service_item_model {
use std::str; use std::str;
use std::{fs, println}; use std::{fs, println};
use tar::{Archive, Builder}; use tar::{Archive, Builder};
use tracing::{debug, debug_span, error, info, instrument};
use zstd::{Decoder, Encoder}; use zstd::{Decoder, Encoder};
impl qobject::ServiceItemMod { impl qobject::ServiceItemMod {
#[qinvokable] #[qinvokable]
@ -436,9 +437,45 @@ mod service_item_model {
#[qinvokable] #[qinvokable]
pub fn select_items( pub fn select_items(
mut self: Pin<&mut Self>, mut self: Pin<&mut Self>,
items: QMap_QString_QVariant, final_index: i32,
) -> bool { ) -> bool {
todo!(); if let Some((current_index, current_item)) = self
.as_ref()
.service_items()
.iter()
.filter(|i| i.selected)
.enumerate()
.next()
{
// Here we will need to branch to get the selected items
debug!(first_item = ?current_index);
debug!(final_item = final_index);
if final_index == current_index {
false
}
let lower = final_index > current_index;
if lower {
let selected = self
.as_mut()
.service_items_mut()
.iter_mut()
.enumerate()
.filter(|i| {
i.0 >= current_index
&& i.0 <= final_index as usize
})
.map(|i| i.1.selected = true);
}
true
} else {
// Here let's branch to select from the first item to the
// final item. Since we don't know which one is selected,
// assume that the first one is "selected"
error!("ERROR: couldn't find first selected item");
false
}
} }
#[qinvokable] #[qinvokable]

View file

@ -3,4 +3,19 @@ mod song_editor {
Yes, Yes,
No, No,
} }
pub struct EditableSong {
title: String,
lyrics: String,
author: String,
ccli: String,
audio: String,
verse_order: String,
background: String,
background_type: String,
horizontal_text_alignment: String,
vertical_text_alignment: String,
font: String,
font_size: i32,
}
} }