phonebookui/cntcommonui/contacteditors/cntnoteeditorviewitem.cpp
changeset 81 640d30f4fb64
parent 72 6abfb1094884
equal deleted inserted replaced
77:c18f9fa7f42e 81:640d30f4fb64
    17 #include "cntnoteeditorviewitem.h"
    17 #include "cntnoteeditorviewitem.h"
    18 #include "cntdetailconst.h"
    18 #include "cntdetailconst.h"
    19 #include "cntdetailmodelitem.h"
    19 #include "cntdetailmodelitem.h"
    20 #include <hbdataformmodel.h>
    20 #include <hbdataformmodel.h>
    21 #include <hbabstractitemview.h>
    21 #include <hbabstractitemview.h>
    22 #include <hblabel.h>
    22 #include <hblineedit.h>
    23 #include <hbmainwindow.h>
    23 #include <hbwidget.h>
    24 #include <qcontactnote.h>
    24 #include <qcontactnote.h>
    25 #include <QGraphicsLinearLayout>
    25 #include <QGraphicsLinearLayout>
    26 
    26 
    27 CntNoteEditorViewItem::CntNoteEditorViewItem( QGraphicsItem* aParent ) :
    27 CntNoteEditorViewItem::CntNoteEditorViewItem( QGraphicsItem* aParent ) :
    28 CntDetailViewItem(aParent),
    28     CntDetailViewItem(aParent),
    29 mEdit(NULL),
    29     mEdit(NULL),
    30 mLayout(NULL)
    30     mLayout(NULL)
    31     {
    31 {
    32     }
    32     
       
    33 }
    33 
    34 
    34 CntNoteEditorViewItem::~CntNoteEditorViewItem()
    35 CntNoteEditorViewItem::~CntNoteEditorViewItem()
    35     {
    36 {
    36     }
       
    37     
    37     
       
    38 }
       
    39 
    38 HbAbstractViewItem* CntNoteEditorViewItem::createItem()
    40 HbAbstractViewItem* CntNoteEditorViewItem::createItem()
    39     {
    41 {
    40     return new CntNoteEditorViewItem( *this );
    42     return new CntNoteEditorViewItem( *this );
    41     }
    43 }
    42 
    44 
    43 void CntNoteEditorViewItem::textChanged(const QString& aText)
    45 void CntNoteEditorViewItem::textChanged(const QString& aText)
    44     {
    46 {
    45     HbDataFormModel* model = static_cast<HbDataFormModel*>(itemView()->model());
    47     HbDataFormModel* model = static_cast<HbDataFormModel*>(itemView()->model());
    46     CntDetailModelItem* item = static_cast<CntDetailModelItem*>( model->itemFromIndex(modelIndex()) );
    48     CntDetailModelItem* item = static_cast<CntDetailModelItem*>( model->itemFromIndex(modelIndex()) );
    47     QContactNote detail = item->detail();
    49     QContactNote detail = item->detail();
    48     detail.setNote( aText );
    50     detail.setNote( aText );
    49     item->setDetail( detail );
    51     item->setDetail( detail );
    50     }
    52 }
    51 
    53 
    52 HbWidget* CntNoteEditorViewItem::createCustomWidget()
    54 HbWidget* CntNoteEditorViewItem::createCustomWidget()
    53     {
    55 {
    54     HbDataFormModel* model = static_cast<HbDataFormModel*>(itemView()->model());
    56     HbDataFormModel* model = static_cast<HbDataFormModel*>(itemView()->model());
    55     CntDetailModelItem* item = static_cast<CntDetailModelItem*>( model->itemFromIndex(modelIndex()) );
    57     CntDetailModelItem* item = static_cast<CntDetailModelItem*>( model->itemFromIndex(modelIndex()) );
    56     QContactNote detail = item->detail();
    58     QContactNote detail = item->detail();
    57 
    59 
    58     mLayout = new QGraphicsLinearLayout(Qt::Vertical);
    60     mLayout = new QGraphicsLinearLayout(Qt::Vertical);
       
    61     mLayout->setContentsMargins(0, 0, 0, 0);
    59     HbWidget* widget = new HbWidget();
    62     HbWidget* widget = new HbWidget();
    60     
    63 
    61     mEdit = new HbLineEdit();
    64     mEdit = new HbLineEdit();
    62     mEdit->setInputMethodHints(Qt::ImhNoPredictiveText);
    65     mEdit->setInputMethodHints(Qt::ImhNoPredictiveText);
    63     
    66 
    64     mEdit->setMaxLength( CNT_NOTE_EDITOR_MAXLENGTH );
    67     mEdit->setMaxLength( CNT_NOTE_EDITOR_MAXLENGTH );
    65     mEdit->setMinRows( CNT_NOTE_EDITOR_MIN_ROWCOUNT );
    68     mEdit->setMinRows( CNT_NOTE_EDITOR_MIN_ROWCOUNT );
    66     mEdit->setText( detail.note() );
    69     mEdit->setText( detail.note() );
    67 
    70 
    68     HbLabel* label = new HbLabel(hbTrId("txt_phob_formlabel_note"));
       
    69     mLayout->addItem(label);
       
    70     mLayout->addItem(mEdit);
    71     mLayout->addItem(mEdit);
    71     widget->setLayout( mLayout );
    72     widget->setLayout( mLayout );
    72     
    73 
    73     connect( mEdit, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)) );
    74     connect( mEdit, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)) );
    74     
    75 
    75     // Naming UI components for automation testability
    76     // Naming UI components for automation testability
    76     QString editorObjName = detail.definitionName() + " line edit %1";
    77     QString editorObjName = detail.definitionName() + " line edit %1";
    77     mEdit->setObjectName(editorObjName.arg(modelIndex().row()));
    78     mEdit->setObjectName(editorObjName.arg(modelIndex().row()));
    78     return widget;
    79     return widget;
    79     }
    80 }
    80 // End of File
    81 // End of File