bluetoothengine/btui/btcpplugin/btcpuidevicedetailsview.cpp
changeset 41 0b2439c3e397
child 47 9e2a905b887f
equal deleted inserted replaced
40:997690c3397a 41:0b2439c3e397
       
     1 /*
       
     2 * Copyright (c) 2010 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:  BtCpUiDeviceDetailsView implementation
       
    15 *
       
    16 */
       
    17 #include <QtGlobal>
       
    18 #include <QGraphicsLinearLayout>
       
    19 #include <HbInstance>
       
    20 #include <hblabel.h>
       
    21 #include <hbmenu.h>
       
    22 #include <hbaction.h>
       
    23 #include <hbcombobox.h>
       
    24 #include <hbgroupbox.h>
       
    25 #include <bluetoothuitrace.h>
       
    26 #include "btcpuidevicedetailsview.h"
       
    27 
       
    28 // docml to load
       
    29 const char* BTUI_DEVICEDETAILSVIEW_DOCML = ":/docml/bt-device-details-view.docml";
       
    30 
       
    31 BtCpUiDeviceDetailsView::BtCpUiDeviceDetailsView(QGraphicsItem *parent)
       
    32     :CpBaseSettingView( 0 , parent )
       
    33 {
       
    34    
       
    35     mSoftKeyBackAction = new HbAction(Hb::BackNaviAction, this);
       
    36     BTUI_ASSERT_X(mSoftKeyBackAction, "BtCpUiBaseView::BtCpUiBaseView", "can't create back action");
       
    37 
       
    38     // Create view for the application.
       
    39     // Set the name for the view. The name should be same as the view's
       
    40     // name in docml.
       
    41     setObjectName("bt_device_details_view");
       
    42 
       
    43     mLoader = new HbDocumentLoader();
       
    44     // Pass the view to documentloader. Document loader uses this view
       
    45     // when docml is parsed, instead of creating new view.
       
    46     QObjectList objectList;
       
    47     objectList.append(this);
       
    48     mLoader->setObjectTree(objectList);
       
    49 
       
    50     // read view info from docml file
       
    51     bool ok = false;
       
    52     mLoader->load( BTUI_DEVICEDETAILSVIEW_DOCML, &ok );
       
    53     // Exit if the file format is invalid
       
    54     BTUI_ASSERT_X( ok, "bt-device-details-view", "Invalid docml file" );
       
    55     
       
    56     mLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
       
    57     mGroupBox = new HbGroupBox();
       
    58     mLayout->addItem(mGroupBox);
       
    59     
       
    60     setLayout( mLayout );
       
    61 
       
    62 }
       
    63 
       
    64 BtCpUiDeviceDetailsView::~BtCpUiDeviceDetailsView()
       
    65 {
       
    66 
       
    67 }
       
    68 
       
    69 void BtCpUiDeviceDetailsView::setDeviceName(const QString &deviceName)
       
    70 {
       
    71     //todo: use Localised string Id.
       
    72     QString heading(hbTrId("%1 details"));
       
    73     
       
    74     if(mGroupBox) {
       
    75         mGroupBox->setHeading(heading.arg(deviceName));
       
    76     }
       
    77 }
       
    78 
       
    79 void BtCpUiDeviceDetailsView::addItem(HbDataForm *item)
       
    80 {
       
    81     if (item && mLayout) {
       
    82         mLayout->addItem(item);
       
    83     }    
       
    84 }
       
    85 
       
    86 void BtCpUiDeviceDetailsView::removeItem(HbDataForm *item)
       
    87 {
       
    88     if (item && mLayout) {
       
    89         //todo: with out this item is not removed from the view.
       
    90         item->setVisible(false);
       
    91         mLayout->removeItem(item);
       
    92     }
       
    93 }
       
    94