clock/clockui/clockalarmeditor/src/clockalarmcustomitem.cpp
changeset 18 c198609911f9
child 55 2c54b51f39c4
child 58 ef813d54df51
equal deleted inserted replaced
0:f979ecb2b13e 18:c198609911f9
       
     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 * Implementation for the ClockAlarmCustomItem class.
       
    16 *
       
    17 */
       
    18 
       
    19 // System includes.
       
    20 #include <HbPushButton>
       
    21 #include <HbDataFormModelItem>
       
    22 #include <HbAbstractItemView>
       
    23 #include <HbDataFormModel>
       
    24 
       
    25 // User includes.
       
    26 #include "clockalarmcustomitem.h"
       
    27 
       
    28 /*!
       
    29 	\class ClockAlarmCustomItem
       
    30 
       
    31 	This class is responsible for creating customitem for Alarm Time field in
       
    32 	Alarmeditor.
       
    33  */
       
    34 
       
    35 /*!
       
    36 	Default Constructor.
       
    37 
       
    38 	\param parent The parent.
       
    39  */
       
    40 ClockAlarmCustomItem::ClockAlarmCustomItem(QGraphicsItem *parent)
       
    41 :HbDataFormViewItem(parent)
       
    42 {
       
    43 	// Nothing yet.
       
    44 }
       
    45 
       
    46 /*!
       
    47 	Destructor.
       
    48  */
       
    49 ClockAlarmCustomItem::~ClockAlarmCustomItem()
       
    50 {
       
    51 	// Nothing yet.
       
    52 }
       
    53 
       
    54 /*!
       
    55 	Creates customitem.
       
    56 
       
    57 	\sa
       
    58  */
       
    59 HbAbstractViewItem* ClockAlarmCustomItem::createItem()
       
    60 {
       
    61 	return new ClockAlarmCustomItem(*this);
       
    62 }
       
    63 
       
    64 /*!
       
    65 	
       
    66 	\sa
       
    67  */
       
    68 bool ClockAlarmCustomItem::canSetModelIndex(const QModelIndex &index) const
       
    69 {
       
    70 	HbDataFormModelItem::DataItemType itemType = 
       
    71 			static_cast<HbDataFormModelItem::DataItemType>(
       
    72 			index.data(HbDataFormModelItem::ItemTypeRole).toInt());
       
    73 
       
    74 	if(itemType == (HbDataFormModelItem::CustomItemBase)) {
       
    75 		return true;
       
    76 	} else {
       
    77 		return false;
       
    78 	}
       
    79 
       
    80 }
       
    81 
       
    82 void ClockAlarmCustomItem::restore()
       
    83 {
       
    84 	HbDataFormModelItem::DataItemType itemType =
       
    85 			static_cast<HbDataFormModelItem::DataItemType>(
       
    86 			modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
       
    87 	if(itemType == (HbDataFormModelItem::CustomItemBase)) {
       
    88 
       
    89 		HbDataFormModel* model =
       
    90 				static_cast<HbDataFormModel*>(
       
    91 				static_cast<HbAbstractViewItem*>(this)->itemView()->model());
       
    92 		HbDataFormModelItem* modlItem = model->itemFromIndex(modelIndex()); 
       
    93 		mCustomButton->setProperty("text", modlItem->contentWidgetData("text"));
       
    94 	}
       
    95 
       
    96 }
       
    97 
       
    98 /*!
       
    99 	Creates the custom widget
       
   100 
       
   101 	\sa
       
   102  */
       
   103 HbWidget* ClockAlarmCustomItem::createCustomWidget()
       
   104 {
       
   105 	mCustomButton = new HbPushButton(this);
       
   106 	return mCustomButton;
       
   107 }
       
   108 
       
   109 // End of file	--Don't remove this.