clock/ftudatetimewizard/src/ftudatetimecustomitem.cpp
changeset 32 ea672fcb0ea0
parent 26 a949c2543c15
child 34 1850873ab5e9
child 37 360d55486d7f
equal deleted inserted replaced
26:a949c2543c15 32:ea672fcb0ea0
     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: Implementation for the FtuDateTimeCustomItem class
       
    15  *
       
    16  */
       
    17 
       
    18 // System includes
       
    19 #include <QObject>
       
    20 #include <hblistwidget.h>
       
    21 #include <hblistwidgetitem.h>
       
    22 #include <hbpushbutton.h>
       
    23 #include <hbdataformmodelitem.h>
       
    24 #include <hbdataformmodel.h>
       
    25 
       
    26 
       
    27 // User includes
       
    28 #include "ftudatetimecustomitem.h"
       
    29 
       
    30 /*!
       
    31     \class FtuDateTimeCustomItem
       
    32     This object creates the Custom item
       
    33  */
       
    34 
       
    35 /*!
       
    36     Constructor.
       
    37  */
       
    38 FtuDateTimeCustomItem::FtuDateTimeCustomItem(QGraphicsItem *parent) :
       
    39 HbDataFormViewItem(parent)
       
    40 {
       
    41 }
       
    42 
       
    43 /*!
       
    44     Destructor.
       
    45  */
       
    46 FtuDateTimeCustomItem::~FtuDateTimeCustomItem()
       
    47 {
       
    48 	// Nothing yet.
       
    49 }
       
    50 
       
    51 /*!
       
    52     Creates the custom item.
       
    53  */
       
    54 HbAbstractViewItem* FtuDateTimeCustomItem::createItem()
       
    55 {
       
    56 	return new FtuDateTimeCustomItem(*this);
       
    57 }
       
    58 
       
    59 /*!
       
    60     Checks if model index can be set or not
       
    61  */
       
    62 bool FtuDateTimeCustomItem::canSetModelIndex(const QModelIndex &index) const
       
    63 {
       
    64 	HbDataFormModelItem::DataItemType itemType = 
       
    65 			static_cast<HbDataFormModelItem::DataItemType>(
       
    66 			index.data(HbDataFormModelItem::ItemTypeRole).toInt());
       
    67 
       
    68 	if(itemType == (HbDataFormModelItem::CustomItemBase)) {
       
    69 		return true;
       
    70 	} else {
       
    71 		return false;
       
    72 	}
       
    73 
       
    74 }
       
    75 
       
    76 /*!
       
    77     
       
    78  */
       
    79 void FtuDateTimeCustomItem::restore()
       
    80 {
       
    81     HbDataFormModelItem::DataItemType itemType =
       
    82             static_cast<HbDataFormModelItem::DataItemType>(
       
    83 				modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
       
    84     if(itemType == (HbDataFormModelItem::CustomItemBase)) {
       
    85     	HbDataFormModel* model = static_cast<HbDataFormModel*>(
       
    86     			static_cast<HbAbstractViewItem*>(this)->itemView()->model());
       
    87     	HbDataFormModelItem* modlItem = model->itemFromIndex(modelIndex()); 
       
    88     	mPushButton->setProperty("text", modlItem->contentWidgetData("text"));
       
    89     }
       
    90 }
       
    91 /*!
       
    92     Creates and returns the custom item.
       
    93  */
       
    94 HbWidget* FtuDateTimeCustomItem::createCustomWidget()
       
    95 {
       
    96 	/*HbPushButton* pushButton = new HbPushButton(this);
       
    97 	return pushButton;*/
       
    98 	mPushButton = new HbPushButton(this);
       
    99 	return mPushButton;
       
   100 }
       
   101 
       
   102 // End of file  --Don't remove this.