]> sigrok.org Git - pulseview.git/blobdiff - pv/toolbars/contextbar.cpp
Initial working context bar
[pulseview.git] / pv / toolbars / contextbar.cpp
index 8e92676a5137c897557e968d67424b72b3df60a7..a538d64ac4caed2f68a44298b8cb6f4220b93a1e 100644 (file)
  * 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 {
@@ -30,5 +38,27 @@ ContextBar::ContextBar(QWidget *parent) :
 {
 }
 
+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