99
|
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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include "tstasksgriditem.h"
|
|
18 |
|
|
19 |
#include <HbPushButton>
|
|
20 |
#include <HbAbstractItemView>
|
|
21 |
#include <HbFrameItem>
|
|
22 |
#include <HbTextItem>
|
|
23 |
#include <HbIconItem>
|
|
24 |
#include <HbStyleLoader>
|
|
25 |
|
|
26 |
#include "tsdataroles.h"
|
|
27 |
|
|
28 |
/*!
|
|
29 |
\class TsTasksGridItem
|
|
30 |
\ingroup group_tsdevicedialogplugin
|
|
31 |
\brief Item that should be presented in grid.
|
|
32 |
*/
|
|
33 |
|
|
34 |
|
|
35 |
TsTasksGridItem::TsTasksGridItem() : HbAbstractViewItem(), mScreenshotLabel(0), mApplicationNameLabel(0), mDeleteButton(0), mActiveLabelFrame(0), mActiveLabel(0)
|
|
36 |
{
|
|
37 |
// Register the custom docml and css to provide our own style to the list items
|
|
38 |
bool widgetmlLoaded = HbStyleLoader::registerFilePath(":/resource/tstasksgriditem.widgetml");
|
|
39 |
Q_ASSERT(widgetmlLoaded);
|
|
40 |
bool cssLoaded = HbStyleLoader::registerFilePath(":/resource/tstasksgriditem.css");
|
|
41 |
Q_ASSERT(cssLoaded);
|
|
42 |
}
|
|
43 |
|
|
44 |
TsTasksGridItem::TsTasksGridItem(const TsTasksGridItem &item) : HbAbstractViewItem(item)
|
|
45 |
{
|
|
46 |
mScreenshotLabel = new HbIconItem(this);
|
|
47 |
mApplicationNameLabel = new HbTextItem(this);
|
|
48 |
mDeleteButton = new HbPushButton(this);
|
|
49 |
HbFrameItem *screenshotFrame = new HbFrameItem(this);
|
|
50 |
screenshotFrame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
|
|
51 |
screenshotFrame->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
|
|
52 |
|
|
53 |
HbFrameItem *applicationLabelFrame = new HbFrameItem(this);
|
|
54 |
applicationLabelFrame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
|
|
55 |
applicationLabelFrame->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
|
|
56 |
|
102
|
57 |
mActiveLabel = new HbTextItem(hbTrId("txt_ts_label_active"), this);
|
99
|
58 |
mActiveLabelFrame = new HbFrameItem(this);
|
|
59 |
mActiveLabelFrame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
|
|
60 |
mActiveLabelFrame->frameDrawer().setFrameGraphicsName("qtg_fr_multimedia_trans");
|
|
61 |
|
|
62 |
mDeleteButton->setIcon(HbIcon("qtg_mono_exit"));
|
|
63 |
|
|
64 |
HbStyle::setItemName(mScreenshotLabel, "screenshot");
|
|
65 |
HbStyle::setItemName(mApplicationNameLabel, "appname");
|
|
66 |
HbStyle::setItemName(mDeleteButton, "closebadge");
|
|
67 |
mDeleteButton->setObjectName("closebadge");
|
|
68 |
HbStyle::setItemName(screenshotFrame, "screenshotFrame");
|
|
69 |
HbStyle::setItemName(applicationLabelFrame, "applicationLabelFrame");
|
|
70 |
HbStyle::setItemName(mActiveLabel, "activeLabel");
|
|
71 |
HbStyle::setItemName(mActiveLabelFrame, "activeLabelFrame");
|
|
72 |
connect(mDeleteButton, SIGNAL(clicked()), this, SLOT(handleDeleteClicked()));
|
|
73 |
}
|
|
74 |
|
|
75 |
HbAbstractViewItem *TsTasksGridItem::createItem()
|
|
76 |
{
|
|
77 |
TsTasksGridItem *newItem = new TsTasksGridItem(*this);
|
|
78 |
connect(newItem, SIGNAL(deleteClicked(QModelIndex)), itemView(), SIGNAL(deleteButtonClicked(QModelIndex)));
|
|
79 |
return newItem;
|
|
80 |
}
|
|
81 |
|
|
82 |
void TsTasksGridItem::handleDeleteClicked()
|
|
83 |
{
|
|
84 |
emit deleteClicked(modelIndex());
|
|
85 |
}
|
|
86 |
|
|
87 |
void TsTasksGridItem::updateChildItems()
|
|
88 |
{
|
|
89 |
mScreenshotLabel->setIcon(modelIndex().data(Qt::DecorationRole).value<HbIcon>());
|
|
90 |
mApplicationNameLabel->setText(modelIndex().data(Qt::DisplayRole).toString());
|
102
|
91 |
|
|
92 |
QVariant closableData(modelIndex().data(TsDataRoles::Closable));
|
|
93 |
const bool isClosable(closableData.isValid() && closableData.toBool());
|
99
|
94 |
if (isClosable) {
|
|
95 |
mDeleteButton->show();
|
102
|
96 |
} else {
|
|
97 |
mDeleteButton->hide();
|
|
98 |
}
|
|
99 |
|
|
100 |
QVariant activeData(modelIndex().data(TsDataRoles::Active));
|
|
101 |
const bool isActive(activeData.isValid() && activeData.toBool());
|
|
102 |
if (isActive) {
|
99
|
103 |
mActiveLabel->show();
|
|
104 |
mActiveLabelFrame->show();
|
|
105 |
} else {
|
|
106 |
mActiveLabel->hide();
|
|
107 |
mActiveLabelFrame->hide();
|
|
108 |
}
|
|
109 |
}
|