tools/drawMapTest/mainwindow.cpp
author unc0rr
Sat, 27 Nov 2010 23:57:31 +0300
changeset 4425 2314bb0c433d
child 4426 969e411c72aa
permissions -rw-r--r--
Small testing app for DrawMap scene
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);
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    13
}
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    14
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    15
MainWindow::~MainWindow()
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    16
{
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    17
    delete ui;
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    18
}
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    19
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    20
void MainWindow::changeEvent(QEvent *e)
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    21
{
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    22
    QMainWindow::changeEvent(e);
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    23
    switch (e->type()) {
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    24
    case QEvent::LanguageChange:
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    25
        ui->retranslateUi(this);
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    26
        break;
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    27
    default:
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
    }
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    30
}
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    31
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    32
void MainWindow::resizeEvent(QResizeEvent * event)
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    33
{
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    34
    Q_UNUSED(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
    if(ui->graphicsView)
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    37
        ui->graphicsView->fitInView(ui->graphicsView->scene()->sceneRect(), Qt::KeepAspectRatio);
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    38
}