#include <glib.h>
#include <libsigrok/libsigrok.h>
+using namespace boost;
using namespace std;
namespace pv {
+namespace view {
+class SelectableItem;
+}
+
MainWindow::MainWindow(DeviceManager &device_manager,
const char *open_file_name,
QWidget *parent) :
setCentralWidget(_central_widget);
_view = new pv::view::View(_session, this);
+ connect(_view, SIGNAL(selection_changed()), this,
+ SLOT(view_selection_changed()));
+
_vertical_layout->addWidget(_view);
// Setup the menu bar
_sampling_bar->set_sampling(state != SigSession::Stopped);
}
+void MainWindow::view_selection_changed()
+{
+ assert(_context_bar);
+
+ const list<weak_ptr<pv::view::SelectableItem> > items(
+ _view->selected_items());
+ _context_bar->set_selected_items(items);
+}
+
} // namespace pv
#include <list>
+#include <boost/weak_ptr.hpp>
+
#include <QMainWindow>
#include "sigsession.h"
void capture_state_changed(int state);
+ void view_selection_changed();
+
private:
DeviceManager &_device_manager;
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stdio.h>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/foreach.hpp>
+
#include "contextbar.h"
+#include <pv/view/selectableitem.h>
+
+using namespace boost;
using namespace std;
namespace pv {
{
}
+void ContextBar::set_selected_items(const list<
+ weak_ptr<pv::view::SelectableItem> > &items)
+{
+ clear();
+
+ if (items.empty())
+ return;
+
+ if (shared_ptr<pv::view::SelectableItem> item =
+ items.front().lock()) {
+
+ assert(item);
+
+ const list<QAction*> actions(
+ item->get_context_bar_actions());
+ BOOST_FOREACH(QAction *action, actions) {
+ assert(action);
+ addAction(action);
+ }
+ }
+}
+
} // namespace toolbars
} // namespace pv
#ifndef PULSEVIEW_PV_TOOLBARS_CONTEXTBAR_H
#define PULSEVIEW_PV_TOOLBARS_CONTEXTBAR_H
+#include <boost/weak_ptr.hpp>
+
#include <QToolBar>
+#include <pv/view/selectableitem.h>
+
namespace pv {
namespace toolbars {
public:
ContextBar(QWidget *parent);
+
+public:
+ void set_selected_items(const std::list<
+ boost::weak_ptr<pv::view::SelectableItem> > &items);
};
} // namespace toolbars