]> sigrok.org Git - pulseview.git/commitdiff
Added View::selected_items
authorJoel Holdsworth <redacted>
Wed, 15 May 2013 16:30:16 +0000 (17:30 +0100)
committerJoel Holdsworth <redacted>
Sun, 19 May 2013 08:46:00 +0000 (09:46 +0100)
pv/view/view.cpp
pv/view/view.h

index eca6b8eabce92c05575cbefeb1473ea95e424028..ca575bec2ebc0e0258e3ee08490e1f6b5e111b8d 100644 (file)
@@ -159,6 +159,27 @@ void View::set_scale_offset(double scale, double offset)
        _viewport->update();
 }
 
+list<weak_ptr<SelectableItem> > View::selected_items() const
+{
+       list<weak_ptr<SelectableItem> > items;
+
+       // List the selected signals
+       const vector< shared_ptr<Signal> > sigs(_session.get_signals());
+       BOOST_FOREACH (shared_ptr<Signal> s, sigs) {
+               assert(s);
+               if (s->selected())
+                       items.push_back(s);
+       }
+
+       // List the selected cursors
+       if (_cursors.first()->selected())
+               items.push_back(_cursors.first());
+       if (_cursors.second()->selected())
+               items.push_back(_cursors.second());
+
+       return items;
+}
+
 bool View::cursors_shown() const
 {
        return _show_cursors;
index 155c875b777c8143bbd34fe8a88336388214a8ba..99c124733bfe094b69f7f48c3f46dbe77ff4659c 100644 (file)
@@ -23,6 +23,8 @@
 
 #include <stdint.h>
 
+#include <boost/weak_ptr.hpp>
+
 #include <QAbstractScrollArea>
 #include <QSizeF>
 
@@ -86,6 +88,8 @@ public:
         */
        void set_scale_offset(double scale, double offset);
 
+       std::list<boost::weak_ptr<SelectableItem> > selected_items() const;
+
        /**
         * Returns true if cursors are displayed. false otherwise.
         */