QTfrontend/ui/widget/drawmapwidget.cpp
changeset 6934 14a230552c2e
parent 6873 30840365af0a
child 6935 472ed92c4173
equal deleted inserted replaced
6933:78d194a30520 6934:14a230552c2e
    17  */
    17  */
    18 
    18 
    19 #include <QFile>
    19 #include <QFile>
    20 #include <QMessageBox>
    20 #include <QMessageBox>
    21 #include <QEvent>
    21 #include <QEvent>
       
    22 #include <QDebug>
    22 
    23 
    23 #include "drawmapwidget.h"
    24 #include "drawmapwidget.h"
    24 
    25 
    25 DrawMapWidget::DrawMapWidget(QWidget *parent) :
    26 DrawMapWidget::DrawMapWidget(QWidget *parent) :
    26     QWidget(parent),
    27     QWidget(parent),
    49     }
    50     }
    50 }
    51 }
    51 
    52 
    52 void DrawMapWidget::setScene(DrawMapScene * scene)
    53 void DrawMapWidget::setScene(DrawMapScene * scene)
    53 {
    54 {
       
    55     m_scene = scene;
       
    56 
    54     ui->graphicsView->setScene(scene);
    57     ui->graphicsView->setScene(scene);
    55     m_scene = scene;
       
    56 }
    58 }
    57 
    59 
    58 void DrawMapWidget::resizeEvent(QResizeEvent * event)
    60 void DrawMapWidget::resizeEvent(QResizeEvent * event)
    59 {
    61 {
    60     Q_UNUSED(event);
    62     Q_UNUSED(event);
   108             QMessageBox::warning(this, tr("File error"), tr("Cannot read file '%1'").arg(fileName));
   110             QMessageBox::warning(this, tr("File error"), tr("Cannot read file '%1'").arg(fileName));
   109         else
   111         else
   110             m_scene->decode(qUncompress(QByteArray::fromBase64(f.readAll())));
   112             m_scene->decode(qUncompress(QByteArray::fromBase64(f.readAll())));
   111     }
   113     }
   112 }
   114 }
       
   115 
       
   116 
       
   117 
       
   118 DrawMapView::DrawMapView(QWidget *parent) :
       
   119     QGraphicsView(parent)
       
   120 {
       
   121    setMouseTracking(true);
       
   122 
       
   123     m_scene = 0;
       
   124 }
       
   125 
       
   126 
       
   127 DrawMapView::~DrawMapView()
       
   128 {
       
   129 
       
   130 }
       
   131 
       
   132 void DrawMapView::setScene(DrawMapScene *scene)
       
   133 {
       
   134     m_scene = scene;
       
   135 
       
   136     QGraphicsView::setScene(scene);
       
   137 }
       
   138 
       
   139 // Why don't I ever recieve this event?
       
   140 void DrawMapView::enterEvent(QEvent *event)
       
   141 {
       
   142     if(m_scene)
       
   143         m_scene->showCursor();
       
   144 
       
   145     QGraphicsView::enterEvent(event);
       
   146 }
       
   147 
       
   148 void DrawMapView::leaveEvent(QEvent *event)
       
   149 {
       
   150     if(m_scene)
       
   151         m_scene->hideCursor();
       
   152 
       
   153     QGraphicsView::leaveEvent(event);
       
   154 }
       
   155 
       
   156 bool DrawMapView::viewportEvent(QEvent *event)
       
   157 {
       
   158     return QGraphicsView::viewportEvent(event);
       
   159 }