app: use new graphview API

Use new APIs from unit test graphview changes
Update the TODO
This commit is contained in:
Stéphane Cerveau 2022-01-27 10:35:39 +01:00
parent d19387f039
commit 42e0057829
2 changed files with 16 additions and 8 deletions

View file

@ -28,9 +28,9 @@
- [ ] create a crate for graphview/node/port - [ ] create a crate for graphview/node/port
- [x] Remove a port from a node if possible - [x] Remove a port from a node if possible
- [ ] Implement graphview unit test - [x] Implement graphview unit test
- [x] add a css class for pad (presence always or sometimes) - [x] add a css class for pad (presence always or sometimes)
- [ ] Add property to port to store some specific value(Caps) - [x] Add property to port to store some specific value(Caps)
### GStreamer: ### GStreamer:
@ -46,7 +46,7 @@
- [ ] Create a window for the video output - [ ] Create a window for the video output
- [ ] Add multiple graphviews with tabs. - [ ] Add multiple graphviews with tabs.
- [x] Property window in the main window - [x] Property window in the main window
- [ ] Connect the GPS status to GST status - [x] Connect the GPS status to GST status
- [ ] Implement graph dot render/load - [ ] Implement graph dot render/load
- [ ] Implement a command line parser to graph - [ ] Implement a command line parser to graph
- [x] Render the parse launch line in a message box - [x] Render the parse launch line in a message box
@ -63,6 +63,7 @@
- [ ] Display tags/meta/message detected - [ ] Display tags/meta/message detected
- [ ] Seek to position - [ ] Seek to position
- [ ] Use one listbox with name, favorites and rank (sort list) - [ ] Use one listbox with name, favorites and rank (sort list)
- [x] See the link creation with a dashed line
### CI/Infra ### CI/Infra

View file

@ -30,6 +30,8 @@ use log::error;
use once_cell::unsync::OnceCell; use once_cell::unsync::OnceCell;
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::HashMap; use std::collections::HashMap;
use std::fs::File;
use std::io::{Read, Write};
use std::ops; use std::ops;
use std::rc::{Rc, Weak}; use std::rc::{Rc, Weak};
@ -778,20 +780,25 @@ impl GPSApp {
} }
fn clear_graph(&self) { fn clear_graph(&self) {
let graph_view = self.graphview.borrow_mut(); let graph_view = self.graphview.borrow();
graph_view.remove_all_nodes(); graph_view.clear();
} }
fn save_graph(&self, filename: &str) -> anyhow::Result<()> { fn save_graph(&self, filename: &str) -> anyhow::Result<()> {
let graph_view = self.graphview.borrow(); let graph_view = self.graphview.borrow();
graph_view.render_xml(filename)?; let mut file = File::create(filename)?;
let buffer = graph_view.render_xml()?;
file.write_all(&buffer)?;
Ok(()) Ok(())
} }
fn load_graph(&self, filename: &str) -> anyhow::Result<()> { fn load_graph(&self, filename: &str) -> anyhow::Result<()> {
self.clear_graph();
let graph_view = self.graphview.borrow(); let graph_view = self.graphview.borrow();
graph_view.load_xml(filename)?; let mut file = File::open(filename)?;
let mut buffer = Vec::new();
file.read_to_end(&mut buffer).expect("buffer overflow");
graph_view.load_from_xml(buffer)?;
Ok(()) Ok(())
} }
} }