]> sigrok.org Git - pulseview.git/commitdiff
Improved propagation of drag event so that the scroll bars can be updated
authorJoel Holdsworth <redacted>
Sat, 17 Nov 2012 12:48:27 +0000 (12:48 +0000)
committerJoel Holdsworth <redacted>
Sun, 18 Nov 2012 13:18:53 +0000 (13:18 +0000)
pv/view/header.cpp
pv/view/header.h
pv/view/view.cpp
pv/view/view.h
pv/view/viewport.cpp
pv/view/viewport.h

index a141b6164754f79760fc27c291d0054b48245da6..e167bffc5c8e38535e82d94692bf96a8193de8f2 100644 (file)
@@ -54,6 +54,9 @@ Header::Header(View &parent) :
                this, SLOT(on_action_set_name_triggered()));
        connect(_action_set_colour, SIGNAL(triggered()),
                this, SLOT(on_action_set_colour_triggered()));
+
+       connect(&_view, SIGNAL(signals_moved()),
+               this, SLOT(on_signals_moved()));
 }
 
 boost::shared_ptr<pv::view::Signal> Header::get_mouse_over_signal(
@@ -113,14 +116,6 @@ void Header::mousePressEvent(QMouseEvent *event)
        const vector< shared_ptr<Signal> > &sigs =
                _view.session().get_signals();
 
-       if(~QApplication::keyboardModifiers() & Qt::ControlModifier) {
-               // Unselect all other signals because the Ctrl is not
-               // pressed
-               _drag_sigs.clear();
-               BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
-                       s->select(false);
-       }
-
        if(event->button() & Qt::LeftButton) {
                _mouse_down_point = event->pos();
 
@@ -140,13 +135,26 @@ void Header::mousePressEvent(QMouseEvent *event)
                else {
                        mouse_over_signal->select(true);
 
+                       if(~QApplication::keyboardModifiers() &
+                               Qt::ControlModifier)
+                               _drag_sigs.clear();
+
                        // Add the signal to the drag list
-                       _drag_sigs.push_back(
-                               make_pair(mouse_over_signal,
+                       if(event->button() & Qt::LeftButton)
+                               _drag_sigs.push_back(
+                                       make_pair(mouse_over_signal,
                                        mouse_over_signal->get_v_offset()));
                }
        }
 
+       if(~QApplication::keyboardModifiers() & Qt::ControlModifier) {
+               // Unselect all other signals because the Ctrl is not
+               // pressed
+               BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
+                       if(s != mouse_over_signal)
+                               s->select(false);
+       }
+
        update();
 }
 
@@ -238,5 +246,11 @@ void Header::on_action_set_colour_triggered()
                context_signal->set_colour(new_colour);
 }
 
+void Header::on_signals_moved()
+{
+       update();
+}
+
+
 } // namespace view
 } // namespace pv
index 35f16de1b36eb7bab29f69ca1cea801b0f7320bc..8e180b8a086cfb6a4e02179726b5ad665089b806 100644 (file)
@@ -65,6 +65,8 @@ private slots:
 
        void on_action_set_colour_triggered();
 
+       void on_signals_moved();
+
 signals:
        void signals_moved();
 
index 0a31e808f20d9e78603994584677631ff1b94c13..e3210fa39f3b9ac9d7bffc20797dd689bf27ce1d 100644 (file)
@@ -87,7 +87,7 @@ View::View(SigSession &session, QWidget *parent) :
                this, SLOT(marker_time_changed()));
 
        connect(_header, SIGNAL(signals_moved()),
-               this, SLOT(signals_moved()));
+               this, SLOT(on_signals_moved()));
 
        setViewportMargins(LabelMarginWidth, RulerHeight, 0, 0);
        setViewport(_viewport);
@@ -317,10 +317,10 @@ void View::marker_time_changed()
        _viewport->update();
 }
 
-void View::signals_moved()
+void View::on_signals_moved()
 {
-       _header->update();
-       _viewport->update();
+       update_scroll();
+       signals_moved();
 }
 
 } // namespace view
index fb52f530fcb1dccae46ac2bdc773875f7adb7d4e..6d7ac36dfb49265ea9c6fe92e0d1a6fc33133ace 100644 (file)
@@ -107,6 +107,8 @@ public:
 signals:
        void hover_point_changed();
 
+       void signals_moved();
+
 private:
        void get_scroll_layout(double &length, double &offset) const;
        
@@ -130,7 +132,7 @@ private slots:
 
        void marker_time_changed();
 
-       void signals_moved();
+       void on_signals_moved();
 
 private:
        SigSession &_session;
index 7d844d27bccadd71a287f5aeb784f9d5f1ad5f85..96111875570ee7e53bf0e9773285686acb01e8a8 100644 (file)
@@ -41,18 +41,21 @@ Viewport::Viewport(View &parent) :
        setMouseTracking(true);
        setAutoFillBackground(true);
        setBackgroundRole(QPalette::Base);
+
+       connect(&_view, SIGNAL(signals_moved()),
+               this, SLOT(on_signals_moved()));
 }
 
 int Viewport::get_total_height() const
 {
-       int height = 0;
+       int h = 0;
        BOOST_FOREACH(const shared_ptr<Signal> s,
                _view.session().get_signals()) {
                assert(s);
-               height += View::SignalHeight;
+               h = max(s->get_v_offset() + View::SignalHeight, h);
        }
 
-       return height;
+       return h;
 }
 
 void Viewport::paintEvent(QPaintEvent *event)
@@ -142,5 +145,10 @@ void Viewport::draw_cursors_foreground(QPainter &p)
        cursors.second.paint(p, r);
 }
 
+void Viewport::on_signals_moved()
+{
+       update();
+}
+
 } // namespace view
 } // namespace pv
index 49b97e3b0d71de953db0b76e70dc9b68e0b7f55a..7d32c4334ff57c24f03474f9b3fe6455039d0eec 100644 (file)
@@ -56,6 +56,9 @@ private:
 
        void draw_cursors_foreground(QPainter &p);
 
+private slots:
+       void on_signals_moved();
+
 private:
        View &_view;