16 */ |
16 */ |
17 |
17 |
18 #ifndef HSWIDGETHOST_H |
18 #ifndef HSWIDGETHOST_H |
19 #define HSWIDGETHOST_H |
19 #define HSWIDGETHOST_H |
20 |
20 |
21 #include <QVariantMap> |
21 #include <HbWidget> |
22 #include <QMetaMethod> |
22 #include <QMetaMethod> |
23 #include <QMetaProperty> |
23 #include <QMetaProperty> |
24 |
24 |
25 #include <HbWidget> |
25 #include "hsdomainmodel_global.h" |
|
26 #include "hsdomainmodeldatastructures.h" |
26 |
27 |
27 #include "hsdomainmodeldatastructures.h" |
|
28 #include "hsdomainmodel_global.h" |
|
29 #include "hstest_global.h" |
28 #include "hstest_global.h" |
|
29 HOMESCREEN_TEST_CLASS(TestRuntimeServices) |
30 |
30 |
|
31 class QStateMachine; |
|
32 |
|
33 class HsWidgetComponent; |
31 class HsPage; |
34 class HsPage; |
32 |
|
33 HOMESCREEN_TEST_CLASS(TestRuntimeServices) |
|
34 |
35 |
35 class HSDOMAINMODEL_EXPORT HsWidgetHost : public HbWidget |
36 class HSDOMAINMODEL_EXPORT HsWidgetHost : public HbWidget |
36 { |
37 { |
37 Q_OBJECT |
38 Q_OBJECT |
38 |
39 |
39 public: |
40 public: |
40 enum State { |
41 HsWidgetHost(int databaseId, QGraphicsItem *parent = 0); |
41 Unloaded, |
42 ~HsWidgetHost(); |
42 Loaded, |
|
43 Initialized, |
|
44 Visible, |
|
45 Hidden, |
|
46 Uninitialized, |
|
47 Finished, |
|
48 Faulted, |
|
49 UninstallingOrUpdating |
|
50 }; |
|
51 |
43 |
52 public: |
44 static HsWidgetHost *createInstance( |
53 static HsWidgetHost *createInstance(HsWidgetData &widgetData, |
45 HsWidgetData &widgetData, |
54 const QVariantHash &preferences = QVariantHash()); |
46 const QVariantHash &preferences = QVariantHash()); |
55 |
|
56 HsWidgetHost(int databaseId, QGraphicsItem *parent = 0); |
|
57 |
|
58 ~HsWidgetHost(); |
|
59 |
|
60 bool load(); |
|
61 void unload(); |
|
62 |
|
63 bool setPage(HsPage *page); |
|
64 HsPage *page() const; |
|
65 |
|
66 bool isValid() const; |
|
67 |
47 |
68 int databaseId() const; |
48 int databaseId() const; |
69 |
49 |
70 State state() const { return mState; } |
50 bool setPage(HsPage *page); |
|
51 HsPage *page() const; |
71 |
52 |
72 bool deleteFromDatabase(); |
53 bool isPannable(QGraphicsSceneMouseEvent *event); |
73 |
54 |
74 bool setWidgetPresentation(); |
55 bool loadPresentation(); |
75 bool setWidgetPresentationData(HsWidgetPresentationData &presentationData); |
56 bool loadPresentation(Qt::Orientation orientation); |
76 bool widgetPresentationData(const QString &key, HsWidgetPresentationData &presentationData); |
57 bool savePresentation(); |
|
58 bool savePresentation(Qt::Orientation orientation); |
|
59 bool savePresentation(HsWidgetPresentationData &presentation); |
|
60 bool getPresentation(HsWidgetPresentationData &presentation); |
|
61 bool removePresentation(Qt::Orientation orientation); |
77 |
62 |
78 HsWidgetPresentationData widgetPresentation(Qt::Orientation orientation); |
|
79 bool loadWidgetPresentation(); |
|
80 bool deleteWidgetPresentation(Qt::Orientation orientation); |
|
81 bool isPannable(QGraphicsSceneMouseEvent *event); |
|
82 signals: |
63 signals: |
83 void widgetFinished(HsWidgetHost *widget); |
64 void event_startAndShow(); |
84 void widgetError(HsWidgetHost *widget); |
65 void event_startAndHide(); |
85 void widgetResized(HsWidgetHost *widget); |
66 void event_unload(); |
86 |
67 void event_show(); |
|
68 void event_hide(); |
|
69 void event_remove(); |
|
70 void event_close(); |
|
71 void event_finished(); |
|
72 void event_faulted(); |
|
73 |
|
74 void finished(); |
|
75 void faulted(); |
|
76 void resized(); |
|
77 void available(); |
|
78 void unavailable(); |
|
79 |
87 public slots: |
80 public slots: |
88 void initializeWidget(); |
81 void startWidget(bool show = true); |
89 void showWidget(); |
82 void showWidget(); |
90 void hideWidget(); |
83 void hideWidget(); |
91 void uninitializeWidget(); |
|
92 void setOnline(bool online = true); |
84 void setOnline(bool online = true); |
|
85 |
|
86 void remove(); |
|
87 void close(); |
93 |
88 |
94 void startDragEffect(); |
89 void startDragEffect(); |
95 void startDropEffect(); |
90 void startDropEffect(); |
96 |
91 |
97 protected: |
92 protected: |
98 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); |
93 bool eventFilter(QObject *watched, QEvent *event); |
99 void mouseMoveEvent(QGraphicsSceneMouseEvent *event); |
94 void mousePressEvent(QGraphicsSceneMouseEvent *) {} |
100 void mousePressEvent(QGraphicsSceneMouseEvent *event); |
95 |
101 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); |
|
102 bool eventFilter(QObject *obj, QEvent *event); |
|
103 |
|
104 private: |
96 private: |
|
97 Q_DISABLE_COPY(HsWidgetHost) |
|
98 void setupEffects(); |
|
99 void setupStates(); |
|
100 |
105 bool setProperty(const char *name, QMetaProperty &property); |
101 bool setProperty(const char *name, QMetaProperty &property); |
106 bool setMethod(const char *signature, QMetaMethod &method); |
102 bool setMethod(const char *signature, QMetaMethod &method); |
107 bool hasSignal(const char *signature); |
103 bool hasSignal(const char *signature); |
|
104 |
|
105 void setNewSize(const QSizeF &size); |
|
106 |
108 bool setPreferencesToWidget(); |
107 bool setPreferencesToWidget(); |
109 void setNewSize(const QSizeF &newSize); |
|
110 |
108 |
111 private slots: |
109 private slots: |
112 void onSetPreferences(const QStringList &names); |
110 void action_connectComponent(); |
|
111 void action_disconnectComponent(); |
|
112 void action_load(); |
|
113 void action_unload(); |
|
114 void action_initialize(); |
|
115 void action_uninitialize(); |
|
116 void action_show(); |
|
117 void action_hide(); |
|
118 void action_finished(); |
|
119 void action_faulted(); |
|
120 void action_remove(); |
|
121 |
113 void onFinished(); |
122 void onFinished(); |
114 void onError(); |
123 void onError(); |
115 void onAboutToUninstall(); |
124 void onSetPreferences(const QStringList &names); |
116 void onUpdated(); |
125 |
117 void onUnavailable(); |
|
118 void onAvailable(); |
|
119 private: |
126 private: |
120 Q_DISABLE_COPY(HsWidgetHost) |
127 int mDatabaseId; |
|
128 QStateMachine *mStateMachine; |
121 QGraphicsWidget *mWidget; |
129 QGraphicsWidget *mWidget; |
122 HsPage *mPage; |
130 HsPage *mPage; |
|
131 HsWidgetComponent *mComponent; |
123 QMetaMethod mOnInitializeMethod; |
132 QMetaMethod mOnInitializeMethod; |
124 QMetaMethod mOnShowMethod; |
133 QMetaMethod mOnShowMethod; |
125 QMetaMethod mOnHideMethod; |
134 QMetaMethod mOnHideMethod; |
126 QMetaMethod mOnUninitializeMethod; |
135 QMetaMethod mOnUninitializeMethod; |
|
136 QMetaMethod mIsPannableMethod; |
127 QMetaProperty mIsOnlineProperty; |
137 QMetaProperty mIsOnlineProperty; |
128 QMetaProperty mRootPathProperty; |
138 QMetaProperty mRootPathProperty; |
129 QMetaMethod mIsPannable; |
139 bool mIsFinishing; |
130 State mState; |
|
131 QString mUri; |
|
132 int mDatabaseId; |
|
133 |
140 |
134 HOMESCREEN_TEST_FRIEND_CLASS(TestRuntimeServices) |
141 HOMESCREEN_TEST_FRIEND_CLASS(TestRuntimeServices) |
135 }; |
142 }; |
136 |
143 |
137 #endif // HSWIDGETHOST_H |
144 #endif // HSWIDGETHOST_H |