Skip to content

Commit 06f24c3

Browse files
committed
Delete
1 parent ac300a6 commit 06f24c3

File tree

5 files changed

+66
-16
lines changed

5 files changed

+66
-16
lines changed

czkawka_core/src/tools/similar_videos/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl SimilarVideos {
124124
CurrentStage::SimilarVideosCalculatingHashes,
125125
non_cached_files_to_check.len(),
126126
self.get_test_type(),
127-
non_cached_files_to_check.values().map(|e| e.size).sum(),
127+
0, // non_cached_files_to_check.values().map(|e| e.size).sum(), // Looks, that at least for now, there is no big difference between checking big and small files, so at least for now, only tracking number of files is enough
128128
);
129129

130130
let mut vec_file_entry: Vec<VideosEntry> = non_cached_files_to_check

krokiet/i18n/en/krokiet.ftl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ rust_checked_tags = Checked tags of { $items_stats }
2222
rust_checked_content = Checked content of { $items_stats } ({ $size_stats })
2323
rust_compared_tags = Compared tags of { $items_stats }
2424
rust_compared_content = Compared content of { $items_stats }
25-
rust_hashed_images = Hashed of { $items_stats } image ({ $size_stats })
26-
rust_compared_image_hashes = Compared { $items_stats } image hash
27-
rust_hashed_videos = Hashed of { $items_stats } video
25+
rust_hashed_images = Hashed { $items_stats } images ({ $size_stats })
26+
rust_compared_image_hashes = Compared { $items_stats } image hashes
27+
rust_hashed_videos = Hashed { $items_stats } videos
2828
rust_checked_files = Checked { $items_stats } file ({ $size_stats })
2929
rust_checked_files_bad_extensions = Checked { $items_stats } file
3030
rust_analyzed_partial_hash = Analyzed partial hash of { $items_stats } files ({ $size_stats })
@@ -43,7 +43,7 @@ rust_found_temporary_files = Found { $items_found } temporary files
4343
rust_no_file_type_selected = Cannot find broken files without any file type selected.
4444
rust_found_broken_files = Found { $items_found } broken files
4545
rust_found_bad_extensions = Found { $items_found } files with bad extensions
46-
rust_found_duplicate_files = Found { $items_found } similar duplicate files
46+
rust_found_duplicate_files = Found { $items_found } duplicate files
4747
rust_found_big_files = Found { $items_found } big files
4848
rust_cannot_load_preset = Cannot change and load preset { $preset_idx } - reason { $reason }, using default settings instead
4949
rust_saved_preset = Saved preset { $preset_idx }
@@ -63,8 +63,10 @@ rust_no_files_deleted = Not selected any files/folders to delete
6363
rust_no_files_renamed = Not selected any files/folders to rename
6464
rust_no_files_moved = Not selected any files/folders to move
6565
66-
rust_delete_confirmation = Are you sure you want to { $items } the selected items?
67-
66+
rust_delete_confirmation = Are you sure you want the selected items?
67+
rust_delete_confirmation_number_simple = { $items } items is selected.
68+
rust_delete_confirmation_number_groups = { $items } items in { $groups } groups are selected.
69+
rust_delete_confirmation_selected_all_in_group = In { $groups } groups, there are all items selected.
6870
6971
# Slint translations, but in arrays
7072

krokiet/src/connect_delete.rs

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ use crossbeam_channel::Sender;
77
use czkawka_core::common::progress_data::ProgressData;
88
use slint::{ComponentHandle, Weak};
99

10+
use crate::model_operations::get_checked_info_from_app;
1011
use crate::model_operations::model_processor::{MessageType, ModelProcessor};
1112
use crate::simpler_model::{SimplerMainListModel, ToSimplerVec};
12-
use crate::{ActiveTab, Callabler, GuiState, MainWindow, Settings};
13+
use crate::{ActiveTab, Callabler, GuiState, MainWindow, Settings, Translations, flk};
1314

1415
pub(crate) fn connect_delete_button(app: &MainWindow, progress_sender: Sender<ProgressData>, stop_flag: Arc<AtomicBool>) {
1516
let a = app.as_weak();
@@ -26,13 +27,41 @@ pub(crate) fn connect_delete_button(app: &MainWindow, progress_sender: Sender<Pr
2627
processor.delete_selected_items(settings.get_move_to_trash(), progress_sender, weak_app, stop_flag);
2728
});
2829

