locationpickerservice/src/locationpickercollectioncontent.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 03 May 2010 12:27:22 +0300
changeset 17 0f22fb80ebba
parent 15 13ae750350c9
child 20 cd10d5b85554
permissions -rw-r--r--
Revision: 201015 Kit: 201018

/*
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: LocationPickerCollectionContent implementation
*
*/

#include <QStandardItemModel>

#include "locationpickerproxymodel.h"
#include "locationpickercollectioncontent.h"
#include "locationpickerdatamanager.h"
#include "locationpickertypes.h"

// ======== MEMBER FUNCTIONS ========

// ----------------------------------------------------------------
// LocationPickerCollectionContent::LocationPickerCollectionContent()
// -----------------------------------------------------------------
LocationPickerCollectionContent::LocationPickerCollectionContent( Qt::Orientations aOrientation , quint32 aCollectionId )
    :mOrientation(aOrientation),
	 mProxyModel(NULL),
    mModel(NULL),
    mDataManager(NULL)
{
    // Create a standard model for the view list
    mModel = new QStandardItemModel( this );
    mDataManager = new LocationPickerDataManager( *mModel, ELocationPickerCollectionContent );
    if( mDataManager->populateModel( mOrientation , aCollectionId ) )
    {
        // Create the proxy model.
        mProxyModel = new LocationPickerProxyModel(mOrientation);
        mProxyModel->setSourceModel(mModel);
        mProxyModel->setDynamicSortFilter(TRUE);
        mProxyModel->setSortRole(Qt::DisplayRole);
        mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
        // sort
        mProxyModel->sort(0, Qt::AscendingOrder);
    }
    else
    {
        // no locations to display.
        QStandardItem *modelItem = new QStandardItem();
        modelItem->setData(QVariant(hbTrId("txt_lint_list_no_location_entries_present")), Qt::DisplayRole);
        mModel->appendRow( modelItem );
     }
}

// ----------------------------------------------------------------
// LocationPickerCollectionContent::~LocationPickerCollectionContent
// -----------------------------------------------------------------
LocationPickerCollectionContent::~LocationPickerCollectionContent()
{
    delete mProxyModel;
    delete mModel;
    delete mDataManager;
}

// ----------------------------------------------------------------
// LocationPickerCollectionContent::getProxyModel
// -----------------------------------------------------------------
LocationPickerProxyModel* LocationPickerCollectionContent::getProxyModel()
    {
    return mProxyModel;
    }


// ----------------------------------------------------------------
// LocationPickerCollectionContent::getDataManager
// -----------------------------------------------------------------
LocationPickerDataManager* LocationPickerCollectionContent::getDataManager()
    {
    return mDataManager;
    }