]> sigrok.org Git - pulseview.git/commitdiff
MarginWidget: Moved in create_popup
authorJoel Holdsworth <redacted>
Sat, 20 Dec 2014 22:56:35 +0000 (22:56 +0000)
committerJoel Holdsworth <redacted>
Mon, 29 Dec 2014 11:56:00 +0000 (11:56 +0000)
pv/view/flag.cpp
pv/view/header.cpp
pv/view/header.hpp
pv/view/marginwidget.cpp
pv/view/marginwidget.hpp
pv/view/ruler.cpp
pv/view/timemarker.cpp
pv/view/trace.cpp

index 81cfae873eb82365f355b109c15cc54b0d390e4a..01d13670a70b87fbbb2042dcbb70c9278724e749 100644 (file)
@@ -61,7 +61,12 @@ QString Flag::get_text() const
 
 pv::widgets::Popup* Flag::create_popup(QWidget *parent)
 {
-       pv::widgets::Popup *const popup = TimeMarker::create_popup(parent);
+       using pv::widgets::Popup;
+
+       Popup *const popup = TimeMarker::create_popup(parent);
+       popup->set_position(parent->mapToGlobal(
+               point(parent->rect())), Popup::Bottom);
+
        QFormLayout *const form = (QFormLayout*)popup->layout();
 
        QLineEdit *const text_edit = new QLineEdit(popup);
index 77ac1aa88c343498bfcaf57939b4f0995862b54a..41dffca1f92323c9ece2090893aea04e90afd30f 100644 (file)
@@ -96,19 +96,6 @@ void Header::clear_selection()
        update();
 }
 
-void Header::show_popup(const shared_ptr<RowItem> &item)
-{
-       using pv::widgets::Popup;
-
-       Popup *const p = item->create_popup(&view_);
-       if (!p)
-               return;
-
-       const QPoint pt(width() - BaselineOffset, item->get_visual_y());
-       p->set_position(mapToGlobal(pt), Popup::Right);
-       p->show();
-}
-
 void Header::paintEvent(QPaintEvent*)
 {
        // The trace labels are not drawn with the arrows exactly on the
index 10335cf5b6faf0cafbfe96f09fcd5ef8bddf4425..48e06a7badab1ef16acc7c83a836bb44f088b670 100644 (file)
@@ -64,8 +64,6 @@ private:
 
        void clear_selection();
 
-       void show_popup(const std::shared_ptr<RowItem> &item);
-
 private:
        void paintEvent(QPaintEvent *event);
 
index f8302f646f73867589e68027580fb8435e378895..6b646832690974b21d77720e858141afc9b3677f 100644 (file)
 
 #include "marginwidget.hpp"
 
+#include <pv/widgets/popup.hpp>
+
+using std::shared_ptr;
+
 namespace pv {
 namespace view {
 
@@ -35,6 +39,13 @@ MarginWidget::MarginWidget(View &parent) :
        setMouseTracking(true);
 }
 
+void MarginWidget::show_popup(const shared_ptr<ViewItem> &item)
+{
+       pv::widgets::Popup *const p = item->create_popup(this);
+       if (p)
+               p->show();
+}
+
 void MarginWidget::clear_selection()
 {
 }
index 6e98e4b083a3e2562835a1a111abb11284238e5b..5b6631af724f3177e5c643bda1f0674e0ad5ccad 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef PULSEVIEW_PV_MARGINWIDGET_H
 #define PULSEVIEW_PV_MARGINWIDGET_H
 
+#include <memory>
+
 #include <QPoint>
 #include <QWidget>
 
@@ -28,6 +30,7 @@ namespace pv {
 namespace view {
 
 class View;
+class ViewItem;
 
 class MarginWidget : public QWidget
 {
@@ -43,6 +46,13 @@ public:
         */
        virtual QSize extended_size_hint() const = 0;
 
+protected:
+       /**
+        * Shows the popup of a the specified @c ViewItem .
+        * @param item The item to show the popup for.
+        */
+       void show_popup(const std::shared_ptr<ViewItem> &item);
+
 public Q_SLOTS:
        virtual void clear_selection();
 
index 47da23a8b78e21a9e5f7725ca533f64d472897ad..7fa9987504ca5ef370b7a8bb5bafcc6758dc5eb5 100644 (file)
@@ -29,7 +29,6 @@
 #include "view.hpp"
 
 #include <pv/util.hpp>
-#include <pv/widgets/popup.hpp>
 
 using namespace Qt;
 
@@ -199,15 +198,8 @@ void Ruler::mouseReleaseEvent(QMouseEvent *)
 {
        using pv::widgets::Popup;
 
-       if (!dragging_ && mouse_down_item_) {
-               Popup *const p = mouse_down_item_->create_popup(&view_);
-               if (p) {
-                       const QPoint arrpos(mouse_down_item_->get_x(),
-                               height() - ViewItem::HighlightRadius);
-                       p->set_position(mapToGlobal(arrpos), Popup::Bottom);
-                       p->show();
-               }
-       }
+       if (!dragging_ && mouse_down_item_)
+               show_popup(mouse_down_item_);
 
        dragging_ = false;
        mouse_down_item_.reset();
index 5b21bfd84b7012025abe59cdca5f5877491be552..894f023bf11c4d547db8649398905a8e57c8abe8 100644 (file)
@@ -76,7 +76,7 @@ float TimeMarker::get_x() const
 
 QPoint TimeMarker::point(const QRect &rect) const
 {
-       return QPoint(get_x(), rect.right());
+       return QPoint(get_x(), rect.bottom());
 }
 
 QRectF TimeMarker::label_rect(const QRectF &rect) const
@@ -159,6 +159,9 @@ pv::widgets::Popup* TimeMarker::create_popup(QWidget *parent)
        using pv::widgets::Popup;
 
        Popup *const popup = new Popup(parent);
+       popup->set_position(parent->mapToGlobal(
+               point(parent->rect())), Popup::Bottom);
+
        QFormLayout *const form = new QFormLayout(popup);
        popup->setLayout(form);
 
index df5a954b43a216f66d7cb11c5799464d882a3fe4..bf1c4ae511f4f507726e97ab2f726b7b95fb6dc0 100644 (file)
@@ -134,6 +134,8 @@ pv::widgets::Popup* Trace::create_popup(QWidget *parent)
        using pv::widgets::Popup;
 
        popup_ = new Popup(parent);
+       popup_->set_position(parent->mapToGlobal(
+               point(parent->rect())), Popup::Right);
 
        create_popup_form();