72
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include "cntnoteeditorviewitem.h"
|
|
18 |
#include "cntdetailconst.h"
|
|
19 |
#include "cntdetailmodelitem.h"
|
|
20 |
#include <hbdataformmodel.h>
|
|
21 |
#include <hbabstractitemview.h>
|
81
|
22 |
#include <hblineedit.h>
|
|
23 |
#include <hbwidget.h>
|
72
|
24 |
#include <qcontactnote.h>
|
|
25 |
#include <QGraphicsLinearLayout>
|
|
26 |
|
|
27 |
CntNoteEditorViewItem::CntNoteEditorViewItem( QGraphicsItem* aParent ) :
|
81
|
28 |
CntDetailViewItem(aParent),
|
|
29 |
mEdit(NULL),
|
|
30 |
mLayout(NULL)
|
|
31 |
{
|
|
32 |
|
|
33 |
}
|
72
|
34 |
|
|
35 |
CntNoteEditorViewItem::~CntNoteEditorViewItem()
|
81
|
36 |
{
|
72
|
37 |
|
81
|
38 |
}
|
|
39 |
|
72
|
40 |
HbAbstractViewItem* CntNoteEditorViewItem::createItem()
|
81
|
41 |
{
|
72
|
42 |
return new CntNoteEditorViewItem( *this );
|
81
|
43 |
}
|
72
|
44 |
|
|
45 |
void CntNoteEditorViewItem::textChanged(const QString& aText)
|
81
|
46 |
{
|
72
|
47 |
HbDataFormModel* model = static_cast<HbDataFormModel*>(itemView()->model());
|
|
48 |
CntDetailModelItem* item = static_cast<CntDetailModelItem*>( model->itemFromIndex(modelIndex()) );
|
|
49 |
QContactNote detail = item->detail();
|
|
50 |
detail.setNote( aText );
|
|
51 |
item->setDetail( detail );
|
81
|
52 |
}
|
72
|
53 |
|
|
54 |
HbWidget* CntNoteEditorViewItem::createCustomWidget()
|
81
|
55 |
{
|
72
|
56 |
HbDataFormModel* model = static_cast<HbDataFormModel*>(itemView()->model());
|
|
57 |
CntDetailModelItem* item = static_cast<CntDetailModelItem*>( model->itemFromIndex(modelIndex()) );
|
|
58 |
QContactNote detail = item->detail();
|
|
59 |
|
|
60 |
mLayout = new QGraphicsLinearLayout(Qt::Vertical);
|
81
|
61 |
mLayout->setContentsMargins(0, 0, 0, 0);
|
72
|
62 |
HbWidget* widget = new HbWidget();
|
81
|
63 |
|
72
|
64 |
mEdit = new HbLineEdit();
|
|
65 |
mEdit->setInputMethodHints(Qt::ImhNoPredictiveText);
|
81
|
66 |
|
72
|
67 |
mEdit->setMaxLength( CNT_NOTE_EDITOR_MAXLENGTH );
|
|
68 |
mEdit->setMinRows( CNT_NOTE_EDITOR_MIN_ROWCOUNT );
|
|
69 |
mEdit->setText( detail.note() );
|
|
70 |
|
|
71 |
mLayout->addItem(mEdit);
|
|
72 |
widget->setLayout( mLayout );
|
81
|
73 |
|
72
|
74 |
connect( mEdit, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)) );
|
81
|
75 |
|
72
|
76 |
// Naming UI components for automation testability
|
|
77 |
QString editorObjName = detail.definitionName() + " line edit %1";
|
|
78 |
mEdit->setObjectName(editorObjName.arg(modelIndex().row()));
|
|
79 |
return widget;
|
81
|
80 |
}
|
72
|
81 |
// End of File
|