From: Soeren Apel Date: Fri, 12 Dec 2014 16:38:55 +0000 (+0100) Subject: SamplingBar: Use DeviceManager::get_display_name() directly X-Git-Tag: pulseview-0.3.0~363 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=53a7cce47482b2220e023bfcb9b4069b6eb88805 SamplingBar: Use DeviceManager::get_display_name() directly --- diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index cc0e0d25..b7f360ff 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -61,7 +61,6 @@ using std::list; using std::map; -using std::pair; using std::shared_ptr; using std::string; @@ -411,13 +410,7 @@ void MainWindow::update_device_list() devices.push_back(selected_device); assert(selected_device); - list< pair< shared_ptr, string> > device_list; - - for (auto device : devices) - device_list.push_back(make_pair( - device, device_manager_.get_display_name(device))); - - sampling_bar_->set_device_list(device_list, selected_device); + sampling_bar_->set_device_list(devices, selected_device); } void MainWindow::closeEvent(QCloseEvent *event) diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index b5a2aee5..7ee4d981 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -111,7 +111,7 @@ SamplingBar::SamplingBar(Session &session, MainWindow &main_window) : } void SamplingBar::set_device_list( - const std::list< std::pair, std::string> > &devices, + const std::list< std::shared_ptr > &devices, shared_ptr selected) { int selected_index = -1; @@ -122,12 +122,12 @@ void SamplingBar::set_device_list( device_selector_.clear(); - for (auto entry : devices) { - auto device = entry.first; - auto display_name = entry.second; - + for (auto device : devices) { assert(device); + string display_name = + session_.device_manager().get_display_name(device); + if (selected == device) selected_index = device_selector_.count(); diff --git a/pv/toolbars/samplingbar.hpp b/pv/toolbars/samplingbar.hpp index 436304bc..10e70cb9 100644 --- a/pv/toolbars/samplingbar.hpp +++ b/pv/toolbars/samplingbar.hpp @@ -63,7 +63,7 @@ public: SamplingBar(Session &session, pv::MainWindow &main_window); void set_device_list( - const std::list< std::pair, std::string> > &devices, + const std::list< std::shared_ptr > &devices, std::shared_ptr selected); std::shared_ptr get_selected_device() const;