[Marble-commits] KDE/kdeedu/marble/src

Bastian Holst bastianholst at gmx.de
Mon Aug 17 22:25:55 CEST 2009


SVN commit 1012563 by bholst:

MarbleGraphicsView: Corrected behavior of LabelGraphicsItem and MarbleGraphicsGridLayout

 M  +7 -2      lib/graphicsview/LabelGraphicsItem.cpp  
 M  +1 -1      lib/graphicsview/LabelGraphicsItem.h  
 M  +24 -9     lib/graphicsview/MarbleGraphicsGridLayout.cpp  
 M  +5 -2      plugins/render/weather/WeatherItem.cpp  


--- trunk/KDE/kdeedu/marble/src/lib/graphicsview/LabelGraphicsItem.cpp #1012562:1012563
@@ -41,12 +41,17 @@
 {
 }
 
-void LabelGraphicsItem::setText( const QString& text )
+void LabelGraphicsItem::setText( const QString& text, int minWidth, int minHeight )
 {
     clear();
     d->m_text = text;
     QFontMetrics metrics( d->font() );
-    setContentSize( metrics.boundingRect( text ).size() + QSize( 4, 2 ) );
+    QSizeF size = metrics.boundingRect( text ).size() + QSizeF( 14, 2 );
+    if ( size.width() < minWidth )
+        size.setWidth( minWidth );
+    if ( size.height() < minHeight )
+        size.setHeight( minHeight );
+    setContentSize( size );
 
     update();
 }
--- trunk/KDE/kdeedu/marble/src/lib/graphicsview/LabelGraphicsItem.h #1012562:1012563
@@ -33,7 +33,7 @@
  public:
     explicit LabelGraphicsItem( MarbleGraphicsItem *parent = 0 );
 
-    void setText( const QString& text );
+    void setText( const QString& text, int minWidth = 0, int minHeight = 0 );
     void setImage( const QImage& image, const QSize& size = QSize() );
     void setIcon( const QIcon& icon, const QSize& size );
 
--- trunk/KDE/kdeedu/marble/src/lib/graphicsview/MarbleGraphicsGridLayout.cpp #1012562:1012563
@@ -115,18 +115,32 @@
     double *endY = new double[d->m_rows];
     QRectF contentRect = parent->contentRect();
 
-    double nextStartX = contentRect.left();
     for ( int i = 0; i < d->m_columns; i++ ) {
-        startX[i] = nextStartX;
-        endX[i] = nextStartX + maxWidth[i];
-        nextStartX = endX[i] + d->m_spacing;
+        if ( i == 0 ) {
+            startX[0] = contentRect.left();
+        }
+        else if ( maxWidth[i] == 0 ) {
+            startX[i] = endX[i-1];
+        }
+        else {
+            startX[i] = endX[i-1] + d->m_spacing;
+        }
+
+        endX[i] = startX[i] + maxWidth[i];
     }
 
-    double nextStartY = contentRect.top();
     for ( int i = 0; i < d->m_rows; i++ ) {
-        startY[i] = nextStartY;
-        endY[i] = nextStartY + maxHeight[i];
-        nextStartY = endY[i] + d->m_spacing;
+        if ( i == 0 ) {
+            startY[0] = contentRect.left();
+        }
+        else if ( maxHeight[i] == 0 ) {
+            startY[i] = endY[i-1];
+        }
+        else {
+            startY[i] = endY[i-1] + d->m_spacing;
+        }
+
+        endY[i] = startY[i] + maxHeight[i];
     }
 
     // Setting the positions
@@ -166,7 +180,8 @@
         }
     }
 
-    parent->setContentSize( QSizeF( endX[d->m_columns - 1], endY[d->m_rows - 1] ) );
+    parent->setContentSize( QSizeF( endX[d->m_columns - 1] - contentRect.left(),
+                                    endY[d->m_rows - 1] - contentRect.top() ) );
 }
 
 Qt::Alignment MarbleGraphicsGridLayout::alignment() const
--- trunk/KDE/kdeedu/marble/src/plugins/render/weather/WeatherItem.cpp #1012562:1012563
@@ -146,7 +146,7 @@
         }
 
         if ( isTemperatureShown() ) {
-            m_temperatureLabel->setText( temperatureString() );
+            m_temperatureLabel->setText( temperatureString(), 0, imageSize.height() );
         }
         else {
             m_temperatureLabel->clear();
@@ -172,9 +172,12 @@
             s_windIcons.render( &painter, windDirectionString );
             m_windDirectionLabel->setImage( windArrow );
         }
+        else {
+            m_windDirectionLabel->clear();
+        }
 
         if ( isWindSpeedShown() ) {
-            m_windSpeedLabel->setText( windSpeedString() );
+            m_windSpeedLabel->setText( windSpeedString(), 0, imageSize.height() );
         }
         else {
             m_windSpeedLabel->clear();


More information about the Marble-commits mailing list