I have a program in where the user "can add music files" by selecting a folder, the contents of the folder are "inserted" in a nana::treebox, and the songs information will be displayed in a nana::listbox.

Each node that represents a music file in the nana::treebox corresponds to an item in the nana::listbox, and a node that does not represent a music file, but the folder in where the music file(s) is/are, corresponds to a category in the nana::listbox.

The user can "change the properties of a music file", the properties are, for example, "Composer", "Vocalist", "Lyrics by"; by selecting a node that represents the music file and pressing a button that will allow to do this. The nana::listbox has colums for "Composer", "Vocalist", "Lyrics by", and the changes will be reflected there.

= = = = =

That is where I need help. When the properties "of a music file" are modified, that is, a struct that is stored inside a node in the nana::treebox, I have to notify an item in the nana::listbox, which means I must relate a node in the nana::treebox with an item inside the nana::listbox. How would you do this?

What I have thought is:
...> Store a reference to the struct that I put inside a node of nana::treebox, inside the item of nana::listbox. The reference I stored was returned by nana::treebox::item_proxy::value() just to clarify. Then I compare the address of the internal struct inside the modified node with all the references inside each item in the nana::listbox until I hit the correct one. [Continues in the next paragraph]

This is inefficient unless I can known the category that owns the item in nana::listbox in advance. I am guessing I can, because, a category inside my nana::listbox represents a folder, similar to a node that represents a folder in the nana::treebox, and both have the exact same name. Can I compare the string that is the title/name of a node (nana::treebox) with the string that is the title/name of a category (nana::listbox)?
I guess is like this?

nana::listbox::cat_proxy cat_iter{ music_info.assoc(modified_node.owner().text()) };

modified_node is a nana::treebox::item_proxy, just to clarify.

I have a program in where the user "can add music files" by selecting a folder, the contents of the folder are "inserted" in a nana::treebox, and the songs information will be displayed in a nana::listbox. Each node that represents a music file in the nana::treebox corresponds to an item in the nana::listbox, and a node that does not represent a music file, but the folder in where the music file(s) is/are, corresponds to a category in the nana::listbox. The user can "change the properties of a music file", the properties are, for example, "Composer", "Vocalist", "Lyrics by"; by selecting a node that represents the music file and pressing a button that will allow to do this. The nana::listbox has colums for "Composer", "Vocalist", "Lyrics by", and the changes will be reflected there. = = = = = That is where I need help. When the properties "of a music file" are modified, that is, a struct that is stored inside a node in the nana::treebox, I have to notify an item in the nana::listbox, which means I must relate a node in the nana::treebox with an item inside the nana::listbox. How would you do this? What I have thought is: ...> Store a reference to the struct that I put inside a node of nana::treebox, inside the item of nana::listbox. The reference I stored was returned by nana::treebox::item_proxy::value() just to clarify. Then I compare the address of the internal struct inside the modified node with all the references inside each item in the nana::listbox until I hit the correct one. [Continues in the next paragraph] This is inefficient unless I can known the category that owns the item in nana::listbox in advance. I am guessing I can, because, a category inside my nana::listbox represents a folder, similar to a node that represents a folder in the nana::treebox, and both have the exact same name. Can I compare the string that is the title/name of a node (nana::treebox) with the string that is the title/name of a category (nana::listbox)? I guess is like this? ```` nana::listbox::cat_proxy cat_iter{ music_info.assoc(modified_node.owner().text()) }; ```` modified_node is a nana::treebox::item_proxy, just to clarify.

I have to notify an item in the nana::listbox, which means I must relate a node in the nana::treebox with an item inside the nana::listbox. How would you do this?

I think the easiest way is to associate a list item with a tree node, using treebox::item_proxy::value. I've omitted that method from my version of the documentation, because it's missing from the official documentation as well, and I didn't notice (I will add it later).

Here's how you would associate a list item with a tree node:

// assume using namespace nana
treebox::item_proxy tree_node = ... ;
listbox::item_proxy list_item = ... ;
tree_node.value(list_item); // this node's associated value is now an iterator to a listbox item

And here's how you would get the associated listbox item (iterator) from a tree node:

treebox::item_proxy tree_node = ... ;
listbox::item_proxy list_item = tree_node.value<listbox::item_proxy>();

Item iterators are not affected by sorting, so you don't have to worry about that.

>I have to notify an item in the nana::listbox, which means I must relate a node in the nana::treebox with an item inside the nana::listbox. How would you do this? I think the easiest way is to associate a list item with a tree node, using `treebox::item_proxy::value`. I've omitted that method from my version of the documentation, because it's missing from the official documentation as well, and I didn't notice (I will add it later). Here's how you would associate a list item with a tree node: ```` // assume using namespace nana treebox::item_proxy tree_node = ... ; listbox::item_proxy list_item = ... ; tree_node.value(list_item); // this node's associated value is now an iterator to a listbox item ```` And here's how you would get the associated listbox item (iterator) from a tree node: ```` treebox::item_proxy tree_node = ... ; listbox::item_proxy list_item = tree_node.value<listbox::item_proxy>(); ```` Item iterators are not affected by sorting, so you don't have to worry about that.
edited Nov 3 at 7:14 pm

Thank you for replying.
Error Flynn, thanks, I did not know iterators weren't invalidated, the design is simpler and faster now.

Thank you for replying. Error Flynn, thanks, I did not know iterators weren't invalidated, the design is simpler and faster now.
17
views
2
replies
2
followers
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft