42
|
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 |
*/
|
47
|
17 |
#include "btcpuidevicedetailsview.h"
|
67
|
18 |
#include <hbdataform.h>
|
42
|
19 |
#include <hbaction.h>
|
|
20 |
#include <bluetoothuitrace.h>
|
67
|
21 |
#include <HbParameterLengthLimiter>
|
42
|
22 |
|
|
23 |
// docml to load
|
|
24 |
const char* BTUI_DEVICEDETAILSVIEW_DOCML = ":/docml/bt-device-details-view.docml";
|
|
25 |
|
|
26 |
BtCpUiDeviceDetailsView::BtCpUiDeviceDetailsView(QGraphicsItem *parent)
|
|
27 |
:CpBaseSettingView( 0 , parent )
|
|
28 |
{
|
|
29 |
|
|
30 |
mSoftKeyBackAction = new HbAction(Hb::BackNaviAction, this);
|
57
|
31 |
BTUI_ASSERT_X(mSoftKeyBackAction, "BtCpUiDeviceDetailsView::BtCpUiDeviceDetailsView", "can't create back action");
|
42
|
32 |
|
|
33 |
// Create view for the application.
|
|
34 |
// Set the name for the view. The name should be same as the view's
|
|
35 |
// name in docml.
|
|
36 |
setObjectName("bt_device_details_view");
|
|
37 |
|
|
38 |
mLoader = new HbDocumentLoader();
|
|
39 |
// Pass the view to documentloader. Document loader uses this view
|
|
40 |
// when docml is parsed, instead of creating new view.
|
|
41 |
QObjectList objectList;
|
|
42 |
objectList.append(this);
|
|
43 |
mLoader->setObjectTree(objectList);
|
|
44 |
|
|
45 |
// read view info from docml file
|
|
46 |
bool ok = false;
|
|
47 |
mLoader->load( BTUI_DEVICEDETAILSVIEW_DOCML, &ok );
|
|
48 |
// Exit if the file format is invalid
|
|
49 |
BTUI_ASSERT_X( ok, "bt-device-details-view", "Invalid docml file" );
|
|
50 |
|
|
51 |
mLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
|
|
52 |
mGroupBox = new HbGroupBox();
|
|
53 |
mLayout->addItem(mGroupBox);
|
|
54 |
|
|
55 |
setLayout( mLayout );
|
|
56 |
|
|
57 |
}
|
|
58 |
|
|
59 |
BtCpUiDeviceDetailsView::~BtCpUiDeviceDetailsView()
|
|
60 |
{
|
|
61 |
|
|
62 |
}
|
|
63 |
|
|
64 |
void BtCpUiDeviceDetailsView::setDeviceName(const QString &deviceName)
|
|
65 |
{
|
57
|
66 |
BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
|
42
|
67 |
|
67
|
68 |
if(mGroupBox) {
|
|
69 |
QString heading = HbParameterLengthLimiter(hbTrId(
|
|
70 |
"txt_bt_subhead_1_details")).arg(deviceName);
|
|
71 |
|
|
72 |
mGroupBox->setHeading(heading);
|
42
|
73 |
}
|
57
|
74 |
BOstraceFunctionExit0(DUMMY_DEVLIST);
|
42
|
75 |
}
|
|
76 |
|
|
77 |
void BtCpUiDeviceDetailsView::addItem(HbDataForm *item)
|
|
78 |
{
|
57
|
79 |
BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
|
42
|
80 |
if (item && mLayout) {
|
|
81 |
mLayout->addItem(item);
|
57
|
82 |
}
|
|
83 |
BOstraceFunctionExit0(DUMMY_DEVLIST);
|
42
|
84 |
}
|
|
85 |
|
|
86 |
void BtCpUiDeviceDetailsView::removeItem(HbDataForm *item)
|
|
87 |
{
|
57
|
88 |
BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
|
42
|
89 |
if (item && mLayout) {
|
67
|
90 |
//With out this item is not removed from the view.
|
42
|
91 |
item->setVisible(false);
|
|
92 |
mLayout->removeItem(item);
|
57
|
93 |
delete item;
|
42
|
94 |
}
|
57
|
95 |
BOstraceFunctionExit0(DUMMY_DEVLIST);
|
42
|
96 |
}
|
|
97 |
|
57
|
98 |
void BtCpUiDeviceDetailsView::removeAllItems()
|
|
99 |
{
|
|
100 |
BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
|
|
101 |
if(mLayout) {
|
|
102 |
QGraphicsLayoutItem *item;
|
|
103 |
int count = mLayout->count();
|
|
104 |
for(int i=count-1; i>=0; i--) {
|
|
105 |
item = mLayout->itemAt(i);
|
|
106 |
mLayout->removeItem(item);
|
|
107 |
delete item;
|
|
108 |
}
|
|
109 |
}
|
|
110 |
BOstraceFunctionExit0(DUMMY_DEVLIST);
|
|
111 |
}
|