videocollection/videocollectionwrapper/src/videolistdatamodel.cpp
changeset 35 3738fe97f027
parent 34 bbb98528c666
child 36 8aed59de29f9
equal deleted inserted replaced
34:bbb98528c666 35:3738fe97f027
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description: VideoListDataModel class implementation
    14 * Description: VideoListDataModel class implementation
    15 * 
    15 * 
    16 */
    16 */
       
    17 
    17 // INCLUDE FILES
    18 // INCLUDE FILES
    18 
    19 
    19 #include <hbglobal.h>
    20 #include <hbglobal.h>
    20 #include <vcxmyvideosdefs.h>
    21 #include <vcxmyvideosdefs.h>
    21 #include "videolistdatamodel.h"
    22 #include "videolistdatamodel.h"
    24 #include "videocollectioncommon.h"
    25 #include "videocollectioncommon.h"
    25 #include "videocollectionutils.h"
    26 #include "videocollectionutils.h"
    26 #include "videodeleteworker.h"
    27 #include "videodeleteworker.h"
    27 #include "videocollectionwrapper.h"
    28 #include "videocollectionwrapper.h"
    28 
    29 
    29 
       
    30 // ================= MEMBER FUNCTIONS =======================
    30 // ================= MEMBER FUNCTIONS =======================
    31 //
    31 //
    32 
    32 
    33 // -----------------------------------------------------------------------------
    33 // -----------------------------------------------------------------------------
    34 // VideoListDataModel()
    34 // VideoListDataModel()
   234 
   234 
   235 // -----------------------------------------------------------------------------
   235 // -----------------------------------------------------------------------------
   236 // prepareDetailRow()
   236 // prepareDetailRow()
   237 // -----------------------------------------------------------------------------
   237 // -----------------------------------------------------------------------------
   238 //
   238 //
   239 QString VideoListDataModel::prepareDetailRow( int index ) const
   239 QString VideoListDataModel::prepareDetailRow(int index) const
   240 {
   240 {
   241     // TODO: download -status?
   241     // TODO: download -status?
   242 
   242 
   243     QString retString;
   243     QString retString;
   244     
   244     
   245     TMPXItemId itemId = mediaIdAtIndex(index);
   245     TMPXItemId itemId = mediaIdAtIndex(index);
   246     
   246     
   247     if(itemId.iId2 != KVcxMvcMediaTypeVideo) //category || album
   247     if(itemId.iId2 != KVcxMvcMediaTypeVideo) //category || album
   248     {
   248     {
   249         //TODO: get real items and total length
   249         retString = prepareVideoCountString(index);
   250         int items          = 99;
       
   251         QString minutesStr = "10";
       
   252         QString secondsStr = "01";
       
   253         retString = hbTrId("txt_videos_dblist_val_ln_videos_l1l2", items).arg(minutesStr).arg(secondsStr);
       
   254     }
   250     }
   255     else //video
   251     else //video
   256     {
   252     {
   257         const QString sizeStr = prepareSizeString(index);
   253         const QString sizeStr = prepareSizeString(index);
   258         const QStringList list = prepareLengthStrings( index );
   254         const QStringList list = prepareLengthStrings( index );
   259         retString = hbTrId("txt_videos_dblist_captured_val_1_l1l2").arg(sizeStr).arg(list.at(0)).arg(list.at(1));
   255         QString duration;
       
   256         duration.append(list.at(0));
       
   257         duration.append(":");
       
   258         duration.append(list.at(1));
       
   259         duration.append(":");
       
   260         duration.append(list.at(2));
       
   261         retString = hbTrId("txt_videos_dblist_captured_val_1_l1").arg(duration).arg(sizeStr);
   260     }
   262     }
   261     return retString; 
   263     return retString; 
   262 }
   264 }
   263 
   265 
   264 // -----------------------------------------------------------------------------
   266 // -----------------------------------------------------------------------------
       
   267 // prepareVideoCountString()
       
   268 // -----------------------------------------------------------------------------
       
   269 //
       
   270 QString VideoListDataModel::prepareVideoCountString(int index) const
       
   271 {
       
   272     QString videoCountString("");
       
   273 
       
   274     quint32 items = d_ptr->getCategoryVideoCountFromIndex(index);
       
   275     if(items > 0)
       
   276     {
       
   277         videoCountString = hbTrId("txt_videos_dblist_val_ln_videos", items);
       
   278     }
       
   279     else
       
   280     {
       
   281         videoCountString = hbTrId("txt_videos_info_no_videos");
       
   282     }
       
   283 
       
   284     return videoCountString;
       
   285 }
       
   286 
       
   287 // -----------------------------------------------------------------------------
   265 // prepareSizeString()
   288 // prepareSizeString()
   266 // -----------------------------------------------------------------------------
   289 // -----------------------------------------------------------------------------
   267 //
   290 //
   268 QString VideoListDataModel::prepareSizeString( int index ) const
   291 QString VideoListDataModel::prepareSizeString(int index) const
   269 {
   292 {
   270     QString sizeStr("");
   293     QString sizeStr("");
   271 
   294 
   272     quint32 size = d_ptr->getVideoSizeFromIndex(index);
   295     quint32 size = d_ptr->getVideoSizeFromIndex(index);
   273     sizeStr = VideoCollectionUtils::instance().prepareSizeString(size);
   296     sizeStr = VideoCollectionUtils::instance().prepareSizeString(size);
   277 
   300 
   278 // -----------------------------------------------------------------------------
   301 // -----------------------------------------------------------------------------
   279 // VideoListDataModel::prepareLengthStrings()
   302 // VideoListDataModel::prepareLengthStrings()
   280 // -----------------------------------------------------------------------------
   303 // -----------------------------------------------------------------------------
   281 //
   304 //
   282 QStringList VideoListDataModel::prepareLengthStrings( int index ) const
   305 QStringList VideoListDataModel::prepareLengthStrings(int index) const
   283 {
   306 {
   284     quint32 total = d_ptr->getVideodurationFromIndex(index);
   307     quint32 total = d_ptr->getVideodurationFromIndex(index);
   285     return VideoCollectionUtils::instance().prepareLengthStrings(total);
   308     return VideoCollectionUtils::instance().prepareLengthStrings(total);
   286 }
   309 }
   287 
   310 
   448 
   471 
   449 // -----------------------------------------------------------------------------
   472 // -----------------------------------------------------------------------------
   450 // albumInUse()
   473 // albumInUse()
   451 // -----------------------------------------------------------------------------
   474 // -----------------------------------------------------------------------------
   452 //
   475 //
   453 
       
   454 TMPXItemId VideoListDataModel::albumInUse()
   476 TMPXItemId VideoListDataModel::albumInUse()
   455 {
   477 {
   456     return d_ptr->mCurrentAlbum;
   478     return d_ptr->mCurrentAlbum;
   457 }
   479 }
       
   480 
       
   481 // -----------------------------------------------------------------------------
       
   482 // removeItemsFromAlbum()
       
   483 // -----------------------------------------------------------------------------
       
   484 //
       
   485 int VideoListDataModel::removeItemsFromAlbum(TMPXItemId &albumId, const QList<TMPXItemId> &items)
       
   486 {
       
   487     int removeCount = d_ptr->removeItemsFromAlbum(albumId, items);
       
   488     if(removeCount)
       
   489     {
       
   490         if(mCollectionClient->removeItemsFromAlbum(albumId, items) < 0)
       
   491         {
       
   492             return -1;
       
   493         }
       
   494         emit albumChanged();
       
   495     }
       
   496     return removeCount;
       
   497 }   
   458 
   498 
   459 // -----------------------------------------------------------------------------
   499 // -----------------------------------------------------------------------------
   460 // deleteStartingFailsSlot()
   500 // deleteStartingFailsSlot()
   461 // -----------------------------------------------------------------------------
   501 // -----------------------------------------------------------------------------
   462 //
   502 //