QTfrontend/ui/widget/drawmapwidget.cpp
changeset 9128 19596777eb7a
parent 9080 9b42757d7e71
child 9472 265e5997580e
equal deleted inserted replaced
9125:c542f6e3a133 9128:19596777eb7a
    60 
    60 
    61 void DrawMapWidget::resizeEvent(QResizeEvent * event)
    61 void DrawMapWidget::resizeEvent(QResizeEvent * event)
    62 {
    62 {
    63     Q_UNUSED(event);
    63     Q_UNUSED(event);
    64 
    64 
       
    65     int height = this->height();
       
    66     int width = this->width();
       
    67 
       
    68     if ((m_scene->height() > 0) && (m_scene->width() > 0) && (height > 0))
       
    69     {
       
    70         qreal saspect = m_scene->width() / m_scene->height();
       
    71 
       
    72         qreal h = height;
       
    73         qreal w = width;
       
    74         qreal waspect = w / h;
       
    75 
       
    76         if (waspect < saspect)
       
    77         {
       
    78             h = w / saspect;
       
    79         }
       
    80         else if (waspect > saspect)
       
    81         {
       
    82             w = saspect * h;
       
    83         }
       
    84 
       
    85         int fixedh = (int)h;
       
    86         int fixedw = (int)w;
       
    87 
       
    88         if (ui->graphicsView->width() != fixedw)
       
    89         {
       
    90             ui->graphicsView->setFixedWidth(fixedw);
       
    91         }
       
    92 
       
    93         if (ui->graphicsView->height() != fixedh)
       
    94         {
       
    95             ui->graphicsView->setFixedHeight(fixedh);
       
    96         }
       
    97 
       
    98     }
       
    99 
    65     if(ui->graphicsView && ui->graphicsView->scene())
   100     if(ui->graphicsView && ui->graphicsView->scene())
    66         ui->graphicsView->fitInView(ui->graphicsView->scene()->sceneRect(), Qt::KeepAspectRatio);
   101         ui->graphicsView->fitInView(m_scene->sceneRect(), Qt::KeepAspectRatio);
    67 }
   102 }
    68 
   103 
    69 void DrawMapWidget::showEvent(QShowEvent * event)
   104 void DrawMapWidget::showEvent(QShowEvent * event)
    70 {
   105 {
    71     Q_UNUSED(event);
   106     Q_UNUSED(event);