locationpickerservice/src/locationpickercollectionlistcontent.cpp
branchRCL_3
changeset 17 1fc85118c3ae
equal deleted inserted replaced
16:8173571d354e 17:1fc85118c3ae
       
     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: LocationPickerCollectionListContent implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QStandardItemModel>
       
    19 
       
    20 #include "locationpickercollectionlistcontent.h"
       
    21 #include "locationpickerdatamanager.h"
       
    22 
       
    23 // ======== MEMBER FUNCTIONS ========
       
    24 
       
    25 // ----------------------------------------------------------------------
       
    26 // LocationPickerCollectionListContent::LocationPickerCollectionListContent()
       
    27 // ----------------------------------------------------------------------
       
    28 LocationPickerCollectionListContent::LocationPickerCollectionListContent()
       
    29     :mModel(NULL),
       
    30     mDataManager(NULL)
       
    31 {
       
    32     // Create a standard model for the view list
       
    33     mModel = new QStandardItemModel( this );
       
    34     if(mModel)
       
    35     {
       
    36         // create data manager to manage data in the model
       
    37         mDataManager = LocationPickerDataManager::getInstance();
       
    38         bool populated = mDataManager->populateModel( *mModel, ELocationPickerCollectionListContent);
       
    39         if(!populated)
       
    40         {
       
    41         qFatal("Error creating collection");
       
    42         }
       
    43     }
       
    44 }
       
    45 
       
    46 // ----------------------------------------------------------------------
       
    47 // LocationPickerCollectionListContent::~LocationPickerCollectionListContent()
       
    48 // ----------------------------------------------------------------------
       
    49 LocationPickerCollectionListContent::~LocationPickerCollectionListContent()
       
    50 {
       
    51     delete mModel;
       
    52 }
       
    53 
       
    54 // ----------------------------------------------------------------
       
    55 // LocationPickerCollectionListContent::getStandardModel
       
    56 // -----------------------------------------------------------------
       
    57 QStandardItemModel* LocationPickerCollectionListContent::getStandardModel()
       
    58 {
       
    59     return mModel;
       
    60 }
       
    61 
       
    62 // ----------------------------------------------------------------------------
       
    63 // LocationPickerCollectionListContent::getData()
       
    64 // ----------------------------------------------------------------------------
       
    65 
       
    66 void LocationPickerCollectionListContent::getData( QModelIndex aIndex, quint32& aValue )
       
    67 {
       
    68     QStandardItem* item = mModel->item( aIndex.row(), aIndex.column() );
       
    69     QVariant var = item->data( Qt::UserRole );
       
    70     aValue = var.toUInt();
       
    71 }