]> uap-core.de Git - note.git/commitdiff
add Show Trash menu item
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 9 Aug 2026 19:16:55 +0000 (21:16 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 9 Aug 2026 19:16:55 +0000 (21:16 +0200)
application/note/src/main.rs
application/note/src/notebook.rs
application/note/src/window.rs

index fc5a96e99bb2b210d319147468269c57599287c7..d97e6ff3ad6a681fa15ce9f70f908f3f66b42c73 100644 (file)
@@ -147,6 +147,8 @@ fn create_menubar(app: &AppContext<MainWindow>) {
         menu.item("Rename").action("note_rename").create();
         menu.item("Delete").action("note_delete").create();
         menu.item("Edit Title").action("note_edit_title").create();
+        menu.separator();
+        menu.item("Show Trash").action("show_trash").create();
     });
 }
 
@@ -178,6 +180,8 @@ fn create_toolbar(app: &AppContext<MainWindow>) {
         menu.item("Rename").action("note_rename").create();
         menu.item("Delete").action("delete_note").create();
         menu.item("Edit Title").action("note_edit_title").create();
+        menu.separator();
+        menu.item("Show Trash").action("show_trash").create();
     });
 }
 
index e83bd18c12d157416c24bfea642a0487d550c949..5c84162013e10a661cf45bccb05a433e0d525198 100644 (file)
@@ -351,7 +351,7 @@ impl Notebook {
 
         self.select_note_from(NoteSelectFrom::NavigationItem(nav.clone()));
     }
-
+    
     pub fn update_note_title(&mut self, update: &NoteTitleUpdate) {
         // TODO: use find_note
         // Find the note in the list (or add it if it doesn't exist yet)
index 44c824ca66dde6ddd2b5c24ac77ad077ae420ab1..7e4d4d63cedab5f368a73bca4e813b8c8c5504a4 100644 (file)
@@ -48,6 +48,7 @@ pub struct MainWindow {
     selected_notebook: Option<UiDoc<Notebook>>,
 
     groups: Vec<Collection>,
+    trash: Option<NotebookItem>,
 
     #[bind]
     notebooks: UiSourceList<NotebookItem>
@@ -64,6 +65,7 @@ impl MainWindow {
             navigation: Navigation::default(),
             selected_notebook: None,
             groups: Vec::new(),
+            trash: None,
             notebooks: UiSourceList::default()
         }
     }
@@ -108,6 +110,30 @@ impl MainWindow {
         }
     }
 
+    #[action]
+    pub fn show_trash(&mut self, _event: &ActionEvent) {
+        let Some(mut obj) = self.obj.get_object() else {
+            return;
+        };
+
+        if let Some(trash) = &mut self.trash {
+            let nav = NavigationItem { collection_id: trash.data.collection_id, ..Default::default() };
+            // detach current notebook
+            if let Some(current) = &self.selected_notebook {
+                current.ctx.call_action("save");
+                obj.ctx.detach(current);
+            }
+
+            let notebook_doc = trash.get_doc(&self.backend);
+            obj.splitview_set_visible(0, true);
+            obj.ctx.attach(&notebook_doc);
+            self.selected_notebook = Some(notebook_doc);
+            //e.obj.splitview_set_visible(0, !nav.note_maximized);
+
+            self.navigation.push(nav);
+        }
+    }
+
     pub fn do_nav(&mut self, direction: NavDirection) -> Option<()> {
         let nav = match direction {
             NavDirection::Forward => self.navigation.go_forward(),
@@ -168,7 +194,8 @@ impl MainWindow {
 
         for elm in nodes.iter() {
             if elm.collection.kind == CollectionType::Trash {
-                // TODO: add to trash list
+                let trash = NotebookItem::from_model(elm.collection.clone());
+                self.trash = Some(trash);
                 continue;
             }