deviceupdatesui/deviceupdates/src/settingsdataformcustomitem.cpp
author hgs
Tue, 13 Jul 2010 03:42:03 +0530
changeset 43 88e14c3d4c4f
parent 38 2d078e09a2f4
child 47 d316aecb87fd
permissions -rw-r--r--
201019
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     1
/*
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     2
 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     3
 * All rights reserved.
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     8
 *
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
     9
 * Initial Contributors:
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    11
 *
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    12
 * Contributors:
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    13
 *
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    14
 * Description:  This class provides custom list item for the
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    15
 * DataForm
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    16
 *
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    17
 */
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    18
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    19
#include <settingsdataformcustomitem.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    20
#include <hbdataformmodelitem.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    21
#include <hblineedit.h>
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    22
#include <hbinputeditorinterface.h>
36
hgs
parents: 33
diff changeset
    23
#include <qgraphicslinearlayout.h>
33
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    24
#include <hblabel.h>
36
hgs
parents: 33
diff changeset
    25
33
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    26
SettingsDataFormCustomItem::SettingsDataFormCustomItem(QGraphicsItem *parent) :
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    27
HbDataFormViewItem(parent)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    28
{
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    29
}
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    30
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    31
SettingsDataFormCustomItem::~SettingsDataFormCustomItem()
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    32
{
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    33
}
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    34
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    35
HbAbstractViewItem* SettingsDataFormCustomItem::createItem()
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    36
{
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    37
    return new SettingsDataFormCustomItem(*this);
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    38
}
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    39
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    40
HbWidget* SettingsDataFormCustomItem::createCustomWidget()
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    41
{
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    42
    HbDataFormModelItem::DataItemType itemType =
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    43
    static_cast<HbDataFormModelItem::DataItemType> 
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    44
    ( modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt() );    
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    45
    switch (itemType)
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    46
    {
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    47
      case HbDataFormModelItem::CustomItemBase :
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    48
            {             
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    49
            HbLineEdit* mLineEdit = new HbLineEdit();
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    50
            mLineEdit->setText(QString("8080"));
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    51
            HbEditorInterface editorInterface(mLineEdit);
38
hgs
parents: 37
diff changeset
    52
            editorInterface.setMode(HbInputModeNumeric); 
hgs
parents: 37
diff changeset
    53
            editorInterface.setInputConstraints(HbEditorConstraintFixedInputMode);            
33
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    54
            return mLineEdit;            
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    55
            }                
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    56
        default:
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    57
            return 0;
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    58
    }
7464c1e21dae 201008_internal
hgs
parents:
diff changeset
    59
}
37
hgs
parents: 36
diff changeset
    60
hgs
parents: 36
diff changeset
    61
 bool SettingsDataFormCustomItem::canSetModelIndex( const QModelIndex& aIndex ) const
hgs
parents: 36
diff changeset
    62
 {
hgs
parents: 36
diff changeset
    63
     int itemType = aIndex.data(HbDataFormModelItem::ItemTypeRole).toInt();
hgs
parents: 36
diff changeset
    64
     return itemType == HbDataFormModelItem::CustomItemBase;
hgs
parents: 36
diff changeset
    65
 }