phonebookui/pbkcommonui/src/cntnoteeditorviewitem.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 46 efe85016a067
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 "cntnoteeditorviewitem.h"
#include "cntdetailconst.h"
#include "cntdetailmodelitem.h"
#include <hbdataformmodel.h>
#include <hbabstractitemview.h>
#include <hblabel.h>
#include <hbmainwindow.h>
#include <qcontactnote.h>
#include <QGraphicsLinearLayout>

CntNoteEditorViewItem::CntNoteEditorViewItem( QGraphicsItem* aParent ) :
CntDetailViewItem(aParent),
mEdit(NULL),
mLayout(NULL)
    {
    }

CntNoteEditorViewItem::~CntNoteEditorViewItem()
    {
    }
    
HbAbstractViewItem* CntNoteEditorViewItem::createItem()
    {
    return new CntNoteEditorViewItem( *this );
    }

void CntNoteEditorViewItem::textChanged(const QString& aText)
    {
    HbDataFormModel* model = static_cast<HbDataFormModel*>(itemView()->model());
    CntDetailModelItem* item = static_cast<CntDetailModelItem*>( model->itemFromIndex(modelIndex()) );
    QContactNote detail = item->detail();
    detail.setNote( aText );
    item->setDetail( detail );
    }

HbWidget* CntNoteEditorViewItem::createCustomWidget()
    {
    HbDataFormModel* model = static_cast<HbDataFormModel*>(itemView()->model());
    CntDetailModelItem* item = static_cast<CntDetailModelItem*>( model->itemFromIndex(modelIndex()) );
    QContactNote detail = item->detail();

    mLayout = new QGraphicsLinearLayout(Qt::Vertical);
    HbWidget* widget = new HbWidget();
    
    mEdit = new HbLineEdit();
    connect( mEdit, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)) );
    mEdit->setMaxLength( CNT_NOTE_EDITOR_MAXLENGTH );
    mEdit->setMinRows( CNT_NOTE_EDITOR_MIN_ROWCOUNT );
    mEdit->setText( detail.note() );

    HbLabel* label = new HbLabel(hbTrId("txt_phob_formlabel_note"));
    mLayout->addItem(label);
    mLayout->addItem(mEdit);
    widget->setLayout( mLayout );
    
    return widget;
    }
// End of File