mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJClient.git
synced 2026-03-28 05:25:39 +03:00
94 lines
2.0 KiB
C++
94 lines
2.0 KiB
C++
#include "tools.h"
|
|
|
|
void Tools::printTime()
|
|
{
|
|
qDebug() << QTime::currentTime().toString("hh:mm:ss");
|
|
}
|
|
|
|
QString Tools::getTime()
|
|
{
|
|
return QTime::currentTime().toString(("hh:mm:ss"));
|
|
}
|
|
|
|
QString Tools::createLocalPath(QString path)
|
|
{
|
|
qDebug() << "Full path: " << path;
|
|
qint8 pos = path.indexOf("Application");
|
|
|
|
QString localPath = path.remove(0,--pos);
|
|
|
|
qDebug() << "Local path: " << localPath;
|
|
return localPath;
|
|
}
|
|
|
|
QString Tools::createReceiveFullPath(QString path, StreamingVersionData *version)
|
|
{
|
|
QString fullPath;
|
|
QString localPath;
|
|
qint8 pos = path.indexOf("Application");
|
|
|
|
if(pos == -1)
|
|
{
|
|
pos = path.indexOf(version->getViewName());
|
|
|
|
if(pos == -1)
|
|
{
|
|
fullPath = QDir::currentPath() + path;
|
|
}
|
|
else
|
|
{
|
|
//StreamingAssets section
|
|
localPath = path.remove(0,pos + version->getViewName().length());
|
|
localPath.prepend(streamingAssetsPath);
|
|
fullPath = QDir::currentPath() + localPath;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//build section
|
|
localPath = path.remove(0,--pos);
|
|
fullPath = QDir::currentPath() + localPath;
|
|
}
|
|
|
|
|
|
qDebug() << "CLIENT: localPath" << localPath;
|
|
|
|
|
|
return fullPath;
|
|
}
|
|
|
|
QString Tools::createSendFullPath(QString path)
|
|
{
|
|
QString fullPath;
|
|
qint8 pos = path.indexOf("Application");
|
|
|
|
QString localPath = path.remove(0,--pos);
|
|
|
|
qDebug() << "CLIENT: localPath" << localPath;
|
|
fullPath = QDir::currentPath() + localPath;
|
|
|
|
return fullPath;
|
|
}
|
|
|
|
QString Tools::convertFileSize(quint64 fileSize, bool withName)
|
|
{
|
|
quint64 megaByte = fileSize / (1024 * 1024);
|
|
QString resultSize;
|
|
|
|
if (megaByte == 0)
|
|
{
|
|
auto kiloByte = fileSize / 1024;
|
|
resultSize = QString::number(kiloByte);
|
|
if(withName)resultSize.append("кб. ");
|
|
}
|
|
else
|
|
{
|
|
resultSize = QString::number(megaByte);
|
|
if(withName)resultSize.append("мб. ");
|
|
}
|
|
|
|
|
|
QString result = resultSize;
|
|
return result;
|
|
}
|