tools/drawMapTest/mainwindow.cpp
author unc0rr
Sun, 28 Nov 2010 17:23:51 +0300
changeset 4426 969e411c72aa
parent 4425 2314bb0c433d
child 4427 c5193713055f
permissions -rw-r--r--
Improve map editor a bit
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4425
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     1
#include "mainwindow.h"
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     2
#include "ui_mainwindow.h"
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     3
#include "drawmapscene.h"
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     4
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     5
MainWindow::MainWindow(QWidget *parent) :
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     6
    QMainWindow(parent),
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     7
    ui(new Ui::MainWindow)
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     8
{
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     9
    ui->setupUi(this);
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    10
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    11
    DrawMapScene * scene = new DrawMapScene(this);
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    12
    ui->graphicsView->setScene(scene);
4426
969e411c72aa Improve map editor a bit
unc0rr
parents: 4425
diff changeset
    13
969e411c72aa Improve map editor a bit
unc0rr
parents: 4425
diff changeset
    14
    connect(ui->pbUndo, SIGNAL(clicked()), scene, SLOT(undo()));
4425
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    15
}
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    16
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    17
MainWindow::~MainWindow()
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    18
{
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    19
    delete ui;
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    20
}
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    21
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    22
void MainWindow::changeEvent(QEvent *e)
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    23
{
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    24
    QMainWindow::changeEvent(e);
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    25
    switch (e->type()) {
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    26
    case QEvent::LanguageChange:
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    27
        ui->retranslateUi(this);
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    28
        break;
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    29
    default:
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    30
        break;
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    31
    }
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    32
}
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    33
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    34
void MainWindow::resizeEvent(QResizeEvent * event)
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    35
{
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    36
    Q_UNUSED(event);
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    37
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    38
    if(ui->graphicsView)
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    39
        ui->graphicsView->fitInView(ui->graphicsView->scene()->sceneRect(), Qt::KeepAspectRatio);
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    40
}