diff options
author | David Robillard <d@drobilla.net> | 2013-01-11 05:40:18 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-01-11 05:40:18 +0000 |
commit | d443ddb053141510311e002c59746a2dd9ba8b16 (patch) | |
tree | 6bbe7b6532824117dc9a1ca25d7a09ef3601c2cc /src/gui | |
parent | 10e9a3a800a35916872abf9e354be4c554338e4e (diff) | |
download | ingen-d443ddb053141510311e002c59746a2dd9ba8b16.tar.gz ingen-d443ddb053141510311e002c59746a2dd9ba8b16.tar.bz2 ingen-d443ddb053141510311e002c59746a2dd9ba8b16.zip |
Use range-based for loops where possible.
Mmm, shiny.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4919 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/BreadCrumbs.cpp | 38 | ||||
-rw-r--r-- | src/gui/GraphBox.cpp | 10 | ||||
-rw-r--r-- | src/gui/GraphCanvas.cpp | 37 | ||||
-rw-r--r-- | src/gui/GraphPortModule.cpp | 5 | ||||
-rw-r--r-- | src/gui/GraphView.cpp | 5 | ||||
-rw-r--r-- | src/gui/LoadGraphWindow.cpp | 6 | ||||
-rw-r--r-- | src/gui/LoadPluginWindow.cpp | 12 | ||||
-rw-r--r-- | src/gui/NodeMenu.cpp | 12 | ||||
-rw-r--r-- | src/gui/NodeModule.cpp | 19 | ||||
-rw-r--r-- | src/gui/Port.cpp | 10 | ||||
-rw-r--r-- | src/gui/PortPropertiesWindow.cpp | 4 | ||||
-rw-r--r-- | src/gui/PropertiesWindow.cpp | 36 | ||||
-rw-r--r-- | src/gui/RDFS.cpp | 8 | ||||
-rw-r--r-- | src/gui/WindowFactory.cpp | 15 |
14 files changed, 99 insertions, 118 deletions
diff --git a/src/gui/BreadCrumbs.cpp b/src/gui/BreadCrumbs.cpp index bc6fc756..22142285 100644 --- a/src/gui/BreadCrumbs.cpp +++ b/src/gui/BreadCrumbs.cpp @@ -42,9 +42,9 @@ BreadCrumbs::BreadCrumbs(App& app) SharedPtr<GraphView> BreadCrumbs::view(const Raul::Path& path) { - for (std::list<BreadCrumb*>::const_iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i) - if ((*i)->path() == path) - return (*i)->view(); + for (const auto& b : _breadcrumbs) + if (b->path() == path) + return b->view(); return SharedPtr<GraphView>(); } @@ -62,17 +62,17 @@ BreadCrumbs::build(Raul::Path path, SharedPtr<GraphView> view) // Moving to a path we already contain, just switch the active button if (!_breadcrumbs.empty() && (path.is_parent_of(_full_path) || path == _full_path)) { - for (std::list<BreadCrumb*>::iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i) { - if ((*i)->path() == path) { - (*i)->set_active(true); - if (!(*i)->view()) - (*i)->set_view(view); + for (const auto& b : _breadcrumbs) { + if (b->path() == path) { + b->set_active(true); + if (!b->view()) + b->set_view(view); // views are expensive, having two around for the same graph is a bug - assert((*i)->view() == view); + assert(b->view() == view); } else { - (*i)->set_active(false); + b->set_active(false); } } @@ -98,8 +98,8 @@ BreadCrumbs::build(Raul::Path path, SharedPtr<GraphView> view) suffix = suffix.substr(suffix.find("/")+1); } - for (std::list<BreadCrumb*>::iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i) - (*i)->set_active(false); + for (const auto& b : _breadcrumbs) + b->set_active(false); _breadcrumbs.back()->set_active(true); // Rebuild from scratch @@ -110,8 +110,8 @@ BreadCrumbs::build(Raul::Path path, SharedPtr<GraphView> view) _active_path = path; // Empty existing breadcrumbs - for (std::list<BreadCrumb*>::iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i) - remove(**i); + for (const auto& b : _breadcrumbs) + remove(*b); _breadcrumbs.clear(); // Add root @@ -179,10 +179,10 @@ BreadCrumbs::breadcrumb_clicked(BreadCrumb* crumb) void BreadCrumbs::object_destroyed(const Raul::URI& uri) { - for (std::list<BreadCrumb*>::iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i) { + for (auto i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i) { if ((*i)->path() == uri.c_str()) { // Remove all crumbs after the removed one (inclusive) - for (std::list<BreadCrumb*>::iterator j = i; j != _breadcrumbs.end(); ) { + for (auto j = i; j != _breadcrumbs.end(); ) { BreadCrumb* bc = *j; j = _breadcrumbs.erase(j); remove(*bc); @@ -195,9 +195,9 @@ BreadCrumbs::object_destroyed(const Raul::URI& uri) void BreadCrumbs::object_moved(const Raul::Path& old_path, const Raul::Path& new_path) { - for (std::list<BreadCrumb*>::iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i) { - if ((*i)->path() == old_path) - (*i)->set_path(new_path); + for (const auto& b : _breadcrumbs) { + if (b->path() == old_path) + b->set_path(new_path); } } diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index 1440bc1a..fd47ee26 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -258,9 +258,8 @@ GraphBox::set_graph(SharedPtr<const GraphModel> graph, _menu_view_control_window->property_sensitive() = false; - for (BlockModel::Ports::const_iterator p = graph->ports().begin(); - p != graph->ports().end(); ++p) { - if (_app->can_control(p->get())) { + for (const auto& p : graph->ports()) { + if (_app->can_control(p.get())) { _menu_view_control_window->property_sensitive() = true; break; } @@ -301,9 +300,8 @@ GraphBox::graph_port_removed(SharedPtr<const PortModel> port) if (!(port->is_input() && _app->can_control(port.get()))) return; - for (BlockModel::Ports::const_iterator i = _graph->ports().begin(); - i != _graph->ports().end(); ++i) { - if ((*i)->is_input() && _app->can_control(i->get())) { + for (const auto& p : _graph->ports()) { + if (p->is_input() && _app->can_control(p.get())) { _menu_view_control_window->property_sensitive() = true; return; } diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index d8ba7b2e..371f7444 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -51,10 +51,6 @@ #include "WidgetFactory.hpp" #include "WindowFactory.hpp" -#define FOREACH_ITEM(iter, coll) \ - for (Items::const_iterator (iter) = coll.begin(); \ - (iter) != coll.end(); ++(iter)) - using namespace std; namespace Ingen { @@ -212,8 +208,8 @@ GraphCanvas::build_menus() // Add known plugins to menu heirarchy SharedPtr<const ClientStore::Plugins> plugins = _app.store()->plugins(); - for (ClientStore::Plugins::const_iterator i = plugins->begin(); i != plugins->end(); ++i) - add_plugin(i->second); + for (const auto& p : *plugins.get()) + add_plugin(p.second); } /** Recursively build the plugin class menu heirarchy rooted at @@ -316,15 +312,13 @@ GraphCanvas::build() } // Create pseudo modules for ports (ports on this canvas, not on our module) - for (BlockModel::Ports::const_iterator i = _graph->ports().begin(); - i != _graph->ports().end(); ++i) { - add_port(*i); + for (const auto& p : _graph->ports()) { + add_port(p); } // Create arcs - for (GraphModel::Arcs::const_iterator i = _graph->arcs().begin(); - i != _graph->arcs().end(); ++i) { - connection(PtrCast<ArcModel>(i->second)); + for (const auto& a : _graph->arcs()) { + connection(PtrCast<ArcModel>(a.second)); } } @@ -487,9 +481,8 @@ GraphCanvas::get_port_view(SharedPtr<PortModel> port) } else { module = dynamic_cast<NodeModule*>(_views[port->parent()]); if (module) { - for (Ganv::Module::iterator p = module->begin(); - p != module->end(); ++p) { - GUI::Port* pv = dynamic_cast<GUI::Port*>(*p); + for (const auto& p : *module) { + GUI::Port* pv = dynamic_cast<GUI::Port*>(p); if (pv && pv->model() == port) return pv; } @@ -769,24 +762,24 @@ GraphCanvas::paste() parser->parse_string(_app.world(), &avoider, str, base_uri, parent, symbol); - for (Store::iterator i = clipboard.begin(); i != clipboard.end(); ++i) { - if (_graph->path().is_root() && i->first.is_root()) + for (const auto& c : clipboard) { + if (_graph->path().is_root() && c.first.is_root()) continue; - Node::Properties& props = i->second->properties(); + Node::Properties& props = c.second->properties(); Node::Properties::iterator x = props.find(uris.ingen_canvasX); - if (x != i->second->properties().end()) + if (x != c.second->properties().end()) x->second = _app.forge().make( x->second.get_float() + (20.0f * _paste_count)); Node::Properties::iterator y = props.find(uris.ingen_canvasY); - if (y != i->second->properties().end()) + if (y != c.second->properties().end()) y->second = _app.forge().make( y->second.get_float() + (20.0f * _paste_count)); - builder.build(i->second); - _pastees.insert(i->first); + builder.build(c.second); + _pastees.insert(c.first); } builder.connect(PtrCast<const GraphModel>(clipboard.object(_graph->path()))); diff --git a/src/gui/GraphPortModule.cpp b/src/gui/GraphPortModule.cpp index 6d8ac465..d495cbe4 100644 --- a/src/gui/GraphPortModule.cpp +++ b/src/gui/GraphPortModule.cpp @@ -75,9 +75,8 @@ GraphPortModule::create(GraphCanvas& canvas, ret->set_port(port); - for (Resource::Properties::const_iterator m = model->properties().begin(); - m != model->properties().end(); ++m) - ret->property_changed(m->first, m->second); + for (const auto& p : model->properties()) + ret->property_changed(p.first, p.second); return ret; } diff --git a/src/gui/GraphView.cpp b/src/gui/GraphView.cpp index 9a755ffe..c795861d 100644 --- a/src/gui/GraphView.cpp +++ b/src/gui/GraphView.cpp @@ -83,9 +83,8 @@ GraphView::set_graph(SharedPtr<const GraphModel> graph) _poly_spin->set_increments(1, 4); _poly_spin->set_value(graph->internal_poly()); - for (Node::Properties::const_iterator i = graph->properties().begin(); - i != graph->properties().end(); ++i) - property_changed(i->first, i->second); + for (const auto& p : graph->properties()) + property_changed(p.first, p.second); // Connect model signals to track state graph->signal_property().connect( diff --git a/src/gui/LoadGraphWindow.cpp b/src/gui/LoadGraphWindow.cpp index a547c279..c7e94a0e 100644 --- a/src/gui/LoadGraphWindow.cpp +++ b/src/gui/LoadGraphWindow.cpp @@ -177,20 +177,20 @@ LoadGraphWindow::ok_clicked() } else { std::list<Glib::ustring> uri_list = get_filenames(); - for (std::list<Glib::ustring>::iterator i = uri_list.begin(); i != uri_list.end(); ++i) { + for (auto u : uri_list) { // Cascade Raul::Atom& x = _initial_data.find(uris.ingen_canvasX)->second; x = _app->forge().make(x.get_float() + 20.0f); Raul::Atom& y = _initial_data.find(uris.ingen_canvasY)->second; y = _app->forge().make(y.get_float() + 20.0f); - Raul::Symbol symbol(symbol_from_filename(*i)); + Raul::Symbol symbol(symbol_from_filename(u)); if (uri_list.size() == 1 && _symbol_entry->get_text() != "") symbol = Raul::Symbol::symbolify(_symbol_entry->get_text()); symbol = avoid_symbol_clash(symbol); - _app->loader()->load_graph(false, *i, + _app->loader()->load_graph(false, u, _graph->path(), symbol, _initial_data); } } diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp index b7e12281..7e61d48d 100644 --- a/src/gui/LoadPluginWindow.cpp +++ b/src/gui/LoadPluginWindow.cpp @@ -205,13 +205,13 @@ LoadPluginWindow::on_show() } void -LoadPluginWindow::set_plugins(SharedPtr<const ClientStore::Plugins> m) +LoadPluginWindow::set_plugins(SharedPtr<const ClientStore::Plugins> plugins) { _rows.clear(); _plugins_liststore->clear(); - for (ClientStore::Plugins::const_iterator i = m->begin(); i != m->end(); ++i) { - add_plugin(i->second); + for (const auto& p : *plugins.get()) { + add_plugin(p.second); } _plugins_liststore->set_sort_column(1, Gtk::SORT_ASCENDING); @@ -445,10 +445,8 @@ LoadPluginWindow::filter_changed() size_t num_visible = 0; const URIs& uris = _app->uris(); - for (ClientStore::Plugins::const_iterator i = _app->store()->plugins()->begin(); - i != _app->store()->plugins()->end(); ++i) { - - const SharedPtr<PluginModel> plugin = (*i).second; + for (const auto& p : *_app->store()->plugins().get()) { + const SharedPtr<PluginModel> plugin = p.second; const Raul::Atom& name = plugin->get_property(uris.doap_name); switch (criteria) { diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp index 484a8af7..548aa68a 100644 --- a/src/gui/NodeMenu.cpp +++ b/src/gui/NodeMenu.cpp @@ -151,13 +151,13 @@ NodeMenu::on_menu_randomize() _app->interface()->bundle_begin(); const BlockModel* const bm = (const BlockModel*)_object.get(); - for (BlockModel::Ports::const_iterator i = bm->ports().begin(); i != bm->ports().end(); ++i) { - if ((*i)->is_input() && _app->can_control(i->get())) { + for (const auto& p : bm->ports()) { + if (p->is_input() && _app->can_control(p.get())) { float min = 0.0f, max = 1.0f; - bm->port_value_range(*i, min, max, _app->sample_rate()); + bm->port_value_range(p, min, max, _app->sample_rate()); const float val = g_random_double_range(0.0, 1.0) * (max - min) + min; _app->interface()->set_property( - (*i)->uri(), + p->uri(), _app->uris().ingen_value, _app->forge().make(val)); } @@ -225,8 +225,8 @@ bool NodeMenu::has_control_inputs() { const BlockModel* const bm = (const BlockModel*)_object.get(); - for (BlockModel::Ports::const_iterator i = bm->ports().begin(); i != bm->ports().end(); ++i) - if ((*i)->is_input() && (*i)->is_numeric()) + for (const auto& p : bm->ports()) + if (p->is_input() && p->is_numeric()) return true; return false; diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index f7333fec..3a73e67e 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -113,13 +113,11 @@ NodeModule::create(GraphCanvas& canvas, ? new SubgraphModule(canvas, graph) : new NodeModule(canvas, block); - for (Resource::Properties::const_iterator m = block->properties().begin(); - m != block->properties().end(); ++m) - ret->property_changed(m->first, m->second); - - for (BlockModel::Ports::const_iterator p = block->ports().begin(); - p != block->ports().end(); ++p) - ret->new_port_view(*p); + for (const auto& p : block->properties()) + ret->property_changed(p.first, p.second); + + for (const auto& p : block->ports()) + ret->new_port_view(p); ret->set_stacked(block->polyphonic()); @@ -355,10 +353,9 @@ void NodeModule::set_control_values() { uint32_t index = 0; - for (BlockModel::Ports::const_iterator p = _block->ports().begin(); - p != _block->ports().end(); ++p) { - if (app().can_control(p->get())) { - value_changed(index, (*p)->value()); + for (const auto& p : _block->ports()) { + if (app().can_control(p.get())) { + value_changed(index, p->value()); } ++index; } diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 6a6cdfe2..6bb96b78 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -249,15 +249,15 @@ Port::build_uri_menu() RDFS::Objects values = RDFS::instances(world, ranges); // Add a menu item for each such class - for (RDFS::Objects::const_iterator i = values.begin(); i != values.end(); ++i) { - if (!i->second.empty()) { - Glib::ustring label = world->rdf_world()->prefixes().qualify(i->first) - + " - " + i->second; + for (const auto& v : values) { + if (!v.second.empty()) { + Glib::ustring label = world->rdf_world()->prefixes().qualify(v.first) + + " - " + v.second; menu->items().push_back(Gtk::Menu_Helpers::MenuElem(label)); Gtk::MenuItem* menu_item = &(menu->items().back()); menu_item->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &Port::on_uri_activated), - i->first)); + v.first)); } } diff --git a/src/gui/PortPropertiesWindow.cpp b/src/gui/PortPropertiesWindow.cpp index a4b2d5fc..a0162fba 100644 --- a/src/gui/PortPropertiesWindow.cpp +++ b/src/gui/PortPropertiesWindow.cpp @@ -56,8 +56,8 @@ PortPropertiesWindow::present(SharedPtr<const PortModel> pm) { assert(pm); - for (list<sigc::connection>::iterator i = _connections.begin(); i != _connections.end(); ++i) - (*i).disconnect(); + for (auto& c : _connections) + c.disconnect(); _connections.clear(); diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp index ea4e6683..548fe8ec 100644 --- a/src/gui/PropertiesWindow.cpp +++ b/src/gui/PropertiesWindow.cpp @@ -156,8 +156,8 @@ PropertiesWindow::set_object(SharedPtr<const ObjectModel> model) // Populate key combo const URISet props = RDFS::properties(world, model); - for (URISet::const_iterator p = props.begin(); p != props.end(); ++p) { - LilvNode* prop = lilv_new_uri(world->lilv_world(), p->c_str()); + for (const auto& p : props) { + LilvNode* prop = lilv_new_uri(world->lilv_world(), p.c_str()); const Glib::ustring label = RDFS::label(world, prop); if (label.empty()) { continue; @@ -173,8 +173,8 @@ PropertiesWindow::set_object(SharedPtr<const ObjectModel> model) RDFS::classes(world, ranges, false); bool show = false; - for (URISet::const_iterator i = ranges.begin(); i != ranges.end(); ++i) { - LilvNode* range = lilv_new_uri(world->lilv_world(), i->c_str()); + for (const auto& r : ranges) { + LilvNode* range = lilv_new_uri(world->lilv_world(), r.c_str()); LilvNodes* objects = lilv_world_find_nodes( world->lilv_world(), NULL, rdf_type, range); @@ -190,7 +190,7 @@ PropertiesWindow::set_object(SharedPtr<const ObjectModel> model) if (show || ranges.empty()) { Gtk::ListStore::iterator ki = _key_store->append(); Gtk::ListStore::Row row = *ki; - row[_combo_columns.uri_col] = *p; + row[_combo_columns.uri_col] = p; row[_combo_columns.label_col] = label; } @@ -200,9 +200,8 @@ PropertiesWindow::set_object(SharedPtr<const ObjectModel> model) lilv_node_free(rdfs_range); lilv_node_free(rdf_type); - for (ObjectModel::Properties::const_iterator i = model->properties().begin(); - i != model->properties().end(); ++i) { - add_property(i->first, i->second); + for (const auto& p : model->properties()) { + add_property(p.first, p.second); } _table->show_all(); @@ -284,9 +283,9 @@ PropertiesWindow::on_show() Gtk::Requisition req; typedef Gtk::Box_Helpers::BoxList Children; - for (Children::const_iterator i = _vbox->children().begin(); i != _vbox->children().end(); ++i) { - req = (*i).get_widget()->size_request(); - if ((*i).get_widget() != _scrolledwindow) { + for (const auto& c : _vbox->children()) { + req = c.get_widget()->size_request(); + if (c.get_widget() != _scrolledwindow) { width = std::max(width, req.width); height += req.height + VBOX_PAD; } @@ -402,12 +401,13 @@ PropertiesWindow::key_changed() RDFS::Objects values = RDFS::instances(world, ranges); // Fill value selector with suitable objects - for (RDFS::Objects::const_iterator i = values.begin(); i != values.end(); ++i) { - if (!i->second.empty()) { + for (const auto& v : values) { + if (!v.second.empty()) { Gtk::ListStore::iterator vi = _value_store->append(); Gtk::ListStore::Row vrow = *vi; - vrow[_combo_columns.uri_col] = i->first; - vrow[_combo_columns.label_col] = i->second; + + vrow[_combo_columns.uri_col] = v.first; + vrow[_combo_columns.label_col] = v.second; } } @@ -446,9 +446,9 @@ void PropertiesWindow::apply_clicked() { Resource::Properties properties; - for (Records::const_iterator r = _records.begin(); r != _records.end(); ++r) { - const Raul::URI& uri = r->first; - const Record& record = r->second; + for (const auto& r : _records) { + const Raul::URI& uri = r.first; + const Record& record = r.second; if (!_model->has_property(uri, record.value)) { properties.insert(make_pair(uri, record.value)); } diff --git a/src/gui/RDFS.cpp b/src/gui/RDFS.cpp index 0420d4dd..bec69cee 100644 --- a/src/gui/RDFS.cpp +++ b/src/gui/RDFS.cpp @@ -51,8 +51,8 @@ classes(World* world, URISet& types, bool super) do { added = 0; URISet klasses; - for (URISet::iterator t = types.begin(); t != types.end(); ++t) { - LilvNode* type = lilv_new_uri(world->lilv_world(), t->c_str()); + for (const auto& t : types) { + LilvNode* type = lilv_new_uri(world->lilv_world(), t.c_str()); LilvNodes* matches = (super) ? lilv_world_find_nodes( world->lilv_world(), type, rdfs_subClassOf, NULL) @@ -153,8 +153,8 @@ instances(World* world, const URISet& types) world->lilv_world(), LILV_NS_RDF "type"); Objects result; - for (URISet::const_iterator i = types.begin(); i != types.end(); ++i) { - LilvNode* type = lilv_new_uri(world->lilv_world(), i->c_str()); + for (const auto& t : types) { + LilvNode* type = lilv_new_uri(world->lilv_world(), t.c_str()); LilvNodes* objects = lilv_world_find_nodes( world->lilv_world(), NULL, rdf_type, type); LILV_FOREACH(nodes, o, objects) { diff --git a/src/gui/WindowFactory.cpp b/src/gui/WindowFactory.cpp index 57a21536..983e246b 100644 --- a/src/gui/WindowFactory.cpp +++ b/src/gui/WindowFactory.cpp @@ -60,17 +60,15 @@ WindowFactory::WindowFactory(App& app) WindowFactory::~WindowFactory() { - for (GraphWindowMap::iterator i = _graph_windows.begin(); - i != _graph_windows.end(); ++i) - delete i->second; + for (const auto& w : _graph_windows) + delete w.second; } void WindowFactory::clear() { - for (GraphWindowMap::iterator i = _graph_windows.begin(); - i != _graph_windows.end(); ++i) - delete i->second; + for (const auto& w : _graph_windows) + delete w.second; _graph_windows.clear(); } @@ -81,9 +79,8 @@ size_t WindowFactory::num_open_graph_windows() { size_t ret = 0; - for (GraphWindowMap::iterator i = _graph_windows.begin(); - i != _graph_windows.end(); ++i) - if (i->second->is_visible()) + for (const auto& w : _graph_windows) + if (w.second->is_visible()) ++ret; return ret; |