annotate panned.cpp @ 45:4286836bb3c9

* Some more work on graph layout; ensure LANG is set for parseable UTF8 output when running Hg
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 10 Nov 2010 12:44:11 +0000
parents
children bd3accba9b3f
rev   line source
cannam@45 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@45 2
cannam@45 3 /*
cannam@45 4 Rosegarden
cannam@45 5 A MIDI and audio sequencer and musical notation editor.
cannam@45 6 Copyright 2000-2010 the Rosegarden development team.
cannam@45 7
cannam@45 8 Other copyrights also apply to some parts of this work. Please
cannam@45 9 see the AUTHORS file and individual file headers for details.
cannam@45 10
cannam@45 11 This program is free software; you can redistribute it and/or
cannam@45 12 modify it under the terms of the GNU General Public License as
cannam@45 13 published by the Free Software Foundation; either version 2 of the
cannam@45 14 License, or (at your option) any later version. See the file
cannam@45 15 COPYING included with this distribution for more information.
cannam@45 16 */
cannam@45 17
cannam@45 18 #include "panned.h"
cannam@45 19
cannam@45 20 #include <QScrollBar>
cannam@45 21
cannam@45 22 #include <iostream>
cannam@45 23
cannam@45 24 Panned::Panned()
cannam@45 25 {
cannam@45 26 }
cannam@45 27
cannam@45 28 void
cannam@45 29 Panned::resizeEvent(QResizeEvent *ev)
cannam@45 30 {
cannam@45 31 QPointF near = mapToScene(0, 0);
cannam@45 32 QPointF far = mapToScene(width(), height());
cannam@45 33 QSizeF sz(far.x()-near.x(), far.y()-near.y());
cannam@45 34 QRectF pr(near, sz);
cannam@45 35
cannam@45 36 if (pr != m_pannedRect) {
cannam@45 37 m_pannedRect = pr;
cannam@45 38 emit pannedRectChanged(pr);
cannam@45 39 }
cannam@45 40
cannam@45 41 QGraphicsView::resizeEvent(ev);
cannam@45 42 }
cannam@45 43
cannam@45 44 void
cannam@45 45 Panned::paintEvent(QPaintEvent *e)
cannam@45 46 {
cannam@45 47 QGraphicsView::paintEvent(e);
cannam@45 48 }
cannam@45 49
cannam@45 50 void
cannam@45 51 Panned::drawForeground(QPainter *paint, const QRectF &)
cannam@45 52 {
cannam@45 53 QPointF near = mapToScene(0, 0);
cannam@45 54 QPointF far = mapToScene(width(), height());
cannam@45 55 QSizeF sz(far.x()-near.x(), far.y()-near.y());
cannam@45 56 QRectF pr(near, sz);
cannam@45 57
cannam@45 58 if (pr != m_pannedRect) {
cannam@45 59 if (pr.x() != m_pannedRect.x()) emit pannedContentsScrolled();
cannam@45 60 m_pannedRect = pr;
cannam@45 61 emit pannedRectChanged(pr);
cannam@45 62 }
cannam@45 63 }
cannam@45 64
cannam@45 65 void
cannam@45 66 Panned::slotSetPannedRect(QRectF pr)
cannam@45 67 {
cannam@45 68 centerOn(pr.center());
cannam@45 69 // setSceneRect(pr);
cannam@45 70 // m_pannedRect = pr;
cannam@45 71 }
cannam@45 72
cannam@45 73 void
cannam@45 74 Panned::wheelEvent(QWheelEvent *ev)
cannam@45 75 {
cannam@45 76 emit wheelEventReceived(ev);
cannam@45 77 QGraphicsView::wheelEvent(ev);
cannam@45 78 }
cannam@45 79
cannam@45 80 void
cannam@45 81 Panned::slotEmulateWheelEvent(QWheelEvent *ev)
cannam@45 82 {
cannam@45 83 QGraphicsView::wheelEvent(ev);
cannam@45 84 }
cannam@45 85
cannam@45 86 void
cannam@45 87 Panned::leaveEvent(QEvent *)
cannam@45 88 {
cannam@45 89 emit mouseLeaves();
cannam@45 90 }