]> sigrok.org Git - pulseview.git/blobdiff - pv/view/viewport.cpp
View: Replaced signals_changed handler with signals_updated call
[pulseview.git] / pv / view / viewport.cpp
index 43da472890120e4eb01acfb59fdd14db0d716cc0..8963e047b355dc8f3f0d2d2eba30fd2cb3b92766 100644 (file)
@@ -52,32 +52,30 @@ Viewport::Viewport(View &parent) :
        setAutoFillBackground(true);
        setBackgroundRole(QPalette::Base);
 
-       connect(&_view.session(), SIGNAL(signals_changed()),
-               this, SLOT(on_signals_changed()));
-
        connect(&_view, SIGNAL(signals_moved()),
                this, SLOT(on_signals_moved()));
-
-       // Trigger the initial event manually. The default device has signals
-       // which were created before this object came into being
-       on_signals_changed();
 }
 
 int Viewport::get_total_height() const
 {
        int h = 0;
-       const vector< shared_ptr<RowItem> > row_items(_view.child_items());
-       for (const shared_ptr<RowItem> r : row_items) {
+       for (auto &i : _view)
+               h = max(i->v_offset() + View::SignalHeight, h);
+       return h;
+}
+
+void Viewport::signals_updated()
+{
+       for (shared_ptr<RowItem> r : _view) {
                assert(r);
-               h = max(r->v_offset() + View::SignalHeight, h);
+               connect(r.get(), SIGNAL(appearance_changed()),
+                       this, SLOT(update()));
        }
-
-       return h;
 }
 
 void Viewport::paintEvent(QPaintEvent*)
 {
-       vector< shared_ptr<RowItem> > row_items(_view.child_items());
+       vector< shared_ptr<RowItem> > row_items(_view.begin(), _view.end());
        stable_sort(row_items.begin(), row_items.end(),
                [](const shared_ptr<RowItem> &a, const shared_ptr<RowItem> &b) {
                        return a->v_offset() < b->v_offset(); });
@@ -233,16 +231,6 @@ bool Viewport::touchEvent(QTouchEvent *event)
        return true;
 }
 
-void Viewport::on_signals_changed()
-{
-       const vector< shared_ptr<RowItem> > row_items(_view.child_items());
-       for (shared_ptr<RowItem> r : row_items) {
-               assert(r);
-               connect(r.get(), SIGNAL(visibility_changed()),
-                       this, SLOT(update()));
-       }
-}
-
 void Viewport::on_signals_moved()
 {
        update();