]> sigrok.org Git - pulseview.git/commitdiff
Process selected device
authorJoel Holdsworth <redacted>
Thu, 7 Mar 2013 23:18:46 +0000 (23:18 +0000)
committerUwe Hermann <redacted>
Sat, 9 Mar 2013 10:43:04 +0000 (11:43 +0100)
pv/dialogs/connect.cpp
pv/dialogs/connect.h
pv/mainwindow.cpp

index f7a75da0c6e081840ee9cd597c90a31d1605d4ac..87fc451acee3819e2b9622cbe849f9d8faec8e79 100644 (file)
@@ -70,6 +70,15 @@ Connect::Connect(QWidget *parent) :
        _layout.addWidget(&_button_box);
 }
 
+struct sr_dev_inst* Connect::get_selected_device() const
+{
+       const QListWidgetItem *const item = _device_list.currentItem();
+       if (!item)
+               return NULL;
+
+       return (sr_dev_inst*)item->data(Qt::UserRole).value<void*>();
+}
+
 void Connect::populate_drivers()
 {
        const int *hwopts;
@@ -150,7 +159,10 @@ void Connect::scan_pressed()
                                g_slist_length(sdi->probes));
                }
 
-               _device_list.addItem(text);
+               QListWidgetItem *const item = new QListWidgetItem(text,
+                       &_device_list);
+               item->setData(Qt::UserRole, qVariantFromValue((void*)sdi));
+               _device_list.addItem(item);
        }
 
        g_slist_free(devices);
index 862184b87326566415b2a142f59baef523dc6b6b..eeb108c105dd5a4c28edaf4e658ed10fa2e137f6 100644 (file)
@@ -31,6 +31,7 @@
 #include <QVBoxLayout>
 
 struct sr_config;
+struct sr_dev_inst;
 
 namespace pv {
 namespace dialogs {
@@ -42,6 +43,8 @@ class Connect : public QDialog
 public:
        Connect(QWidget *parent);
 
+       struct sr_dev_inst* get_selected_device() const;
+
 private:
        void populate_drivers();
 
index c9fa4c1a25fc749a9d47804ea369b8c9ff3e1ad1..03562b8f54e57d421aefa86fe764e6d6f376a819 100644 (file)
@@ -226,7 +226,17 @@ void MainWindow::on_actionOpen_triggered()
 void MainWindow::on_actionConnect_triggered()
 {
        dialogs::Connect dlg(this);
-       dlg.exec();
+       if(!dlg.exec())
+               return;
+
+       struct sr_dev_inst *const sdi = dlg.get_selected_device();
+       if (sdi) {
+               assert(_sampling_bar);
+
+               _devices.push_back(sdi);
+               _sampling_bar->set_device_list(_devices);
+               _sampling_bar->set_selected_device(sdi);
+       }
 }
 
 void MainWindow::on_actionQuit_triggered()