From: Joel Holdsworth Date: Tue, 9 Dec 2014 00:13:50 +0000 (+0000) Subject: MarginWidget: Moved in dragging_, mouse_point_, and mouse_down_point_ X-Git-Tag: pulseview-0.3.0~370 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=f4433aa958fb9c85ce82ef5545d722625cb64f9e;p=pulseview.git MarginWidget: Moved in dragging_, mouse_point_, and mouse_down_point_ --- diff --git a/pv/view/cursorheader.cpp b/pv/view/cursorheader.cpp index e308867c..f79a5785 100644 --- a/pv/view/cursorheader.cpp +++ b/pv/view/cursorheader.cpp @@ -47,7 +47,6 @@ int CursorHeader::calculateTextHeight() CursorHeader::CursorHeader(View &parent) : MarginWidget(parent), - dragging_(false), textHeight_(calculateTextHeight()) { setMouseTracking(true); @@ -84,6 +83,8 @@ void CursorHeader::paintEvent(QPaintEvent*) void CursorHeader::mouseMoveEvent(QMouseEvent *e) { + mouse_point_ = e->pos(); + if (!(e->buttons() & Qt::LeftButton)) return; @@ -149,5 +150,11 @@ void CursorHeader::mouseReleaseEvent(QMouseEvent *) i->drag_release(); } +void CursorHeader::leaveEvent(QEvent*) +{ + mouse_point_ = QPoint(-1, -1); + update(); +} + } // namespace view } // namespace pv diff --git a/pv/view/cursorheader.hpp b/pv/view/cursorheader.hpp index f37112ec..5ae2a253 100644 --- a/pv/view/cursorheader.hpp +++ b/pv/view/cursorheader.hpp @@ -58,12 +58,11 @@ private: void mouseMoveEvent(QMouseEvent *e); void mousePressEvent(QMouseEvent *e); void mouseReleaseEvent(QMouseEvent *); + void leaveEvent(QEvent*); int calculateTextHeight(); - QPoint mouse_down_point_; std::shared_ptr mouse_down_item_; - bool dragging_; const int textHeight_; }; diff --git a/pv/view/header.cpp b/pv/view/header.cpp index 4da188af..837d1916 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -60,8 +60,7 @@ static bool item_selected(shared_ptr r) } Header::Header(View &parent) : - MarginWidget(parent), - dragging_(false) + MarginWidget(parent) { setFocusPolicy(Qt::ClickFocus); setMouseTracking(true); diff --git a/pv/view/header.hpp b/pv/view/header.hpp index 662e19f2..ae39bc84 100644 --- a/pv/view/header.hpp +++ b/pv/view/header.hpp @@ -88,10 +88,7 @@ Q_SIGNALS: void signals_moved(); private: - QPoint mouse_point_; - QPoint mouse_down_point_; std::shared_ptr mouse_down_item_; - bool dragging_; }; } // namespace view diff --git a/pv/view/marginwidget.cpp b/pv/view/marginwidget.cpp index f3abe361..e44233c8 100644 --- a/pv/view/marginwidget.cpp +++ b/pv/view/marginwidget.cpp @@ -27,7 +27,8 @@ namespace view { MarginWidget::MarginWidget(View &parent) : QWidget(&parent), - view_(parent) + view_(parent), + dragging_(false) { setAttribute(Qt::WA_NoSystemBackground, true); } diff --git a/pv/view/marginwidget.hpp b/pv/view/marginwidget.hpp index 9ff4276b..b4f0eb72 100644 --- a/pv/view/marginwidget.hpp +++ b/pv/view/marginwidget.hpp @@ -21,6 +21,7 @@ #ifndef PULSEVIEW_PV_MARGINWIDGET_H #define PULSEVIEW_PV_MARGINWIDGET_H +#include #include namespace pv { @@ -43,6 +44,9 @@ Q_SIGNALS: protected: pv::view::View &view_; + QPoint mouse_point_; + QPoint mouse_down_point_; + bool dragging_; }; } // namespace view