radioapp/radiowidgets/src/radiofrequencystrip.cpp
changeset 33 11b6825f0862
parent 32 189d20c34778
child 37 451b2e1545b2
child 41 3a6b55c6390c
--- a/radioapp/radiowidgets/src/radiofrequencystrip.cpp	Wed Jun 23 18:12:57 2010 +0300
+++ b/radioapp/radiowidgets/src/radiofrequencystrip.cpp	Tue Jul 06 14:16:27 2010 +0300
@@ -25,6 +25,7 @@
 #include <HbColorScheme>
 #include <HbEvent>
 #include <HbSwipeGesture>
+#include <HbDeviceProfile>
 
 #include "radiofrequencystrip.h"
 #include "radiofrequencyitem.h"
@@ -36,8 +37,8 @@
 #include "radiologger.h"
 
 // Frequency lines
-const int TAB_HEIGHT_SMALL = 10;
-const int TAB_HEIGHT_BIG = 15;
+const int TAB_HEIGHT_SMALL = 12;
+const int TAB_HEIGHT_BIG = 18;
 const int PEN_WIDTH_FAVORITE = 4;
 const qreal INDICATOR_WIDTH = 2.0;
 
@@ -52,7 +53,6 @@
 const qreal PIXMAP_OVERLAP = qreal( ONE_TAB_DISTANCE ) / 2;
 const int ITEM_WIDTH = ONE_TAB_DISTANCE * 5;
 const int PIXMAP_WIDTH = ITEM_WIDTH + (int)PIXMAP_OVERLAP;
-const int STRIP_HEIGHT = 50;
 
 const uint ONE_HUNDRED_KHZ = 100000;
 
@@ -84,17 +84,10 @@
 /*!
  *
  */
-static QLineF makeTab( qreal pos, int height )
-{
-    return QLineF( pos, STRIP_HEIGHT - height, pos, STRIP_HEIGHT );
-}
-
-/*!
- *
- */
 RadioFrequencyStrip::RadioFrequencyStrip() :
     RadioStripBase(),
     mUiEngine( NULL ),
+    mItemHeight( 8 ),
     mMinFrequency( 87500000 ),
     mMaxFrequency( 108000000 ),
     mFrequencyStepSize( 100000 ),
@@ -114,18 +107,24 @@
     RadioUtil::setFrequencyStrip( this );
 
     setScrollingStyle( HbScrollArea::PanWithFollowOn );
-    setItemSize( QSizeF( ITEM_WIDTH + PIXMAP_OVERLAP / 2, STRIP_HEIGHT ) );
+    setItemSize( QSizeF( ITEM_WIDTH + PIXMAP_OVERLAP / 2, mItemHeight ) );
     setOverlap( PIXMAP_OVERLAP / 2 );
-
-    initModel();
+}
 
-    initSelector();
-
-    initEmptyItems();
+/*!
+ * Property
+ */
+void RadioFrequencyStrip::setItemHeight( int itemHeight )
+{
+    mItemHeight = itemHeight;
+}
 