29-
// let a = app.as_weak();
30-
// app.on_delete_popup_dialog_show_requested(move|| {
31-
// let app = a.upgrade().expect("Failed to upgrade app :(");
32-
// let settings = app.global::<Settings>();
33-
// let active_tab = app.global::<GuiState>().get_active_tab();
34-
// let model = active_tab.get_tool_model(&app);
35-
// });
30+
let a = app.as_weak();
31+
app.on_delete_popup_dialog_show_requested(move || {
32+
let app = a.upgrade().expect("Failed to upgrade app :(");
33+
let translation = app.global::<Translations>();
34+
let res = get_checked_info_from_app(&app);
35+
// TODO - items formatting should be done in GUI, not here
36+
let mut base = flk!("rust_delete_confirmation");
37+
if let Some(group_res) = res.groups_with_checked_items {
38+
base.push_str(
39+
format!(
40+
"\n{}",
41+
flk!(
42+
"rust_delete_confirmation_number_groups",
43+
items = res.checked_items_number,
44+
groups = group_res.groups_with_checked_items
45+
)
46+
)
47+
.as_str(),
48+
);
49+
if group_res.number_of_groups_with_all_items_checked > 0 {
50+
base.push_str(
51+
format!(
52+
"\n{}",
53+
flk!("rust_delete_confirmation_selected_all_in_group", groups = group_res.number_of_groups_with_all_items_checked)
54+
)
55+
.as_str(),
56+
);
57+
}
58+
} else {
59+
base.push_str(format!("\n{}", flk!("rust_delete_confirmation_number_simple", items = res.checked_items_number)).as_str());
60+
}
61+
translation.set_delete_confirmation_text(base.into());
62+
63+
app.invoke_delete_popup_dialog_configured();
64+
});
3665
}
3766

3867
impl ModelProcessor {

krokiet/src/connect_translation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ fn translate_items(app: &MainWindow) {
304304
translation.set_popup_move_copy_checkbox_text(flk!("popup_move_copy_checkbox").into());
305305
translation.set_popup_move_preserve_folder_checkbox_text(flk!("popup_move_preserve_folder_checkbox").into());
306306
translation.set_delete_text(flk!("delete").into());
307-
translation.set_delete_confirmation_text(flk!("rust_delete_confirmation", items = 0).into());
307+
translation.set_delete_confirmation_text(flk!("rust_delete_confirmation").into());
308308
translation.set_stopping_scan_text(flk!("stopping_scan").into());
309309
translation.set_searching_text(flk!("searching").into());
310310
translation.set_subsettings_videos_crop_detect_text(flk!("subsettings_videos_crop_detect").into());

krokiet/src/model_operations/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ fn get_checked_group_info_from_model(model: &ModelRc<MainListModel>) -> CheckedI
131131
if group_with_selected_item {
132132
groups_with_checked_items += 1;
133133
}
134+
current_group_all_checked = true;
135+
group_with_selected_item = false;
134136
} else {
135137
if item.checked {
136138
checked_items_number += 1;
@@ -292,5 +294,22 @@ mod tests {
292294
assert_eq!(result.checked_items_number, 3);
293295
assert_eq!(groups_info.groups_with_checked_items, 1);
294296
assert_eq!(groups_info.number_of_groups_with_all_items_checked, 1);
297+
298+
let mut items = get_model_vec(8);
299+
items[0].header_row = true;
300+
items[1].checked = true;
301+
items[2].checked = true;
302+
items[3].checked = false;
303+
items[4].header_row = true;
304+
items[5].checked = true;
305+
items[6].header_row = true;
306+
items[7].checked = false;
307+
308+
let model = ModelRc::new(VecModel::from(items));
309+
let result = get_checked_group_info_from_model(&model);
310+
let groups_info = result.groups_with_checked_items.unwrap();
311+
assert_eq!(result.checked_items_number, 3);
312+
assert_eq!(groups_info.groups_with_checked_items, 2);
313+
assert_eq!(groups_info.number_of_groups_with_all_items_checked, 1);
295314
}
296315
}

0 commit comments

Comments
 (0)