phonebookui/pbkcommonui/src/cnteditorfactory.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 27 May 2010 12:45:19 +0300
changeset 37 fd64c38c277d
parent 31 2a11b5b00470
child 40 b46a585f6909
permissions -rw-r--r--
Revision: 201019 Kit: 2010121

/*
* 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 "cnteditorfactory.h"
#include "cntnameeditormodel.h"
#include "cntphonenumbermodel.h"
#include "cntphonenumberviewitem.h"
#include "cntemaileditormodel.h"
#include "cntemaileditorviewitem.h"
#include "cntaddressmodel.h"
#include "cntaddressviewitem.h"
#include "cnturleditormodel.h"
#include "cnturleditorviewitem.h"
#include "cntnoteeditormodel.h"
#include "cntnoteeditorviewitem.h"
#include "cntdateeditormodel.h"
#include "cntdateeditorviewitem.h"
#include "cntcompanyeditormodel.h"
#include "cntfamilyeditormodel.h"
#include "cntdetaileditor.h"
#include "cntgroupeditormodel.h"
#include "cntabstractview.h"
#include "cntdetaileditor.h"

CntEditorFactory::CntEditorFactory( QObject* aParent ) :
    QObject(aParent)
{
}

CntEditorFactory::~CntEditorFactory()
{
}

/*!
The View's Id should have been set before calling this function.
*/
void CntEditorFactory::setupEditorView(CntDetailEditor &aEditor, QContact &aContact)
{
    int viewId = aEditor.viewId();
    
    switch ( viewId )
    {
    case emailEditorView: 
    {
        aEditor.setDetails(new CntEmailEditorModel(new QContact(aContact)), new CntEmailEditorViewItem);
        aEditor.setHeader(hbTrId("txt_phob_subtitle_edit_email_address"));
        aEditor.setInsertAction(hbTrId("txt_phob_list_add_email_address"));
        break;
    }
        
    case namesEditorView:
    {
        aEditor.setDetails(new CntNameEditorModel(new QContact(aContact)), NULL);
        aEditor.setHeader(hbTrId("txt_phob_subtitle_edit_contact_name"));
        break;
    }

    case urlEditorView:
    {
        aEditor.setDetails(new CntUrlEditorModel(new QContact(aContact)), new CntUrlEditorViewItem);
        aEditor.setHeader(hbTrId("txt_phob_subtitle_edit_web_address"));
        aEditor.setInsertAction(hbTrId("txt_phob_list_add_url_address"));
        break;
    }
    
    case companyEditorView:
    {
        aEditor.setDetails(new CntCompanyEditorModel(new QContact(aContact)), NULL);
        aEditor.setHeader(hbTrId("txt_phob_subtitle_edit_company_details"));
        break;
    }
    
    case phoneNumberEditorView:
    {
        aEditor.setDetails(new CntPhoneNumberModel(new QContact(aContact)), new CntPhoneNumberViewItem);
        aEditor.setHeader(hbTrId("txt_phob_subtitle_edit_phone_number"));
        aEditor.setInsertAction(hbTrId("txt_phob_opt_add_number"));
        break;
    }
    
    case noteEditorView:
    {
        aEditor.setDetails(new CntNoteEditorModel(new QContact(aContact)), new CntNoteEditorViewItem);
        aEditor.setHeader(hbTrId("Edit note details"));
        aEditor.setInsertAction(hbTrId("Add note"));
        break;
    }

    case familyDetailEditorView:
    {
        aEditor.setDetails(new CntFamilyEditorModel(new QContact(aContact)), NULL);
        aEditor.setHeader(hbTrId("txt_phob_subtitle_edit_family_details"));
        break;
    }

    case addressEditorView:
    {
        aEditor.setDetails(new CntAddressModel(new QContact(aContact)),  new CntAddressViewItem() );
        aEditor.setHeader(hbTrId("txt_phob_subtitle_edit_address_details"));
        break;
    }

    case dateEditorView:
    {
        aEditor.setDetails(new CntDateEditorModel(new QContact(aContact)), new CntDateEditorViewItem);
        aEditor.setHeader(hbTrId("txt_phob_subtitle_edit_date"));
        break;
    }
        
    case groupEditorView:
    {
        aEditor.setDetails(new CntGroupEditorModel(new QContact(aContact)), NULL);
        aEditor.setHeader(hbTrId("txt_phob_subtitle_edit_group_details"));
        break;
    }

    default:
       break;
    }
}
// End of File