diff options
author | David Robillard <d@drobilla.net> | 2010-01-03 17:35:30 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-01-03 17:35:30 +0000 |
commit | 10616b98af494614d84eff40d94917be1364988c (patch) | |
tree | be900bbc848351bb11b5ff58df9e14de57ca0f68 | |
parent | a5dcac142ad4abe1403a5f5ca4b65a38db808e93 (diff) | |
download | ingen-10616b98af494614d84eff40d94917be1364988c.tar.gz ingen-10616b98af494614d84eff40d94917be1364988c.tar.bz2 ingen-10616b98af494614d84eff40d94917be1364988c.zip |
Follow renames in patch tree window (fix ticket #409).
Look up patches by model pointer rather than path in patch tree window (faster).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2331 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/gui/PatchTreeWindow.cpp | 41 | ||||
-rw-r--r-- | src/gui/PatchTreeWindow.hpp | 12 |
2 files changed, 32 insertions, 21 deletions
diff --git a/src/gui/PatchTreeWindow.cpp b/src/gui/PatchTreeWindow.cpp index b3b0f682..262c4d60 100644 --- a/src/gui/PatchTreeWindow.cpp +++ b/src/gui/PatchTreeWindow.cpp @@ -92,18 +92,18 @@ PatchTreeWindow::add_patch(SharedPtr<PatchModel> pm) } else { row[_patch_tree_columns.name_col] = pm->path().name(); } - row[_patch_tree_columns.enabled_col] = false; + row[_patch_tree_columns.enabled_col] = pm->enabled(); row[_patch_tree_columns.patch_model_col] = pm; _patches_treeview->expand_row(_patch_treestore->get_path(iter), true); } else { Gtk::TreeModel::Children children = _patch_treestore->children(); - Gtk::TreeModel::iterator c = find_patch(children, pm->parent()->path()); + Gtk::TreeModel::iterator c = find_patch(children, pm->parent()); if (c != children.end()) { Gtk::TreeModel::iterator iter = _patch_treestore->append(c->children()); Gtk::TreeModel::Row row = *iter; row[_patch_tree_columns.name_col] = pm->path().name(); - row[_patch_tree_columns.enabled_col] = false; + row[_patch_tree_columns.enabled_col] = pm->enabled(); row[_patch_tree_columns.patch_model_col] = pm; _patches_treeview->expand_row(_patch_treestore->get_path(iter), true); } @@ -111,32 +111,38 @@ PatchTreeWindow::add_patch(SharedPtr<PatchModel> pm) pm->signal_property.connect(sigc::bind( sigc::mem_fun(this, &PatchTreeWindow::patch_property_changed), - pm->path())); + pm)); + + pm->signal_moved.connect(sigc::bind( + sigc::mem_fun(this, &PatchTreeWindow::patch_moved), + pm)); pm->signal_destroyed.connect(sigc::bind( sigc::mem_fun(this, &PatchTreeWindow::remove_patch), - pm->path())); + pm)); } void -PatchTreeWindow::remove_patch(const Path& path) +PatchTreeWindow::remove_patch(SharedPtr<PatchModel> pm) { - Gtk::TreeModel::iterator i = find_patch(_patch_treestore->children(), path); + Gtk::TreeModel::iterator i = find_patch(_patch_treestore->children(), pm); if (i != _patch_treestore->children().end()) _patch_treestore->erase(i); } Gtk::TreeModel::iterator -PatchTreeWindow::find_patch(Gtk::TreeModel::Children root, const Path& path) +PatchTreeWindow::find_patch( + Gtk::TreeModel::Children root, + SharedPtr<Client::ObjectModel> patch) { for (Gtk::TreeModel::iterator c = root.begin(); c != root.end(); ++c) { SharedPtr<PatchModel> pm = (*c)[_patch_tree_columns.patch_model_col]; - if (pm->path() == path) { + if (patch == pm) { return c; } else if ((*c)->children().size() > 0) { - Gtk::TreeModel::iterator ret = find_patch(c->children(), path); + Gtk::TreeModel::iterator ret = find_patch(c->children(), patch); if (ret != c->children().end()) return ret; } @@ -188,16 +194,17 @@ PatchTreeWindow::event_patch_enabled_toggled(const Glib::ustring& path_str) void -PatchTreeWindow::patch_property_changed(const URI& key, const Atom& value, const Path& path) +PatchTreeWindow::patch_property_changed(const URI& key, const Atom& value, + SharedPtr<PatchModel> patch) { _enable_signal = false; if (key.str() == "ingen:enabled" && value.type() == Atom::BOOL) { - Gtk::TreeModel::iterator i = find_patch(_patch_treestore->children(), path); + Gtk::TreeModel::iterator i = find_patch(_patch_treestore->children(), patch); if (i != _patch_treestore->children().end()) { Gtk::TreeModel::Row row = *i; row[_patch_tree_columns.enabled_col] = value.get_bool(); } else { - cerr << "[PatchTreeWindow] Unable to find patch " << path << endl; + cerr << "[PatchTreeWindow] Unable to find patch " << patch->path() << endl; } } _enable_signal = true; @@ -205,18 +212,18 @@ PatchTreeWindow::patch_property_changed(const URI& key, const Atom& value, const void -PatchTreeWindow::patch_moved(const Path& old_path, const Path& new_path) +PatchTreeWindow::patch_moved(SharedPtr<PatchModel> patch) { _enable_signal = false; Gtk::TreeModel::iterator i - = find_patch(_patch_treestore->children(), old_path); + = find_patch(_patch_treestore->children(), patch); if (i != _patch_treestore->children().end()) { Gtk::TreeModel::Row row = *i; - row[_patch_tree_columns.name_col] = new_path.name(); + row[_patch_tree_columns.name_col] = patch->path().name(); } else { - cerr << "[PatchTreeWindow] Unable to find patch " << old_path << endl; + cerr << "[PatchTreeWindow] Unable to find patch " << patch->path() << endl; } _enable_signal = true; diff --git a/src/gui/PatchTreeWindow.hpp b/src/gui/PatchTreeWindow.hpp index bba3b1ac..c745b07d 100644 --- a/src/gui/PatchTreeWindow.hpp +++ b/src/gui/PatchTreeWindow.hpp @@ -47,18 +47,22 @@ public: void new_object(SharedPtr<Client::ObjectModel> object); - void patch_property_changed(const Raul::URI& key, const Raul::Atom& value, const Raul::Path& path); - void patch_moved(const Raul::Path& old_path, const Raul::Path& new_path); + void patch_property_changed(const Raul::URI& key, const Raul::Atom& value, + SharedPtr<Client::PatchModel> pm); + + void patch_moved(SharedPtr<Client::PatchModel> patch); void add_patch(SharedPtr<Client::PatchModel> pm); - void remove_patch(const Raul::Path& path); + void remove_patch(SharedPtr<Client::PatchModel> pm); void show_patch_menu(GdkEventButton* ev); protected: void event_patch_activated(const Gtk::TreeModel::Path& path, Gtk::TreeView::Column* col); void event_patch_enabled_toggled(const Glib::ustring& path_str); - Gtk::TreeModel::iterator find_patch(Gtk::TreeModel::Children root, const Raul::Path& path); + Gtk::TreeModel::iterator find_patch( + Gtk::TreeModel::Children root, + SharedPtr<Client::ObjectModel> patch); PatchTreeView* _patches_treeview; |