using std::abs;
using std::back_inserter;
using std::copy;
+using std::dynamic_pointer_cast;
using std::max;
using std::min;
using std::none_of;
return nullptr;
}
+void Viewport::item_hover(const shared_ptr<ViewItem> &item)
+{
+ if (item)
+ setCursor(dynamic_pointer_cast<RowItem>(item) ?
+ Qt::SizeVerCursor : Qt::SizeHorCursor);
+ else
+ unsetCursor();
+}
+
void Viewport::drag()
{
drag_offset_ = view_.offset();
explicit Viewport(View &parent);
private:
+ /**
+ * Indicates when a view item is being hovered over.
+ * @param item The item that is being hovered over, or @c nullptr
+ * if no view item is being hovered over.
+ */
+ void item_hover(const std::shared_ptr<pv::view::ViewItem> &item);
+
/**
* Gets the first view item which has a hit-box that contains @c pt .
* @param pt the point to search with.
update();
}
+void ViewWidget::item_hover(const shared_ptr<ViewItem> &item)
+{
+ (void)item;
+}
+
void ViewWidget::item_clicked(const shared_ptr<ViewItem> &item)
{
(void)item;
mouse_down_item_ = nullptr;
}
-void ViewWidget::mouseMoveEvent(QMouseEvent *event)
+void ViewWidget::mouseMoveEvent(QMouseEvent *e)
{
- assert(event);
- mouse_point_ = event->pos();
+ assert(e);
+ mouse_point_ = e->pos();
- if (!(event->buttons() & Qt::LeftButton))
- return;
-
- if (!item_dragging_)
+ if (!e->buttons())
+ item_hover(get_mouse_over_item(e->pos()));
+ else if (e->buttons() & Qt::LeftButton)
{
- if ((event->pos() - mouse_down_point_).manhattanLength() <
- QApplication::startDragDistance())
- return;
+ if (!item_dragging_)
+ {
+ if ((e->pos() - mouse_down_point_).manhattanLength() <
+ QApplication::startDragDistance())
+ return;
- if (!accept_drag())
- return;
+ if (!accept_drag())
+ return;
- item_dragging_ = true;
- }
+ item_dragging_ = true;
+ }
- // Do the drag
- drag_items(event->pos() - mouse_down_point_);
+ // Do the drag
+ drag_items(e->pos() - mouse_down_point_);
- update();
+ update();
+ }
}
void ViewWidget::leaveEvent(QEvent*)
protected:
ViewWidget(View &parent);
+ /**
+ * Indicates when a view item is being hovered over.
+ * @param item The item that is being hovered over, or @c nullptr
+ * if no view item is being hovered over.
+ * @remarks the default implementation does nothing.
+ */
+ virtual void item_hover(
+ const std::shared_ptr<pv::view::ViewItem> &item);
+
/**
* Indicates the event an a view item has been clicked.
* @param item the view item that has been clicked.