Skip to content

Commit

Permalink
Convert fsutils class to namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Gelmir committed Jan 22, 2014
1 parent bd9dcf1 commit 5854a28
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 30 deletions.
7 changes: 4 additions & 3 deletions src/fs_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ QString fsutils::QDesktopServicesDownloadLocation() {
// TODO: Use IKnownFolderManager to get path of FOLDERID_Downloads
// instead of hardcoding "Downloads"
// Unfortunately, this would break compatibility with WinXP
return QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath(tr("Downloads"));
return QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath(
QCoreApplication::translate("fsutils", "Downloads"));
#endif

#ifdef Q_WS_X11
Expand Down Expand Up @@ -459,7 +460,7 @@ QString fsutils::QDesktopServicesDownloadLocation() {
}

if (save_path.isEmpty() || !QFile::exists(save_path)) {
save_path = QDir::home().absoluteFilePath(tr("Downloads"));
save_path = QDir::home().absoluteFilePath(QCoreApplication::translate("fsutils", "Downloads"));
qDebug() << Q_FUNC_INFO << "using" << save_path << "as fallback since the XDG detection did not work";
}

Expand All @@ -471,7 +472,7 @@ QString fsutils::QDesktopServicesDownloadLocation() {
#endif

// Fallback
return QDir::home().absoluteFilePath(tr("Downloads"));
return QDir::home().absoluteFilePath(QCoreApplication::translate("fsutils", "Downloads"));
}

QString fsutils::searchEngineLocation() {
Expand Down
52 changes: 25 additions & 27 deletions src/fs_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,37 @@
/**
* Utility functions related to file system.
*/
class fsutils
namespace fsutils
{
Q_DECLARE_TR_FUNCTIONS(fsutils)

public:
static QString toNativePath(const QString& path);
static QString fromNativePath(const QString& path);
static QString fileExtension(const QString& filename);
static QString fileName(const QString& file_path);
static qint64 computePathSize(const QString& path);
static bool sameFiles(const QString& path1, const QString& path2);
static QString updateLabelInSavePath(const QString &defaultSavePath, const QString &save_path, const QString& old_label, const QString& new_label);
static QString toValidFileSystemName(QString filename);
static bool isValidFileSystemName(const QString& filename);
static long long freeDiskSpaceOnPath(QString path);
static QString branchPath(const QString& file_path, QString* removed = 0);
static bool sameFileNames(const QString& first, const QString& second);
static QString expandPath(const QString& path);
static QString expandPathAbs(const QString& path);
static bool isValidTorrentFile(const QString& path);
static bool smartRemoveEmptyFolderTree(const QString& dir_path);
static bool forceRemove(const QString& file_path);
QString toNativePath(const QString& path);
QString fromNativePath(const QString& path);
QString fileExtension(const QString& filename);
QString fileName(const QString& file_path);
qint64 computePathSize(const QString& path);
bool sameFiles(const QString& path1, const QString& path2);
QString updateLabelInSavePath(const QString &defaultSavePath, const QString &save_path, const QString& old_label, const QString& new_label);
QString toValidFileSystemName(QString filename);
bool isValidFileSystemName(const QString& filename);
long long freeDiskSpaceOnPath(QString path);
QString branchPath(const QString& file_path, QString* removed = 0);
bool sameFileNames(const QString& first, const QString& second);
QString expandPath(const QString& path);
QString expandPathAbs(const QString& path);
bool isValidTorrentFile(const QString& path);
bool smartRemoveEmptyFolderTree(const QString& dir_path);
bool forceRemove(const QString& file_path);

/* Ported from Qt4 to drop dependency on QtGui */
static QString QDesktopServicesDataLocation();
static QString QDesktopServicesCacheLocation();
static QString QDesktopServicesDownloadLocation();
QString QDesktopServicesDataLocation();
QString QDesktopServicesCacheLocation();
QString QDesktopServicesDownloadLocation();
/* End of Qt4 code */
static QString searchEngineLocation();
static QString BTBackupLocation();
static QString cacheLocation();
QString searchEngineLocation();
QString BTBackupLocation();
QString cacheLocation();

};
}

#endif // FS_UTILS_H

0 comments on commit 5854a28

Please sign in to comment.