videocollection/videocollectionwrapper/tsrc/testvideomodel/stub/src/videocollectionutils.cpp
changeset 37 4eb2df7f7cbe
parent 36 8aed59de29f9
equal deleted inserted replaced
36:8aed59de29f9 37:4eb2df7f7cbe
    60 //
    60 //
    61 QString VideoCollectionUtils::prepareLengthString(quint32 length)
    61 QString VideoCollectionUtils::prepareLengthString(quint32 length)
    62 {
    62 {
    63     const int secondsInMinute( 60 );
    63     const int secondsInMinute( 60 );
    64     const int secondsInHour( 3600 );
    64     const int secondsInHour( 3600 );
    65     QString lengthStr("");
    65 
    66     
    66 	quint32 hours = length / secondsInHour;
    67     if ( length > 0 )
    67 	quint32 minutes = length / secondsInMinute % secondsInMinute;
       
    68 	quint32 seconds = length % secondsInMinute;
       
    69 
       
    70     QString hrs(QString::number(hours));
       
    71     if(hours < 10)
    68     {
    72     {
    69         quint32 hours = length / secondsInHour;
    73     	hrs.prepend(QString::number(0));
    70         quint32 minutes = length / secondsInMinute % secondsInMinute;
    74     }
    71         quint32 seconds = length % secondsInMinute;
    75     QString mins(QString::number(minutes));
    72         
    76     if(minutes < 10)
    73         if ( hours > 0 )
    77     {
    74         {
    78     	mins.prepend(QString::number(0));
    75             if(hours == 1)
    79     }
    76             {
    80     QString secs(QString::number(seconds));
    77                 lengthStr = QObject::tr("%1 hour ").arg(QString::number(hours));
    81     if(seconds < 10)
    78             }
    82     {
    79             else
    83     	secs.prepend(QString::number(0));
    80             {
    84     }
    81                 lengthStr += QObject::tr("%1 hours ").arg(QString::number(hours));
       
    82             }
       
    83         }
       
    84 
    85 
    85         if ( minutes > 0 )
    86     QString lengthStr(hbTrId( "txt_videos_list_l1l2l3" ).arg( hrs ).arg( mins ).arg( secs ));
    86         {
    87 
    87             if(minutes == 1)
    88     return lengthStr.trimmed();
    88             {
       
    89                 lengthStr += QObject::tr("%1 minute ").arg(QString::number(minutes));
       
    90             }
       
    91             else
       
    92             {
       
    93                 lengthStr += QObject::tr("%1 minutes ").arg(QString::number(minutes));
       
    94             }
       
    95         }
       
    96         if (seconds > 0 && hours == 0)
       
    97         {
       
    98             if(seconds == 1)
       
    99             {
       
   100                 lengthStr += QObject::tr("%1 second").arg(QString::number(seconds));
       
   101             }
       
   102             else
       
   103             {
       
   104                 lengthStr += QObject::tr("%1 seconds").arg(QString::number(seconds));
       
   105             }
       
   106         }
       
   107     } else {
       
   108         lengthStr += QObject::tr("0 seconds");
       
   109     }
       
   110     
       
   111     return lengthStr;
       
   112 }
    89 }
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // VideoCollectionUtils::prepareShortLengthString()
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 const QString VideoCollectionUtils::prepareShortLengthString(quint32 total)
       
   119 {
       
   120 	const int secondsInMinute( 60 );
       
   121     const int secondsInHour( 3600 );
       
   122 
       
   123     int hour = total / secondsInHour;
       
   124     total = total % secondsInHour;
       
   125     int minutes = total / secondsInMinute;
       
   126     total = total % secondsInMinute;
       
   127     int second = total;
       
   128 
       
   129     QTime time( hour ,minutes ,second );
       
   130     QString str;
       
   131 
       
   132     HbExtendedLocale locale = HbExtendedLocale::system();
       
   133 
       
   134     str = locale.format( time, r_qtn_time_durat_long_with_zero );
       
   135 
       
   136     return str;
       
   137 }
       
   138 
       
   139 
    90 
   140 // -----------------------------------------------------------------------------
    91 // -----------------------------------------------------------------------------
   141 // prepareSizeString
    92 // prepareSizeString
   142 // -----------------------------------------------------------------------------
    93 // -----------------------------------------------------------------------------
   143 //
    94 //