refactor: move functions to utils + code-review fixes

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers
2023-05-06 19:10:58 -07:00
parent d0b6f0124b
commit 62a402d05a
10 changed files with 194 additions and 146 deletions

View File

@ -1,6 +1,7 @@
#pragma once
#include <QString>
#include <QUrl>
namespace StringUtils {
@ -29,4 +30,15 @@ inline QString fromStdString(string s)
#endif
int naturalCompare(const QString& s1, const QString& s2, Qt::CaseSensitivity cs);
/**
* @brief Truncate a url while keeping its readability py placing the `...` in the middle of the path
* @param url Url to truncate
* @param max_len max lenght of url in charaters
* @param hard_limit if truncating the path can't get the url short enough, truncate it normaly.
*/
QString truncateUrlHumanFriendly(QUrl &url, int max_len, bool hard_limit = false);
QString humanReadableFileSize(double bytes, bool use_si = false, int decimal_points = 1);
} // namespace StringUtils