projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
68e0a53
)
Allow for a context menu in the view area
author
Soeren Apel
<soeren@apelpie.net>
Thu, 2 Aug 2018 06:56:51 +0000
(08:56 +0200)
committer
Uwe Hermann
<uwe@hermann-uwe.de>
Tue, 21 Aug 2018 10:02:38 +0000
(12:02 +0200)
pv/views/trace/trace.cpp
patch
|
blob
|
history
pv/views/trace/trace.hpp
patch
|
blob
|
history
pv/views/trace/view.cpp
patch
|
blob
|
history
pv/views/trace/view.hpp
patch
|
blob
|
history
pv/views/trace/viewitem.cpp
patch
|
blob
|
history
pv/views/trace/viewitem.hpp
patch
|
blob
|
history
pv/views/trace/viewport.hpp
patch
|
blob
|
history
diff --git
a/pv/views/trace/trace.cpp
b/pv/views/trace/trace.cpp
index 7d8501122753aabe9f4d739d2dbea82d211fab5b..3b79dcd98aea33db43ca32fbe9f37415048dc2c6 100644
(file)
--- a/
pv/views/trace/trace.cpp
+++ b/
pv/views/trace/trace.cpp
@@
-187,6
+187,14
@@
QRectF Trace::label_rect(const QRectF &rect) const
label_size.height());
}
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;
void Trace::set_current_segment(const int segment)
{
current_segment_ = segment;
diff --git
a/pv/views/trace/trace.hpp
b/pv/views/trace/trace.hpp
index d6d53045e4bbf69ce68aff934a94195280a40d38..bc97736c03de58f1ccc4d9d2e09571c110c6d909 100644
(file)
--- a/
pv/views/trace/trace.hpp
+++ b/
pv/views/trace/trace.hpp
@@
-128,6
+128,14
@@
public:
*/
QRectF label_rect(const QRectF &rect) const;
*/
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;
void set_current_segment(const int segment);
int get_current_segment() const;
diff --git
a/pv/views/trace/view.cpp
b/pv/views/trace/view.cpp
index 024e3bf48d665b0043252551c72ef2202da80de5..99e75bfdc9ec72de6281d86b3d922e626a5911a5 100644
(file)
--- a/
pv/views/trace/view.cpp
+++ b/
pv/views/trace/view.cpp
@@
-38,6
+38,7
@@
#include <QApplication>
#include <QEvent>
#include <QFontMetrics>
#include <QApplication>
#include <QEvent>
#include <QFontMetrics>
+#include <QMenu>
#include <QMouseEvent>
#include <QScrollBar>
#include <QVBoxLayout>
#include <QMouseEvent>
#include <QScrollBar>
#include <QVBoxLayout>
@@
-1251,6
+1252,17
@@
bool View::eventFilter(QObject *object, QEvent *event)
return QObject::eventFilter(object, event);
}
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
void View::resizeEvent(QResizeEvent* event)
{
// Only adjust the top margin if we shrunk vertically
diff --git
a/pv/views/trace/view.hpp
b/pv/views/trace/view.hpp
index 4f364404ce01acf2c9f9b4ee18d8cfb2dc517843..1cff6ab7bbf245f52a7508c20b52b446e26d15bc 100644
(file)
--- a/
pv/views/trace/view.hpp
+++ b/
pv/views/trace/view.hpp
@@
-394,6
+394,8
@@
private:
bool eventFilter(QObject *object, QEvent *event);
bool eventFilter(QObject *object, QEvent *event);
+ virtual void contextMenuEvent(QContextMenuEvent *event);
+
void resizeEvent(QResizeEvent *event);
void update_hover_point();
void resizeEvent(QResizeEvent *event);
void update_hover_point();
diff --git
a/pv/views/trace/viewitem.cpp
b/pv/views/trace/viewitem.cpp
index 2141687c92b12fc546bbe87346681a65655dc4d3..7c1fae736699e2215aefb71e7aaec1f0a714fe00 100644
(file)
--- a/
pv/views/trace/viewitem.cpp
+++ b/
pv/views/trace/viewitem.cpp
@@
-88,6
+88,12
@@
QMenu* ViewItem::create_context_menu(QWidget *parent)
return new QMenu(parent);
}
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;
widgets::Popup* ViewItem::create_popup(QWidget *parent)
{
(void)parent;
diff --git
a/pv/views/trace/viewitem.hpp
b/pv/views/trace/viewitem.hpp
index f3e0f9b67f5470b6942ae52d10351a2c58ea5db2..91242f57478e3bb9223bb8f01abf14118853c21a 100644
(file)
--- a/
pv/views/trace/viewitem.hpp
+++ b/
pv/views/trace/viewitem.hpp
@@
-157,6
+157,8
@@
public:
public:
virtual QMenu* create_context_menu(QWidget *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();
virtual pv::widgets::Popup* create_popup(QWidget *parent);
virtual void delete_pressed();
diff --git
a/pv/views/trace/viewport.hpp
b/pv/views/trace/viewport.hpp
index ab67f69f3ee2d618895b6d5595a7251f97ef538c..a49084b43ebe901f6e9cd7bb6ab2ad199e41e580 100644
(file)
--- a/
pv/views/trace/viewport.hpp
+++ b/
pv/views/trace/viewport.hpp
@@
-48,14
+48,6
@@
class Viewport : public ViewWidget
public:
explicit Viewport(View &parent);
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.
/**
* Gets the first view item which has a hit-box that contains @c pt .
* @param pt the point to search with.
@@
-64,6
+56,14
@@
private:
*/
shared_ptr<ViewItem> get_mouse_over_item(const QPoint &pt);
*/
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.
*/
/**
* Sets this item into the dragged state.
*/