|
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: video collection view plugin's ui utils class |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "videocollectionviewutils.h" |
|
19 #include "videocollectionviewutilsdata.h" |
|
20 |
|
21 int VideoCollectionViewUtilsData::mLastError = 0; |
|
22 bool VideoCollectionViewUtilsData::mLoadSortingValuesFails = false; |
|
23 int VideoCollectionViewUtilsData::mVideoSortRole = -1; |
|
24 int VideoCollectionViewUtilsData::mCollectionSortRole = -1; |
|
25 Qt::SortOrder VideoCollectionViewUtilsData::mVideoSortOrder = Qt::AscendingOrder; |
|
26 Qt::SortOrder VideoCollectionViewUtilsData::mCollectionSortOrder = Qt::AscendingOrder; |
|
27 QString VideoCollectionViewUtilsData::mIconString = ""; |
|
28 QString VideoCollectionViewUtilsData::mPressedString = ""; |
|
29 QVariant VideoCollectionViewUtilsData::mLastStatusAdditional = QVariant(); |
|
30 VideoCollectionCommon::TCollectionLevels VideoCollectionViewUtilsData::mWidgetLevel = VideoCollectionCommon::ELevelVideos; |
|
31 TMPXItemId VideoCollectionViewUtilsData::mActivityCollectionId = TMPXItemId::InvalidId(); |
|
32 QString VideoCollectionViewUtilsData::mActivityCollectionName = ""; |
|
33 QList<QString> VideoCollectionViewUtilsData::mCenRepStringValues; |
|
34 QList<int> VideoCollectionViewUtilsData::mCenRepIntValues; |
|
35 |
|
36 VideoCollectionViewUtils& VideoCollectionViewUtils::instance() |
|
37 { |
|
38 static VideoCollectionViewUtils _popupInstance; |
|
39 return _popupInstance; |
|
40 } |
|
41 |
|
42 VideoCollectionViewUtils::VideoCollectionViewUtils(): |
|
43 mVideosSortRole(-1), |
|
44 mCollectionsSortRole(-1), |
|
45 mVideosSortOrder(Qt::AscendingOrder), |
|
46 mCollectionsSortOrder(Qt::AscendingOrder) |
|
47 { |
|
48 // not stubbed |
|
49 } |
|
50 |
|
51 VideoCollectionViewUtils::~VideoCollectionViewUtils() |
|
52 { |
|
53 VideoCollectionViewUtilsData::reset(); |
|
54 } |
|
55 |
|
56 int VideoCollectionViewUtils::saveSortingValues(int role, Qt::SortOrder order, VideoCollectionCommon::TCollectionLevels target) |
|
57 { |
|
58 int status(0); |
|
59 if(target == VideoCollectionCommon::ELevelCategory ) |
|
60 { |
|
61 VideoCollectionViewUtilsData::mCollectionSortRole = role; |
|
62 mCollectionsSortRole = role; |
|
63 VideoCollectionViewUtilsData::mCollectionSortOrder = order; |
|
64 mCollectionsSortOrder = order; |
|
65 } |
|
66 else if(target > VideoCollectionCommon::ELevelCategory && |
|
67 target <= VideoCollectionCommon::ELevelAlbum) |
|
68 { |
|
69 VideoCollectionViewUtilsData::mVideoSortRole = role; |
|
70 mVideosSortRole = role; |
|
71 VideoCollectionViewUtilsData::mVideoSortOrder = order; |
|
72 mVideosSortOrder = order; |
|
73 } |
|
74 else |
|
75 { |
|
76 status = -1; |
|
77 } |
|
78 return status; |
|
79 } |
|
80 |
|
81 int VideoCollectionViewUtils::loadSortingValues(int &role, Qt::SortOrder &order, VideoCollectionCommon::TCollectionLevels target) |
|
82 { |
|
83 if (VideoCollectionViewUtilsData::mLoadSortingValuesFails) |
|
84 { |
|
85 return -1; |
|
86 } |
|
87 if(target == VideoCollectionCommon::ELevelCategory ) |
|
88 { |
|
89 role = VideoCollectionViewUtilsData::mCollectionSortRole; |
|
90 order = VideoCollectionViewUtilsData::mCollectionSortOrder; |
|
91 } |
|
92 else if(target > VideoCollectionCommon::ELevelCategory && |
|
93 target <= VideoCollectionCommon::ELevelAlbum) |
|
94 { |
|
95 role = VideoCollectionViewUtilsData::mVideoSortRole; |
|
96 order = VideoCollectionViewUtilsData::mVideoSortOrder; |
|
97 } |
|
98 else |
|
99 { |
|
100 return -1; |
|
101 } |
|
102 return 0; |
|
103 } |
|
104 |
|
105 QString VideoCollectionViewUtils::getCenRepStringValue(int key) |
|
106 { |
|
107 Q_UNUSED(key); |
|
108 if(VideoCollectionViewUtilsData::mCenRepStringValues.count() > 0) |
|
109 { |
|
110 QString str = VideoCollectionViewUtilsData::mCenRepStringValues.takeFirst(); |
|
111 if(str != CENREP_NO_STRING) |
|
112 { |
|
113 return str; |
|
114 } |
|
115 } |
|
116 return QString(); |
|
117 } |
|
118 |
|
119 int VideoCollectionViewUtils::getCenRepIntValue(int key) |
|
120 { |
|
121 Q_UNUSED(key); |
|
122 if(VideoCollectionViewUtilsData::mCenRepIntValues.count() > 0) |
|
123 { |
|
124 int value = VideoCollectionViewUtilsData::mCenRepIntValues.takeFirst(); |
|
125 if(value != CENREP_NO_INT) |
|
126 { |
|
127 return value; |
|
128 } |
|
129 } |
|
130 return -1; |
|
131 } |
|
132 |
|
133 void VideoCollectionViewUtils::initListView(HbListView *view) |
|
134 { |
|
135 Q_UNUSED(view); |
|
136 // not stubbed |
|
137 } |
|
138 |
|
139 void VideoCollectionViewUtils::setWidgetActivityLevel(const VideoCollectionCommon::TCollectionLevels &level) |
|
140 { |
|
141 VideoCollectionViewUtilsData::mWidgetLevel = level; |
|
142 } |
|
143 |
|
144 void VideoCollectionViewUtils::getActivityWidgetLevel(VideoCollectionCommon::TCollectionLevels &level) |
|
145 { |
|
146 level = VideoCollectionViewUtilsData::mWidgetLevel; |
|
147 } |
|
148 |
|
149 void VideoCollectionViewUtils::setCollectionActivityData(const TMPXItemId &id, const QString &name) |
|
150 { |
|
151 VideoCollectionViewUtilsData::mActivityCollectionId = id; |
|
152 VideoCollectionViewUtilsData::mActivityCollectionName = name; |
|
153 } |
|
154 |
|
155 void VideoCollectionViewUtils::getCollectionActivityData(TMPXItemId &id, QString &name) |
|
156 { |
|
157 id = VideoCollectionViewUtilsData::mActivityCollectionId; |
|
158 name = VideoCollectionViewUtilsData::mActivityCollectionName; |
|
159 } |
|
160 |
|
161 |
|
162 void VideoCollectionViewUtils::sortModel(VideoSortFilterProxyModel *model, |
|
163 bool async, VideoCollectionCommon::TCollectionLevels target) |
|
164 { |
|
165 Q_UNUSED(model); |
|
166 Q_UNUSED(async); |
|
167 Q_UNUSED(target); |
|
168 // not stubbed |
|
169 } |
|
170 |
|
171 void VideoCollectionViewUtils::showStatusMsgSlot(int statusCode, QVariant &additional) |
|
172 { |
|
173 VideoCollectionViewUtilsData::mLastStatusAdditional = additional; |
|
174 VideoCollectionViewUtilsData::mLastError = statusCode; |
|
175 } |