forked from qt-creator/qt-creator
ProjectNode: Rename path() to filePath()
Change-Id: I78bb73f8c9457fd74c470eacbf54eb9195ac9681 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -110,7 +110,7 @@ static bool sortByPrefixAndLang(ProjectExplorer::FolderNode *a, ProjectExplorer:
|
||||
|
||||
static bool sortNodesByPath(ProjectExplorer::Node *a, ProjectExplorer::Node *b)
|
||||
{
|
||||
return a->path() < b->path();
|
||||
return a->filePath() < b->filePath();
|
||||
}
|
||||
|
||||
ResourceTopLevelNode::ResourceTopLevelNode(const Utils::FileName &filePath, FolderNode *parent)
|
||||
@@ -120,7 +120,7 @@ ResourceTopLevelNode::ResourceTopLevelNode(const Utils::FileName &filePath, Fold
|
||||
m_document = new ResourceFileWatcher(this);
|
||||
Core::DocumentManager::addDocument(m_document);
|
||||
|
||||
Utils::FileName base = parent->path();
|
||||
Utils::FileName base = parent->filePath();
|
||||
if (filePath.isChildOf(base))
|
||||
setDisplayName(filePath.relativeChildPath(base).toString());
|
||||
else
|
||||
@@ -138,7 +138,7 @@ void ResourceTopLevelNode::update()
|
||||
QList<ProjectExplorer::FolderNode *> newFolderList;
|
||||
QMap<QPair<QString, QString>, QList<ProjectExplorer::FileNode *> > filesToAdd;
|
||||
|
||||
ResourceFile file(path().toString());
|
||||
ResourceFile file(filePath().toString());
|
||||
if (file.load() == Core::IDocument::OpenResult::Success) {
|
||||
QSet<QPair<QString, QString > > prefixes;
|
||||
|
||||
@@ -160,7 +160,7 @@ void ResourceTopLevelNode::update()
|
||||
const QString &fileName = file.file(i, j);
|
||||
QString alias = file.alias(i, j);
|
||||
if (alias.isEmpty())
|
||||
alias = path().toFileInfo().absoluteDir().relativeFilePath(fileName);
|
||||
alias = filePath().toFileInfo().absoluteDir().relativeFilePath(fileName);
|
||||
if (fileNames.contains(fileName)) {
|
||||
// The file name is duplicated, skip it
|
||||
// Note: this is wrong, but the qrceditor doesn't allow it either
|
||||
@@ -215,7 +215,7 @@ QList<ProjectExplorer::ProjectAction> ResourceTopLevelNode::supportedActions(Pro
|
||||
|
||||
bool ResourceTopLevelNode::addFiles(const QStringList &filePaths, QStringList *notAdded)
|
||||
{
|
||||
return addFilesToResource(path(), filePaths, notAdded, QLatin1String("/"), QString());
|
||||
return addFilesToResource(filePath(), filePaths, notAdded, QLatin1String("/"), QString());
|
||||
}
|
||||
|
||||
bool ResourceTopLevelNode::removeFiles(const QStringList &filePaths, QStringList *notRemoved)
|
||||
@@ -225,31 +225,31 @@ bool ResourceTopLevelNode::removeFiles(const QStringList &filePaths, QStringList
|
||||
|
||||
bool ResourceTopLevelNode::addPrefix(const QString &prefix, const QString &lang)
|
||||
{
|
||||
ResourceFile file(path().toString());
|
||||
ResourceFile file(filePath().toString());
|
||||
if (file.load() != Core::IDocument::OpenResult::Success)
|
||||
return false;
|
||||
int index = file.addPrefix(prefix, lang);
|
||||
if (index == -1)
|
||||
return false;
|
||||
Core::DocumentManager::expectFileChange(path().toString());
|
||||
Core::DocumentManager::expectFileChange(filePath().toString());
|
||||
file.save();
|
||||
Core::DocumentManager::unexpectFileChange(path().toString());
|
||||
Core::DocumentManager::unexpectFileChange(filePath().toString());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ResourceTopLevelNode::removePrefix(const QString &prefix, const QString &lang)
|
||||
{
|
||||
ResourceFile file(path().toString());
|
||||
ResourceFile file(filePath().toString());
|
||||
if (file.load() != Core::IDocument::OpenResult::Success)
|
||||
return false;
|
||||
for (int i = 0; i < file.prefixCount(); ++i) {
|
||||
if (file.prefix(i) == prefix
|
||||
&& file.lang(i) == lang) {
|
||||
file.removePrefix(i);
|
||||
Core::DocumentManager::expectFileChange(path().toString());
|
||||
Core::DocumentManager::expectFileChange(filePath().toString());
|
||||
file.save();
|
||||
Core::DocumentManager::unexpectFileChange(path().toString());
|
||||
Core::DocumentManager::unexpectFileChange(filePath().toString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -258,7 +258,7 @@ bool ResourceTopLevelNode::removePrefix(const QString &prefix, const QString &la
|
||||
|
||||
bool ResourceTopLevelNode::removeNonExistingFiles()
|
||||
{
|
||||
ResourceFile file(path().toString());
|
||||
ResourceFile file(filePath().toString());
|
||||
if (file.load() != Core::IDocument::OpenResult::Success)
|
||||
return false;
|
||||
|
||||
@@ -273,16 +273,16 @@ bool ResourceTopLevelNode::removeNonExistingFiles()
|
||||
}
|
||||
}
|
||||
|
||||
Core::DocumentManager::expectFileChange(path().toString());
|
||||
Core::DocumentManager::expectFileChange(filePath().toString());
|
||||
file.save();
|
||||
Core::DocumentManager::unexpectFileChange(path().toString());
|
||||
Core::DocumentManager::unexpectFileChange(filePath().toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
ProjectExplorer::FolderNode::AddNewInformation ResourceTopLevelNode::addNewInformation(const QStringList &files, Node *context) const
|
||||
{
|
||||
QString name = QCoreApplication::translate("ResourceTopLevelNode", "%1 Prefix: %2")
|
||||
.arg(path().fileName())
|
||||
.arg(filePath().fileName())
|
||||
.arg(QLatin1Char('/'));
|
||||
|
||||
int p = -1;
|
||||
@@ -309,7 +309,7 @@ bool ResourceTopLevelNode::showInSimpleTree() const
|
||||
}
|
||||
|
||||
ResourceFolderNode::ResourceFolderNode(const QString &prefix, const QString &lang, ResourceTopLevelNode *parent)
|
||||
: ProjectExplorer::FolderNode(Utils::FileName(parent->path()).appendPath(prefix)),
|
||||
: ProjectExplorer::FolderNode(Utils::FileName(parent->filePath()).appendPath(prefix)),
|
||||
// TOOD Why add existing directory doesn't work
|
||||
m_topLevelNode(parent),
|
||||
m_prefix(prefix),
|
||||
@@ -344,14 +344,14 @@ QList<ProjectExplorer::ProjectAction> ResourceFolderNode::supportedActions(Proje
|
||||
|
||||
bool ResourceFolderNode::addFiles(const QStringList &filePaths, QStringList *notAdded)
|
||||
{
|
||||
return addFilesToResource(m_topLevelNode->path(), filePaths, notAdded, m_prefix, m_lang);
|
||||
return addFilesToResource(m_topLevelNode->filePath(), filePaths, notAdded, m_prefix, m_lang);
|
||||
}
|
||||
|
||||
bool ResourceFolderNode::removeFiles(const QStringList &filePaths, QStringList *notRemoved)
|
||||
{
|
||||
if (notRemoved)
|
||||
*notRemoved = filePaths;
|
||||
ResourceFile file(m_topLevelNode->path().toString());
|
||||
ResourceFile file(m_topLevelNode->filePath().toString());
|
||||
if (file.load() != Core::IDocument::OpenResult::Success)
|
||||
return false;
|
||||
int index = file.indexOfPrefix(m_prefix, m_lang);
|
||||
@@ -366,16 +366,16 @@ bool ResourceFolderNode::removeFiles(const QStringList &filePaths, QStringList *
|
||||
file.removeFile(index, j);
|
||||
--j;
|
||||
}
|
||||
Core::DocumentManager::expectFileChange(m_topLevelNode->path().toString());
|
||||
Core::DocumentManager::expectFileChange(m_topLevelNode->filePath().toString());
|
||||
file.save();
|
||||
Core::DocumentManager::unexpectFileChange(m_topLevelNode->path().toString());
|
||||
Core::DocumentManager::unexpectFileChange(m_topLevelNode->filePath().toString());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ResourceFolderNode::renameFile(const QString &filePath, const QString &newFilePath)
|
||||
{
|
||||
ResourceFile file(m_topLevelNode->path().toString());
|
||||
ResourceFile file(m_topLevelNode->filePath().toString());
|
||||
if (file.load() != Core::IDocument::OpenResult::Success)
|
||||
return false;
|
||||
int index = file.indexOfPrefix(m_prefix, m_lang);
|
||||
@@ -385,9 +385,9 @@ bool ResourceFolderNode::renameFile(const QString &filePath, const QString &newF
|
||||
for (int j = 0; j < file.fileCount(index); ++j) {
|
||||
if (file.file(index, j) == filePath) {
|
||||
file.replaceFile(index, j, newFilePath);
|
||||
Core::DocumentManager::expectFileChange(m_topLevelNode->path().toString());
|
||||
Core::DocumentManager::expectFileChange(m_topLevelNode->filePath().toString());
|
||||
file.save();
|
||||
Core::DocumentManager::unexpectFileChange(m_topLevelNode->path().toString());
|
||||
Core::DocumentManager::unexpectFileChange(m_topLevelNode->filePath().toString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -397,7 +397,7 @@ bool ResourceFolderNode::renameFile(const QString &filePath, const QString &newF
|
||||
|
||||
bool ResourceFolderNode::renamePrefix(const QString &prefix, const QString &lang)
|
||||
{
|
||||
ResourceFile file(m_topLevelNode->path().toString());
|
||||
ResourceFile file(m_topLevelNode->filePath().toString());
|
||||
if (file.load() != Core::IDocument::OpenResult::Success)
|
||||
return false;
|
||||
int index = file.indexOfPrefix(m_prefix, m_lang);
|
||||
@@ -407,16 +407,16 @@ bool ResourceFolderNode::renamePrefix(const QString &prefix, const QString &lang
|
||||
if (!file.replacePrefixAndLang(index, prefix, lang))
|
||||
return false;
|
||||
|
||||
Core::DocumentManager::expectFileChange(m_topLevelNode->path().toString());
|
||||
Core::DocumentManager::expectFileChange(m_topLevelNode->filePath().toString());
|
||||
file.save();
|
||||
Core::DocumentManager::unexpectFileChange(m_topLevelNode->path().toString());
|
||||
Core::DocumentManager::unexpectFileChange(m_topLevelNode->filePath().toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
ProjectExplorer::FolderNode::AddNewInformation ResourceFolderNode::addNewInformation(const QStringList &files, Node *context) const
|
||||
{
|
||||
QString name = QCoreApplication::translate("ResourceTopLevelNode", "%1 Prefix: %2")
|
||||
.arg(m_topLevelNode->path().fileName())
|
||||
.arg(m_topLevelNode->filePath().fileName())
|
||||
.arg(displayName());
|
||||
|
||||
int p = -1; // never the default
|
||||
@@ -473,7 +473,7 @@ ResourceFileWatcher::ResourceFileWatcher(ResourceTopLevelNode *node)
|
||||
{
|
||||
setId("ResourceNodeWatcher");
|
||||
setMimeType(QLatin1String(ResourceEditor::Constants::C_RESOURCE_MIMETYPE));
|
||||
setFilePath(node->path());
|
||||
setFilePath(node->filePath());
|
||||
}
|
||||
|
||||
bool ResourceFileWatcher::save(QString *errorString, const QString &fileName, bool autoSave)
|
||||
@@ -526,7 +526,7 @@ ResourceFileNode::ResourceFileNode(const Utils::FileName &filePath, const QStrin
|
||||
m_qrcPath(qrcPath)
|
||||
|
||||
{
|
||||
QDir baseDir = topLevel->path().toFileInfo().absoluteDir();
|
||||
QDir baseDir = topLevel->filePath().toFileInfo().absoluteDir();
|
||||
m_displayName = QDir(baseDir).relativeFilePath(filePath.toString());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user