25 #include <hbdialog.h> |
25 #include <hbdialog.h> |
26 #include <hbmessagebox.h> |
26 #include <hbmessagebox.h> |
27 #include <hbnotificationdialog.h> |
27 #include <hbnotificationdialog.h> |
28 #include <hbparameterlengthlimiter.h> |
28 #include <hbparameterlengthlimiter.h> |
29 #include <xqsettingsmanager.h> |
29 #include <xqsettingsmanager.h> |
30 #include <centralrepository.h> |
|
31 #include <vcxmyvideosdefs.h> |
30 #include <vcxmyvideosdefs.h> |
32 |
31 |
33 #include "videocollectioncommon.h" |
32 #include "videocollectioncommon.h" |
34 #include "videocollectionviewutils.h" |
33 #include "videocollectionviewutils.h" |
35 #include "videosortfilterproxymodel.h" |
34 #include "videosortfilterproxymodel.h" |
99 INFO_3("VideoCollectionViewUtils::saveSortingValues() saving: role: %d, order: %d, target: %d", role, order, target); |
98 INFO_3("VideoCollectionViewUtils::saveSortingValues() saving: role: %d, order: %d, target: %d", role, order, target); |
100 |
99 |
101 int status = -1; |
100 int status = -1; |
102 if (target != VideoCollectionCommon::ELevelInvalid) |
101 if (target != VideoCollectionCommon::ELevelInvalid) |
103 { |
102 { |
104 CRepository *cenRep = 0; |
|
105 TRAP_IGNORE(cenRep = CRepository::NewL(TUid::Uid(KVideoCollectionViewCenrepUid))); |
|
106 |
|
107 int *rolePtr = &mVideosSortRole; |
103 int *rolePtr = &mVideosSortRole; |
108 Qt::SortOrder *orderPtr = &mVideosSortOrder; |
104 Qt::SortOrder *orderPtr = &mVideosSortOrder; |
109 |
105 |
110 int roleKey(KVideoCollectionViewCenrepVideoSortingRoleKey); |
106 int roleKey(KVideoCollectionViewCenrepVideoSortingRoleKey); |
111 int orderKey(KVideoCollectionViewCenrepVideoSortingOrderKey); |
107 int orderKey(KVideoCollectionViewCenrepVideoSortingOrderKey); |
116 orderPtr = &mCollectionsSortOrder; |
112 orderPtr = &mCollectionsSortOrder; |
117 |
113 |
118 roleKey = KVideoCollectionViewCenrepCollectionsSortingRoleKey; |
114 roleKey = KVideoCollectionViewCenrepCollectionsSortingRoleKey; |
119 orderKey = KVideoCollectionViewCenrepCollectionsSortingOrderKey; |
115 orderKey = KVideoCollectionViewCenrepCollectionsSortingOrderKey; |
120 } |
116 } |
121 |
117 XQSettingsManager mgr; |
122 if(cenRep) |
118 XQCentralRepositorySettingsKey crRoleKey(KVideoCollectionViewCenrepUid, roleKey); |
123 { |
119 XQCentralRepositorySettingsKey crOrderKey(KVideoCollectionViewCenrepUid, orderKey); |
124 status = cenRep->Set(roleKey, static_cast<TInt>(role)); |
120 QVariant value; |
125 if(status == KErrNone) |
121 value = role; |
126 { |
122 if(!mgr.writeItemValue(crRoleKey, value)) |
127 status = cenRep->Set(orderKey, static_cast<TInt>(order)); |
123 { |
128 } |
124 return -1; |
129 delete cenRep; |
125 } |
130 } |
126 value = order; |
131 |
127 if(!mgr.writeItemValue(crOrderKey, value)) |
|
128 { |
|
129 return -1; |
|
130 } |
132 *rolePtr = role; |
131 *rolePtr = role; |
133 *orderPtr = order; |
132 *orderPtr = order; |
|
133 status = 0; |
134 } |
134 } |
135 return status; |
135 return status; |
136 } |
136 } |
137 |
137 |
138 // --------------------------------------------------------------------------- |
138 // --------------------------------------------------------------------------- |
140 // --------------------------------------------------------------------------- |
140 // --------------------------------------------------------------------------- |
141 // |
141 // |
142 int VideoCollectionViewUtils::loadSortingValues(int &role, Qt::SortOrder &order, VideoCollectionCommon::TCollectionLevels target) |
142 int VideoCollectionViewUtils::loadSortingValues(int &role, Qt::SortOrder &order, VideoCollectionCommon::TCollectionLevels target) |
143 { |
143 { |
144 FUNC_LOG; |
144 FUNC_LOG; |
145 int err(0); |
|
146 |
145 |
147 if ((target > VideoCollectionCommon::ELevelCategory) && |
146 if ((target > VideoCollectionCommon::ELevelCategory) && |
148 (mVideosSortRole != -1)) |
147 (mVideosSortRole != -1)) |
149 { |
148 { |
150 role = mVideosSortRole; |
149 role = mVideosSortRole; |
156 role = mCollectionsSortRole; |
155 role = mCollectionsSortRole; |
157 order = mCollectionsSortOrder; |
156 order = mCollectionsSortOrder; |
158 } |
157 } |
159 else if (target != VideoCollectionCommon::ELevelInvalid) |
158 else if (target != VideoCollectionCommon::ELevelInvalid) |
160 { |
159 { |
161 int *rolePtr = &mVideosSortRole; |
160 int roleKey(KVideoCollectionViewCenrepVideoSortingRoleKey); |
162 Qt::SortOrder *orderPtr = &mVideosSortOrder; |
161 int orderKey(KVideoCollectionViewCenrepVideoSortingOrderKey); |
163 int roleKey(KVideoCollectionViewCenrepVideoSortingRoleKey); |
162 |
164 int orderKey(KVideoCollectionViewCenrepVideoSortingOrderKey); |
163 int *rolePtr = &mVideosSortRole; |
165 |
164 Qt::SortOrder *orderPtr = &mVideosSortOrder; |
|
165 |
166 if(target == VideoCollectionCommon::ELevelCategory) |
166 if(target == VideoCollectionCommon::ELevelCategory) |
167 { |
167 { |
168 roleKey = KVideoCollectionViewCenrepCollectionsSortingRoleKey; |
168 roleKey = KVideoCollectionViewCenrepCollectionsSortingRoleKey; |
169 orderKey = KVideoCollectionViewCenrepCollectionsSortingOrderKey; |
169 orderKey = KVideoCollectionViewCenrepCollectionsSortingOrderKey; |
170 rolePtr = &mCollectionsSortRole; |
170 rolePtr = &mCollectionsSortRole; |
171 orderPtr = &mCollectionsSortOrder; |
171 orderPtr = &mCollectionsSortOrder; |
172 } |
172 } |
173 |
173 |
174 CRepository *cenRep = 0; |
174 *rolePtr = getCenRepIntValue(roleKey); |
175 TRAP(err, cenRep = CRepository::NewL(TUid::Uid(KVideoCollectionViewCenrepUid))); |
175 int orderValue = getCenRepIntValue(orderKey); |
176 if(cenRep) |
176 |
177 { |
177 if(*rolePtr < 0 || (orderValue < Qt::AscendingOrder || orderValue > Qt::DescendingOrder)) |
178 int sortRole(-1); |
178 { |
179 int sortOrder(-1); |
179 *rolePtr = -1; |
180 err = cenRep->Get(roleKey, sortRole); |
180 return -1; |
181 if(err == KErrNone) |
181 } |
182 { |
182 orderValue == Qt::AscendingOrder ? |
183 err = cenRep->Get(orderKey, sortOrder); |
183 *orderPtr = Qt::AscendingOrder : *orderPtr = Qt::DescendingOrder; |
184 if(err == KErrNone) |
184 |
185 { |
|
186 *orderPtr = static_cast<Qt::SortOrder>(sortOrder); |
|
187 *rolePtr = sortRole; |
|
188 } |
|
189 } |
|
190 delete cenRep; |
|
191 } |
|
192 |
|
193 role = *rolePtr; |
185 role = *rolePtr; |
194 order = *orderPtr; |
186 order = *orderPtr; |
195 } |
187 } |
196 INFO_3("VideoCollectionViewUtils::loadSortingValues() loaded: role: %d, order: %d, target: %d", role, order, target); |
188 INFO_3("VideoCollectionViewUtils::loadSortingValues() loaded: role: %d, order: %d, target: %d", role, order, target); |
197 return err; |
189 return 0; |
198 } |
190 } |
199 |
191 |
200 // --------------------------------------------------------------------------- |
192 // --------------------------------------------------------------------------- |
201 // getCenrepStringValue |
193 // getCenrepStringValue |
202 // --------------------------------------------------------------------------- |
194 // --------------------------------------------------------------------------- |