bluetoothengine/btui/btcpplugin/btcpuidevicedetailsview.cpp
author hgs
Wed, 13 Oct 2010 13:15:31 +0300
changeset 67 16e4b9007960
parent 57 5ebadcda06cb
permissions -rw-r--r--
201039_4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:  BtCpUiDeviceDetailsView implementation
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
47
9e2a905b887f 201029_02
hgs
parents: 42
diff changeset
    17
#include "btcpuidevicedetailsview.h"
67
16e4b9007960 201039_4
hgs
parents: 57
diff changeset
    18
#include <hbdataform.h>
42
hgs
parents:
diff changeset
    19
#include <hbaction.h>
hgs
parents:
diff changeset
    20
#include <bluetoothuitrace.h>
67
16e4b9007960 201039_4
hgs
parents: 57
diff changeset
    21
#include <HbParameterLengthLimiter>
42
hgs
parents:
diff changeset
    22
hgs
parents:
diff changeset
    23
// docml to load
hgs
parents:
diff changeset
    24
const char* BTUI_DEVICEDETAILSVIEW_DOCML = ":/docml/bt-device-details-view.docml";
hgs
parents:
diff changeset
    25
hgs
parents:
diff changeset
    26
BtCpUiDeviceDetailsView::BtCpUiDeviceDetailsView(QGraphicsItem *parent)
hgs
parents:
diff changeset
    27
    :CpBaseSettingView( 0 , parent )
hgs
parents:
diff changeset
    28
{
hgs
parents:
diff changeset
    29
   
hgs
parents:
diff changeset
    30
    mSoftKeyBackAction = new HbAction(Hb::BackNaviAction, this);
57
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
    31
    BTUI_ASSERT_X(mSoftKeyBackAction, "BtCpUiDeviceDetailsView::BtCpUiDeviceDetailsView", "can't create back action");
42
hgs
parents:
diff changeset
    32
hgs
parents:
diff changeset
    33
    // Create view for the application.
hgs
parents:
diff changeset
    34
    // Set the name for the view. The name should be same as the view's
hgs
parents:
diff changeset
    35
    // name in docml.
hgs
parents:
diff changeset
    36
    setObjectName("bt_device_details_view");
hgs
parents:
diff changeset
    37
hgs
parents:
diff changeset
    38
    mLoader = new HbDocumentLoader();
hgs
parents:
diff changeset
    39
    // Pass the view to documentloader. Document loader uses this view
hgs
parents:
diff changeset
    40
    // when docml is parsed, instead of creating new view.
hgs
parents:
diff changeset
    41
    QObjectList objectList;
hgs
parents:
diff changeset
    42
    objectList.append(this);
hgs
parents:
diff changeset
    43
    mLoader->setObjectTree(objectList);
hgs
parents:
diff changeset
    44
hgs
parents:
diff changeset
    45
    // read view info from docml file
hgs
parents:
diff changeset
    46
    bool ok = false;
hgs
parents:
diff changeset
    47
    mLoader->load( BTUI_DEVICEDETAILSVIEW_DOCML, &ok );
hgs
parents:
diff changeset
    48
    // Exit if the file format is invalid
hgs
parents:
diff changeset
    49
    BTUI_ASSERT_X( ok, "bt-device-details-view", "Invalid docml file" );
hgs
parents:
diff changeset
    50
    
hgs
parents:
diff changeset
    51
    mLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
hgs
parents:
diff changeset
    52
    mGroupBox = new HbGroupBox();
hgs
parents:
diff changeset
    53
    mLayout->addItem(mGroupBox);
hgs
parents:
diff changeset
    54
    
hgs
parents:
diff changeset
    55
    setLayout( mLayout );
hgs
parents:
diff changeset
    56
hgs
parents:
diff changeset
    57
}
hgs
parents:
diff changeset
    58
hgs
parents:
diff changeset
    59
BtCpUiDeviceDetailsView::~BtCpUiDeviceDetailsView()
hgs
parents:
diff changeset
    60
{
hgs
parents:
diff changeset
    61
hgs
parents:
diff changeset
    62
}
hgs
parents:
diff changeset
    63
hgs
parents:
diff changeset
    64
void BtCpUiDeviceDetailsView::setDeviceName(const QString &deviceName)
hgs
parents:
diff changeset
    65
{
57
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
    66
    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
42
hgs
parents:
diff changeset
    67
    
67
16e4b9007960 201039_4
hgs
parents: 57
diff changeset
    68
    if(mGroupBox) {        
16e4b9007960 201039_4
hgs
parents: 57
diff changeset
    69
        QString heading = HbParameterLengthLimiter(hbTrId(
16e4b9007960 201039_4
hgs
parents: 57
diff changeset
    70
                "txt_bt_subhead_1_details")).arg(deviceName);
16e4b9007960 201039_4
hgs
parents: 57
diff changeset
    71
16e4b9007960 201039_4
hgs
parents: 57
diff changeset
    72
        mGroupBox->setHeading(heading);
42
hgs
parents:
diff changeset
    73
    }
57
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
    74
    BOstraceFunctionExit0(DUMMY_DEVLIST);
42
hgs
parents:
diff changeset
    75
}
hgs
parents:
diff changeset
    76
hgs
parents:
diff changeset
    77
void BtCpUiDeviceDetailsView::addItem(HbDataForm *item)
hgs
parents:
diff changeset
    78
{
57
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
    79
    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
42
hgs
parents:
diff changeset
    80
    if (item && mLayout) {
hgs
parents:
diff changeset
    81
        mLayout->addItem(item);
57
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
    82
    }
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
    83
    BOstraceFunctionExit0(DUMMY_DEVLIST);
42
hgs
parents:
diff changeset
    84
}
hgs
parents:
diff changeset
    85
hgs
parents:
diff changeset
    86
void BtCpUiDeviceDetailsView::removeItem(HbDataForm *item)
hgs
parents:
diff changeset
    87
{
57
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
    88
    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
42
hgs
parents:
diff changeset
    89
    if (item && mLayout) {
67
16e4b9007960 201039_4
hgs
parents: 57
diff changeset
    90
        //With out this item is not removed from the view.
42
hgs
parents:
diff changeset
    91
        item->setVisible(false);
hgs
parents:
diff changeset
    92
        mLayout->removeItem(item);
57
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
    93
        delete item;
42
hgs
parents:
diff changeset
    94
    }
57
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
    95
    BOstraceFunctionExit0(DUMMY_DEVLIST);
42
hgs
parents:
diff changeset
    96
}
hgs
parents:
diff changeset
    97
57
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
    98
void BtCpUiDeviceDetailsView::removeAllItems()
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
    99
{
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
   100
    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
   101
    if(mLayout) {
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
   102
        QGraphicsLayoutItem *item;
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
   103
        int count = mLayout->count();
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
   104
        for(int i=count-1; i>=0; i--) {
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
   105
            item = mLayout->itemAt(i);
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
   106
            mLayout->removeItem(item);
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
   107
            delete item;
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
   108
        }
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
   109
    }
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
   110
    BOstraceFunctionExit0(DUMMY_DEVLIST);
5ebadcda06cb 201035_7
hgs
parents: 47
diff changeset
   111
}