QTfrontend/ui/widget/drawmapwidget.h
changeset 7006 6af78154dc62
parent 6952 7f70f37bbf08
child 9080 9b42757d7e71
equal deleted inserted replaced
6852:9e724f4863a3 7006:6af78154dc62
     1 /*
     1 /*
     2  * Hedgewars, a free turn based strategy game
     2  * Hedgewars, a free turn based strategy game
     3  * Copyright (c) 2012 Andrey Korotaev <unC0Rr@gmail.com>
     3  * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
     4  *
     4  *
     5  * This program is free software; you can redistribute it and/or modify
     5  * This program is free software; you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation; version 2 of the License
     7  * the Free Software Foundation; version 2 of the License
     8  *
     8  *
    21 
    21 
    22 #include <QWidget>
    22 #include <QWidget>
    23 #include <QHBoxLayout>
    23 #include <QHBoxLayout>
    24 #include <QPushButton>
    24 #include <QPushButton>
    25 #include <QGraphicsView>
    25 #include <QGraphicsView>
       
    26 #include <QLabel>
    26 
    27 
    27 #include "qaspectratiolayout.h"
    28 #include "qaspectratiolayout.h"
    28 #include "drawmapscene.h"
    29 #include "drawmapscene.h"
       
    30 
       
    31 
       
    32 class DrawMapView : public QGraphicsView
       
    33 {
       
    34     Q_OBJECT
       
    35 
       
    36 public:
       
    37     explicit DrawMapView(QWidget *parent = 0);
       
    38     ~DrawMapView();
       
    39 
       
    40     void setScene(DrawMapScene *scene);
       
    41 
       
    42 protected:
       
    43     void enterEvent(QEvent * event);
       
    44     void leaveEvent(QEvent * event);
       
    45     bool viewportEvent(QEvent * event);
       
    46 
       
    47 private:
       
    48     DrawMapScene * m_scene;
       
    49 };
    29 
    50 
    30 namespace Ui
    51 namespace Ui
    31 {
    52 {
    32     class Ui_DrawMapWidget
    53     class Ui_DrawMapWidget
    33     {
    54     {
    34         public:
    55         public:
    35             QGraphicsView *graphicsView;
    56             DrawMapView *graphicsView;
       
    57             QLabel * lblPoints;
    36 
    58 
    37             void setupUi(QWidget *drawMapWidget)
    59             void setupUi(QWidget *drawMapWidget)
    38             {
    60             {
    39                 QAspectRatioLayout * arLayout = new QAspectRatioLayout(drawMapWidget);
    61                 QVBoxLayout * vbox = new QVBoxLayout(drawMapWidget);
       
    62                 vbox->setMargin(0);
       
    63                 lblPoints = new QLabel("0", drawMapWidget);
       
    64                 vbox->addWidget(lblPoints);
       
    65                 QAspectRatioLayout * arLayout = new QAspectRatioLayout();
    40                 arLayout->setMargin(0);
    66                 arLayout->setMargin(0);
       
    67                 vbox->addLayout(arLayout);
    41 
    68 
    42                 graphicsView = new QGraphicsView(drawMapWidget);
    69                 graphicsView = new DrawMapView(drawMapWidget);
    43                 arLayout->addWidget(graphicsView);
    70                 arLayout->addWidget(graphicsView);
    44 
    71 
    45                 retranslateUi(drawMapWidget);
    72                 retranslateUi(drawMapWidget);
    46 
    73 
    47                 QMetaObject::connectSlotsByName(drawMapWidget);
    74                 QMetaObject::connectSlotsByName(drawMapWidget);
    68         void setScene(DrawMapScene * scene);
    95         void setScene(DrawMapScene * scene);
    69 
    96 
    70     public slots:
    97     public slots:
    71         void undo();
    98         void undo();
    72         void clear();
    99         void clear();
       
   100         void setErasing(bool erasing);
    73         void save(const QString & fileName);
   101         void save(const QString & fileName);
    74         void load(const QString & fileName);
   102         void load(const QString & fileName);
    75 
   103 
    76     protected:
   104     protected:
    77         void changeEvent(QEvent *e);
   105         void changeEvent(QEvent *e);
    80 
   108 
    81     private:
   109     private:
    82         Ui::DrawMapWidget *ui;
   110         Ui::DrawMapWidget *ui;
    83 
   111 
    84         DrawMapScene * m_scene;
   112         DrawMapScene * m_scene;
       
   113 
       
   114     private slots:
       
   115         void pathChanged();
    85 };
   116 };
    86 
   117 
    87 #endif // DRAWMAPWIDGET_H
   118 #endif // DRAWMAPWIDGET_H