]> uap-core.de Git - note.git/commitdiff
switch right-panel tabview when selecting notes
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 25 May 2026 15:12:33 +0000 (17:12 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 25 May 2026 15:12:33 +0000 (17:12 +0200)
application/src/note.rs
application/src/notebook.rs
application/src/window.rs

index 3b1ea08644985d194057117c1c46ca3755e85565..ffc2e77e5f8ec595ada1eb5104bf7d17496bdc80 100644 (file)
@@ -1,7 +1,7 @@
 use entity::note::NoteType;
 use ui_rs::{ui_actions, UiModel};
 use ui_rs::ui::*;
-
+use crate::window::NoteTypeTabView;
 
 #[derive(UiModel, Default)]
 pub struct Note {
@@ -16,6 +16,14 @@ pub struct Note {
 
 #[ui_actions]
 impl Note {
+    pub fn init_from_model(&mut self, model: &entity::note::Model) {
+        self.text.set(model.content.as_str());
 
-
+        let tab = match(model.kind) {
+            NoteType::PlainTextNote => NoteTypeTabView::TextArea,
+            NoteType::MDTextNote => NoteTypeTabView::TextArea,
+            _ => NoteTypeTabView::Empty
+        };
+        self.note_type.set(tab as i64);
+    }
 }
\ No newline at end of file
index 128acfe8cddd51177d6492560b36b07ef7a90c98..40de6f4fca06ca67e217f9c037543aaf6d942564 100644 (file)
@@ -1,7 +1,8 @@
 use ui_rs::{action, ui_actions, UiModel};
 use ui_rs::ui::*;
 
-use entity::note::Model as Note;
+use entity::note::{Model as Note, NoteType};
+use crate::window::NoteTypeTabView;
 
 #[derive(UiModel, Default)]
 pub struct Notebook {
@@ -56,7 +57,7 @@ impl Notebook {
                         nb.ctx.attach(&d);
                     }
 
-                    n.text.set(note.content.as_str());
+                    n.init_from_model(&note);
                 });
 
                 // Attach the new note
index 8785995142ac8a974c1d0db0bc395a32a1dfac34..b37b03858d49adf5e8b37cae7d69fc860d0c8c22 100644 (file)
@@ -180,7 +180,7 @@ pub fn create_window(app: &App, ctx: &AppContext<MainWindow>) -> UiObject<MainWi
                     b.varname("note_type");
                 },
                 |tabview| {
-                    //tabview.tab("empty", |_obj| {});
+                    tabview.tab("empty", |_obj| {});
 
                     tabview.tab("textnote", |obj| {
                         obj.textarea(|b|{
@@ -202,3 +202,7 @@ fn init_window_data(window: &mut MainWindow, data: &App) {
     window.update_notebook_structure(&data.notebooks);
 }
 
+pub enum NoteTypeTabView {
+    Empty = 0,
+    TextArea = 1
+}
\ No newline at end of file