32 #include <QMouseEvent> 39 using std::back_inserter;
41 using std::dynamic_pointer_cast;
43 using std::shared_ptr;
44 using std::stable_sort;
53 pinch_zoom_active_(false)
55 setAutoFillBackground(
true);
56 setBackgroundRole(QPalette::Base);
73 const vector< shared_ptr<ViewItem> >
items(this->
items());
74 for (
auto i = items.rbegin(); i != items.rend(); i++)
75 if ((*i)->enabled() && (*i)->hit_box_rect(pp).contains(pt))
82 if (item && item->is_draggable(pos))
83 setCursor(dynamic_pointer_cast<ViewItem>(item) ?
84 Qt::SizeHorCursor : Qt::SizeVerCursor);
116 vector< shared_ptr<ViewItem> >
items;
117 const vector< shared_ptr<ViewItem> > view_items(
119 copy(view_items.begin(), view_items.end(), back_inserter(items));
121 copy(time_items.begin(), time_items.end(), back_inserter(items));
127 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 128 QList<QEventPoint> touchPoints =
event->points();
130 QList<QTouchEvent::TouchPoint> touchPoints =
event->touchPoints();
133 if (touchPoints.count() != 2) {
137 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 138 if (event->device()->type() == QInputDevice::DeviceType::TouchPad) {
142 const QEventPoint &touchPoint0 = touchPoints.first();
143 const QEventPoint &touchPoint1 = touchPoints.last();
146 (event->touchPointStates() & QEventPoint::Pressed)) {
152 double w = touchPoint1.position().x() - touchPoint0.position().x();
156 double offset =
pinch_offset0_ - touchPoint0.position().x() * scale;
161 if (event->device()->type() == QTouchDevice::TouchPad) {
165 const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
166 const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();
169 (event->touchPointStates() & Qt::TouchPointPressed)) {
175 double w = touchPoint1.pos().x() - touchPoint0.pos().x();
185 if (event->touchPointStates() & Qt::TouchPointReleased) {
188 if (touchPoint0.state() & Qt::TouchPointReleased) {
194 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 208 typedef void (
ViewItem::*LayerPaintFunc)(
210 LayerPaintFunc layer_paint_funcs[] = {
215 assert(none_of(row_items.begin(), row_items.end(),
216 [](
const shared_ptr<ViewItem> &r) {
return !r; }));
218 stable_sort(row_items.begin(), row_items.end(),
219 [](
const shared_ptr<ViewItem> &a,
const shared_ptr<ViewItem> &b) {
220 return a->drag_point(QRect()).y() < b->drag_point(QRect()).y(); });
223 assert(none_of(time_items.begin(), time_items.end(),
224 [](
const shared_ptr<TimeItem> &
t) {
return !
t; }));
229 bool use_antialiasing =
230 window()->windowHandle()->screen()->devicePixelRatio() < 2.0;
231 p.setRenderHint(QPainter::Antialiasing, use_antialiasing);
233 for (LayerPaintFunc *paint_func = layer_paint_funcs;
234 *paint_func; paint_func++) {
236 for (
const shared_ptr<TimeItem>&
t : time_items)
237 (
t.get()->*(*paint_func))(p, time_pp);
240 for (
const shared_ptr<ViewItem>& r : row_items)
241 (r.get()->*(*paint_func))(p, row_pp);
251 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 252 if (event->buttons() & Qt::LeftButton)
254 else if (event->buttons() & Qt::RightButton)
257 if (event->buttons() & Qt::LeftButton)
259 else if (event->buttons() & Qt::RightButton)
268 #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) 269 int delta = (
event->angleDelta().x() != 0) ? event->angleDelta().x() :
event->angleDelta().y();
271 int delta =
event->delta();
274 #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) 275 if (event->angleDelta().y() != 0) {
277 if (event->orientation() == Qt::Vertical) {
279 if (event->modifiers() & Qt::ControlModifier) {
283 (delta * height()) / (8 * 120));
284 }
else if (event->modifiers() & Qt::ShiftModifier) {
292 #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) 293 view_.
zoom(delta / 120.0, event->position().x());
298 #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) 299 }
else if (event->angleDelta().x() != 0) {
301 }
else if (event->orientation() == Qt::Horizontal) {
void item_hover(const shared_ptr< ViewItem > &item, QPoint pos)
bool allow_vertical_dragging_
void mouseDoubleClickEvent(QMouseEvent *event)
vector< shared_ptr< T > > list_by_type()
void drag_by(const QPoint &delta)
x y t t *t x y t t t x y t t t x *y t *t t x *y t *t t x y t t t x y t t t t(t+t)") define_sfop3(16
void set_v_offset(int offset)
const pv::util::Timestamp & offset() const
T value(details::expression_node< T > *n)
shared_ptr< ViewItem > get_mouse_over_item(const QPoint &pt)
void paintEvent(QPaintEvent *event)
vector< shared_ptr< TimeItem > > time_items() const
static void remove_change_handler(GlobalSettingsInterface *cb)
void set_scale_offset(double scale, const pv::util::Timestamp &offset)
boost::optional< pv::util::Timestamp > drag_offset_
void wheelEvent(QWheelEvent *event)
static const QString Key_View_AllowVerticalDragging
void on_setting_changed(const QString &key, const QVariant &value)
vector< shared_ptr< ViewItem > > items()
int owner_visual_v_offset() const
virtual void paint_back(QPainter &p, ViewItemPaintParams &pp)
virtual void paint_mid(QPainter &p, ViewItemPaintParams &pp)
virtual void paint_fore(QPainter &p, ViewItemPaintParams &pp)
static void add_change_handler(GlobalSettingsInterface *cb)
bool touch_event(QTouchEvent *event)