]> sigrok.org Git - pulseview.git/blobdiff - pv/popups/channels.cpp
Standardize on 'event' as name for all Qt events.
[pulseview.git] / pv / popups / channels.cpp
index f30ce627d72f3ae675571506f5eb58b878a57570..c3388581f2c402426e62a0281d61d809fa899eec 100644 (file)
 
 #include <map>
 
+#ifdef _WIN32
+// Windows: Avoid boost/thread namespace pollution (which includes windows.h).
+#define NOGDI
+#define NORESOURCE
+#endif
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+
 #include <QCheckBox>
 #include <QFormLayout>
 #include <QGridLayout>
 
 #include "channels.hpp"
 
-#include <pv/prop/binding/deviceoptions.hpp>
+#include <pv/binding/device.hpp>
+#include <pv/devices/device.hpp>
 #include <pv/session.hpp>
 #include <pv/view/signal.hpp>
 
-#include <libsigrok/libsigrok.hpp>
+#include <libsigrokcxx/libsigrokcxx.hpp>
 
 using namespace Qt;
 
@@ -42,6 +51,7 @@ using std::map;
 using std::mutex;
 using std::set;
 using std::shared_ptr;
+using std::unordered_set;
 using std::vector;
 
 using sigrok::Channel;
@@ -64,27 +74,24 @@ Channels::Channels(Session &session, QWidget *parent) :
        // Create the layout
        setLayout(&layout_);
 
-       shared_ptr<sigrok::Device> device = session_.device();
+       const shared_ptr<sigrok::Device> device = session_.device()->device();
        assert(device);
 
        // Collect a set of signals
        map<shared_ptr<Channel>, shared_ptr<Signal> > 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;
 
        // Populate channel groups
-       for (auto entry : device->channel_groups())
-       {
+       for (auto entry : device->channel_groups()) {
                shared_ptr<ChannelGroup> group = entry.second;
                // Make a set of signals, and removed this signals from the
                // signal map.
                vector< shared_ptr<Signal> > group_sigs;
-               for (auto channel : group->channels())
-               {
+               for (auto channel : group->channels()) {
                        const auto iter = signal_map.find(channel);
 
                        if (iter == signal_map.end())
@@ -99,8 +106,7 @@ Channels::Channels(Session &session, QWidget *parent) :
 
        // Make a vector of the remaining channels
        vector< shared_ptr<Signal> > global_sigs;
-       for (auto channel : device->channels())
-       {
+       for (auto channel : device->channels()) {
                const map<shared_ptr<Channel>, shared_ptr<Signal> >::
                        const_iterator iter = signal_map.find(channel);
                if (iter != signal_map.end())
@@ -108,7 +114,7 @@ Channels::Channels(Session &session, QWidget *parent) :
        }
 
        // Create a group
-       populate_group(NULL, global_sigs);
+       populate_group(nullptr, global_sigs);
 
        // Create the enable/disable all buttons
        connect(&enable_all_channels_, SIGNAL(clicked()),
@@ -135,9 +141,8 @@ void Channels::set_all_channels(bool set)
        updating_channels_ = true;
 
        for (map<QCheckBox*, shared_ptr<Signal> >::const_iterator i =
-               check_box_signal_map_.begin();
-               i != check_box_signal_map_.end(); i++)
-       {
+                       check_box_signal_map_.begin();
+                       i != check_box_signal_map_.end(); i++) {
                const shared_ptr<Signal> sig = (*i).second;
                assert(sig);
 
@@ -151,14 +156,14 @@ void Channels::set_all_channels(bool set)
 void Channels::populate_group(shared_ptr<ChannelGroup> group,
        const vector< shared_ptr<pv::view::Signal> > sigs)
 {
-       using pv::prop::binding::DeviceOptions;
+       using pv::binding::Device;
 
        // Only bind options if this is a group. We don't do it for general
        // options, because these properties are shown in the device config
        // popup.
-       shared_ptr<DeviceOptions> binding;
+       shared_ptr<Device> binding;
        if (group)
-               binding = shared_ptr<DeviceOptions>(new DeviceOptions(group));
+               binding = shared_ptr<Device>(new Device(group));
 
        // Create a title if the group is going to have any content
        if ((!sigs.empty() || (binding && !binding->properties().empty())) &&
@@ -185,8 +190,7 @@ QGridLayout* Channels::create_channel_group_grid(
        int row = 0, col = 0;
        QGridLayout *const grid = new QGridLayout();
 
-       for (const shared_ptr<pv::view::Signal>& sig : sigs)
-       {
+       for (const shared_ptr<pv::view::Signal>& sig : sigs) {
                assert(sig);
 
                QCheckBox *const checkbox = new QCheckBox(sig->name());
@@ -198,23 +202,22 @@ QGridLayout* Channels::create_channel_group_grid(
 
                check_box_signal_map_[checkbox] = sig;
 
-               if(++col >= 8)
+               if (++col >= 8)
                        col = 0, row++;
        }
 
        return grid;
 }
 
-void Channels::showEvent(QShowEvent *e)
+void Channels::showEvent(QShowEvent *event)
 {
-       pv::widgets::Popup::showEvent(e);
+       pv::widgets::Popup::showEvent(event);
 
        updating_channels_ = true;
 
        for (map<QCheckBox*, shared_ptr<Signal> >::const_iterator i =
-               check_box_signal_map_.begin();
-               i != check_box_signal_map_.end(); i++)
-       {
+                       check_box_signal_map_.begin();
+                       i != check_box_signal_map_.end(); i++) {
                const shared_ptr<Signal> sig = (*i).second;
                assert(sig);