-bool readDataFromDevice(QIODevice *dev, quint32 &blockSize, QVariant &item) {
- QDataStream in(dev);
- in.setVersion(QDataStream::Qt_4_2);
-
- if(blockSize == 0) {
- if(dev->bytesAvailable() < (int)sizeof(quint32)) return false;
- in >> blockSize;
- }
- if(dev->bytesAvailable() < blockSize) return false;
- in >> item;
- return true;
+
+QString secondsToString(int timeInSeconds)
+{
+ QList<QPair<int, QString> > timeUnit;
+ timeUnit.append(qMakePair(365*24*60*60, QCoreApplication::translate("Quassel::secondsToString()", "year")));
+ timeUnit.append(qMakePair(24*60*60, QCoreApplication::translate("Quassel::secondsToString()", "day")));
+ timeUnit.append(qMakePair(60*60, QCoreApplication::translate("Quassel::secondsToString()", "h")));
+ timeUnit.append(qMakePair(60, QCoreApplication::translate("Quassel::secondsToString()", "min")));
+ timeUnit.append(qMakePair(1, QCoreApplication::translate("Quassel::secondsToString()", "sec")));
+
+ QStringList returnString;
+ for (int i = 0; i < timeUnit.size(); i++) {
+ int n = timeInSeconds / timeUnit[i].first;
+ if (n > 0) {
+ returnString += QString("%1 %2").arg(QString::number(n), timeUnit[i].second);
+ }
+ timeInSeconds = timeInSeconds % timeUnit[i].first;
+ }
+ return returnString.join(", ");