Comments (9)
I used sortable trees in process-viewer and bound the sorting to "hidden" columns. Here are the lines that might be interesting for you: https://github.com/GuillaumeGomez/process-viewer/blob/15e9252f096f831adda747cb693f0d5c27c1ecab/src/display_procs.rs#L66-L75 and https://github.com/GuillaumeGomez/process-viewer/blob/15e9252f096f831adda747cb693f0d5c27c1ecab/src/display_procs.rs#L177-L180
from examples.
But this is the thing I'm struggling with: you're storing the data in the ListStore
. I have my data in a Vec
.
You're filling the store once, fully, with insert_with_values
, and don't seem to update later.
But if vec[7]
changed in my program, how do I know where vec[7]
's data is in the TreeView? which cell do I update?
from examples.
I actually do here: https://github.com/GuillaumeGomez/process-viewer/blob/15e9252f096f831adda747cb693f0d5c27c1ecab/src/process_viewer.rs#L100-L116
from examples.
So that's a linear search. It's going to be O(n^2) for me, because in my program I emit an event "7th row of the Vec changed, 3rd row of the Vec changed, 11th row of the Vec changed". If I use a treeiter to scan through entire store every time to find where my Vec's data ended up in, it'll be super slow.
I have my expectations set by Cocoa, where I can say "treeview.column1.text
binds to mymodel.field1
" and vec[7].field1.set()
sends a message to treeview.column1
to update itself.
but here I have column.add_attribute(&cell, "text", 0);
where 0
is the column number, not name of the field in the model.
from examples.
You can try the other way around: using a vec of references to the liststore
. Then no need to have the data twice.
from examples.
Does the TreeIter
survive sorting? i.e. if it was iter of 0th row, and user reverses sorting, is it going start pointing to the last row?
from examples.
Good question... I'm pretty sure you can have access to the data location directly, never looked how however. If you find out, please tell me. :3
from examples.
gtk_list_store_set_valuesv: assertion 'iter_is_valid (iter, list_store)' failed
Nope, I can't store iters.
from examples.
I think I've got a solution:
- Use an unsorted
ListStore
for 1:1 relationship withVec
, and copy data back and forth using index<>row mapping - Prevent
ListStore
from being mixed up by wrapping itTreeModelSort
https://stackoverflow.com/a/19063670/27009
from examples.
Related Issues (20)
- Clone_macros doesn't work HOT 7
- Example for GtkSwitcher usage
- could not compile `gtk-rs-examples` HOT 3
- Add an example with mutable state HOT 1
- How to set app menu bar on macOS? HOT 2
- Example of STYLE_CLASS_* constants
- A command-line flags example
- in basic_subclass exmaple, the Private struct is exposed to gtk
- Fatal Crash with Drag and Drop on Mac OS X HOT 3
- windows build error HOT 1
- macOS Details (menu bar + docks)
- MenuBar and Toolbar with Glade and Actions
- MacOS overlay broken
- Come up with a way to handle panics
- Example with multi selection with header rows
- Cannot build basic.rs HOT 2
- No examples with Popover/PopoverMenu
- Add Glade signal handlers example if applicable HOT 1
- Put DEPRECATION notice in README HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from examples.