cpsecplugins/devicelockplugin/src/cpremotelockdataformviewitem.cpp
changeset 19 098e361762d2
child 30 cc1cea6aabaf
equal deleted inserted replaced
17:8957df7b0072 19:098e361762d2
       
     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 
       
    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 	return new CpRemoteLockDataFormViewItem(*this);
       
    62 }
       
    63 
       
    64 
       
    65 /*
       
    66  *****************************************************************
       
    67  * Name        : canSetModelIndex
       
    68  * Parameters  : QModelIndex&
       
    69  * Return value: bool
       
    70  * Description : 
       
    71  *****************************************************************
       
    72  */
       
    73 bool CpRemoteLockDataFormViewItem::canSetModelIndex(const QModelIndex &index) const
       
    74 {
       
    75 	int type = index.data(HbDataFormModelItem::ItemTypeRole).toInt();
       
    76 	return ((type == CpRemoteLockItem) || (type == CpCodeEditItem));
       
    77 }
       
    78 
       
    79 
       
    80 /*
       
    81  *****************************************************************
       
    82  * Name        : createCustomWidget
       
    83  * Parameters  : None
       
    84  * Return value: HbWidget
       
    85  * Description : creates a custom widget
       
    86  *****************************************************************
       
    87  */
       
    88 HbWidget *CpRemoteLockDataFormViewItem::createCustomWidget()
       
    89     {
       
    90     int type = modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt();
       
    91     if (type == CpCodeEditItem)
       
    92         {
       
    93         CpLockEdit *edit = new CpLockEdit("1234");
       
    94         edit->setEchoMode(HbLineEdit::Password);
       
    95         edit->setReadOnly(true);
       
    96         return edit;
       
    97         }
       
    98     else
       
    99         {
       
   100         return 0;
       
   101         }
       
   102 }
       
   103 
       
   104 
       
   105 /*
       
   106  *****************************************************************
       
   107  * Name        : CpLockEdit
       
   108  * Parameters  : QString&, QGraphicsitem
       
   109  * Return value: None
       
   110  * Description : constructor
       
   111  *****************************************************************
       
   112  */
       
   113 CpLockEdit::CpLockEdit(const QString &text, QGraphicsItem *parent /*= 0*/)
       
   114 : HbLineEdit(text,parent)
       
   115 {
       
   116 }
       
   117 
       
   118 
       
   119 /*
       
   120  *****************************************************************
       
   121  * Name        : CpLockEdit
       
   122  * Parameters  : None
       
   123  * Return value: None
       
   124  * Description : destructor
       
   125  *****************************************************************
       
   126  */
       
   127 CpLockEdit::~CpLockEdit()
       
   128     {
       
   129     
       
   130     }
       
   131 
       
   132 
       
   133 /*
       
   134  *****************************************************************
       
   135  * Name        : mousePressEvent
       
   136  * Parameters  : QGraphicsSceneMouseEvent*
       
   137  * Return value: None
       
   138  * Description : handles mouse events
       
   139  *****************************************************************
       
   140  */
       
   141 void CpLockEdit::mousePressEvent(QGraphicsSceneMouseEvent *event)
       
   142 {
       
   143     if (event->button() != Qt::LeftButton) {
       
   144         event->ignore();
       
   145         return;
       
   146     }
       
   147 
       
   148     if (rect().contains(event->pos())) {
       
   149         emit clicked();
       
   150         event->accept();
       
   151     }
       
   152     else {
       
   153         event->ignore();
       
   154     } 
       
   155 }