57
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-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: BTUISearchListViewItem implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "btcpuimaingridviewitem.h"
|
|
20 |
#include "btdevicemodel.h"
|
|
21 |
#include "btuiiconutil.h"
|
|
22 |
#include <QGraphicsGridLayout>
|
|
23 |
#include <hbstyle.h>
|
|
24 |
#include <bluetoothuitrace.h>
|
|
25 |
|
|
26 |
BtCpUiMainGridViewItem::BtCpUiMainGridViewItem(QGraphicsItem * parent) :
|
|
27 |
HbGridViewItem(parent)
|
|
28 |
{
|
|
29 |
BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
|
|
30 |
mDeviceNameLabel = 0;
|
|
31 |
mDevTypeIconLabel = 0;
|
|
32 |
mDevTypeTextLabel = 0;
|
|
33 |
mBtuiModelSortFilter = ((BtCpUiMainGridViewItem *)parent)->mBtuiModelSortFilter;
|
|
34 |
BOstraceFunctionExit0(DUMMY_DEVLIST);
|
|
35 |
}
|
|
36 |
|
|
37 |
BtCpUiMainGridViewItem::~BtCpUiMainGridViewItem()
|
|
38 |
{
|
|
39 |
BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
|
|
40 |
BOstraceFunctionExit0(DUMMY_DEVLIST);
|
|
41 |
}
|
|
42 |
|
|
43 |
/*
|
|
44 |
* This method is called by the HbListView when it needs a new
|
|
45 |
* view item element.
|
|
46 |
*
|
|
47 |
*/
|
|
48 |
HbAbstractViewItem * BtCpUiMainGridViewItem::createItem()
|
|
49 |
{
|
|
50 |
BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
|
|
51 |
HbAbstractViewItem *item = new BtCpUiMainGridViewItem(*this);
|
|
52 |
BOstraceFunctionExitExt(DUMMY_DEVLIST, this, item);
|
|
53 |
return item;
|
|
54 |
}
|
|
55 |
|
|
56 |
/*!
|
|
57 |
UpdateChildItem updates the item graphics.
|
|
58 |
Screen elements are created once if not already done. This may increase the overall memory
|
|
59 |
consumption of the application, however, this is deemed inconsequential. There might be a small
|
|
60 |
performance improvement with current style.
|
|
61 |
*/
|
|
62 |
void BtCpUiMainGridViewItem::updateChildItems()
|
|
63 |
{
|
|
64 |
BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
|
|
65 |
QModelIndex index;
|
|
66 |
|
|
67 |
// Get device name from model
|
|
68 |
if (mBtuiModelSortFilter)
|
|
69 |
index = mBtuiModelSortFilter->mapToSource(modelIndex());
|
|
70 |
else
|
|
71 |
index = modelIndex();
|
|
72 |
|
|
73 |
// create new icon label if needed
|
|
74 |
if (!mDevTypeIconLabel) {
|
|
75 |
mDevTypeIconLabel = new HbLabel(this);
|
|
76 |
HbStyle::setItemName(mDevTypeIconLabel, "deviceIcon");
|
|
77 |
}
|
|
78 |
|
|
79 |
// create new label if needed
|
|
80 |
if (!mDeviceNameLabel) {
|
|
81 |
mDeviceNameLabel = new HbLabel(this);
|
|
82 |
HbStyle::setItemName(mDeviceNameLabel, "deviceName");
|
|
83 |
}
|
|
84 |
|
|
85 |
// create new label if needed
|
|
86 |
if (!mDevTypeTextLabel) {
|
|
87 |
mDevTypeTextLabel = new HbLabel(this);
|
|
88 |
HbStyle::setItemName(mDevTypeTextLabel, "deviceType");
|
|
89 |
}
|
|
90 |
|
|
91 |
QString data = index.data(Qt::DisplayRole).toString();
|
|
92 |
int cod = (index.data(BtDeviceModel::CoDRole)).toInt();
|
|
93 |
int majorProperty = (index.data(BtDeviceModel::MajorPropertyRole)).toInt();
|
|
94 |
|
|
95 |
mDeviceNameLabel->setPlainText(data);
|
|
96 |
mDevTypeTextLabel->setPlainText( getDeviceTypeString( cod ));
|
|
97 |
|
|
98 |
HbIcon icon =
|
|
99 |
getBadgedDeviceTypeIcon( cod, majorProperty,
|
|
100 |
BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight );
|
|
101 |
mDevTypeIconLabel->setIcon(icon);
|
|
102 |
BOstraceFunctionExit0(DUMMY_DEVLIST);
|
|
103 |
}
|
|
104 |
|
|
105 |
|
|
106 |
void BtCpUiMainGridViewItem::setModelSortFilter(BtuiModelSortFilter *filter)
|
|
107 |
{
|
|
108 |
mBtuiModelSortFilter = filter;
|
|
109 |
}
|