mpviewplugins/mpmediawallviewplugin/src/mptracklistwidget.cpp
changeset 55 f3930dda3342
parent 47 4cc1412daed0
equal deleted inserted replaced
51:560ce2306a17 55:f3930dda3342
    26 
    26 
    27 #include <hblistview.h>
    27 #include <hblistview.h>
    28 #include <hbframeitem.h>
    28 #include <hbframeitem.h>
    29 #include <hbmainwindow.h>
    29 #include <hbmainwindow.h>
    30 #include <hbstyleloader.h>
    30 #include <hbstyleloader.h>
       
    31 #include <hbscrollbar.h>
       
    32 #include <hbcolorscheme.h>
    31 
    33 
    32 
    34 
    33 #include "mptracklistwidget.h"
    35 #include "mptracklistwidget.h"
    34 
    36 
    35 
    37 
    36 const int swipeAngleTolerance = 30; // angle is from 0 to 360
    38 const int swipeAngleTolerance = 30; // angle is from 0 to 360
       
    39 const int tracklistOutlineSize = 1; //
    37 
    40 
    38 /*!
    41 /*!
    39     \class MpTrackListWidget
    42     \class MpTrackListWidget
    40     \brief Widget with a list of tracks for Media Wall.
    43     \brief Widget with a list of tracks for Media Wall.
    41     
    44     
    54 /*!
    57 /*!
    55    Creates the MpTrackListWidget. 
    58    Creates the MpTrackListWidget. 
    56  */
    59  */
    57 MpTrackListWidget::MpTrackListWidget( QGraphicsItem *parent ) : HbWidget( parent ) 
    60 MpTrackListWidget::MpTrackListWidget( QGraphicsItem *parent ) : HbWidget( parent ) 
    58 {
    61 {
       
    62     setFlag( QGraphicsItem::ItemHasNoContents, false );
    59     // Register the custorm css path for the list items.
    63     // Register the custorm css path for the list items.
    60     HbStyleLoader::registerFilePath(":/css/mpcustomlistitem.css");
    64     HbStyleLoader::registerFilePath( ":/css/mpcustomlistitem.css" );
    61     HbStyleLoader::registerFilePath(":/css/mpcustomlistitem.hblistviewitem.widgetml");    
    65     HbStyleLoader::registerFilePath( ":/css/mpcustomlistitem.hblistviewitem.widgetml" );    
    62     mList = new HbListView( this );
    66     mList = new HbListView( this );
    63     // set layout name that matches the custom list item layout.
    67     // set layout name that matches the custom list item layout.
    64     mList->setLayoutName("mpmwtracklist");
    68     mList->setLayoutName( "mpmwtracklist" );
       
    69     HbScrollBar *scrollbar = mList->verticalScrollBar();
       
    70     scrollbar->show();
       
    71     scrollbar->setInteractive( true );
       
    72     mList->setVerticalScrollBarPolicy( HbScrollArea::ScrollBarAlwaysOn );
    65     
    73     
    66     //grab the gesture for close.
    74     //grab the gesture for close.
    67     grabGesture(Qt::SwipeGesture);
    75     grabGesture(Qt::SwipeGesture);
    68     
    76     
    69     mFrameItem = new HbFrameItem( this );
    77     mFrameItem = new HbFrameItem( this );
    70     mFrameItem->frameDrawer().setFrameType( HbFrameDrawer::NinePieces );
    78     mFrameItem->frameDrawer().setFrameType( HbFrameDrawer::OnePiece );
    71     mFrameItem->frameDrawer().setFrameGraphicsName( "qtg_fr_multimedia_trans" );  
    79     mFrameItem->frameDrawer().setFrameGraphicsName( "qtg_fr_popup_c" );  //replace for qtg_graf_mediawall_list_bg when available.
    72     mFrameItem->setZValue(-1);
    80     mFrameItem->setFlag(QGraphicsItem::ItemStacksBehindParent);
    73 }
    81 }
    74 
    82 
    75 /*!
    83 /*!
    76  Destructs the track list widget.
    84  Destructs the track list widget.
    77  */
    85  */
    91     \reimp
    99     \reimp
    92  */
   100  */
    93 void MpTrackListWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
   101 void MpTrackListWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
    94 {
   102 {
    95     mFrameItem->setGeometry( rect() );
   103     mFrameItem->setGeometry( rect() );
    96     qreal margin = 0.0;
   104     qreal margin = tracklistOutlineSize;
    97     style()->parameter(QString("var(hb-param-margin-gene-middle-vertical)"), margin);
       
    98     mList->setGeometry( rect().adjusted( margin, margin, -margin, -margin ) );
   105     mList->setGeometry( rect().adjusted( margin, margin, -margin, -margin ) );
    99     HbWidget::resizeEvent( event );
   106     HbWidget::resizeEvent( event );
   100 }
   107 }
   101 
   108 
   102 /*!
   109 /*!
   141         }
   148         }
   142     }    
   149     }    
   143 }
   150 }
   144 
   151 
   145 /*!
   152 /*!
       
   153     \reimp
       
   154  */
       
   155 void MpTrackListWidget::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
       
   156 {
       
   157     Q_UNUSED( widget )
       
   158     Q_UNUSED( option )
       
   159     painter->save();
       
   160     qreal outlineWidth(tracklistOutlineSize);
       
   161     painter->setPen(QPen(HbColorScheme::color("qtc_view_normal_secondary"), outlineWidth,Qt::SolidLine,Qt::FlatCap,Qt::MiterJoin));
       
   162     painter->drawRect( rect().adjusted(outlineWidth/2,outlineWidth/2,-outlineWidth/2,-outlineWidth/2) );
       
   163     painter->restore();
       
   164 }
       
   165 
       
   166 /*!
   146     Maps swipe \a angle to QSwipeGesture::SwipeDirection based on a tolerance 
   167     Maps swipe \a angle to QSwipeGesture::SwipeDirection based on a tolerance 
   147     parameter and orientation. This funtions helps to identify a swipe even 
   168     parameter and orientation. This funtions helps to identify a swipe even 
   148     if it is not sharp movement from 180 to 0 degrees on the righ swipe 
   169     if it is not sharp movement from 180 to 0 degrees on the righ swipe 
   149     gesture for instance. Since gesture events are mesured on device 
   170     gesture for instance. Since gesture events are mesured on device 
   150     cordinates this also helps to correct the gesture to local cordinates 
   171     cordinates this also helps to correct the gesture to local cordinates