]> sigrok.org Git - pulseview.git/blobdiff - pv/view/view.cpp
Added devices::File as a common base of file devices
[pulseview.git] / pv / view / view.cpp
index 59127c364bb7f0bf35ed83e3de0a8398357d53d1..67d4f404d1162577f9afe524ea46f547d31b402c 100644 (file)
@@ -36,7 +36,7 @@
 #include <QMouseEvent>
 #include <QScrollBar>
 
-#include <libsigrok/libsigrok.hpp>
+#include <libsigrokcxx/libsigrokcxx.hpp>
 
 #include "decodetrace.hpp"
 #include "header.hpp"
@@ -48,6 +48,7 @@
 #include "viewport.hpp"
 
 #include "pv/session.hpp"
+#include "pv/devices/device.hpp"
 #include "pv/data/logic.hpp"
 #include "pv/data/logicsegment.hpp"
 #include "pv/util.hpp"
@@ -84,8 +85,6 @@ const int View::MaxScrollValue = INT_MAX / 2;
 
 const int View::ScaleUnits[3] = {1, 2, 5};
 
-const QSizeF View::LabelPadding(4, 0);
-
 View::View(Session &session, QWidget *parent) :
        QAbstractScrollArea(parent),
        session_(session),
@@ -94,7 +93,6 @@ View::View(Session &session, QWidget *parent) :
        header_(new Header(*this)),
        scale_(1e-6),
        offset_(0),
-       v_offset_(0),
        updating_scroll_(false),
        tick_period_(0.0),
        tick_prefix_(0),
@@ -106,7 +104,7 @@ View::View(Session &session, QWidget *parent) :
        connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
                this, SLOT(h_scroll_value_changed(int)));
        connect(verticalScrollBar(), SIGNAL(valueChanged(int)),
-               this, SLOT(v_scroll_value_changed(int)));
+               this, SLOT(v_scroll_value_changed()));
 
        connect(&session_, SIGNAL(signals_changed()),
                this, SLOT(signals_changed()));
@@ -117,9 +115,6 @@ View::View(Session &session, QWidget *parent) :
        connect(&session_, SIGNAL(frame_ended()),
                this, SLOT(data_updated()));
 
-       connect(header_, SIGNAL(signals_moved()),
-               this, SLOT(on_signals_moved()));
-
        connect(header_, SIGNAL(selection_changed()),
                ruler_, SLOT(clear_selection()));
        connect(ruler_, SIGNAL(selection_changed()),
@@ -207,7 +202,14 @@ double View::offset() const
 
 int View::owner_visual_v_offset() const
 {
-       return -v_offset_;
+       return -verticalScrollBar()->sliderPosition();
+}
+
+void View::set_v_offset(int offset)
+{
+       verticalScrollBar()->setSliderPosition(offset);
+       header_->update();
+       viewport_->update();
 }
 
 unsigned int View::depth() const
@@ -296,7 +298,7 @@ void View::set_scale_offset(double scale, double offset)
 set< shared_ptr<SignalData> > View::get_visible_data() const
 {
        shared_lock<shared_mutex> lock(session().signals_mutex());
-       const vector< shared_ptr<Signal> > &sigs(session().signals());
+       const unordered_set< shared_ptr<Signal> > &sigs(session().signals());
 
        // Make a set of all the visible data objects
        set< shared_ptr<SignalData> > visible_data;
@@ -322,7 +324,7 @@ pair<double, double> View::get_time_extents() const
                        const double start_time = s->start_time();
                        left_time = min(left_time, start_time);
                        right_time = max(right_time, start_time +
-                               d->get_max_sample_count() / samplerate);
+                               d->max_sample_count() / samplerate);
                }
        }
 
@@ -661,9 +663,8 @@ void View::h_scroll_value_changed(int value)
        viewport_->update();
 }
 
-void View::v_scroll_value_changed(int value)
+void View::v_scroll_value_changed()
 {
-       v_offset_ = value;
        header_->update();
        viewport_->update();
 }
@@ -675,7 +676,7 @@ void View::signals_changed()
        // Populate the traces
        clear_child_items();
 
-       shared_ptr<sigrok::Device> device = session_.device();
+       shared_ptr<sigrok::Device> device = session_.device()->device();
        assert(device);
 
        // Collect a set of signals
@@ -683,7 +684,7 @@ void View::signals_changed()
                signal_map;
 
        shared_lock<shared_mutex> lock(session_.signals_mutex());
-       const vector< shared_ptr<Signal> > &sigs(session_.signals());
+       const unordered_set< shared_ptr<Signal> > &sigs(session_.signals());
 
        for (const shared_ptr<Signal> &sig : sigs)
                signal_map[sig->channel()] = sig;
@@ -747,18 +748,14 @@ void View::data_updated()
        viewport_->update();
 }
 
-void View::on_signals_moved()
-{
-       update_scroll();
-       signals_moved();
-}
-
 void View::process_sticky_events()
 {
        if (sticky_events_ & RowItemHExtentsChanged)
                update_layout();
-       if (sticky_events_ & RowItemVExtentsChanged)
+       if (sticky_events_ & RowItemVExtentsChanged) {
                restack_all_row_items();
+               update_scroll();
+       }
 
        // Clear the sticky events
        sticky_events_ = 0;