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