if(mouse_over_signal)
mouse_over_signal->select(!mouse_over_signal->selected());
+ if(event->button() & Qt::LeftButton) {
+ _mouse_down_point = event->pos();
+
+ // Save the current signal offsets
+ BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
+ _mouse_down_signal_offsets[s.get()] =
+ s->get_v_offset();
+ }
+
update();
}
+void Header::mouseReleaseEvent(QMouseEvent *event)
+{
+ assert(event);
+ if(event->button() == Qt::LeftButton)
+ _mouse_down_signal_offsets.clear();
+}
+
void Header::mouseMoveEvent(QMouseEvent *event)
{
assert(event);
_mouse_point = event->pos();
+
+ // Move the signals if we are dragging
+ if(!_mouse_down_signal_offsets.empty()) {
+ const vector< shared_ptr<Signal> > &sigs =
+ _view.session().get_signals();
+ const int delta = event->pos().y() - _mouse_down_point.y();
+
+ BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
+ if(s->selected())
+ s->set_v_offset(
+ _mouse_down_signal_offsets[s.get()] +
+ delta);
+
+ signals_moved();
+ }
+
update();
}
#include <boost/shared_ptr.hpp>
+#include <map>
+
#include <QWidget>
namespace pv {
private:
void mousePressEvent(QMouseEvent * event);
+ void mouseReleaseEvent(QMouseEvent *event);
+
void mouseMoveEvent(QMouseEvent *event);
void leaveEvent(QEvent *event);
void on_action_set_colour_triggered();
+signals:
+ void signals_moved();
+
private:
View &_view;
QPoint _mouse_point;
+ QPoint _mouse_down_point;
+
+ std::map<const Signal*, int> _mouse_down_signal_offsets;
boost::shared_ptr<Signal> _context_signal;
QAction *_action_set_name;
connect(&_cursors.second, SIGNAL(time_changed()),
this, SLOT(marker_time_changed()));
+ connect(_header, SIGNAL(signals_moved()),
+ this, SLOT(signals_moved()));
+
setViewportMargins(LabelMarginWidth, RulerHeight, 0, 0);
setViewport(_viewport);
_viewport->update();
}
+void View::signals_moved()
+{
+ _header->update();
+ _viewport->update();
+}
+
} // namespace view
} // namespace pv
void marker_time_changed();
+ void signals_moved();
+
private:
SigSession &_session;