cpsecplugins/devicelockplugin/src/cpremotelockdataformviewitem.cpp
branchRCL_3
changeset 49 09b1ac925e3f
equal deleted inserted replaced
47:63339781d179 49:09b1ac925e3f
       
     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  *
       
    16  */
       
    17 
       
    18 #include "cpremotelockdataformviewitem.h"
       
    19 #include <hblabel.h>
       
    20 #include <QGraphicsSceneMouseEvent>
       
    21 #include <../../inc/cpsecplugins.h>
       
    22 
       
    23 
       
    24 /*
       
    25  *****************************************************************
       
    26  * Name        : CpRemoteLockDataFormViewItem
       
    27  * Parameters  : QGraphicsItem*
       
    28  * Return value: None
       
    29  * Description : constructor
       
    30  *****************************************************************
       
    31  */
       
    32 CpRemoteLockDataFormViewItem::CpRemoteLockDataFormViewItem(QGraphicsItem *parent )
       
    33 : HbDataFormViewItem(parent)
       
    34 {
       
    35 }
       
    36 
       
    37 
       
    38 /*
       
    39  *****************************************************************
       
    40  * Name        : ~CpRemoteLockDataFormViewItem
       
    41  * Parameters  : None
       
    42  * Return value: None
       
    43  * Description : destructor
       
    44  *****************************************************************
       
    45  */
       
    46 CpRemoteLockDataFormViewItem::~CpRemoteLockDataFormViewItem()
       
    47 {
       
    48 }
       
    49 
       
    50 
       
    51 /*
       
    52  *****************************************************************
       
    53  * Name        : createItem
       
    54  * Parameters  : None
       
    55  * Return value: HbAbstractViewItem*
       
    56  * Description : creates a HbAbstractViewItem
       
    57  *****************************************************************
       
    58  */
       
    59 HbAbstractViewItem* CpRemoteLockDataFormViewItem::createItem()
       
    60 {
       
    61 	RDEBUG("0", 0);
       
    62 	return new CpRemoteLockDataFormViewItem(*this);
       
    63 }
       
    64 
       
    65 
       
    66 /*
       
    67  *****************************************************************
       
    68  * Name        : canSetModelIndex
       
    69  * Parameters  : QModelIndex&
       
    70  * Return value: bool
       
    71  * Description : 
       
    72  *****************************************************************
       
    73  */
       
    74 bool CpRemoteLockDataFormViewItem::canSetModelIndex(const QModelIndex &index) const
       
    75 {
       
    76 	int type = index.data(HbDataFormModelItem::ItemTypeRole).toInt();
       
    77 	RDEBUG("type", type);
       
    78 	return ((type == CpRemoteLockItem) || (type == CpCodeEditItem));
       
    79 }
       
    80 
       
    81 
       
    82 /*
       
    83  *****************************************************************
       
    84  * Name        : createCustomWidget
       
    85  * Parameters  : None
       
    86  * Return value: HbWidget
       
    87  * Description : creates a custom widget
       
    88  *****************************************************************
       
    89  */
       
    90 HbWidget *CpRemoteLockDataFormViewItem::createCustomWidget()
       
    91     {
       
    92     int type = modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt();
       
    93     RDEBUG("type", type);
       
    94     if (type == CpCodeEditItem)
       
    95         {
       
    96         CpLockEdit *edit = new CpLockEdit("1234");
       
    97         edit->setEchoMode(HbLineEdit::Password);
       
    98         edit->setReadOnly(true);
       
    99         return edit;
       
   100         }
       
   101     else
       
   102         {
       
   103         return 0;
       
   104         }
       
   105 }
       
   106 
       
   107 
       
   108 /*
       
   109  *****************************************************************
       
   110  * Name        : CpLockEdit
       
   111  * Parameters  : QString&, QGraphicsitem
       
   112  * Return value: None
       
   113  * Description : constructor
       
   114  *****************************************************************
       
   115  */
       
   116 CpLockEdit::CpLockEdit(const QString &text, QGraphicsItem *parent /*= 0*/)
       
   117 : HbLineEdit(text,parent)
       
   118 {
       
   119 }
       
   120 
       
   121 
       
   122 /*
       
   123  *****************************************************************
       
   124  * Name        : CpLockEdit
       
   125  * Parameters  : None
       
   126  * Return value: None
       
   127  * Description : destructor
       
   128  *****************************************************************
       
   129  */
       
   130 CpLockEdit::~CpLockEdit()
       
   131     {
       
   132     
       
   133     }
       
   134 
       
   135 
       
   136 /*
       
   137  *****************************************************************
       
   138  * Name        : mousePressEvent
       
   139  * Parameters  : QGraphicsSceneMouseEvent*
       
   140  * Return value: None
       
   141  * Description : handles mouse events
       
   142  *****************************************************************
       
   143  */
       
   144 void CpLockEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
       
   145 {
       
   146 		RDEBUG("0", 0);
       
   147     if (event->button() != Qt::LeftButton) {
       
   148         event->ignore();
       
   149         return;
       
   150     }
       
   151 
       
   152     if (rect().contains(event->pos())) {
       
   153         emit clicked();
       
   154         event->accept();
       
   155     }
       
   156     else {
       
   157         event->ignore();
       
   158     } 
       
   159 }