return (pos.x() <= view->header_width());
}
-bool Trace::is_draggable() const
+bool Trace::is_draggable(QPoint pos) const
{
// While the header label that belongs to this trace is draggable,
- // the trace itself shall not be
- return false;
+ // the trace itself shall not be. Hence we return true if the header
+ // was clicked and false if the trace area was clicked
+ const View *view = owner_->view();
+ assert(view);
+
+ return (pos.x() <= view->header_width());
}
void Trace::set_segment_display_mode(SegmentDisplayMode mode)
/**
* Returns true if the item may be dragged/moved.
*/
- virtual bool is_draggable() const;
+ virtual bool is_draggable(QPoint pos) const;
/**
* Configures the segment display mode to use.
return true;
}
-bool TriggerMarker::is_draggable() const
+bool TriggerMarker::is_draggable(QPoint pos) const
{
+ (void)pos;
return false;
}
#include "timeitem.hpp"
+#include <QPoint>
+
namespace pv {
namespace views {
namespace trace {
/**
Returns true if the item may be dragged/moved.
*/
- bool is_draggable() const override;
+ bool is_draggable(QPoint pos) const override;
/**
* Sets the time of the marker.
selected_ = select;
}
-bool ViewItem::is_draggable() const
+bool ViewItem::is_draggable(QPoint pos) const
{
+ (void)pos;
return true;
}
void ViewItem::drag()
{
- if (is_draggable())
- drag_point_ = drag_point(QRect());
+ drag_point_ = drag_point(QRect());
}
void ViewItem::drag_release()
/**
* Returns true if the item may be dragged/moved.
*/
- virtual bool is_draggable() const;
+ virtual bool is_draggable(QPoint pos) const;
/**
* Returns true if the item is being dragged.
return nullptr;
}
-void Viewport::item_hover(const shared_ptr<ViewItem> &item)
+void Viewport::item_hover(const shared_ptr<ViewItem> &item, QPoint pos)
{
- if (item && item->is_draggable())
+ if (item && item->is_draggable(pos))
setCursor(dynamic_pointer_cast<RowItem>(item) ?
Qt::SizeVerCursor : Qt::SizeHorCursor);
else
#include <boost/optional.hpp>
+#include <QPoint>
#include <QTimer>
#include <QTouchEvent>
* @param item The item that is being hovered over, or @c nullptr
* if no view item is being hovered over.
*/
- void item_hover(const shared_ptr<ViewItem> &item);
+ void item_hover(const shared_ptr<ViewItem> &item, QPoint pos);
/**
* Sets this item into the dragged state.
i->select(false);
}
-void ViewWidget::item_hover(const shared_ptr<ViewItem> &item)
+void ViewWidget::item_hover(const shared_ptr<ViewItem> &item, QPoint pos)
{
(void)item;
+ (void)pos;
}
void ViewWidget::item_clicked(const shared_ptr<ViewItem> &item)
bool item_dragged = false;
const auto items = this->items();
for (auto &i : items)
- if (i->selected()) {
+ if (i->selected() && i->is_draggable(event->pos())) {
item_dragged = true;
i->drag();
}
mouse_point_ = event->pos();
if (!event->buttons())
- item_hover(get_mouse_over_item(event->pos()));
+ item_hover(get_mouse_over_item(event->pos()), event->pos());
else if (event->buttons() & Qt::LeftButton) {
if (!item_dragging_) {
if ((event->pos() - mouse_down_point_).manhattanLength() <
#include <memory>
+#include <QPoint>
#include <QWidget>
using std::shared_ptr;
* if no view item is being hovered over.
* @remarks the default implementation does nothing.
*/
- virtual void item_hover(const shared_ptr<ViewItem> &item);
+ virtual void item_hover(const shared_ptr<ViewItem> &item, QPoint pos);
/**
* Indicates the event an a view item has been clicked.