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 "tsdevicedialogcontainer.h" |
|
18 |
|
19 #include <QAbstractListModel> |
|
20 |
|
21 #include <HbDialog> |
|
22 #include <HbMainWindow> |
|
23 |
|
24 #include "tstasksgrid.h" |
|
25 #include "tstasksgriditem.h" |
|
26 |
|
27 namespace { |
|
28 const char KDocmlPath[] = ":/resource/layout.docml"; |
|
29 } |
|
30 |
|
31 TsDeviceDialogContainer::TsDeviceDialogContainer(QAbstractListModel *model, QObject *parent) : QObject(parent) |
|
32 { |
|
33 bool ok(true); |
|
34 mLoader.load(KDocmlPath, &ok); |
|
35 Q_ASSERT(ok); |
|
36 |
|
37 HbDialog *dialog = qobject_cast<HbDialog*>(mLoader.findWidget("tsdevicedialog")); |
|
38 TsTasksGrid *grid = qobject_cast<TsTasksGrid *>(mLoader.findWidget("taskgrid")); |
|
39 Q_ASSERT(dialog); |
|
40 Q_ASSERT(grid); |
|
41 |
|
42 changeOrientation(dialog->mainWindow()->orientation()); |
|
43 |
|
44 grid->setModel(model); |
|
45 |
|
46 // needed because of Qt::QueuedConnection used below |
|
47 // @todo: check if we actually need queued connections |
|
48 qRegisterMetaType<QModelIndex>("QModelIndex"); |
|
49 |
|
50 // connect the grid and model |
|
51 disconnect(grid, SIGNAL(activated(QModelIndex)), model, SLOT(openApplication(QModelIndex))); |
|
52 disconnect(grid, SIGNAL(activated(QModelIndex)), dialog, SLOT(close())); |
|
53 disconnect(grid, SIGNAL(deleteButtonClicked(QModelIndex)), model, SLOT(closeApplication(QModelIndex))); |
|
54 |
|
55 connect(grid, SIGNAL(activated(QModelIndex)), model, SLOT(openApplication(QModelIndex))); |
|
56 connect(grid, SIGNAL(activated(QModelIndex)), dialog, SLOT(close())); |
|
57 connect(grid, SIGNAL(deleteButtonClicked(QModelIndex)), model, SLOT(closeApplication(QModelIndex)), Qt::QueuedConnection); |
|
58 |
|
59 connect(dialog->mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(changeOrientation(Qt::Orientation))); |
|
60 connect(dialog, SIGNAL(aboutToClose()), this, SIGNAL(deviceDialogClosed())); |
|
61 } |
|
62 |
|
63 TsDeviceDialogContainer::~TsDeviceDialogContainer() |
|
64 { |
|
65 } |
|
66 |
|
67 bool TsDeviceDialogContainer::setDeviceDialogParameters(const QVariantMap ¶meters) |
|
68 { |
|
69 Q_UNUSED(parameters); |
|
70 return false; |
|
71 } |
|
72 |
|
73 int TsDeviceDialogContainer::deviceDialogError() const |
|
74 { |
|
75 return 0; |
|
76 } |
|
77 |
|
78 void TsDeviceDialogContainer::closeDeviceDialog(bool byClient) |
|
79 { |
|
80 Q_UNUSED(byClient) |
|
81 // @todo: should there be hide calls? deviceDialogWidget->hide(); |
|
82 emit deviceDialogClosed(); |
|
83 } |
|
84 |
|
85 HbPopup *TsDeviceDialogContainer::deviceDialogWidget() const |
|
86 { |
|
87 HbDialog *widget = qobject_cast<HbDialog*>(mLoader.findWidget("tsdevicedialog")); |
|
88 Q_ASSERT(widget); |
|
89 return widget; |
|
90 } |
|
91 |
|
92 QObject *TsDeviceDialogContainer::signalSender() const |
|
93 { |
|
94 return const_cast<TsDeviceDialogContainer*>(this); |
|
95 } |
|
96 |
|
97 void TsDeviceDialogContainer::changeOrientation(Qt::Orientation orientation) |
|
98 { |
|
99 bool ok(true); |
|
100 if (orientation == Qt::Horizontal) { |
|
101 mLoader.load(KDocmlPath, "landscape", &ok); |
|
102 } else { |
|
103 mLoader.load(KDocmlPath, "portrait", &ok); |
|
104 } |
|
105 Q_ASSERT(ok); |
|
106 } |
|