9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 #include "tsdevicedialogcontainer.h" |
|
18 |
17 |
19 #include <QAbstractListModel> |
18 #include <QAbstractListModel> |
20 |
|
21 #include <HbDialog> |
19 #include <HbDialog> |
22 #include <HbMainWindow> |
20 #include <HbMainWindow> |
23 |
21 #include <HbLabel> |
24 #include <tspropertydefs.h> |
22 #include <tspropertydefs.h> |
25 |
23 |
|
24 #include "tsdevicedialogcontainer.h" |
26 #include "tstasksgrid.h" |
25 #include "tstasksgrid.h" |
27 #include "tstasksgriditem.h" |
26 #include "tstasksgriditem.h" |
28 |
27 |
29 namespace { |
28 namespace { |
30 const char KDocmlPath[] = ":/resource/layout.docml"; |
29 const char KDocmlPath[] = ":/resource/layout.docml"; |
31 } |
30 } |
32 |
31 |
33 TsDeviceDialogContainer::TsDeviceDialogContainer(QAbstractListModel *model, QObject *parent) : QObject(parent), mVisibilityPublisher(TsProperty::KTsPath) |
32 TsDeviceDialogContainer::TsDeviceDialogContainer(QAbstractListModel *model, |
|
33 QObject *parent) |
|
34 : |
|
35 QObject(parent), |
|
36 mVisibilityPublisher(TsProperty::KTsPath) |
34 { |
37 { |
35 bool ok(true); |
38 bool ok(true); |
36 mLoader.load(KDocmlPath, &ok); |
39 mLoader.load(KDocmlPath, &ok); |
37 Q_ASSERT(ok); |
40 Q_ASSERT(ok); |
38 |
41 |
39 HbDialog *dialog = qobject_cast<HbDialog*>(mLoader.findWidget("tsdevicedialog")); |
42 HbDialog *dialog = |
40 TsTasksGrid *grid = qobject_cast<TsTasksGrid *>(mLoader.findWidget("taskgrid")); |
43 qobject_cast<HbDialog*>(mLoader.findWidget("tsdevicedialog")); |
|
44 TsTasksGrid *grid = |
|
45 qobject_cast<TsTasksGrid *>(mLoader.findWidget("taskgrid")); |
41 Q_ASSERT(dialog); |
46 Q_ASSERT(dialog); |
42 Q_ASSERT(grid); |
47 Q_ASSERT(grid); |
43 |
48 |
|
49 grid->setModel(model); |
|
50 |
44 changeOrientation(dialog->mainWindow()->orientation()); |
51 changeOrientation(dialog->mainWindow()->orientation()); |
45 |
52 switchViewOnModelChange(); |
46 grid->setModel(model); |
|
47 |
53 |
48 // needed because of Qt::QueuedConnection used below |
54 // needed because of Qt::QueuedConnection used below |
49 // @todo: check if we actually need queued connections |
55 // @todo: check if we actually need queued connections |
50 qRegisterMetaType<QModelIndex>("QModelIndex"); |
56 qRegisterMetaType<QModelIndex>("QModelIndex"); |
51 |
57 |
52 // connect the grid and model |
58 // connect the grid and model |
53 disconnect(grid, SIGNAL(activated(QModelIndex)), model, SLOT(openApplication(QModelIndex))); |
59 connect(grid, |
54 disconnect(grid, SIGNAL(activated(QModelIndex)), dialog, SLOT(close())); |
60 SIGNAL(activated(QModelIndex)), |
55 disconnect(grid, SIGNAL(deleteButtonClicked(QModelIndex)), model, SLOT(closeApplication(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); |
56 |
71 |
57 connect(grid, SIGNAL(activated(QModelIndex)), model, SLOT(openApplication(QModelIndex))); |
72 connect(dialog->mainWindow(), |
58 connect(grid, SIGNAL(activated(QModelIndex)), dialog, SLOT(close())); |
73 SIGNAL(orientationChanged(Qt::Orientation)), |
59 connect(grid, SIGNAL(deleteButtonClicked(QModelIndex)), model, SLOT(closeApplication(QModelIndex)), Qt::QueuedConnection); |
74 this, |
|
75 SLOT(changeOrientation(Qt::Orientation))); |
|
76 connect(dialog, |
|
77 SIGNAL(aboutToClose()), |
|
78 this, |
|
79 SIGNAL(deviceDialogClosed())); |
60 |
80 |
61 connect(dialog->mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(changeOrientation(Qt::Orientation))); |
81 // note: connect to more signals when partial model updates are implemented |
62 connect(dialog, SIGNAL(aboutToClose()), this, SIGNAL(deviceDialogClosed())); |
82 connect(model, |
63 |
83 SIGNAL(modelReset()), |
64 connect(this, SIGNAL(deviceDialogClosed()), this, SLOT(notifyDialogClosed())); |
84 this, |
65 mVisibilityPublisher.setValue(TsProperty::KVisibilityPath, true); |
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)); |
66 mVisibilityPublisher.sync(); |
93 mVisibilityPublisher.sync(); |
67 } |
94 } |
68 |
95 |
69 TsDeviceDialogContainer::~TsDeviceDialogContainer() |
96 TsDeviceDialogContainer::~TsDeviceDialogContainer() |
70 { |
97 { |
71 delete deviceDialogWidget(); |
98 delete deviceDialogWidget(); |
72 } |
99 } |
73 |
100 |
74 bool TsDeviceDialogContainer::setDeviceDialogParameters(const QVariantMap ¶meters) |
101 bool TsDeviceDialogContainer::setDeviceDialogParameters( |
|
102 const QVariantMap ¶meters) |
75 { |
103 { |
76 Q_UNUSED(parameters); |
104 Q_UNUSED(parameters); |
77 return false; |
105 return false; |
78 } |
106 } |
79 |
107 |