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