30
|
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: Videolist selection dialog
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef VIDEOLISTSELECTIONDIALOG_H
|
|
19 |
#define VIDEOLISTSELECTIONDIALOG_H
|
|
20 |
|
|
21 |
#include <hbdialog.h>
|
34
|
22 |
#include <qset.h>
|
30
|
23 |
#include <qitemselectionmodel.h>
|
34
|
24 |
#include <mpxitemid.h>
|
30
|
25 |
|
|
26 |
class QGraphicItem;
|
|
27 |
class QItemSelection;
|
34
|
28 |
class HbWidget;
|
30
|
29 |
class HbLabel;
|
|
30 |
class HbCheckBox;
|
|
31 |
class HbStackedWidget;
|
34
|
32 |
class VideoCollectionUiLoader;
|
|
33 |
class VideoCollectionWrapper;
|
|
34 |
class VideoSortFilterProxyModel;
|
30
|
35 |
class VideoListWidget;
|
|
36 |
|
|
37 |
class VideoListSelectionDialog: public HbDialog
|
|
38 |
{
|
|
39 |
/**
|
|
40 |
* definition required for emitting / connecting signals
|
|
41 |
*/
|
|
42 |
Q_OBJECT
|
|
43 |
|
|
44 |
/**
|
|
45 |
* disable copy-constructor and assignment operator
|
|
46 |
*/
|
|
47 |
Q_DISABLE_COPY(VideoListSelectionDialog)
|
|
48 |
|
|
49 |
|
|
50 |
public:
|
|
51 |
|
34
|
52 |
enum TSelectionFunction
|
|
53 |
{
|
|
54 |
EDeleteVideos,
|
35
|
55 |
EAddToCollection,
|
|
56 |
ERemoveFromCollection,
|
40
|
57 |
ECreateCollection,
|
34
|
58 |
ESelectCollection
|
|
59 |
};
|
|
60 |
|
30
|
61 |
/**
|
|
62 |
* Constructor
|
|
63 |
*
|
|
64 |
* @param uiLoader used to load UI components from docml
|
|
65 |
* @param parent item's parent component
|
|
66 |
*/
|
|
67 |
VideoListSelectionDialog(VideoCollectionUiLoader *uiLoader, QGraphicsItem *parent=0);
|
|
68 |
|
|
69 |
/**
|
|
70 |
* Destructor
|
|
71 |
*/
|
|
72 |
~VideoListSelectionDialog();
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Method setups provided title and videolist content widget.
|
|
76 |
* Prepares dialog for showing.
|
|
77 |
* If either provided title is empty or widget is NULL, dialog
|
|
78 |
* is in invalid state and cannot be shown using exec.
|
|
79 |
*
|
34
|
80 |
* @param type selection dialog function typy
|
|
81 |
* @param activeItem id of item that the selection concerns
|
30
|
82 |
*/
|
34
|
83 |
void setupContent(int type, TMPXItemId activeItem = TMPXItemId::InvalidId());
|
30
|
84 |
|
|
85 |
public slots:
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Shows modal dialog build from the provided Videolistwidget.
|
|
89 |
*
|
|
90 |
*/
|
35
|
91 |
void exec();
|
30
|
92 |
|
37
|
93 |
/**
|
|
94 |
* Signaled by HbInputDialog when it's closed.
|
|
95 |
*/
|
|
96 |
void newAlbumNameDialogFinished(HbAction *action);
|
|
97 |
|
30
|
98 |
private slots:
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Slot connected to mCheckBox's stateChanged -signal.
|
|
102 |
* Selects or deselects all items if mForcedCheck -flag is false.
|
|
103 |
*
|
|
104 |
* If Forcedcehck is true, it indeicates that we want to change the checked state
|
|
105 |
* only, not slect or deselect anything. This is needed for example if after
|
|
106 |
* all items are marked, user manually deselects item's. In that case all is not
|
|
107 |
* marked, so checked state needs to be changed.
|
|
108 |
*
|
|
109 |
* @param state Qt::Checked everything should be set as selected.
|
|
110 |
*/
|
|
111 |
void markAllStateChangedSlot(int state);
|
|
112 |
|
|
113 |
/**
|
|
114 |
* disables or enables popup's primary action in case selection changes
|
|
115 |
*
|
|
116 |
* @param selected item selection list containing selected
|
|
117 |
* @param deselected item selection list containing not selected (not used in this scope)
|
|
118 |
*/
|
|
119 |
void selectionChangedSlot(const QItemSelection &selected, const QItemSelection &deselected);
|
|
120 |
|
|
121 |
/**
|
34
|
122 |
* connected to list's activated -signal. Called when singel item is selected.
|
|
123 |
* If dialog's selection type is ESelectCollection, saves mpx id from provided index.
|
|
124 |
* and closes dialog by triggering primary action
|
|
125 |
*
|
|
126 |
* @param index of item selected
|
|
127 |
*/
|
|
128 |
void singleItemSelectedSlot(const QModelIndex &index);
|
|
129 |
|
|
130 |
/**
|
|
131 |
* handles model ready signal from model.
|
|
132 |
* In case dialog type is ESelectCollection and there are no data
|
|
133 |
* in model, opens up a selection dialog for user to input new album name
|
|
134 |
* In case type is something else than ESelectCollection, calls
|
|
135 |
* updateCounterSlot()
|
|
136 |
*/
|
|
137 |
void modelReadySlot();
|
|
138 |
|
|
139 |
/**
|
30
|
140 |
* Changes the counter value. Sets the checkbutton state based on selection count.
|
|
141 |
*
|
|
142 |
*/
|
|
143 |
void updateCounterSlot();
|
|
144 |
|
34
|
145 |
/**
|
|
146 |
* Primary action triggered signal slot.
|
|
147 |
*
|
|
148 |
*/
|
|
149 |
void primaryActionTriggeredSlot();
|
35
|
150 |
|
|
151 |
/**
|
|
152 |
* called when dialog has been finished
|
|
153 |
*
|
|
154 |
* @param action causing the finished
|
|
155 |
*/
|
|
156 |
void finishedSlot(HbAction *action);
|
34
|
157 |
|
30
|
158 |
private:
|
|
159 |
|
|
160 |
/**
|
34
|
161 |
* Method initializes dialog by getting all ui components and
|
|
162 |
* checking if they are valid
|
|
163 |
*
|
|
164 |
* @return bool true if inisializaion ok
|
|
165 |
*/
|
|
166 |
bool initDialog();
|
|
167 |
|
|
168 |
/**
|
|
169 |
* Method activated dialog based on value in mTypeOfSelection
|
|
170 |
*/
|
|
171 |
void activateSelection();
|
|
172 |
|
|
173 |
/**
|
30
|
174 |
* connects all required signals into appropriate slots
|
|
175 |
* for selection mode
|
|
176 |
*/
|
|
177 |
void connectSignals();
|
|
178 |
|
|
179 |
/**
|
|
180 |
* disconnects all signals
|
|
181 |
*/
|
|
182 |
void disconnectSignals();
|
|
183 |
|
34
|
184 |
/**
|
|
185 |
* Gets selected item's name from appropriate model.
|
|
186 |
*
|
|
187 |
* @return QString item's name
|
|
188 |
*/
|
|
189 |
QString getSelectedName();
|
|
190 |
|
|
191 |
/**
|
37
|
192 |
* Finalizes the operation.
|
34
|
193 |
*/
|
37
|
194 |
void finalize(QString albumName = "");
|
34
|
195 |
|
|
196 |
private:
|
30
|
197 |
|
|
198 |
/**
|
|
199 |
* docml UI loader, not owned
|
|
200 |
*/
|
|
201 |
VideoCollectionUiLoader *mUiLoader;
|
34
|
202 |
|
30
|
203 |
/**
|
34
|
204 |
* type for defining selection functionality
|
30
|
205 |
*/
|
34
|
206 |
int mTypeOfSelection;
|
30
|
207 |
|
|
208 |
/**
|
|
209 |
* Selection
|
|
210 |
*/
|
|
211 |
QItemSelection mSelection;
|
|
212 |
|
|
213 |
/**
|
34
|
214 |
* Selected video items
|
|
215 |
*/
|
|
216 |
QSet<TMPXItemId> mSelectedVideos;
|
|
217 |
|
|
218 |
/**
|
|
219 |
* selected single items album id
|
|
220 |
*/
|
|
221 |
TMPXItemId mSelectedAlbumId;
|
|
222 |
|
|
223 |
/**
|
40
|
224 |
* Text for a new album.
|
|
225 |
*/
|
|
226 |
QString mNewAlbumText;
|
|
227 |
|
|
228 |
/**
|
30
|
229 |
* header label
|
|
230 |
*/
|
|
231 |
HbLabel *mHeading;
|
|
232 |
|
|
233 |
/**
|
34
|
234 |
* container widget for itemcount and checkbox;
|
|
235 |
*/
|
|
236 |
HbWidget *mCheckboxContainer;
|
|
237 |
|
|
238 |
/**
|
30
|
239 |
* counter label from docml
|
|
240 |
*/
|
|
241 |
HbLabel *mItemCount;
|
|
242 |
|
|
243 |
/**
|
37
|
244 |
* checkbox label from docml
|
|
245 |
*/
|
|
246 |
HbLabel *mCheckBoxText;
|
|
247 |
|
|
248 |
/**
|
30
|
249 |
* mark all checkbox
|
|
250 |
*/
|
|
251 |
HbCheckBox *mCheckBox;
|
|
252 |
|
|
253 |
/**
|
|
254 |
* videolist container in dialog
|
|
255 |
*/
|
|
256 |
HbStackedWidget *mListContainer;
|
|
257 |
|
|
258 |
/**
|
|
259 |
* flag indicating that we've changed check-btn state
|
|
260 |
* explicitly and don't wanna handle selection based on that
|
|
261 |
*/
|
34
|
262 |
bool mForcedCheck;
|
30
|
263 |
|
34
|
264 |
/**
|
|
265 |
* Video list model
|
|
266 |
*/
|
|
267 |
VideoSortFilterProxyModel *mModel;
|
|
268 |
|
|
269 |
/**
|
|
270 |
* List widget to show in selection
|
36
|
271 |
*/
|
34
|
272 |
VideoListWidget *mListWidget;
|
36
|
273 |
|
|
274 |
/**
|
|
275 |
* Action to accept the selection dialog.
|
|
276 |
*/
|
|
277 |
HbAction *mPrimaryAction;
|
|
278 |
|
|
279 |
/**
|
|
280 |
* Action to cancel the selection dialog.
|
|
281 |
*/
|
|
282 |
HbAction *mSecondaryAction;
|
30
|
283 |
};
|
|
284 |
|
|
285 |
#endif //VIDEOLISTSELECTIONDIALOG_H
|