Implement class for handling filesystem paths

PR #15915.
This commit is contained in:
Vladimir Golovnev
2022-02-08 06:03:48 +03:00
committed by GitHub
parent facfa26eed
commit dd1bd8ad10
131 changed files with 2252 additions and 1868 deletions

View File

@@ -44,6 +44,7 @@
#include "base/bittorrent/torrentinfo.h"
#include "base/exceptions.h"
#include "base/global.h"
#include "base/path.h"
#include "base/utils/fs.h"
#include "autoexpandabledialog.h"
#include "raisedmessagebox.h"
@@ -52,12 +53,12 @@
namespace
{
QString getFullPath(const QModelIndex &idx)
Path getFullPath(const QModelIndex &idx)
{
QStringList paths;
Path path;
for (QModelIndex i = idx; i.isValid(); i = i.parent())
paths.prepend(i.data().toString());
return paths.join(QLatin1Char {'/'});
path = Path(i.data().toString()) / path;
return path;
}
}
@@ -130,9 +131,9 @@ void TorrentContentTreeView::renameSelectedFile(BitTorrent::AbstractFileStorage
if (newName == oldName)
return; // Name did not change
const QString parentPath = getFullPath(modelIndex.parent());
const QString oldPath {parentPath.isEmpty() ? oldName : parentPath + QLatin1Char {'/'} + oldName};
const QString newPath {parentPath.isEmpty() ? newName : parentPath + QLatin1Char {'/'} + newName};
const Path parentPath = getFullPath(modelIndex.parent());
const Path oldPath = parentPath / Path(oldName);
const Path newPath = parentPath / Path(newName);
try
{