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 implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <QGraphicsItem>
|
|
19 |
#include <hblabel.h>
|
|
20 |
#include <hbcheckbox.h>
|
|
21 |
#include <hbaction.h>
|
|
22 |
#include <hbstackedwidget.h>
|
34
|
23 |
#include <hbabstractitemview.h>
|
|
24 |
#include <hbinputdialog.h>
|
|
25 |
#include <vcxmyvideosdefs.h>
|
|
26 |
|
30
|
27 |
#include "videocollectionuiloader.h"
|
|
28 |
#include "videolistwidget.h"
|
|
29 |
#include "videosortfilterproxymodel.h"
|
|
30 |
#include "videolistselectiondialog.h"
|
34
|
31 |
#include "videocollectionwrapper.h"
|
|
32 |
#include "videocollectionviewutils.h"
|
|
33 |
#include "videocollectionclient.h"
|
|
34 |
|
|
35 |
/**
|
|
36 |
* global qHash function required fo creating hash values for TMPXItemId -keys
|
|
37 |
*/
|
|
38 |
inline uint qHash(TMPXItemId key)
|
|
39 |
{
|
|
40 |
QPair<uint, uint> keyPair(key.iId1, key.iId2);
|
|
41 |
|
|
42 |
return qHash(keyPair);
|
|
43 |
}
|
30
|
44 |
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
// VideoListSelectionDialog
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
VideoListSelectionDialog::VideoListSelectionDialog(VideoCollectionUiLoader *uiLoader,
|
|
50 |
QGraphicsItem *parent) :
|
|
51 |
HbDialog(parent),
|
|
52 |
mUiLoader(uiLoader),
|
34
|
53 |
mTypeOfSelection(-1),
|
30
|
54 |
mHeading(0),
|
34
|
55 |
mCheckboxContainer(0),
|
30
|
56 |
mItemCount(0),
|
|
57 |
mCheckBox(0),
|
|
58 |
mListContainer(0),
|
34
|
59 |
mForcedCheck(false),
|
|
60 |
mModel(0),
|
|
61 |
mListWidget(0)
|
30
|
62 |
{
|
|
63 |
setDismissPolicy(HbDialog::NoDismiss);
|
34
|
64 |
setTimeout(HbDialog::NoTimeout);
|
|
65 |
|
|
66 |
// create model for list widget
|
|
67 |
mModel =
|
|
68 |
VideoCollectionWrapper::instance().getModel(
|
|
69 |
VideoCollectionWrapper::EGeneric);
|
|
70 |
if (mModel)
|
|
71 |
{
|
|
72 |
// create list widget
|
|
73 |
mListWidget = new VideoListWidget(mUiLoader);
|
|
74 |
if (mListWidget)
|
|
75 |
{
|
|
76 |
mListWidget->initialize(*mModel);
|
|
77 |
}
|
|
78 |
}
|
30
|
79 |
}
|
|
80 |
|
|
81 |
// ---------------------------------------------------------------------------
|
|
82 |
// ~VideoListSelectionDialog
|
|
83 |
// ---------------------------------------------------------------------------
|
|
84 |
//
|
|
85 |
VideoListSelectionDialog::~VideoListSelectionDialog()
|
|
86 |
{
|
34
|
87 |
delete mListWidget;
|
30
|
88 |
}
|
|
89 |
|
|
90 |
// ---------------------------------------------------------------------------
|
34
|
91 |
// setupContent
|
30
|
92 |
// ---------------------------------------------------------------------------
|
|
93 |
//
|
34
|
94 |
void VideoListSelectionDialog::setupContent(int type, TMPXItemId activeItem)
|
30
|
95 |
{
|
34
|
96 |
if(type < EDeleteVideos || type > ESelectCollection)
|
30
|
97 |
{
|
34
|
98 |
return;
|
|
99 |
}
|
|
100 |
|
|
101 |
mTypeOfSelection = type;
|
|
102 |
if(!initDialog())
|
|
103 |
{
|
30
|
104 |
return;
|
|
105 |
}
|
34
|
106 |
mSelection.clear();
|
|
107 |
mSelectedVideos.clear();
|
|
108 |
mSelectedAlbumId = TMPXItemId::InvalidId();
|
30
|
109 |
|
34
|
110 |
// if provided "owner" is album or category
|
|
111 |
if(activeItem != TMPXItemId::InvalidId())
|
|
112 |
{
|
|
113 |
// if album, set as "selected"
|
|
114 |
if(activeItem.iId2 == KVcxMvcMediaTypeAlbum)
|
|
115 |
{
|
|
116 |
mSelectedAlbumId = activeItem;
|
|
117 |
}
|
|
118 |
else if(activeItem.iId2 == KVcxMvcMediaTypeVideo)
|
|
119 |
{
|
|
120 |
mSelectedVideos.insert(activeItem);
|
|
121 |
}
|
|
122 |
}
|
|
123 |
// set (or reset) generic id filter
|
|
124 |
mModel->setGenericIdFilter(activeItem, (mTypeOfSelection == EDeleteVideos));
|
|
125 |
activateSelection();
|
|
126 |
}
|
|
127 |
|
|
128 |
// ---------------------------------------------------------------------------
|
|
129 |
// initDialog
|
|
130 |
// ---------------------------------------------------------------------------
|
|
131 |
//
|
|
132 |
bool VideoListSelectionDialog::initDialog()
|
|
133 |
{
|
|
134 |
if(!mModel)
|
|
135 |
{
|
|
136 |
mModel = VideoCollectionWrapper::instance().getModel(VideoCollectionWrapper::EGeneric);
|
|
137 |
if (!mModel)
|
|
138 |
{
|
|
139 |
return false;
|
|
140 |
}
|
|
141 |
}
|
|
142 |
if(!mListWidget)
|
|
143 |
{
|
|
144 |
mListWidget = new VideoListWidget(mUiLoader);
|
|
145 |
mListWidget->initialize(*mModel);
|
|
146 |
}
|
|
147 |
if (!mListContainer)
|
|
148 |
{
|
|
149 |
mListContainer =
|
|
150 |
mUiLoader->findWidget<HbStackedWidget>(DOCML_NAME_LIST_CONTAINER);
|
|
151 |
if(mListContainer && mListWidget)
|
|
152 |
{
|
|
153 |
mListContainer->addWidget(mListWidget);
|
|
154 |
}
|
|
155 |
}
|
30
|
156 |
if(!mHeading)
|
|
157 |
{
|
|
158 |
mHeading = mUiLoader->findWidget<HbLabel>(DOCML_NAME_DLG_HEADINGLBL);
|
|
159 |
}
|
34
|
160 |
if(!mCheckboxContainer)
|
|
161 |
{
|
|
162 |
mCheckboxContainer = mUiLoader->findWidget<HbWidget>(DOCML_NAME_CHECK_CONTAINER);
|
|
163 |
}
|
|
164 |
|
30
|
165 |
if(!mItemCount)
|
|
166 |
{
|
|
167 |
mItemCount = mUiLoader->findWidget<HbLabel>(DOCML_NAME_LBL_SELECTION);
|
|
168 |
mItemCount->setAlignment(Qt::AlignRight);
|
34
|
169 |
}
|
30
|
170 |
if(!mCheckBox)
|
|
171 |
{
|
|
172 |
mCheckBox = mUiLoader->findWidget<HbCheckBox >(DOCML_NAME_MARKALL);
|
|
173 |
}
|
|
174 |
if(!primaryAction())
|
|
175 |
{
|
34
|
176 |
setPrimaryAction(new HbAction(tr("OK"), this)); //TODO: localisation
|
30
|
177 |
}
|
|
178 |
if(!secondaryAction())
|
|
179 |
{
|
34
|
180 |
setSecondaryAction(new HbAction(tr("Cancel"), this)); //TODO: localisation
|
|
181 |
}
|
|
182 |
if(!mListWidget || !mListContainer || !mHeading || !mCheckBox || !primaryAction() || !secondaryAction())
|
|
183 |
{
|
|
184 |
return false;
|
|
185 |
}
|
|
186 |
return true;
|
|
187 |
}
|
|
188 |
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
// activateSelection
|
|
191 |
// ---------------------------------------------------------------------------
|
|
192 |
//
|
|
193 |
void VideoListSelectionDialog::activateSelection()
|
|
194 |
{
|
|
195 |
// "add to collection" and "select collection" -selections needs
|
|
196 |
// additional functionality for primary key
|
|
197 |
if(mTypeOfSelection == EAddToCollection ||
|
|
198 |
mTypeOfSelection == ESelectCollection)
|
|
199 |
{
|
|
200 |
primaryAction()->disconnect(SIGNAL(triggered()));
|
|
201 |
connect(primaryAction(), SIGNAL(triggered()), this, SLOT(primaryActionTriggeredSlot()));
|
30
|
202 |
}
|
34
|
203 |
|
|
204 |
if(mTypeOfSelection == EDeleteVideos || mTypeOfSelection == EAddToCollection)
|
|
205 |
{
|
|
206 |
mSelection.clear();
|
|
207 |
mListWidget->setSelectionMode(HbAbstractItemView::MultiSelection);
|
|
208 |
mListWidget->activate(VideoCollectionCommon::ELevelVideos);
|
|
209 |
mCheckboxContainer->setVisible(true);
|
|
210 |
mItemCount->setPlainText(tr("0/%1").arg(mModel->rowCount()));
|
|
211 |
mCheckBox->setChecked(false);
|
|
212 |
QString txt("");
|
|
213 |
mTypeOfSelection == EDeleteVideos ? txt = tr("Delete items") : txt = tr("Add to collection"); // localisation missing
|
|
214 |
mHeading->setPlainText(txt);
|
|
215 |
mTypeOfSelection == EDeleteVideos ? txt = hbTrId("txt_common_menu_delete") : txt = tr("Add"); // localisation missing
|
|
216 |
primaryAction()->setText(txt);
|
|
217 |
primaryAction()->setDisabled(true);
|
|
218 |
}
|
|
219 |
else
|
|
220 |
{
|
|
221 |
mListWidget->setSelectionMode(-1);
|
|
222 |
mListWidget->activate(VideoCollectionCommon::ELevelCategory);
|
|
223 |
mCheckboxContainer->setVisible(false);
|
|
224 |
mHeading->setPlainText(tr("Select collection")); // localisation missing
|
|
225 |
primaryAction()->setText(tr("New")); // localisation missing
|
|
226 |
primaryAction()->setDisabled(false);
|
|
227 |
}
|
|
228 |
// sort to make sure dialog has correctly filtered content
|
|
229 |
// at the same order as in view
|
|
230 |
VideoCollectionViewUtils::sortModel(mModel, false);
|
30
|
231 |
}
|
|
232 |
|
|
233 |
// ---------------------------------------------------------------------------
|
|
234 |
// exec
|
|
235 |
// ---------------------------------------------------------------------------
|
|
236 |
//
|
|
237 |
HbAction* VideoListSelectionDialog::exec()
|
|
238 |
{
|
34
|
239 |
// clear checkbox
|
|
240 |
mCheckBox->setChecked(false);
|
30
|
241 |
|
34
|
242 |
mListWidget->clearSelection();
|
30
|
243 |
|
34
|
244 |
// scroll list back to top
|
|
245 |
mListWidget->scrollTo(mModel->index(0, 0));
|
30
|
246 |
|
|
247 |
connectSignals();
|
|
248 |
|
|
249 |
// Launch popup syncronously
|
|
250 |
bool accepted = false;
|
|
251 |
HbDialog::exec() == primaryAction() ? accepted = true : accepted = false;
|
|
252 |
|
|
253 |
disconnectSignals();
|
34
|
254 |
|
|
255 |
if(accepted)
|
|
256 |
{
|
|
257 |
// user is adding videos into selected collection
|
|
258 |
// or selecting collection where to add videos
|
|
259 |
if(mTypeOfSelection == EAddToCollection ||
|
|
260 |
mTypeOfSelection == ESelectCollection)
|
|
261 |
{
|
|
262 |
if(mSelectedAlbumId != TMPXItemId::InvalidId() && mSelectedVideos.count())
|
|
263 |
{
|
|
264 |
if(mModel->addItemsInAlbum(mSelectedAlbumId, mSelectedVideos.toList()) == 0)
|
|
265 |
{
|
|
266 |
QVariant data = getSelectedName();
|
|
267 |
VideoCollectionViewUtils::instance().showStatusMsgSlot(
|
|
268 |
VideoCollectionCommon::statusVideosAddedToCollection,
|
|
269 |
data);
|
|
270 |
}
|
|
271 |
}
|
|
272 |
}
|
|
273 |
// user is deleting videos
|
|
274 |
else if(mTypeOfSelection == EDeleteVideos)
|
|
275 |
{
|
|
276 |
QVariant data = mSelection.indexes().count();
|
|
277 |
VideoCollectionViewUtils::instance().showStatusMsgSlot(
|
|
278 |
VideoCollectionCommon::statusDeleteInProgress,
|
|
279 |
data);
|
|
280 |
// delete items
|
|
281 |
mModel->deleteItems(mSelection.indexes());
|
30
|
282 |
|
34
|
283 |
}
|
|
284 |
return primaryAction();
|
|
285 |
}
|
|
286 |
return secondaryAction();
|
30
|
287 |
}
|
|
288 |
|
|
289 |
// ---------------------------------------------------------------------------
|
|
290 |
// markAllStateChanged
|
|
291 |
// ---------------------------------------------------------------------------
|
|
292 |
//
|
|
293 |
void VideoListSelectionDialog::markAllStateChangedSlot(int state)
|
34
|
294 |
{
|
30
|
295 |
if(mForcedCheck)
|
|
296 |
{
|
|
297 |
return;
|
|
298 |
}
|
|
299 |
if( state == Qt::Checked)
|
|
300 |
{
|
34
|
301 |
mListWidget->selectAll();
|
30
|
302 |
}
|
|
303 |
else
|
|
304 |
{
|
34
|
305 |
mListWidget->clearSelection();
|
30
|
306 |
}
|
|
307 |
}
|
|
308 |
|
|
309 |
// ---------------------------------------------------------------------------
|
|
310 |
// selectionChangedSlot
|
|
311 |
// ---------------------------------------------------------------------------
|
|
312 |
//
|
|
313 |
void VideoListSelectionDialog::selectionChangedSlot(const QItemSelection &selected, const QItemSelection &deselected)
|
|
314 |
{
|
|
315 |
|
|
316 |
if(!primaryAction())
|
|
317 |
{
|
|
318 |
return;
|
|
319 |
}
|
34
|
320 |
|
30
|
321 |
if(selected.indexes().count() > 0)
|
|
322 |
{
|
|
323 |
mSelection.merge(selected, QItemSelectionModel::Select);
|
|
324 |
}
|
|
325 |
|
|
326 |
if(deselected.indexes().count() > 0)
|
|
327 |
{
|
|
328 |
mSelection.merge(deselected, QItemSelectionModel::Deselect);
|
|
329 |
}
|
|
330 |
|
|
331 |
if(mSelection.indexes().count() > 0)
|
|
332 |
{
|
|
333 |
primaryAction()->setDisabled(false);
|
|
334 |
}
|
|
335 |
else
|
|
336 |
{
|
|
337 |
primaryAction()->setDisabled(true);
|
|
338 |
}
|
|
339 |
|
|
340 |
updateCounterSlot();
|
|
341 |
}
|
|
342 |
|
|
343 |
// ---------------------------------------------------------------------------
|
34
|
344 |
// singleItemSelectedSlot
|
|
345 |
// ---------------------------------------------------------------------------
|
|
346 |
//
|
|
347 |
void VideoListSelectionDialog::singleItemSelectedSlot(const QModelIndex &index)
|
|
348 |
{
|
|
349 |
if(mTypeOfSelection == ESelectCollection)
|
|
350 |
{
|
|
351 |
if(index.isValid())
|
|
352 |
{
|
|
353 |
mSelectedAlbumId = mModel->getMediaIdAtIndex(index);
|
|
354 |
primaryAction()->trigger();
|
|
355 |
}
|
|
356 |
}
|
|
357 |
}
|
|
358 |
|
|
359 |
// ---------------------------------------------------------------------------
|
|
360 |
// modelReadySlot
|
|
361 |
// ---------------------------------------------------------------------------
|
|
362 |
//
|
|
363 |
void VideoListSelectionDialog::modelReadySlot()
|
|
364 |
{
|
|
365 |
if(!mModel)
|
|
366 |
{
|
|
367 |
return;
|
|
368 |
}
|
|
369 |
|
|
370 |
if(mTypeOfSelection == ESelectCollection && ! mModel->rowCount())
|
|
371 |
{
|
|
372 |
// in case there are no albums, start input dialog right away
|
|
373 |
mSelectedAlbumId = queryNewAlbum();
|
|
374 |
if(mSelectedAlbumId != TMPXItemId::InvalidId())
|
|
375 |
{
|
|
376 |
primaryAction()->trigger();
|
|
377 |
}
|
|
378 |
else
|
|
379 |
{
|
|
380 |
secondaryAction()->trigger();
|
|
381 |
}
|
|
382 |
return;
|
|
383 |
}
|
|
384 |
updateCounterSlot();
|
|
385 |
}
|
|
386 |
|
|
387 |
// ---------------------------------------------------------------------------
|
30
|
388 |
// updateCounterSlot
|
|
389 |
// ---------------------------------------------------------------------------
|
|
390 |
//
|
|
391 |
void VideoListSelectionDialog::updateCounterSlot()
|
|
392 |
{
|
34
|
393 |
if(!mItemCount || !mModel)
|
30
|
394 |
{
|
|
395 |
return;
|
|
396 |
}
|
|
397 |
// orbit does not update HbLabel read from docml in case it isn't cleared first
|
34
|
398 |
int rowCount = mModel->rowCount();
|
|
399 |
|
|
400 |
|
30
|
401 |
int selectionCount = mSelection.indexes().count();
|
|
402 |
mItemCount->setPlainText(tr("%1/%2").arg(selectionCount).arg(rowCount));
|
|
403 |
|
|
404 |
mForcedCheck = true;
|
|
405 |
if(selectionCount == rowCount && rowCount > 0)
|
|
406 |
{
|
|
407 |
mCheckBox->setChecked(true);
|
|
408 |
}
|
|
409 |
else
|
|
410 |
{
|
|
411 |
mCheckBox->setChecked(false);
|
|
412 |
}
|
|
413 |
mForcedCheck = false;
|
|
414 |
|
|
415 |
}
|
|
416 |
|
|
417 |
// ---------------------------------------------------------------------------
|
34
|
418 |
// primaryActionTriggeredSlot
|
|
419 |
// ---------------------------------------------------------------------------
|
|
420 |
//
|
|
421 |
void VideoListSelectionDialog::primaryActionTriggeredSlot()
|
|
422 |
{
|
|
423 |
// reconnect primary action
|
|
424 |
primaryAction()->disconnect(SIGNAL(triggered()));
|
|
425 |
connect(primaryAction(), SIGNAL(triggered()), this, SLOT(close()));
|
|
426 |
|
|
427 |
if(mTypeOfSelection == EDeleteVideos)
|
|
428 |
{
|
|
429 |
primaryAction()->trigger();
|
|
430 |
return;
|
|
431 |
}
|
|
432 |
|
|
433 |
// update video items selection here before content changes.
|
|
434 |
int count = mSelection.indexes().count();
|
|
435 |
TMPXItemId id = TMPXItemId::InvalidId();
|
|
436 |
for(int i = 0; i < count; ++i)
|
|
437 |
{
|
|
438 |
id = mModel->getMediaIdAtIndex(mSelection.indexes().at(i));
|
|
439 |
if(id.iId2 == KVcxMvcMediaTypeVideo)
|
|
440 |
{
|
|
441 |
mSelectedVideos.insert(id);
|
|
442 |
}
|
|
443 |
}
|
|
444 |
|
|
445 |
if(mSelectedAlbumId != TMPXItemId::InvalidId())
|
|
446 |
{
|
|
447 |
primaryAction()->trigger();
|
|
448 |
return;
|
|
449 |
}
|
|
450 |
|
|
451 |
|
|
452 |
else if(mTypeOfSelection == ESelectCollection)
|
|
453 |
{
|
|
454 |
// there's no selected collection and primary action pressed
|
|
455 |
// -> user is willing to create a new collection
|
|
456 |
mSelectedAlbumId = queryNewAlbum();
|
|
457 |
if(mSelectedAlbumId != TMPXItemId::InvalidId())
|
|
458 |
{
|
|
459 |
primaryAction()->trigger();
|
|
460 |
}
|
|
461 |
else
|
|
462 |
{
|
|
463 |
// cancelled
|
|
464 |
secondaryAction()->trigger();
|
|
465 |
}
|
|
466 |
}
|
|
467 |
else if(mTypeOfSelection == EAddToCollection)
|
|
468 |
{
|
|
469 |
// videos for collection selected, but collection
|
|
470 |
// not yet selected, activate selection for it
|
|
471 |
mTypeOfSelection = ESelectCollection;
|
|
472 |
activateSelection();
|
|
473 |
}
|
|
474 |
}
|
|
475 |
|
|
476 |
// ---------------------------------------------------------------------------
|
30
|
477 |
// connectSignals
|
|
478 |
// ---------------------------------------------------------------------------
|
|
479 |
//
|
|
480 |
void VideoListSelectionDialog::connectSignals()
|
|
481 |
{
|
|
482 |
// selection changes
|
34
|
483 |
connect(mListWidget, SIGNAL(activated(const QModelIndex&)),
|
|
484 |
this, SLOT(singleItemSelectedSlot(const QModelIndex&)));
|
|
485 |
|
|
486 |
connect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),
|
|
487 |
this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &)));
|
30
|
488 |
|
|
489 |
// model changes signals
|
34
|
490 |
connect(mModel, SIGNAL(modelReady()), this, SLOT(modelReadySlot()));
|
|
491 |
connect(mModel, SIGNAL(modelChanged()), this, SLOT(updateCounterSlot()));
|
30
|
492 |
|
|
493 |
// mark all state changes
|
|
494 |
connect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(markAllStateChangedSlot(int)));
|
|
495 |
}
|
|
496 |
|
|
497 |
// ---------------------------------------------------------------------------
|
|
498 |
// disconnectSignals
|
|
499 |
// ---------------------------------------------------------------------------
|
|
500 |
//
|
|
501 |
void VideoListSelectionDialog::disconnectSignals()
|
34
|
502 |
{
|
|
503 |
disconnect(mListWidget, SIGNAL(activated(const QModelIndex&)),
|
|
504 |
this, SLOT(singleItemSelectedSlot(const QModelIndex&)));
|
30
|
505 |
|
34
|
506 |
disconnect(mListWidget->selectionModel(), SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),
|
30
|
507 |
this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection &)));
|
|
508 |
|
|
509 |
// model changes signals
|
34
|
510 |
disconnect(mModel, SIGNAL(modelReady()), this, SLOT(modelReadySlot()));
|
|
511 |
disconnect(mModel, SIGNAL(modelChanged()), this, SLOT(updateCounterSlot()));
|
30
|
512 |
|
|
513 |
// mark all state changes
|
34
|
514 |
disconnect(mCheckBox, SIGNAL(stateChanged(int)), this, SLOT(markAllStateChangedSlot(int)));
|
30
|
515 |
}
|
|
516 |
|
34
|
517 |
// ---------------------------------------------------------------------------
|
|
518 |
// getSelectedName
|
|
519 |
// ---------------------------------------------------------------------------
|
|
520 |
//
|
|
521 |
QString VideoListSelectionDialog::getSelectedName()
|
|
522 |
{
|
|
523 |
QString name;
|
|
524 |
if(mSelectedAlbumId.iId2 > KVcxMvcMediaTypeVideo)
|
|
525 |
{
|
|
526 |
VideoSortFilterProxyModel *model =
|
|
527 |
VideoCollectionWrapper::instance().getModel(
|
|
528 |
VideoCollectionWrapper::ECollections);
|
|
529 |
if(!model)
|
|
530 |
{
|
|
531 |
return name;
|
|
532 |
}
|
|
533 |
QModelIndex index = model->indexOfId(mSelectedAlbumId);
|
|
534 |
if(index.isValid())
|
|
535 |
{
|
|
536 |
name = model->data(index, Qt::DisplayRole).toStringList().first();
|
|
537 |
}
|
|
538 |
}
|
|
539 |
|
|
540 |
return name;
|
|
541 |
}
|
30
|
542 |
|
34
|
543 |
// ---------------------------------------------------------------------------
|
|
544 |
// queryNewAlbum
|
|
545 |
// ---------------------------------------------------------------------------
|
|
546 |
//
|
|
547 |
TMPXItemId VideoListSelectionDialog::queryNewAlbum()
|
|
548 |
{
|
|
549 |
TMPXItemId newId = TMPXItemId::InvalidId();
|
|
550 |
bool ok = false;
|
|
551 |
QString label(tr("Enter name:")); // localisation missing
|
|
552 |
QString text(tr("New collection")); // localisation missing
|
|
553 |
text = HbInputDialog::getText(label, text, &ok);
|
|
554 |
if (ok && text.length())
|
|
555 |
{
|
|
556 |
// check for duplicate album name and add new album
|
|
557 |
newId = mModel->addNewAlbum(mModel->resolveAlbumName(text));
|
|
558 |
}
|
|
559 |
return newId;
|
|
560 |
}
|
|
561 |
|