|
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: VideoListToolbar class definition |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef VIDEOLISTTOOLBAR_H |
|
19 #define VIDEOLISTTOOLBAR_H |
|
20 |
|
21 #include <qobject.h> |
|
22 #include <hbaction.h> |
|
23 #include <videocollectioncommon.h> |
|
24 #include <videocollectionviewutils.h> |
|
25 |
|
26 class QActionGroup; |
|
27 class QAction; |
|
28 class HbToolBarExtension; |
|
29 class VideoServices; |
|
30 class VideoOperatorService; |
|
31 class VideoCollectionUiLoader; |
|
32 class VideoListView; |
|
33 |
|
34 /** |
|
35 * Class controls the visible toolbar actions. |
|
36 */ |
|
37 class VideoListToolbar: public QObject |
|
38 { |
|
39 Q_OBJECT |
|
40 |
|
41 public: |
|
42 |
|
43 /** |
|
44 * Contructor. |
|
45 */ |
|
46 VideoListToolbar(VideoCollectionUiLoader* uiLoader, VideoListView* parent); |
|
47 |
|
48 /** |
|
49 * Destructor. |
|
50 */ |
|
51 ~VideoListToolbar(); |
|
52 |
|
53 /** |
|
54 * Creates needed internal variables. Should be called before this class is used. |
|
55 * Note that the service information should be set in the VideoCollectionViewUtils |
|
56 * before this is called for correct operation. |
|
57 */ |
|
58 void initialize(); |
|
59 |
|
60 signals: |
|
61 |
|
62 /** |
|
63 * Emitted when actions for toolbar have been changed. |
|
64 */ |
|
65 void actionsChanged(QList<QAction*> actions); |
|
66 |
|
67 /** |
|
68 * Emitted when need changes to toolbar extension. |
|
69 */ |
|
70 void toolbarExtensionChanged(HbToolBarExtension* extension); |
|
71 |
|
72 /** |
|
73 * Emitted when all videos action is triggered. |
|
74 */ |
|
75 void allVideosActionTriggered(); |
|
76 |
|
77 /** |
|
78 * Emitted when collection view action is triggered. |
|
79 */ |
|
80 void collectionViewActionTriggered(); |
|
81 |
|
82 public slots: |
|
83 |
|
84 /** |
|
85 * Should be called, whenever state of the view changes, that |
|
86 * could affect the toolbar actions. |
|
87 * |
|
88 * @param currentLevel current view level. |
|
89 * @param noVideos if list has videos or not. |
|
90 * @param modelReady if the model is ready or not. |
|
91 */ |
|
92 void viewStateChanged(VideoCollectionCommon::TCollectionLevels currentLevel, |
|
93 bool noVideos, bool modelReady); |
|
94 |
|
95 /** |
|
96 * Launches the first operator service from the operator service list. |
|
97 */ |
|
98 void openOperatorServiceSlot(); |
|
99 |
|
100 /** |
|
101 * Slot is connected into "Add videos" signal |
|
102 * |
|
103 */ |
|
104 void addVideosToCollectionSlot(); |
|
105 |
|
106 /** |
|
107 * Slot is connected into "remove videos" signal |
|
108 */ |
|
109 void removeVideosFromCollectionSlot(); |
|
110 |
|
111 private: |
|
112 |
|
113 /** |
|
114 * Creates actions for toolbar. |
|
115 */ |
|
116 void createToolbarActions(); |
|
117 |
|
118 /** |
|
119 * Loads video services from central respository and creates toolbar buttons for them. |
|
120 */ |
|
121 void createOperatorServicesToolbarActions(); |
|
122 |
|
123 /** |
|
124 * Loads video service from Central Repository and stores it into member array. |
|
125 * |
|
126 * @param titleKey CenRep key for service title. |
|
127 * @param iconKey CenRep key for icon resource. |
|
128 * @param uriKey CenRep key for service URI. |
|
129 * @param uidKey CenRep key for service application UID. |
|
130 */ |
|
131 void loadOperatorService(int titleKey, int iconKey, int uriKey, int uidKey); |
|
132 |
|
133 /** |
|
134 * Creates action with given parameters. createActionGroup() must be called successfully |
|
135 * before using this method. |
|
136 * |
|
137 * @param tooltip Tooltip text for the action. |
|
138 * @param icon Filepath for the icon file. |
|
139 * @param actionGroup Actiongroup for created action. |
|
140 * @param slot Slot for the triggered signal of the action. |
|
141 * @return HbAction pointer if creation ok, otherwise 0 |
|
142 */ |
|
143 HbAction* createAction(QString icon, QActionGroup* actionGroup, const char *slot); |
|
144 |
|
145 private: |
|
146 |
|
147 /** |
|
148 * Actions ids used in tool bar |
|
149 */ |
|
150 enum TViewActionIds |
|
151 { |
|
152 ETBActionAllVideos = 10, |
|
153 ETBActionCollections = 11, |
|
154 ETBActionServices = 12, |
|
155 ETBActionAddVideos = 13, |
|
156 ETBActionRemoveVideos = 14 |
|
157 }; |
|
158 |
|
159 /** |
|
160 * Holds the current level state. |
|
161 */ |
|
162 VideoCollectionCommon::TCollectionLevels mCurrentLevel; |
|
163 |
|
164 /** |
|
165 * Reference to video collection view utils |
|
166 */ |
|
167 VideoCollectionViewUtils &mUiUtils; |
|
168 |
|
169 /** |
|
170 * Pointer to the XML UI (DocML) loader. |
|
171 * Not owned |
|
172 */ |
|
173 VideoCollectionUiLoader* mUiLoader; |
|
174 |
|
175 /** |
|
176 * Pointer to parent VideoListView. |
|
177 * Not own. |
|
178 */ |
|
179 VideoListView* mListView; |
|
180 |
|
181 /** |
|
182 * Pointer to videoservices instance |
|
183 * if exists, app has started as service |
|
184 */ |
|
185 VideoServices* mVideoServices; |
|
186 |
|
187 /** |
|
188 * Action group for the toolbar. |
|
189 */ |
|
190 QActionGroup* mToolbarViewsActionGroup; |
|
191 |
|
192 /** |
|
193 * Action group for the toolbar. |
|
194 */ |
|
195 QActionGroup* mToolbarCollectionActionGroup; |
|
196 |
|
197 /** |
|
198 * Map containing toolbar actions |
|
199 */ |
|
200 QMap<TViewActionIds, HbAction*> mToolbarActions; |
|
201 |
|
202 /** |
|
203 * Actions for different view states |
|
204 */ |
|
205 QHash<VideoCollectionCommon::TCollectionLevels, QList<QAction*> > mViewStateActions; |
|
206 |
|
207 /** |
|
208 * Toolbar extension for operator services when there's more than |
|
209 * one of them. |
|
210 */ |
|
211 HbToolBarExtension *mToolbarServiceExtension; |
|
212 |
|
213 /** |
|
214 * List of operator services. |
|
215 */ |
|
216 QList<VideoOperatorService *> mVideoOperatorServices; |
|
217 }; |
|
218 |
|
219 #endif // VIDEOLISTTOOLBAR_H |