cannam@45: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ cannam@45: cannam@45: /* cannam@45: Rosegarden cannam@45: A MIDI and audio sequencer and musical notation editor. cannam@45: Copyright 2000-2010 the Rosegarden development team. cannam@45: cannam@45: Other copyrights also apply to some parts of this work. Please cannam@45: see the AUTHORS file and individual file headers for details. cannam@45: cannam@45: This program is free software; you can redistribute it and/or cannam@45: modify it under the terms of the GNU General Public License as cannam@45: published by the Free Software Foundation; either version 2 of the cannam@45: License, or (at your option) any later version. See the file cannam@45: COPYING included with this distribution for more information. cannam@45: */ cannam@45: cannam@45: #include "panned.h" cannam@45: cannam@45: #include Chris@46: #include cannam@45: cannam@45: #include cannam@45: cannam@45: Panned::Panned() cannam@45: { Chris@46: // setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); Chris@46: setRenderHints(QPainter::Antialiasing); cannam@45: } cannam@45: cannam@45: void cannam@45: Panned::resizeEvent(QResizeEvent *ev) cannam@45: { cannam@45: QPointF near = mapToScene(0, 0); cannam@45: QPointF far = mapToScene(width(), height()); cannam@45: QSizeF sz(far.x()-near.x(), far.y()-near.y()); cannam@45: QRectF pr(near, sz); cannam@45: cannam@45: if (pr != m_pannedRect) { cannam@45: m_pannedRect = pr; cannam@45: emit pannedRectChanged(pr); cannam@45: } cannam@45: cannam@45: QGraphicsView::resizeEvent(ev); cannam@45: } cannam@45: cannam@45: void cannam@45: Panned::paintEvent(QPaintEvent *e) cannam@45: { cannam@45: QGraphicsView::paintEvent(e); cannam@45: } cannam@45: cannam@45: void cannam@45: Panned::drawForeground(QPainter *paint, const QRectF &) cannam@45: { cannam@45: QPointF near = mapToScene(0, 0); cannam@45: QPointF far = mapToScene(width(), height()); cannam@45: QSizeF sz(far.x()-near.x(), far.y()-near.y()); cannam@45: QRectF pr(near, sz); cannam@45: cannam@45: if (pr != m_pannedRect) { cannam@45: if (pr.x() != m_pannedRect.x()) emit pannedContentsScrolled(); cannam@45: m_pannedRect = pr; cannam@45: emit pannedRectChanged(pr); cannam@45: } cannam@45: } cannam@45: cannam@45: void cannam@45: Panned::slotSetPannedRect(QRectF pr) cannam@45: { cannam@45: centerOn(pr.center()); cannam@45: // setSceneRect(pr); cannam@45: // m_pannedRect = pr; cannam@45: } cannam@45: cannam@45: void cannam@45: Panned::wheelEvent(QWheelEvent *ev) cannam@45: { cannam@45: emit wheelEventReceived(ev); cannam@45: QGraphicsView::wheelEvent(ev); cannam@45: } cannam@45: cannam@45: void cannam@45: Panned::slotEmulateWheelEvent(QWheelEvent *ev) cannam@45: { cannam@45: QGraphicsView::wheelEvent(ev); cannam@45: } cannam@45: cannam@45: void cannam@45: Panned::leaveEvent(QEvent *) cannam@45: { cannam@45: emit mouseLeaves(); cannam@45: }