-bool Viewport::touchEvent(QTouchEvent *event)
-{
- QList<QTouchEvent::TouchPoint> touchPoints = event->touchPoints();
-
- if (touchPoints.count() != 2) {
- _pinch_zoom_active = false;
- return false;
- }
-
- const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
- const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();
-
- if (!_pinch_zoom_active ||
- (event->touchPointStates() & Qt::TouchPointPressed)) {
- _pinch_offset0 = _view.offset() + _view.scale() * touchPoint0.pos().x();
- _pinch_offset1 = _view.offset() + _view.scale() * touchPoint1.pos().x();
- _pinch_zoom_active = true;
- }
-
- double w = touchPoint1.pos().x() - touchPoint0.pos().x();
- if (abs(w) >= 1.0) {
- double scale = (_pinch_offset1 - _pinch_offset0) / w;
- if (scale < 0)
- scale = -scale;
- double offset = _pinch_offset0 - touchPoint0.pos().x() * scale;
- if (scale > 0)
- _view.set_scale_offset(scale, offset);
- }
-
- if (event->touchPointStates() & Qt::TouchPointReleased) {
- _pinch_zoom_active = false;
-
- if (touchPoint0.state() & Qt::TouchPointReleased) {
- // Primary touch released
- _mouse_down_valid = false;
- } else {
- // Update the mouse down fields so that continued
- // dragging with the primary touch will work correctly
- _mouse_down_point = touchPoint0.pos().toPoint();
- _mouse_down_offset = _view.offset();
- _mouse_down_valid = true;
- }
- }
-
- return true;
-}
-
-void Viewport::on_signals_changed()
-{
- const vector< shared_ptr<RowItem> > row_items(_view.child_items());
- for (shared_ptr<RowItem> r : row_items) {
- assert(r);
- connect(r.get(), SIGNAL(visibility_changed()),
- this, SLOT(update()));
- }
-}
-
-void Viewport::on_signals_moved()
-{
- update();
-}
-