ui/views/listview/src/glxlistview.cpp
changeset 71 27f2d7aec52a
parent 54 0f0f3f26f787
child 72 0a8e959402e5
equal deleted inserted replaced
69:45459746d5e8 71:27f2d7aec52a
    23 #include <hblistview.h>
    23 #include <hblistview.h>
    24 #include <hbmainwindow.h>
    24 #include <hbmainwindow.h>
    25 #include <hbdocumentloader.h>
    25 #include <hbdocumentloader.h>
    26 #include <hbabstractviewitem.h>
    26 #include <hbabstractviewitem.h>
    27 #include <hblistviewitem.h>
    27 #include <hblistviewitem.h>
       
    28 #include <hbgroupbox.h>
       
    29 #include <hbparameterlengthlimiter.h>
       
    30 
    28 //User Includes
    31 //User Includes
    29 #include "glxviewids.h"
    32 #include "glxviewids.h"
    30 #include "glxlistview.h"
    33 #include "glxlistview.h"
    31 #include "glxmodelparm.h"
    34 #include "glxmodelparm.h"
    32 #include "glxdocloaderdefs.h"
    35 #include "glxdocloaderdefs.h"
    33 #include "glxcommandhandlers.hrh"
    36 #include "glxcommandhandlers.hrh"
    34 
    37 #include "glxlocalisationstrings.h"
    35 
    38 
    36 GlxListView::GlxListView(HbMainWindow *window) 
    39 GlxListView::GlxListView(HbMainWindow *window) 
    37     : GlxView ( GLX_LISTVIEW_ID ), 
    40     : GlxView ( GLX_LISTVIEW_ID ), 
    38       mListView(NULL), 
    41       mListView(NULL), 
    39       mView(NULL), 
    42       mView(NULL), 
       
    43       mAlbumCount(NULL),
    40       mWindow(window), 
    44       mWindow(window), 
    41       mModel ( NULL),
    45       mModel ( NULL),
    42       mIsLongPress( false )
    46       mIsLongPress( false )
    43 {
    47 {
    44     qDebug("GlxListView::GlxListView()");
    48     qDebug("GlxListView::GlxListView()");
    62 void GlxListView::setModel(QAbstractItemModel *model) 
    66 void GlxListView::setModel(QAbstractItemModel *model) 
    63 {
    67 {
    64     qDebug("GlxListView::setModel()");
    68     qDebug("GlxListView::setModel()");
    65     if ( mModel ) {
    69     if ( mModel ) {
    66         disconnect(mModel, SIGNAL(listPopulated()), this, SLOT( populated()));
    70         disconnect(mModel, SIGNAL(listPopulated()), this, SLOT( populated()));
       
    71         disconnect( mModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( showAlbumCount() ) );
       
    72         disconnect( mModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( showAlbumCount() ) );
    67     }
    73     }
    68     mModel =  model ;
    74     mModel =  model ;
    69     mListView->setModel(mModel);
    75     mListView->setModel(mModel);
    70     connect(mModel, SIGNAL(listPopulated()), this, SLOT( populated()));
    76     connect(mModel, SIGNAL(listPopulated()), this, SLOT( populated()));
       
    77     connect( mModel, SIGNAL( rowsInserted( QModelIndex, int, int ) ), this, SLOT( showAlbumCount() ) );
       
    78     connect( mModel, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( showAlbumCount() ) );
       
    79     showAlbumCount();
    71 }
    80 }
    72 
    81 
    73 void GlxListView::addToolBar( HbToolBar *toolBar ) 
    82 void GlxListView::addToolBar( HbToolBar *toolBar ) 
    74 {
    83 {
    75     setToolBar(toolBar) ;
    84     setToolBar(toolBar) ;
   137         mDocLoader->load(GLX_LISTVIEW_DOCMLPATH,&loaded);
   146         mDocLoader->load(GLX_LISTVIEW_DOCMLPATH,&loaded);
   138         if(loaded) {
   147         if(loaded) {
   139             //retrieve the widgets
   148             //retrieve the widgets
   140             mView = static_cast<HbView*>(mDocLoader->findWidget(QString(GLX_LISTVIEW_VIEW)));
   149             mView = static_cast<HbView*>(mDocLoader->findWidget(QString(GLX_LISTVIEW_VIEW)));
   141             mListView = static_cast<HbListView*>(mDocLoader->findWidget(QString(GLX_LISTVIEW_LIST)));
   150             mListView = static_cast<HbListView*>(mDocLoader->findWidget(QString(GLX_LISTVIEW_LIST)));
       
   151             mAlbumCount = static_cast<HbGroupBox*>(mDocLoader->findWidget(QString(GLX_LISTVIEW_ALBUMCOUNT)));
   142 
   152 
   143             if( mListView ) { 
   153             if( mListView ) { 
   144                 //sets the widget
   154                 //sets the widget
   145                 setWidget((QGraphicsWidget*) mView);
   155                 setWidget((QGraphicsWidget*) mView);
   146                 HbListViewItem *prototype = mListView->listItemPrototype();
   156                 HbListViewItem *prototype = mListView->listItemPrototype();
   166         takeWidget();    
   176         takeWidget();    
   167     }       
   177     }       
   168 
   178 
   169     removeViewConnection();
   179     removeViewConnection();
   170 
   180 
       
   181     if(mAlbumCount) {
       
   182         delete mAlbumCount ;
       
   183         mAlbumCount = NULL;
       
   184     }
       
   185 
   171     if(mListView) {
   186     if(mListView) {
   172         delete mListView;
   187         delete mListView;
   173         mListView = NULL;
   188         mListView = NULL;
   174     }
   189     }
   175 
   190 
   229     }
   244     }
   230     mIsLongPress = true;
   245     mIsLongPress = true;
   231     emit itemSpecificMenuTriggered(viewId(),coords);
   246     emit itemSpecificMenuTriggered(viewId(),coords);
   232 }
   247 }
   233 
   248 
       
   249 void GlxListView::showAlbumCount()
       
   250 {
       
   251     int albumCnt = mModel->rowCount();
       
   252     QString text = HbParameterLengthLimiter(GLX_ALBUM_LIST_COUNT_LABEL, albumCnt);
       
   253     mAlbumCount->setHeading(text);
       
   254 }