33
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2005 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: This class provides custom list item for the
|
|
15 |
* DataForm
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
#include <settingsdataformcustomitem.h>
|
|
20 |
#include <hbdataformmodelitem.h>
|
|
21 |
#include <hblineedit.h>
|
|
22 |
#include <hbinputeditorinterface.h>
|
36
|
23 |
#include <qgraphicslinearlayout.h>
|
33
|
24 |
#include <hblabel.h>
|
36
|
25 |
|
33
|
26 |
SettingsDataFormCustomItem::SettingsDataFormCustomItem(QGraphicsItem *parent) :
|
|
27 |
HbDataFormViewItem(parent)
|
|
28 |
{
|
|
29 |
}
|
|
30 |
|
|
31 |
SettingsDataFormCustomItem::~SettingsDataFormCustomItem()
|
|
32 |
{
|
|
33 |
}
|
|
34 |
|
|
35 |
HbAbstractViewItem* SettingsDataFormCustomItem::createItem()
|
|
36 |
{
|
|
37 |
return new SettingsDataFormCustomItem(*this);
|
|
38 |
}
|
|
39 |
|
|
40 |
HbWidget* SettingsDataFormCustomItem::createCustomWidget()
|
|
41 |
{
|
|
42 |
HbDataFormModelItem::DataItemType itemType =
|
|
43 |
static_cast<HbDataFormModelItem::DataItemType>
|
|
44 |
( modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt() );
|
|
45 |
switch (itemType)
|
|
46 |
{
|
|
47 |
case HbDataFormModelItem::CustomItemBase :
|
|
48 |
{
|
|
49 |
HbLineEdit* mLineEdit = new HbLineEdit();
|
|
50 |
mLineEdit->setText(QString("8080"));
|
|
51 |
HbEditorInterface editorInterface(mLineEdit);
|
38
|
52 |
editorInterface.setMode(HbInputModeNumeric);
|
|
53 |
editorInterface.setInputConstraints(HbEditorConstraintFixedInputMode);
|
33
|
54 |
return mLineEdit;
|
|
55 |
}
|
|
56 |
default:
|
|
57 |
return 0;
|
|
58 |
}
|
|
59 |
}
|
37
|
60 |
|
|
61 |
bool SettingsDataFormCustomItem::canSetModelIndex( const QModelIndex& aIndex ) const
|
|
62 |
{
|
|
63 |
int itemType = aIndex.data(HbDataFormModelItem::ItemTypeRole).toInt();
|
|
64 |
return itemType == HbDataFormModelItem::CustomItemBase;
|
|
65 |
}
|