phonebookui/phonebookservices/src/cntservicecontactselectionview.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 23 Jun 2010 18:02:44 +0300
changeset 46 efe85016a067
parent 40 b46a585f6909
child 50 77bc263e1626
child 59 a642906a277a
permissions -rw-r--r--
Revision: 201023 Kit: 2010125

/*
* Copyright (c) 2009 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:
*
*/

#include "cntservicecontactselectionview.h"

#include <QCoreApplication>
#include <QModelIndex>
#include "cntservicehandler.h"
#include <hblistview.h>
#include <cntlistmodel.h>

CntServiceContactSelectionView::CntServiceContactSelectionView(CntServiceHandler *aServiceHandler):
CntBaseSelectionView(),
mServiceHandler(aServiceHandler)
{
    connect(mListView, SIGNAL(activated(const QModelIndex&)), this, SLOT(onListViewActivated(const QModelIndex&)));
    connect( this, SIGNAL(viewClosed()), this, SLOT(aboutToCloseView()) );
    connect( this, SIGNAL(viewOpened(CntAbstractViewManager*, const CntViewParameters)), this, SLOT(aboutToOpenView(CntAbstractViewManager*, const CntViewParameters)) );
}

CntServiceContactSelectionView::~CntServiceContactSelectionView()
{

}

void CntServiceContactSelectionView::onListViewActivated(const QModelIndex &aIndex)
{
    QContact contact = mListModel->contact(aIndex);
    contact.saveDetail(&mDetail);
    
    CntViewParameters params;
    params.insert(EViewId, serviceEditView);
    QVariant var;
    var.setValue(contact);
    params.insert(ESelectedContact, var);
    mMgr->changeView(params);
}

void CntServiceContactSelectionView::aboutToCloseView()
{
    connect(mServiceHandler, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
    mServiceHandler->completeEdit(0);
}

void CntServiceContactSelectionView::aboutToOpenView(CntAbstractViewManager* aMgr, const CntViewParameters viewParameters)
{
    mMgr = aMgr;
    
    QContactDetailFilter filter;
    filter.setDetailDefinitionName(QContactType::DefinitionName, QContactType::FieldType);
    QString typeContact = QContactType::TypeContact;
    filter.setValue(typeContact);
    mListModel->setFilter(filter);
    // hide my card if it's not set
    if (mListModel->myCardId() == 0)
    {
        mListModel->showMyCard(false);
    }
    mDetail = viewParameters.value(ESelectedDetail).value<QContactDetail>();
}

// EOF