deviceupdatesui/deviceupdates/src/customviewitem.cpp
changeset 59 b7be70e619ea
equal deleted inserted replaced
53:1273bf2c520c 59:b7be70e619ea
       
     1 /*
       
     2  * Copyright (c) 2010 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:  Custom list item implementation.
       
    15  *
       
    16  */
       
    17 
       
    18 #include <hblistviewitem.h>
       
    19 #include <QGraphicsLinearLayout.h>
       
    20 #include "customviewitem.h"
       
    21 #include "dmadvancedview.h"
       
    22 
       
    23 CustomViewItem::CustomViewItem(DmAdvancedView* serversview,
       
    24         QGraphicsItem * parent) :
       
    25     HbListViewItem(parent), mButton(0), callBackView(serversview)
       
    26     {
       
    27     }
       
    28 
       
    29 CustomViewItem::~CustomViewItem()
       
    30     {
       
    31     }
       
    32 
       
    33 HbAbstractViewItem * CustomViewItem::createItem()
       
    34     {
       
    35     return new CustomViewItem(*this);
       
    36     }
       
    37 
       
    38 void CustomViewItem::updateChildItems()
       
    39     {
       
    40     int itemType(modelIndex().data(Hb::ItemTypeRole).toInt());
       
    41     if ( itemType == CustomViewItem::ItemType )
       
    42         {
       
    43         if ( mButton == 0 )
       
    44             {
       
    45             QGraphicsLinearLayout * layout = new QGraphicsLinearLayout();
       
    46             mButton = new HbPushButton(this);
       
    47 
       
    48             mButton->setText(hbTrId(
       
    49                     "txt_device_update_button_new_server_profile"));            
       
    50             connect(mButton, SIGNAL(clicked()), callBackView, SLOT(
       
    51                     createNewProfile()));
       
    52             layout->addItem(mButton);            
       
    53             layout->setContentsMargins(leftMargin, topAndBottomMargin,
       
    54                     rightMargin, topAndBottomMargin);
       
    55             setStretchingStyle(HbListViewItem::StretchLandscape);
       
    56             setLayout(layout);
       
    57             }
       
    58         }
       
    59     else
       
    60         {
       
    61         HbListViewItem::updateChildItems();
       
    62         setStretchingStyle(HbListViewItem::StretchLandscape);
       
    63         }
       
    64     }
       
    65 
       
    66 bool CustomViewItem::canSetModelIndex(const QModelIndex &index)
       
    67     {
       
    68     Q_UNUSED(index);
       
    69     return true;
       
    70     }
       
    71 
       
    72 int CustomViewItem::type() const
       
    73     {    
       
    74     return CustomViewItem::ItemType;
       
    75     }
       
    76