QTfrontend/ui/widget/drawmapwidget.cpp
author unc0rr
Fri, 27 Apr 2012 00:43:48 +0400
changeset 6934 14a230552c2e
parent 6873 30840365af0a
child 6935 472ed92c4173
permissions -rw-r--r--
Cursor for DrawMapScene. Feel free to ajust its look.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
     1
/*
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
     2
 * Hedgewars, a free turn based strategy game
6700
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
     3
 * Copyright (c) 2012 Andrey Korotaev <unC0Rr@gmail.com>
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
     4
 *
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
     8
 *
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
    12
 * GNU General Public License for more details.
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
    13
 *
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
    14
 * You should have received a copy of the GNU General Public License
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
    15
 * along with this program; if not, write to the Free Software
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
    17
 */
088d40d8aba2 Happy 2011 :)
koda
parents: 4586
diff changeset
    18
4560
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    19
#include <QFile>
4586
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
    20
#include <QMessageBox>
5252
ded882439548 file association for mac!
koda
parents: 4976
diff changeset
    21
#include <QEvent>
6934
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
    22
#include <QDebug>
4560
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    23
4477
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    24
#include "drawmapwidget.h"
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    25
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    26
DrawMapWidget::DrawMapWidget(QWidget *parent) :
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    27
    QWidget(parent),
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    28
    ui(new Ui::DrawMapWidget)
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    29
{
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    30
    ui->setupUi(this);
4560
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    31
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    32
    m_scene = 0;
4477
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    33
}
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    34
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    35
DrawMapWidget::~DrawMapWidget()
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    36
{
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    37
    delete ui;
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    38
}
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    39
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    40
void DrawMapWidget::changeEvent(QEvent *e)
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    41
{
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    42
    QWidget::changeEvent(e);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    43
    switch (e->type())
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    44
    {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    45
        case QEvent::LanguageChange:
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    46
            ui->retranslateUi(this);
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    47
            break;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    48
        default:
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6060
diff changeset
    49
            break;
4477
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    50
    }
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    51
}
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    52
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    53
void DrawMapWidget::setScene(DrawMapScene * scene)
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    54
{
6934
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
    55
    m_scene = scene;
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
    56
4477
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    57
    ui->graphicsView->setScene(scene);
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    58
}
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    59
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    60
void DrawMapWidget::resizeEvent(QResizeEvent * event)
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    61
{
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    62
    Q_UNUSED(event);
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    63
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    64
    if(ui->graphicsView && ui->graphicsView->scene())
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    65
        ui->graphicsView->fitInView(ui->graphicsView->scene()->sceneRect(), Qt::KeepAspectRatio);
63a21fac8bf7 Add QAspectRatioLayout borrowed from http://wiki.forum.nokia.com/index.php/CS001309_-_Maintaining_square_form_for_a_widget_in_Qt to maintain width == height * 2 aspect ratio for map drawing widget
unc0rr
parents:
diff changeset
    66
}
4556
c7f4eb6cbd0c Make use of showEvent, so there's no more need in manual resizing of draw map widget
unc0rr
parents: 4520
diff changeset
    67
c7f4eb6cbd0c Make use of showEvent, so there's no more need in manual resizing of draw map widget
unc0rr
parents: 4520
diff changeset
    68
void DrawMapWidget::showEvent(QShowEvent * event)
c7f4eb6cbd0c Make use of showEvent, so there's no more need in manual resizing of draw map widget
unc0rr
parents: 4520
diff changeset
    69
{
c7f4eb6cbd0c Make use of showEvent, so there's no more need in manual resizing of draw map widget
unc0rr
parents: 4520
diff changeset
    70
    Q_UNUSED(event);
c7f4eb6cbd0c Make use of showEvent, so there's no more need in manual resizing of draw map widget
unc0rr
parents: 4520
diff changeset
    71
c7f4eb6cbd0c Make use of showEvent, so there's no more need in manual resizing of draw map widget
unc0rr
parents: 4520
diff changeset
    72
    resizeEvent(0);
c7f4eb6cbd0c Make use of showEvent, so there's no more need in manual resizing of draw map widget
unc0rr
parents: 4520
diff changeset
    73
}
4560
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    74
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    75
void DrawMapWidget::undo()
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    76
{
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    77
    if(m_scene) m_scene->undo();
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    78
}
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    79
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    80
void DrawMapWidget::clear()
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    81
{
4586
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
    82
    if(m_scene) m_scene->clearMap();
4560
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    83
}
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    84
6873
30840365af0a Eraser tool
unc0rr
parents: 6700
diff changeset
    85
void DrawMapWidget::setErasing(bool erasing)
30840365af0a Eraser tool
unc0rr
parents: 6700
diff changeset
    86
{
30840365af0a Eraser tool
unc0rr
parents: 6700
diff changeset
    87
    if(m_scene) m_scene->setErasing(erasing);
30840365af0a Eraser tool
unc0rr
parents: 6700
diff changeset
    88
}
30840365af0a Eraser tool
unc0rr
parents: 6700
diff changeset
    89
4560
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    90
void DrawMapWidget::save(const QString & fileName)
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
    91
{
4586
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
    92
    if(m_scene)
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
    93
    {
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
    94
        QFile file(fileName);
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
    95
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
    96
        if(!file.open(QIODevice::WriteOnly))
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
    97
            QMessageBox::warning(this, tr("File error"), tr("Cannot open file '%1' for writing").arg(fileName));
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
    98
        else
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
    99
            file.write(qCompress(m_scene->encode()).toBase64());
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
   100
    }
4560
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
   101
}
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
   102
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
   103
void DrawMapWidget::load(const QString & fileName)
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
   104
{
4586
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
   105
    if(m_scene)
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
   106
    {
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
   107
        QFile f(fileName);
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
   108
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
   109
        if(!f.open(QIODevice::ReadOnly))
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
   110
            QMessageBox::warning(this, tr("File error"), tr("Cannot read file '%1'").arg(fileName));
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
   111
        else
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
   112
            m_scene->decode(qUncompress(QByteArray::fromBase64(f.readAll())));
4ba4f021070f - Allow user to use undo, to clear, save and load drawn maps
unc0rr
parents: 4560
diff changeset
   113
    }
4560
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4556
diff changeset
   114
}
6934
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   115
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   116
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   117
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   118
DrawMapView::DrawMapView(QWidget *parent) :
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   119
    QGraphicsView(parent)
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   120
{
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   121
   setMouseTracking(true);
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   122
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   123
    m_scene = 0;
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   124
}
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   125
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   126
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   127
DrawMapView::~DrawMapView()
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   128
{
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   129
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   130
}
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   131
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   132
void DrawMapView::setScene(DrawMapScene *scene)
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   133
{
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   134
    m_scene = scene;
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   135
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   136
    QGraphicsView::setScene(scene);
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   137
}
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   138
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   139
// Why don't I ever recieve this event?
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   140
void DrawMapView::enterEvent(QEvent *event)
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   141
{
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   142
    if(m_scene)
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   143
        m_scene->showCursor();
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   144
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   145
    QGraphicsView::enterEvent(event);
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   146
}
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   147
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   148
void DrawMapView::leaveEvent(QEvent *event)
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   149
{
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   150
    if(m_scene)
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   151
        m_scene->hideCursor();
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   152
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   153
    QGraphicsView::leaveEvent(event);
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   154
}
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   155
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   156
bool DrawMapView::viewportEvent(QEvent *event)
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   157
{
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   158
    return QGraphicsView::viewportEvent(event);
14a230552c2e Cursor for DrawMapScene. Feel free to ajust its look.
unc0rr
parents: 6873
diff changeset
   159
}