idlehomescreen/xmluirendering/renderingplugins/xnnewstickerfactory/src/xnnewstickercontrol.cpp
equal
deleted
inserted
replaced
172 |
172 |
173 return KNullDesC; |
173 return KNullDesC; |
174 } |
174 } |
175 |
175 |
176 // ----------------------------------------------------------------------------- |
176 // ----------------------------------------------------------------------------- |
|
177 // CXnNewstickerControl::LastIndexWithContent |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 TInt CXnNewstickerControl::LastIndexWithContent() |
|
181 { |
|
182 for( TInt i(iTitleTexts.Count()-1); i>=0; --i ) |
|
183 { |
|
184 if ( iTitleTexts[ i ]->Des().Length() > 0 ) |
|
185 { |
|
186 return i; |
|
187 } |
|
188 } |
|
189 return KErrNotFound; |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
177 // CXnNewstickerControl::ClearTitles |
193 // CXnNewstickerControl::ClearTitles |
178 // ----------------------------------------------------------------------------- |
194 // ----------------------------------------------------------------------------- |
179 // |
195 // |
180 void CXnNewstickerControl::ClearTitles() |
196 void CXnNewstickerControl::ClearTitles() |
181 { |
197 { |
250 // |
266 // |
251 TBool CXnNewstickerControl::SetCurrentTitle( TBool aSetDefault ) |
267 TBool CXnNewstickerControl::SetCurrentTitle( TBool aSetDefault ) |
252 { |
268 { |
253 TBool ret( EFalse ); |
269 TBool ret( EFalse ); |
254 TInt lastIndex( iTitleTexts.Count() - 1 ); |
270 TInt lastIndex( iTitleTexts.Count() - 1 ); |
|
271 TInt lastIndexWithContent = LastIndexWithContent(); |
255 |
272 |
256 if( aSetDefault ) |
273 if( aSetDefault ) |
257 { |
274 { |
|
275 // set last index as default |
258 iCurrentTitleIndex = GetNextTitleWithContent( lastIndex, ETrue ); |
276 iCurrentTitleIndex = GetNextTitleWithContent( lastIndex, ETrue ); |
259 } |
277 } |
260 else if( iCurrentTitleIndex >= lastIndex ) |
278 else if( iCurrentTitleIndex >= lastIndex ) |
261 { |
279 { |
|
280 // if iCurrentTitleIndex is in last position start from beginning |
262 iCurrentTitleIndex = GetNextTitleWithContent( 0 ); |
281 iCurrentTitleIndex = GetNextTitleWithContent( 0 ); |
263 } |
282 } |
264 else |
283 else |
265 { |
284 { |
266 iCurrentTitleIndex = GetNextTitleWithContent( iCurrentTitleIndex + 1 ); |
285 if ( iCurrentTitleIndex + 1 > lastIndexWithContent ) |
267 } |
286 { |
268 |
287 // if lastIndexWithContent is creater than next item |
269 if( iCurrentTitleIndex == lastIndex) |
288 // it means all next items are empty strings |
270 { |
289 iCurrentTitleIndex = lastIndexWithContent; |
|
290 } |
|
291 else |
|
292 { |
|
293 // find next index with content |
|
294 iCurrentTitleIndex |
|
295 = GetNextTitleWithContent( iCurrentTitleIndex + 1 ); |
|
296 } |
|
297 } |
|
298 |
|
299 if( iCurrentTitleIndex == lastIndexWithContent || |
|
300 lastIndexWithContent == KErrNotFound ) |
|
301 { |
|
302 // loop done stop periodic timer. |
271 ret = ETrue; |
303 ret = ETrue; |
272 } |
304 } |
273 |
305 |
274 return ret; |
306 return ret; |
275 } |
307 } |