-    initPositions();
-
-    mFrequency = RadioUiEngine::lastTunedFrequency();
+/*!
+ * Property
+ */
+int RadioFrequencyStrip::itemHeight() const
+{
+    return mItemHeight;
 }
 
 /*!
@@ -137,6 +136,14 @@
     mMinFrequency       = mUiEngine->minFrequency();
     mMaxFrequency       = mUiEngine->maxFrequency();
     mFrequencyStepSize  = mUiEngine->frequencyStepSize();
+    mFrequency          = RadioUiEngine::lastTunedFrequency();
+
+    initModel();
+    initEmptyItems();
+    initPositions();
+
+    HbDeviceProfile deviceProfile;
+    mItemHeight = static_cast<int>( mItemHeight * deviceProfile.unitValue() );
 
     mLeftButton = uiLoader.findWidget<HbPushButton>( DOCML::MV_NAME_PREV_BUTTON );
     mRightButton = uiLoader.findWidget<HbPushButton>( DOCML::MV_NAME_NEXT_BUTTON );
@@ -411,6 +418,8 @@
     LOG_METHOD;
     RadioStripBase::resizeEvent( event );
 
+    initSelector();
+
     const qreal height = event->newSize().height();
     const qreal width = event->newSize().width();
 
@@ -545,7 +554,7 @@
  */
 void RadioFrequencyStrip::initSelector()
 {
-    QPixmap selectorPixmap = QPixmap( QSize( SELECTOR_WIDTH, STRIP_HEIGHT ) );
+    QPixmap selectorPixmap = QPixmap( QSize( SELECTOR_WIDTH, (int)size().height() ) );
     selectorPixmap.fill( Qt::red );
     mSelectorImage->setPixmap( selectorPixmap );
     mSelectorImage->setZValue( SELECTOR_Z_POS );
@@ -676,7 +685,7 @@
  */
 QPixmap RadioFrequencyStrip::drawPixmap( uint frequency, QList<RadioStation> stations, RadioFrequencyItem* item )
 {
-    QPixmap pixmap( PIXMAP_WIDTH, STRIP_HEIGHT );
+    QPixmap pixmap( PIXMAP_WIDTH, mItemHeight );
     pixmap.fill( Qt::transparent );
     QPainter painter( &pixmap );
     QPen normalPen = painter.pen();
@@ -685,8 +694,8 @@
     painter.setPen( normalPen );
 
     if ( frequency == 0 ) {
-        painter.drawLine( makeTab( mSeparatorPos - 1 + ROUNDER, STRIP_HEIGHT ) );
-        painter.drawLine( makeTab( mSeparatorPos + ROUNDER, STRIP_HEIGHT ) );
+        painter.drawLine( makeTab( mSeparatorPos - 1 + ROUNDER, mItemHeight ) );
+        painter.drawLine( makeTab( mSeparatorPos + ROUNDER, mItemHeight ) );
         return pixmap;
     }
 
@@ -710,7 +719,11 @@
         if ( frequency % ONE_HERTZ == 0 ) {
 
             // Draw the high frequency tab and the frequency text for the even number
-            painter.drawLine( makeTab( pixels + leftOverlap, TAB_HEIGHT_BIG ) );
+            normalPen.setWidth( 3 );
+            painter.setPen( normalPen );
+            painter.drawLine( makeTab( pixels + leftOverlap - 1, TAB_HEIGHT_BIG ) );
+            normalPen.setWidth( 1 );
+            painter.setPen( normalPen );
 
             // Draw the frequency text and its 00 decimals
             painter.setFont( DECIMAL_FONT );
@@ -736,7 +749,7 @@
     // Draw favorites and local stations
     favoritePen.setColor( Qt::yellow );
 
-    const int markerYPos = STRIP_HEIGHT - 20;
+    const int markerYPos = mItemHeight - 28;
     foreach ( const RadioStation& station, stations ) {
         const uint frequency = station.frequency();
         pixels = qreal( frequency - startFrequency ) / PIXEL_IN_HZ;
@@ -745,7 +758,6 @@
             favoritePen.setWidth( PEN_WIDTH_FAVORITE );
             painter.setPen( favoritePen );
             painter.drawEllipse( int( pixels + leftOverlap - 3 ), markerYPos - 3, 6, 6 );
-//            painter.drawPixmap( pixels - 10, 20, 20, 20, mFavoriteIcon.pixmap() );
         } else if ( station.isType( RadioStation::LocalStation ) ) {
 
             favoritePen.setWidth( 1 );
@@ -760,6 +772,14 @@
 /*!
  *
  */
+QLineF RadioFrequencyStrip::makeTab( qreal pos, int height )
+{
+    return QLineF( pos, mItemHeight - height, pos, mItemHeight );
+}
+
+/*!
+ *
+ */
 void RadioFrequencyStrip::emitFrequencyChanged( uint frequency )
 {
     if ( frequency > 0 && frequency != mFrequency ) {