locationpickerservice/src/locationpickercollectionlistview.cpp
changeset 17 0f22fb80ebba
parent 15 13ae750350c9
child 18 9cb5557eea6b
child 20 cd10d5b85554
equal deleted inserted replaced
15:13ae750350c9 17:0f22fb80ebba
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: LocationPickerCollectionListView implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include <HbListView>
       
    19 #include <QStandardItemModel>
       
    20 #include <HbListViewItem>
       
    21 
       
    22 #include "locationpickercollectionlistview.h"
       
    23 #include "locationpickercollectioncontent.h"
       
    24 #include "locationpickertoolbar.h"
       
    25 #include "locationpickerappwindow.h"
       
    26 #include "locationpickerdatamanager.h"
       
    27 #include "locationpickertypes.h"
       
    28 
       
    29 // ======== MEMBER FUNCTIONS ========
       
    30 
       
    31 // ----------------------------------------------------------------------
       
    32 // LocationPickerCollectionListView::LocationPickerCollectionListView()
       
    33 // ----------------------------------------------------------------------
       
    34 LocationPickerCollectionListView::LocationPickerCollectionListView(
       
    35         LocationPickerAppWindow *aWindow, QGraphicsItem* aParent )
       
    36         :HbView( aParent )
       
    37 
       
    38 {
       
    39     mWindow = aWindow;
       
    40     //Creation of List View
       
    41     mListView=new HbListView( this );
       
    42     connect(mListView, SIGNAL(activated(const QModelIndex &)), this, SLOT(handleActivated(const QModelIndex &)));
       
    43 
       
    44     //Set grahics size for the list items.
       
    45     HbListViewItem *hbListItem = new HbListViewItem();
       
    46     hbListItem->setGraphicsSize(HbListViewItem::MediumIcon);
       
    47 
       
    48     // Create a standard model for the view list
       
    49     mModel = new QStandardItemModel( this );
       
    50     mListView->setModel( mModel, hbListItem );
       
    51     
       
    52     mDataManager = new LocationPickerDataManager( *mModel, ELocationPickerCollectionListView );
       
    53     mDataManager->populateModel();
       
    54 
       
    55     setWidget( mListView );
       
    56     
       
    57     
       
    58     // create back action
       
    59     mSecondaryBackAction = new HbAction( Hb::BackAction, this );
       
    60     // add back key action
       
    61     setNavigationAction( mSecondaryBackAction );
       
    62     connect(mSecondaryBackAction, SIGNAL(triggered()), mWindow,
       
    63                                 SLOT(backButtonTriggered()));
       
    64 
       
    65 }
       
    66 
       
    67 // ----------------------------------------------------------------------
       
    68 // LocationPickerCollectionListView::~LocationPickerCollectionListView()
       
    69 // ----------------------------------------------------------------------
       
    70 LocationPickerCollectionListView::~LocationPickerCollectionListView()
       
    71 {
       
    72     if( mDataManager )
       
    73         delete mDataManager;
       
    74 }
       
    75 
       
    76 
       
    77 // ----------------------------------------------------------------------
       
    78 // LocationPickerCollectionListView::handleActivated()
       
    79 // ----------------------------------------------------------------------
       
    80 void LocationPickerCollectionListView::handleActivated( const QModelIndex &aIndex )
       
    81 {
       
    82     // get the collection/category id
       
    83     quint32 categoryId = 0;
       
    84     mDataManager->getData( aIndex.row(), categoryId );
       
    85 
       
    86     // Create a content view of the selected collection
       
    87     LocationPickerToolBar *toolBar = new LocationPickerToolBar( mWindow, this );
       
    88     mCollectionContentView = new LocationPickerCollectionContent( mWindow, categoryId );
       
    89     mCollectionContentView->setToolBar(toolBar);
       
    90 
       
    91     // switch to the content view
       
    92     mWindow->addView( mCollectionContentView );
       
    93     mWindow->setCurrentView( mCollectionContentView );
       
    94 }
       
    95 
       
    96 // ----------------------------------------------------------------------
       
    97 // LocationPickerCollectionListView::deleteCollectionContentView()
       
    98 // ----------------------------------------------------------------------
       
    99 void LocationPickerCollectionListView::deleteCollectionContentView()
       
   100 {
       
   101     // delete the content view
       
   102     mWindow->removeView(mCollectionContentView);
       
   103     delete mCollectionContentView;
       
   104     mCollectionContentView = NULL;
       
   105 }
       
   106