diff options
| author | Nick Dedekind <nicholas.dedekind@gmail.com> | 2013-08-16 11:06:30 +0100 |
|---|---|---|
| committer | Nick Dedekind <nicholas.dedekind@gmail.com> | 2013-08-16 11:06:30 +0100 |
| commit | 3141fbd9f2cd30b53657189f305f50b4f19f3445 (patch) | |
| tree | 836a359d543deb95c6b36d43089047b85bdbb162 /dash | |
| parent | 2a454a93a5f82ec79e51fa3e78f4d79c3a19fd2b (diff) | |
better handling of adding categories/filters
(bzr r3472.1.2)
Diffstat (limited to 'dash')
| -rwxr-xr-x | dash/ScopeView.cpp | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/dash/ScopeView.cpp b/dash/ScopeView.cpp index 861f1ca24..a9442ec7f 100755 --- a/dash/ScopeView.cpp +++ b/dash/ScopeView.cpp @@ -293,18 +293,11 @@ void ScopeView::SetupCategories(Categories::Ptr const& categories) conn = categories->category_removed.connect(sigc::mem_fun(this, &ScopeView::OnCategoryRemoved)); category_removed_connection_ = conn_manager_.Add(conn); - auto resync_categories = [this, categories] (bool add = false) - { - ClearCategories(); - if (add) - { - for (unsigned int i = 0; i < categories->count(); ++i) - OnCategoryAdded(categories->RowAtIndex(i)); - } - }; + categories->model.changed.connect(sigc::hide([this]() { ClearCategories(); })); - categories->model.changed.connect(sigc::hide(resync_categories)); - resync_categories(true); + ClearCategories(); + for (unsigned int i = 0; i < categories->count(); ++i) + OnCategoryAdded(categories->RowAtIndex(i)); scope_->category_order.changed.connect(sigc::mem_fun(this, &ScopeView::OnCategoryOrderChanged)); } @@ -393,23 +386,21 @@ void ScopeView::SetupFilters(Filters::Ptr const& filters) conn = filters->filter_removed.connect(sigc::mem_fun(this, &ScopeView::OnFilterRemoved)); filter_removed_connection_ = conn_manager_.Add(conn); - auto resync_filters = [this, filters] (bool add = false) + auto clear_filters = [this, filters] () { auto conn = conn_manager_.Get(filter_removed_connection_); bool blocked = conn.block(true); filter_bar_->ClearFilters(); - if (add) - { - for (unsigned int i = 0; i < filters->count(); ++i) - OnFilterAdded(filters->FilterAtIndex(i)); - } conn.block(blocked); }; - filters->model.changed.connect(sigc::hide(resync_filters)); - resync_filters(true); + filters->model.changed.connect(sigc::hide(clear_filters)); + + clear_filters(); + for (unsigned int i = 0; i < filters->count(); ++i) + OnFilterAdded(filters->FilterAtIndex(i)); } void ScopeView::OnCategoryAdded(Category const& category) |
