updating the drag system to use a more efficient process
Some checks are pending
/ test (push) Waiting to run
Some checks are pending
/ test (push) Waiting to run
This commit is contained in:
parent
75ff187505
commit
085c8244f9
3 changed files with 52 additions and 29 deletions
|
|
@ -18,6 +18,20 @@ pub enum ServiceItemKind {
|
|||
Content(Slide),
|
||||
}
|
||||
|
||||
impl ServiceItemKind {
|
||||
pub fn title(&self) -> String {
|
||||
match self {
|
||||
ServiceItemKind::Song(song) => song.title.to_string(),
|
||||
ServiceItemKind::Video(video) => video.title.to_string(),
|
||||
ServiceItemKind::Image(image) => image.title.to_string(),
|
||||
ServiceItemKind::Presentation(presentation) => {
|
||||
presentation.title.to_string()
|
||||
}
|
||||
ServiceItemKind::Content(slide) => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ServiceItemKind {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
let s = match self {
|
||||
|
|
|
|||
17
src/main.rs
17
src/main.rs
|
|
@ -16,6 +16,7 @@ use cosmic::iced_core::text::Wrapping;
|
|||
use cosmic::iced_futures::Subscription;
|
||||
use cosmic::iced_widget::{column, row, stack};
|
||||
use cosmic::theme;
|
||||
use cosmic::widget::button::Catalog;
|
||||
use cosmic::widget::dnd_destination::dnd_destination;
|
||||
use cosmic::widget::menu::key_bind::Modifier;
|
||||
use cosmic::widget::menu::{ItemWidth, KeyBind};
|
||||
|
|
@ -735,7 +736,7 @@ impl cosmic::Application for App {
|
|||
]
|
||||
.spacing(cosmic::theme::active().cosmic().space_s()),
|
||||
)
|
||||
.padding(cosmic::theme::active().cosmic().space_xxxl())
|
||||
.padding(cosmic::theme::active().cosmic().space_xl())
|
||||
.style(nav_bar_style);
|
||||
let modal = Container::new(modal)
|
||||
.padding([
|
||||
|
|
@ -745,7 +746,17 @@ impl cosmic::Application for App {
|
|||
.center_x(Length::Fill)
|
||||
.align_top(Length::Fill);
|
||||
let mouse_stack = stack!(
|
||||
mouse_area(Space::new(Length::Fill, Length::Fill))
|
||||
mouse_area(
|
||||
container(Space::new(Length::Fill, Length::Fill))
|
||||
.style(|_| {
|
||||
container::background(
|
||||
cosmic::iced::Background::Color(
|
||||
Color::BLACK,
|
||||
)
|
||||
.scale_alpha(0.3),
|
||||
)
|
||||
})
|
||||
)
|
||||
.on_press(Message::CloseSearch),
|
||||
modal
|
||||
);
|
||||
|
|
@ -1167,7 +1178,7 @@ impl cosmic::Application for App {
|
|||
.iter()
|
||||
.enumerate()
|
||||
.find(|(id, _)| index == *id)
|
||||
&& let Some(slide) = item.slides.first()
|
||||
&& let Some(_slide) = item.slides.first()
|
||||
{
|
||||
self.current_item = (index, 0);
|
||||
self.presenter.update(
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ use cosmic::{
|
|||
dialog::file_chooser::open::Dialog,
|
||||
iced::{
|
||||
alignment::Vertical, clipboard::dnd::DndAction,
|
||||
keyboard::Modifiers, Background, Border, Color, Length,
|
||||
keyboard::Modifiers, wgpu::core::command::DynComputePass,
|
||||
Background, Border, Color, Length,
|
||||
},
|
||||
iced_core::widget::tree::State,
|
||||
iced_widget::{column, row as rowm, text as textm},
|
||||
|
|
@ -26,12 +27,13 @@ use tracing::{debug, error, warn};
|
|||
use crate::core::{
|
||||
content::Content,
|
||||
images::{self, update_image_in_db, Image},
|
||||
kinds::ServiceItemKind,
|
||||
model::{KindWrapper, LibraryKind, Model},
|
||||
presentations::{
|
||||
self, add_presentation_to_db, update_presentation_in_db,
|
||||
Presentation,
|
||||
},
|
||||
service_items::ServiceItem,
|
||||
service_items::{ServiceItem, ServiceTrait},
|
||||
songs::{self, update_song_in_db, Song},
|
||||
videos::{self, update_video_in_db, Video},
|
||||
};
|
||||
|
|
@ -920,56 +922,52 @@ impl<'a> Library {
|
|||
pub async fn search_items(
|
||||
&self,
|
||||
query: String,
|
||||
) -> Vec<ServiceItem> {
|
||||
) -> Vec<ServiceItemKind> {
|
||||
let query = query.to_lowercase();
|
||||
let mut items: Vec<ServiceItem> = self
|
||||
let mut items: Vec<ServiceItemKind> = self
|
||||
.song_library
|
||||
.items
|
||||
.iter()
|
||||
.clone()
|
||||
.into_iter()
|
||||
.filter(|song| song.title.to_lowercase().contains(&query))
|
||||
.map(
|
||||
super::super::core::content::Content::to_service_item,
|
||||
)
|
||||
.map(|song| ServiceItemKind::Song(song))
|
||||
.collect();
|
||||
let videos: Vec<ServiceItem> = self
|
||||
let videos: Vec<ServiceItemKind> = self
|
||||
.video_library
|
||||
.items
|
||||
.iter()
|
||||
.clone()
|
||||
.into_iter()
|
||||
.filter(|vid| vid.title.to_lowercase().contains(&query))
|
||||
.map(
|
||||
super::super::core::content::Content::to_service_item,
|
||||
)
|
||||
.map(|video| ServiceItemKind::Video(video))
|
||||
.collect();
|
||||
let images: Vec<ServiceItem> = self
|
||||
let images: Vec<ServiceItemKind> = self
|
||||
.image_library
|
||||
.items
|
||||
.iter()
|
||||
.clone()
|
||||
.into_iter()
|
||||
.filter(|image| {
|
||||
image.title.to_lowercase().contains(&query)
|
||||
})
|
||||
.map(
|
||||
super::super::core::content::Content::to_service_item,
|
||||
)
|
||||
.map(|image| ServiceItemKind::Image(image))
|
||||
.collect();
|
||||
let presentations: Vec<ServiceItem> = self
|
||||
let presentations: Vec<ServiceItemKind> = self
|
||||
.presentation_library
|
||||
.items
|
||||
.iter()
|
||||
.clone()
|
||||
.into_iter()
|
||||
.filter(|pres| pres.title.to_lowercase().contains(&query))
|
||||
.map(
|
||||
super::super::core::content::Content::to_service_item,
|
||||
)
|
||||
.map(|pres| ServiceItemKind::Presentation(pres))
|
||||
.collect();
|
||||
items.extend(videos);
|
||||
items.extend(images);
|
||||
items.extend(presentations);
|
||||
let mut items: Vec<(usize, ServiceItem)> = items
|
||||
let mut items: Vec<(usize, ServiceItemKind)> = items
|
||||
.into_iter()
|
||||
.map(|item| {
|
||||
(
|
||||
levenshtein::distance(
|
||||
query.bytes(),
|
||||
item.title.bytes(),
|
||||
item.title().bytes(),
|
||||
),
|
||||
item,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue