|
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 |
|
18 #ifndef MPXVIEWPLUGIN_H |
|
19 #define MPXVIEWPLUGIN_H |
|
20 |
|
21 #ifdef BUILD_VIEWFRAMEWORK |
|
22 #define VFDLL_EXPORT Q_DECL_EXPORT |
|
23 #else |
|
24 #define VFDLL_EXPORT Q_DECL_IMPORT |
|
25 #endif |
|
26 |
|
27 #include <QObject> |
|
28 |
|
29 class QGraphicsWidget; |
|
30 class MpxViewPlugin; |
|
31 |
|
32 class VFDLL_EXPORT MpxPluginViewInterface { |
|
33 |
|
34 public: |
|
35 virtual MpxViewPlugin *viewPlugin() = 0; |
|
36 |
|
37 }; |
|
38 |
|
39 Q_DECLARE_INTERFACE(MpxPluginViewInterface , "org.nokia.mmdt.MpxViewPlugin/1.0" ); |
|
40 |
|
41 class VFDLL_EXPORT MpxViewPlugin : public QObject, public MpxPluginViewInterface { |
|
42 |
|
43 Q_OBJECT |
|
44 Q_INTERFACES(MpxPluginViewInterface) |
|
45 |
|
46 public: |
|
47 |
|
48 /* COMMENT: |
|
49 * following two methods are kind of second-phase create & destroy. Rationale for this step is that |
|
50 * we need some way to promote lazy resources allocation (on application demand) and early resource |
|
51 * deallocation (again, on application direct command). |
|
52 */ |
|
53 |
|
54 /** |
|
55 * createView is the second operation (after plugin construction which is done somewhere |
|
56 * in the plugin framework) executed in the application layer to make a fully operational |
|
57 * View Plugin descendant. |
|
58 * I should allocate all of those resources that are required by plugin, but which are |
|
59 * too expensive to allocate in constructor (eg. in case of plugin prefetching). |
|
60 */ |
|
61 virtual void createView() = 0; |
|
62 |
|
63 /** |
|
64 * destroyView is an operation that should be executed just before plugin deletion. |
|
65 * Implementation should destroy all of resources allocated during createView execution. |
|
66 * It's reason d'etre is based on a fact, that application doesn't controll when exactly |
|
67 * plugin will be deleted, so destructor execution could be postponed still holding resources. |
|
68 */ |
|
69 virtual void destroyView() = 0; |
|
70 |
|
71 /* COMMENT: |
|
72 * view activation and deactivation are reversible operations |
|
73 * that allows us to give up resources that we could temporary deallocate when that |
|
74 * specific view plugin goes into background. |
|
75 */ |
|
76 |
|
77 /** |
|
78 * Called to notice view activation. |
|
79 */ |
|
80 virtual void activateView() = 0; |
|
81 |
|
82 /** |
|
83 * Called to notice view deactivation. |
|
84 */ |
|
85 virtual void deactivateView() = 0; |
|
86 |
|
87 /** |
|
88 * gives actual view component, ready to put somewhere into the app layout. |
|
89 * However, beware that calling to activate/deactivate in the meantime |
|
90 * can invalidate that pointer. |
|
91 * |
|
92 * NOTE: Returned type is choosen to be as generic as possible, |
|
93 * so please ensure that it fulfills all your needs (it was HbView* before) |
|
94 */ |
|
95 virtual QGraphicsWidget* getView() = 0; |
|
96 |
|
97 public slots: |
|
98 |
|
99 /** |
|
100 * Signalled by application when orientation has changed. |
|
101 */ |
|
102 virtual void orientationChange(Qt::Orientation orientation) = 0; |
|
103 |
|
104 /** |
|
105 * Implementation should take care either to implement |
|
106 * go-back operation internally or to emit proper |
|
107 * command signal to delegate that responsibility to |
|
108 * framework (eg. to switch to previous view). |
|
109 */ |
|
110 virtual void back() = 0; |
|
111 |
|
112 signals: |
|
113 |
|
114 /** |
|
115 * Command is the only way to notify from plugin to application |
|
116 * about action needed to be executed. |
|
117 * |
|
118 * @param aCommand enumeration of command type. |
|
119 * Currently supported are: ViewBack, CloseApp, GoToNowPlaying, GoToCollectionView. |
|
120 * NOTE: It should be specified how to determine between broadly supported operations |
|
121 * (back, close etc.) and application/plugin specific (go to collection, go to now playing etc.) |
|
122 * |
|
123 * There is also one major issue here, that there is no guaranted order of command delivery, |
|
124 * so there is second option to use common observer pattern. Should be discussed. |
|
125 */ |
|
126 void command(int aCommand); |
|
127 |
|
128 public: |
|
129 |
|
130 virtual MpxViewPlugin *viewPlugin() { return this; } |
|
131 |
|
132 }; |
|
133 |
|
134 #endif /*MPXVIEWPLUGIN_H_*/ |
|
135 |