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 |
*
|
107
|
14 |
* Description:
|
99
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <QAbstractListModel>
|
|
19 |
#include <HbDialog>
|
|
20 |
#include <HbMainWindow>
|
107
|
21 |
#include <HbLabel>
|
99
|
22 |
#include <tspropertydefs.h>
|
|
23 |
|
107
|
24 |
#include "tsdevicedialogcontainer.h"
|
99
|
25 |
#include "tstasksgrid.h"
|
|
26 |
#include "tstasksgriditem.h"
|
|
27 |
|
|
28 |
namespace {
|
|
29 |
const char KDocmlPath[] = ":/resource/layout.docml";
|
|
30 |
}
|
|
31 |
|
107
|
32 |
TsDeviceDialogContainer::TsDeviceDialogContainer(QAbstractListModel *model,
|
|
33 |
QObject *parent)
|
|
34 |
:
|
|
35 |
QObject(parent),
|
|
36 |
mVisibilityPublisher(TsProperty::KTsPath)
|
99
|
37 |
{
|
|
38 |
bool ok(true);
|
|
39 |
mLoader.load(KDocmlPath, &ok);
|
|
40 |
Q_ASSERT(ok);
|
|
41 |
|
107
|
42 |
HbDialog *dialog =
|
|
43 |
qobject_cast<HbDialog*>(mLoader.findWidget("tsdevicedialog"));
|
|
44 |
TsTasksGrid *grid =
|
|
45 |
qobject_cast<TsTasksGrid *>(mLoader.findWidget("taskgrid"));
|
99
|
46 |
Q_ASSERT(dialog);
|
|
47 |
Q_ASSERT(grid);
|
|
48 |
|
107
|
49 |
grid->setModel(model);
|
99
|
50 |
|
107
|
51 |
changeOrientation(dialog->mainWindow()->orientation());
|
|
52 |
switchViewOnModelChange();
|
99
|
53 |
|
|
54 |
// needed because of Qt::QueuedConnection used below
|
|
55 |
// @todo: check if we actually need queued connections
|
|
56 |
qRegisterMetaType<QModelIndex>("QModelIndex");
|
|
57 |
|
|
58 |
// connect the grid and model
|
107
|
59 |
connect(grid,
|
|
60 |
SIGNAL(activated(QModelIndex)),
|
|
61 |
model,
|
|
62 |
SLOT(openApplication(QModelIndex)));
|
|
63 |
connect(grid,
|
|
64 |
SIGNAL(activated(QModelIndex)),
|
|
65 |
dialog,
|
|
66 |
SLOT(close()));
|
|
67 |
connect(grid,
|
|
68 |
SIGNAL(deleteButtonClicked(QModelIndex)),
|
|
69 |
model, SLOT(closeApplication(QModelIndex)),
|
|
70 |
Qt::QueuedConnection);
|
99
|
71 |
|
107
|
72 |
connect(dialog->mainWindow(),
|
|
73 |
SIGNAL(orientationChanged(Qt::Orientation)),
|
|
74 |
this,
|
|
75 |
SLOT(changeOrientation(Qt::Orientation)));
|
|
76 |
connect(dialog,
|
|
77 |
SIGNAL(aboutToClose()),
|
|
78 |
this,
|
|
79 |
SIGNAL(deviceDialogClosed()));
|
99
|
80 |
|
107
|
81 |
// note: connect to more signals when partial model updates are implemented
|
|
82 |
connect(model,
|
|
83 |
SIGNAL(modelReset()),
|
|
84 |
this,
|
|
85 |
SLOT(switchViewOnModelChange()));
|
|
86 |
|
|
87 |
connect(this,
|
|
88 |
SIGNAL(deviceDialogClosed()),
|
|
89 |
this,
|
|
90 |
SLOT(notifyDialogClosed()));
|
|
91 |
mVisibilityPublisher.setValue(TsProperty::KVisibilityPath,
|
|
92 |
static_cast<int>(true));
|
99
|
93 |
mVisibilityPublisher.sync();
|
|
94 |
}
|
|
95 |
|
107
|
96 |
TsDeviceDialogContainer::~TsDeviceDialogContainer()
|
|
97 |
{
|
99
|
98 |
delete deviceDialogWidget();
|
|
99 |
}
|
|
100 |
|
107
|
101 |
bool TsDeviceDialogContainer::setDeviceDialogParameters(
|
|
102 |
const QVariantMap ¶meters)
|
99
|
103 |
{
|
|
104 |
Q_UNUSED(parameters);
|
|
105 |
return false;
|
|
106 |
}
|
|
107 |
|
|
108 |
int TsDeviceDialogContainer::deviceDialogError() const
|
|
109 |
{
|
|
110 |
return 0;
|
|
111 |
}
|
|
112 |
|
|
113 |
void TsDeviceDialogContainer::closeDeviceDialog(bool byClient)
|
|
114 |
{
|
|
115 |
Q_UNUSED(byClient)
|
|
116 |
// @todo: should there be hide calls? deviceDialogWidget->hide();
|
|
117 |
emit deviceDialogClosed();
|
|
118 |
}
|
|
119 |
|
|
120 |
HbPopup *TsDeviceDialogContainer::deviceDialogWidget() const
|
|
121 |
{
|
107
|
122 |
HbDialog *widget =
|
|
123 |
qobject_cast<HbDialog*>(mLoader.findWidget("tsdevicedialog"));
|
99
|
124 |
Q_ASSERT(widget);
|
|
125 |
return widget;
|
|
126 |
}
|
|
127 |
|
|
128 |
QObject *TsDeviceDialogContainer::signalSender() const
|
|
129 |
{
|
|
130 |
return const_cast<TsDeviceDialogContainer*>(this);
|
|
131 |
}
|
|
132 |
|
|
133 |
void TsDeviceDialogContainer::changeOrientation(Qt::Orientation orientation)
|
|
134 |
{
|
|
135 |
bool ok(true);
|
|
136 |
if (orientation == Qt::Horizontal) {
|
|
137 |
mLoader.load(KDocmlPath, "landscape", &ok);
|
|
138 |
} else {
|
|
139 |
mLoader.load(KDocmlPath, "portrait", &ok);
|
|
140 |
}
|
|
141 |
Q_ASSERT(ok);
|
|
142 |
}
|
|
143 |
|
|
144 |
void TsDeviceDialogContainer::notifyDialogClosed()
|
|
145 |
{
|
107
|
146 |
mVisibilityPublisher.setValue(TsProperty::KVisibilityPath,
|
|
147 |
static_cast<int>(false));
|
99
|
148 |
mVisibilityPublisher.sync();
|
|
149 |
}
|
107
|
150 |
|
|
151 |
void TsDeviceDialogContainer::switchViewOnModelChange()
|
|
152 |
{
|
|
153 |
TsTasksGrid *grid =
|
|
154 |
qobject_cast<TsTasksGrid *>(mLoader.findWidget("taskgrid"));
|
|
155 |
HbLabel *noItemsLabel =
|
|
156 |
qobject_cast<HbLabel *>(mLoader.findWidget("noitemslabel"));
|
|
157 |
Q_ASSERT(grid);
|
|
158 |
Q_ASSERT(noItemsLabel);
|
|
159 |
|
|
160 |
if (grid->model()->rowCount()) {
|
|
161 |
noItemsLabel->hide();
|
|
162 |
grid->show();
|
|
163 |
} else {
|
|
164 |
noItemsLabel->show();
|
|
165 |
grid->hide();
|
|
166 |
}
|
|
167 |
}
|