mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 08:36:52 +08:00
Ref T258, utility functions
This commit is contained in:
@@ -406,6 +406,12 @@ namespace BlackMisc
|
||||
return fixedPaths;
|
||||
}
|
||||
|
||||
QString CFileUtils::toWindowsLocalPath(const QString &path)
|
||||
{
|
||||
QString p = CFileUtils::fixWindowsUncPath(path);
|
||||
return p.replace('/', '\\');
|
||||
}
|
||||
|
||||
QString CFileUtils::humanReadableFileSize(qint64 size)
|
||||
{
|
||||
// from https://stackoverflow.com/a/30958189/356726
|
||||
|
||||
@@ -151,6 +151,9 @@ namespace BlackMisc
|
||||
//! Fix UNC file paths
|
||||
static QStringList fixWindowsUncPaths(const QStringList &filePaths);
|
||||
|
||||
//! To Windows path using "\" delimiter
|
||||
static QString toWindowsLocalPath(const QString &path);
|
||||
|
||||
//! Human readable (GB, MB, ..) file size
|
||||
static QString humanReadableFileSize(qint64 size);
|
||||
|
||||
|
||||
@@ -331,6 +331,14 @@ namespace BlackMisc
|
||||
if (in.isEmpty()) { return ignoreEmpty ? e : ea; }
|
||||
return QStringLiteral("'") % in % QStringLiteral("'");
|
||||
}
|
||||
|
||||
const QString inQuotes(const QString &in, bool ignoreEmpty)
|
||||
{
|
||||
static const QString e;
|
||||
static const QString ea("\"\"");
|
||||
if (in.isEmpty()) { return ignoreEmpty ? e : ea; }
|
||||
return QStringLiteral("\"") % in % QStringLiteral("\"");
|
||||
}
|
||||
}
|
||||
|
||||
//! \endcond
|
||||
|
||||
@@ -123,6 +123,9 @@ namespace BlackMisc
|
||||
//! Return string in apostrophes
|
||||
BLACKMISC_EXPORT const QString inApostrophes(const QString &in, bool ignoreEmpty = false);
|
||||
|
||||
//! Return string in quotes
|
||||
BLACKMISC_EXPORT const QString inQuotes(const QString &in, bool ignoreEmpty = false);
|
||||
|
||||
//! Bool to on/off
|
||||
BLACKMISC_EXPORT const QString &boolToOnOff(bool v);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user