|
1 /* |
|
2 * Copyright (c) 2009 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: hsmenuitemmodel.cpp |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "hsmenuitemmodel.h" |
|
19 #include "hsmenuserviceutils.h" |
|
20 |
|
21 // Constants |
|
22 const QSize smallIconSize(55, 55); |
|
23 |
|
24 /*! |
|
25 Constructor |
|
26 \param query used to create model |
|
27 \param pointer to parent object |
|
28 */ |
|
29 HsMenuItemModel::HsMenuItemModel(const CaQuery &query, QObject *parent) : |
|
30 CaItemModel(query, parent) |
|
31 { |
|
32 setIconSize(smallIconSize); |
|
33 } |
|
34 |
|
35 /*! |
|
36 Destructor |
|
37 */ |
|
38 HsMenuItemModel::~HsMenuItemModel() |
|
39 { |
|
40 |
|
41 } |
|
42 |
|
43 /*! |
|
44 Sets sort order in the model |
|
45 */ |
|
46 void HsMenuItemModel::setSort( |
|
47 HsSortAttribute sortAttribute) |
|
48 { |
|
49 HSMENUTEST_FUNC_ENTRY("HsMenuItemModel::setSort"); |
|
50 CaItemModel::setSort(HsMenuServiceUtils::sortBy(sortAttribute), |
|
51 HsMenuServiceUtils::sortOrder(sortAttribute)); |
|
52 HSMENUTEST_FUNC_EXIT(" HsMenuItemModel::setSort"); |
|
53 } |
|
54 |
|
55 /*! |
|
56 Returns data of particular collection |
|
57 \param index |
|
58 \param role |
|
59 \retval |
|
60 */ |
|
61 QVariant HsMenuItemModel::data(const QModelIndex &index, |
|
62 int role) const |
|
63 { |
|
64 HSMENUTEST_FUNC_ENTRY("HsMenuItemModel::data"); |
|
65 QVariant variant; |
|
66 |
|
67 if (role == Qt::DecorationRole && secondLineVisibility() |
|
68 && newIconNeeded(index)) { |
|
69 QList<QVariant> icons; |
|
70 |
|
71 icons << CaItemModel::data(index, role); |
|
72 icons << HbIcon(newIconId()); |
|
73 |
|
74 variant = QVariant(icons); |
|
75 } else { |
|
76 variant = CaItemModel::data(index, role); |
|
77 } |
|
78 HSMENUTEST_FUNC_EXIT("HsMenuItemModel::data"); |
|
79 return variant; |
|
80 |
|
81 } |
|
82 |
|
83 /*! |
|
84 Checks if blink icon needed for entry |
|
85 \param entry entry representing an item |
|
86 \retval decision |
|
87 */ |
|
88 bool HsMenuItemModel::newIconNeeded(const QModelIndex &index) const |
|
89 { |
|
90 HSMENUTEST_FUNC_ENTRY("HsMenuItemModel::newIconNeeded"); |
|
91 bool result = false; |
|
92 if (root().isValid() |
|
93 && (!(entry(index)->flags() & UsedEntryFlag)) |
|
94 && entry(root())->entryTypeName() == collectionDownloadedTypeName()) { |
|
95 result = true; |
|
96 } |
|
97 HSMENUTEST_FUNC_EXIT("HsMenuItemModel::newIconNeeded"); |
|
98 return result; |
|
99 } |