File indexing completed on 2024-10-06 03:46:38

0001 /*
0002     SPDX-FileCopyrightText: 2003 Russell Steffen <rsteffen@bayarea.net>
0003     SPDX-FileCopyrightText: 2003 Stephan Zehetner <s.zehetner@nevox.org>
0004     SPDX-FileCopyrightText: 2006 Dmitry Suzdalev <dimsuz@gmail.com>
0005     SPDX-FileCopyrightText: 2006 Inge Wallin <inge@lysator.liu.se>
0006     SPDX-FileCopyrightText: 2006 Pierre Ducroquet <pinaraf@gmail.com>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #include "mapview.h"
0012 #include "mapscene.h"
0013 #include <QGraphicsScene>
0014 #include <QResizeEvent>
0015 
0016 MapView::MapView( MapScene* scene, QWidget *parent )
0017     : QGraphicsView(scene, parent), m_scene(scene)
0018 {
0019     setCacheMode( QGraphicsView::CacheBackground );
0020     setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
0021     setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
0022     setMouseTracking(true);
0023 
0024     setMinimumSize( sizeHint() );
0025     resize( sizeHint() );
0026 }
0027 
0028 void MapView::resizeEvent( QResizeEvent* ev )
0029 {
0030     m_scene->resizeScene(QRectF(0, 0, ev->size().width(), ev->size().height()));
0031     QGraphicsView::resizeEvent(ev);
0032 }
0033 
0034 QSize MapView::sizeHint() const
0035 {
0036     return QSize( (int)m_scene->width(), (int)m_scene->height() );
0037 }