return shared_ptr<RowItem>();
}
-bool Header::accept_drag() const
-{
- // Check all the drag items share a common owner
- RowItemOwner *item_owner = nullptr;
- for (shared_ptr<RowItem> r : view_)
- if (r->dragging()) {
- if (!item_owner)
- item_owner = r->owner();
- else if(item_owner != r->owner())
- return false;
- }
-
- return item_owner;
-}
-
void Header::drag_items(const QPoint &delta)
{
RowItemOwner *item_owner = nullptr;
std::shared_ptr<pv::view::ViewItem> get_mouse_over_item(
const QPoint &pt);
- /**
- * Returns true if the selection of row items allows dragging.
- * @return Returns true if the drag is acceptable.
- */
- bool accept_drag() const;
-
/**
* Drag the dragging items by the delta offset.
* @param delta the drag offset in pixels.
*/
void show_popup(const std::shared_ptr<ViewItem> &item);
- /**
- * Returns true if the selection of row items allows dragging.
- * @return Returns true if the drag is acceptable.
- */
- virtual bool accept_drag() const = 0;
-
/**
* Drag the dragging items by the delta offset.
* @param delta the drag offset in pixels.
return nullptr;
}
-bool Ruler::accept_drag() const
-{
- return true;
-}
-
void Ruler::drag_items(const QPoint &delta)
{
const vector< shared_ptr<TimeItem> > items(view_.time_items());
std::shared_ptr<pv::view::ViewItem> get_mouse_over_item(
const QPoint &pt);
- /**
- * Returns true if the selection of time items allows dragging.
- * @return Returns true if the drag is acceptable.
- */
- bool accept_drag() const;
-
/**
* Drag the dragging items by the delta offset.
* @param delta the drag offset in pixels.
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <algorithm>
+
+#include "rowitem.hpp"
+#include "timeitem.hpp"
#include "view.hpp"
#include "viewwidget.hpp"
+using std::any_of;
+using std::shared_ptr;
+using std::vector;
+
namespace pv {
namespace view {
{
}
+bool ViewWidget::accept_drag() const
+{
+ const vector< shared_ptr<TimeItem> > items(view_.time_items());
+
+ const bool any_row_items_selected = any_of(view_.begin(), view_.end(),
+ [](const shared_ptr<RowItem> &r) { return r->selected(); });
+
+ const bool any_time_items_selected = any_of(items.begin(), items.end(),
+ [](const shared_ptr<TimeItem> &i) { return i->selected(); });
+
+ if (any_row_items_selected && !any_time_items_selected)
+ {
+ // Check all the drag items share a common owner
+ RowItemOwner *item_owner = nullptr;
+ for (shared_ptr<RowItem> r : view_)
+ if (r->dragging()) {
+ if (!item_owner)
+ item_owner = r->owner();
+ else if(item_owner != r->owner())
+ return false;
+ }
+
+ return true;
+ }
+ else if (any_time_items_selected && !any_row_items_selected)
+ {
+ return true;
+ }
+
+ return false;
+}
+
} // namespace view
} // namespace pv
protected:
ViewWidget(View &parent);
+ /**
+ * Returns true if the selection of row items allows dragging.
+ * @return Returns true if the drag is acceptable.
+ */
+ bool accept_drag() const;
+
protected:
pv::view::View &view_;
};