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