label_size.height());
}
+QRectF Trace::hit_box_rect(const ViewItemPaintParams &pp) const
+{
+ pair<int, int> extents = v_extents();
+ const int top = pp.top() + get_visual_y() + extents.first;
+ const int height = extents.second - extents.first;
+ return QRectF(pp.left(), top, pp.width(), height);
+}
+
void Trace::set_current_segment(const int segment)
{
current_segment_ = segment;
*/
QRectF label_rect(const QRectF &rect) const;
+ /**
+ * Computes the outline rectangle of the viewport hit-box.
+ * @param rect the rectangle of the viewport area.
+ * @return Returns the rectangle of the hit-box.
+ * @remarks The default implementation returns an empty hit-box.
+ */
+ virtual QRectF hit_box_rect(const ViewItemPaintParams &pp) const;
+
void set_current_segment(const int segment);
int get_current_segment() const;
#include <QApplication>
#include <QEvent>
#include <QFontMetrics>
+#include <QMenu>
#include <QMouseEvent>
#include <QScrollBar>
#include <QVBoxLayout>
return QObject::eventFilter(object, event);
}
+void View::contextMenuEvent(QContextMenuEvent *event)
+{
+ const shared_ptr<ViewItem> r = viewport_->get_mouse_over_item(event->pos());
+ if (!r)
+ return;
+
+ QMenu *menu = r->create_view_context_menu(this);
+ if (menu)
+ menu->exec(event->globalPos());
+}
+
void View::resizeEvent(QResizeEvent* event)
{
// Only adjust the top margin if we shrunk vertically
bool eventFilter(QObject *object, QEvent *event);
+ virtual void contextMenuEvent(QContextMenuEvent *event);
+
void resizeEvent(QResizeEvent *event);
void update_hover_point();
return new QMenu(parent);
}
+QMenu* ViewItem::create_view_context_menu(QWidget *parent)
+{
+ (void)parent;
+ return nullptr;
+}
+
widgets::Popup* ViewItem::create_popup(QWidget *parent)
{
(void)parent;
public:
virtual QMenu* create_context_menu(QWidget *parent);
+ virtual QMenu* create_view_context_menu(QWidget *parent);
+
virtual pv::widgets::Popup* create_popup(QWidget *parent);
virtual void delete_pressed();
public:
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 shared_ptr<ViewItem> &item);
-
/**
* Gets the first view item which has a hit-box that contains @c pt .
* @param pt the point to search with.
*/
shared_ptr<ViewItem> get_mouse_over_item(const QPoint &pt);
+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 shared_ptr<ViewItem> &item);
+
/**
* Sets this item into the dragged state.
*/