videocollection/videocollectionwrapper/src/videocollectionutils.cpp
changeset 35 3738fe97f027
parent 34 bbb98528c666
child 36 8aed59de29f9
equal deleted inserted replaced
34:bbb98528c666 35:3738fe97f027
    68         
    68         
    69         if ( hours > 0 )
    69         if ( hours > 0 )
    70         {
    70         {
    71             if(hours == 1)
    71             if(hours == 1)
    72             {
    72             {
    73                 lengthStr = QObject::tr("%1 hour ").arg(QString::number(hours)); //TODO: Localisation
    73                 lengthStr = QObject::tr("%1 hour ").arg(QString::number(hours)); //localisation
    74             }
    74             }
    75             else
    75             else
    76             {
    76             {
    77                 lengthStr += QObject::tr("%1 hours ").arg(QString::number(hours)); //TODO: Localisation
    77                 lengthStr += QObject::tr("%1 hours ").arg(QString::number(hours)); //localisation
    78             }
    78             }
    79         }
    79         }
    80 
    80 
    81         if ( minutes > 0 )
    81         if ( minutes > 0 )
    82         {
    82         {
    83             if(minutes == 1)
    83             if(minutes == 1)
    84             {
    84             {
    85                 lengthStr += QObject::tr("%1 minute ").arg(QString::number(minutes)); //TODO: Localisation
    85                 lengthStr += QObject::tr("%1 minute ").arg(QString::number(minutes)); //localisation
    86             }
    86             }
    87             else
    87             else
    88             {
    88             {
    89                 lengthStr += QObject::tr("%1 minutes ").arg(QString::number(minutes)); //TODO: Localisation
    89                 lengthStr += QObject::tr("%1 minutes ").arg(QString::number(minutes)); //localisation
    90             }
    90             }
    91         }
    91         }
    92         if (seconds > 0 && hours == 0)
    92         if (seconds > 0 && hours == 0)
    93         {
    93         {
    94             if(seconds == 1)
    94             if(seconds == 1)
    95             {
    95             {
    96                 lengthStr += QObject::tr("%1 second").arg(QString::number(seconds)); //TODO: Localisation
    96                 lengthStr += QObject::tr("%1 second").arg(QString::number(seconds)); //localisation
    97             }
    97             }
    98             else
    98             else
    99             {
    99             {
   100                 lengthStr += QObject::tr("%1 seconds").arg(QString::number(seconds)); //TODO: Localisation
   100                 lengthStr += QObject::tr("%1 seconds").arg(QString::number(seconds)); //localisation
   101             }
   101             }
   102         }
   102         }
   103     } else {
   103     } else {
   104         lengthStr += QObject::tr("0 seconds"); //TODO: Localisation
   104         lengthStr += QObject::tr("0 seconds"); //TODO: Localisation
   105     }
   105     }
   111 // -----------------------------------------------------------------------------
   111 // -----------------------------------------------------------------------------
   112 //
   112 //
   113 const QStringList VideoCollectionUtils::prepareLengthStrings(quint32 total)
   113 const QStringList VideoCollectionUtils::prepareLengthStrings(quint32 total)
   114 {
   114 {
   115     const int secondsInMinute( 60 );
   115     const int secondsInMinute( 60 );
   116 
   116     const int secondsInHour( 3600 );
       
   117 
       
   118     quint32 hours(0);
   117     quint32 minutes(0);
   119     quint32 minutes(0);
   118     quint32 seconds(0);
   120     quint32 seconds(0);
   119     
   121     
   120     if ( total > 0 )
   122     QString hrs("");
   121     {
       
   122         minutes = (total / secondsInMinute);
       
   123         seconds = (total % secondsInMinute);
       
   124     }
       
   125     
       
   126     QString mins("");
   123     QString mins("");
   127     QString secs("");
   124     QString secs("");
       
   125 
       
   126     if ( total > 0 )
       
   127     {
       
   128     	hours =   (total / secondsInHour);
       
   129     	total = total - (hours * secondsInHour);
       
   130     	minutes = (total / secondsInMinute);
       
   131         seconds = (total % secondsInMinute);
       
   132     }
       
   133     
       
   134     hrs = QString::number(hours); 
   128     
   135     
   129     if (minutes < 10)
   136     if (minutes < 10)
   130     {
   137     {
   131         mins = "0" + QString::number(minutes); 
   138         mins = "0" + QString::number(minutes); 
   132         
   139         
   133     }
   140     }
   134     else
   141     else
   135     {
   142     {
   136         mins = QString::number(minutes);
   143         mins = QString::number(minutes);
   137     }
   144     }
   138       
   145 
   139     QString secondsStr("");
       
   140     
       
   141     if (seconds < 10)
   146     if (seconds < 10)
   142     {
   147     {
   143         secs = "0" + QString::number(seconds); 
   148         secs = "0" + QString::number(seconds); 
   144         
   149         
   145     }
   150     }
   148         secs = QString::number(seconds);
   153         secs = QString::number(seconds);
   149     }
   154     }
   150     
   155     
   151     QStringList retVal;
   156     QStringList retVal;
   152     
   157     
       
   158     retVal.append(hrs);
   153     retVal.append(mins);
   159     retVal.append(mins);
   154     retVal.append(secs);
   160     retVal.append(secs);
   155     
   161     
   156     return retVal;
   162     return retVal;
   157 }
   163 }
   178         
   184         
   179         if ( size >= videoSizeGB )
   185         if ( size >= videoSizeGB )
   180         {
   186         {
   181             dispSize  = size + videoSizeHalfGB;
   187             dispSize  = size + videoSizeHalfGB;
   182             dispSize /= videoSizeGB;
   188             dispSize /= videoSizeGB;
   183             sizeStr = QString(QObject::tr("%1 GB").arg(QString::number(dispSize))); //TODO: Localisation
   189             sizeStr = QString(QObject::tr("%1 GB").arg(QString::number(dispSize))); //localisation
   184         }
   190         }
   185         else if ( size >= videoSizeMB )
   191         else if ( size >= videoSizeMB )
   186         {
   192         {
   187             dispSize  = size + videoSizeHalfMB;
   193             dispSize  = size + videoSizeHalfMB;
   188             dispSize /= videoSizeMB;
   194             dispSize /= videoSizeMB;
   189             sizeStr = QString(QObject::tr("%1 MB").arg(QString::number(dispSize))); //TODO: Localisation
   195             sizeStr = QString(QObject::tr("%1 MB").arg(QString::number(dispSize))); //localisation
   190         }
   196         }
   191         else if (size >= videoSizeKB) 
   197         else if (size >= videoSizeKB) 
   192         {
   198         {
   193             dispSize  = size + videoSizeHalfKB;
   199             dispSize  = size + videoSizeHalfKB;
   194             dispSize /= videoSizeKB;
   200             dispSize /= videoSizeKB;
   195             sizeStr = QString(QObject::tr("%1 kB").arg(QString::number(dispSize))); //TODO: Localisation
   201             sizeStr = QString(QObject::tr("%1 kB").arg(QString::number(dispSize))); //localisation
   196         }
   202         }
   197         else
   203         else
   198         {
   204         {
   199             sizeStr = QString(QObject::tr("%1B").arg(QString::number(size))); //TODO: Localisation
   205             sizeStr = QString(QObject::tr("%1B").arg(QString::number(size))); //localisation
   200         }
   206         }
   201     }
   207     }
   202     
   208     
   203     return sizeStr;
   209     return sizeStr;
   204 }
   210 }