Core: Use FileName for file path in IDocument

Change-Id: I85f7398aee59d0d36f0e5c3bf88ff3c96002e394
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2014-12-21 21:54:30 +02:00
committed by Orgad Shaneh
parent 9c1b28fec2
commit c6a983d271
123 changed files with 327 additions and 324 deletions

View File

@@ -44,6 +44,7 @@
#include <coreplugin/editormanager/ieditorfactory.h>
#include <coreplugin/editormanager/iexternaleditor.h>
#include <utils/fileutils.h>
#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/pathchooser.h>
@@ -265,8 +266,8 @@ static void addFileInfo(const QString &fileName, IDocument *document, bool isLin
(The added file names are guaranteed to be absolute and cleaned.) */
static void addFileInfo(IDocument *document)
{
const QString fixedName = DocumentManager::fixFileName(document->filePath(), DocumentManager::KeepLinks);
const QString fixedResolvedName = DocumentManager::fixFileName(document->filePath(), DocumentManager::ResolveLinks);
const QString fixedName = DocumentManager::fixFileName(document->filePath().toString(), DocumentManager::KeepLinks);
const QString fixedResolvedName = DocumentManager::fixFileName(document->filePath().toString(), DocumentManager::ResolveLinks);
addFileInfo(fixedResolvedName, document, false);
if (fixedName != fixedResolvedName)
addFileInfo(fixedName, document, true);
@@ -285,7 +286,8 @@ void DocumentManager::addDocuments(const QList<IDocument *> &documents, bool add
foreach (IDocument *document, documents) {
if (document && !d->m_documentsWithoutWatch.contains(document)) {
connect(document, SIGNAL(destroyed(QObject*)), m_instance, SLOT(documentDestroyed(QObject*)));
connect(document, SIGNAL(filePathChanged(QString,QString)), m_instance, SLOT(filePathChanged(QString,QString)));
connect(document, &IDocument::filePathChanged,
m_instance, &DocumentManager::filePathChanged);
d->m_documentsWithoutWatch.append(document);
}
}
@@ -296,7 +298,7 @@ void DocumentManager::addDocuments(const QList<IDocument *> &documents, bool add
if (document && !d->m_documentsWithWatch.contains(document)) {
connect(document, SIGNAL(changed()), m_instance, SLOT(checkForNewFileName()));
connect(document, SIGNAL(destroyed(QObject*)), m_instance, SLOT(documentDestroyed(QObject*)));
connect(document, SIGNAL(filePathChanged(QString,QString)), m_instance, SLOT(filePathChanged(QString,QString)));
connect(document, &IDocument::filePathChanged, m_instance, &DocumentManager::filePathChanged);
addFileInfo(document);
}
}
@@ -387,20 +389,20 @@ void DocumentManager::renamedFile(const QString &from, const QString &to)
foreach (IDocument *document, documentsToRename) {
d->m_blockedIDocument = document;
removeFileInfo(document);
document->setFilePath(to);
document->setFilePath(Utils::FileName::fromString(to));
addFileInfo(document);
d->m_blockedIDocument = 0;
}
emit m_instance->allDocumentsRenamed(from, to);
}
void DocumentManager::filePathChanged(const QString &oldName, const QString &newName)
void DocumentManager::filePathChanged(const Utils::FileName &oldName, const Utils::FileName &newName)
{
IDocument *doc = qobject_cast<IDocument *>(sender());
QTC_ASSERT(doc, return);
if (doc == d->m_blockedIDocument)
return;
emit m_instance->documentRenamed(doc, oldName, newName);
emit m_instance->documentRenamed(doc, oldName.toString(), newName.toString());
}
/*!
@@ -564,7 +566,7 @@ static bool saveModifiedFilesHelper(const QList<IDocument *> &documents,
foreach (IDocument *document, documents) {
if (document && document->isModified()) {
QString name = document->filePath();
QString name = document->filePath().toString();
if (name.isEmpty())
name = document->suggestedFileName();
@@ -634,7 +636,7 @@ static bool saveModifiedFilesHelper(const QList<IDocument *> &documents,
bool DocumentManager::saveDocument(IDocument *document, const QString &fileName, bool *isReadOnly)
{
bool ret = true;
QString effName = fileName.isEmpty() ? document->filePath() : fileName;
QString effName = fileName.isEmpty() ? document->filePath().toString() : fileName;
expectFileChange(effName); // This only matters to other IDocuments which refer to this file
bool addWatcher = removeDocument(document); // So that our own IDocument gets no notification at all
@@ -721,7 +723,7 @@ QString DocumentManager::getSaveAsFileName(const IDocument *document, const QStr
{
if (!document)
return QLatin1String("");
QString absoluteFilePath = document->filePath();
QString absoluteFilePath = document->filePath().toString();
const QFileInfo fi(absoluteFilePath);
QString path;
QString fileName;
@@ -1063,7 +1065,7 @@ void DocumentManager::checkForReload()
success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents);
} else {
// Ask about content change
previousReloadAnswer = Utils::reloadPrompt(document->filePath(), document->isModified(),
previousReloadAnswer = Utils::reloadPrompt(document->filePath().toString(), document->isModified(),
ICore::dialogParent());
switch (previousReloadAnswer) {
case Utils::ReloadAll:
@@ -1086,13 +1088,13 @@ void DocumentManager::checkForReload()
while (unhandled) {
if (previousDeletedAnswer != Utils::FileDeletedCloseAll) {
previousDeletedAnswer =
Utils::fileDeletedPrompt(document->filePath(),
Utils::fileDeletedPrompt(document->filePath().toString(),
trigger == IDocument::TriggerExternal,
QApplication::activeWindow());
}
switch (previousDeletedAnswer) {
case Utils::FileDeletedSave:
documentsToSave.insert(document, document->filePath());
documentsToSave.insert(document, document->filePath().toString());
unhandled = false;
break;
case Utils::FileDeletedSaveAs:
@@ -1115,7 +1117,7 @@ void DocumentManager::checkForReload()
}
if (!success) {
if (errorString.isEmpty())
errorStrings << tr("Cannot reload %1").arg(QDir::toNativeSeparators(document->filePath()));
errorStrings << tr("Cannot reload %1").arg(document->filePath().toUserOutput());
else
errorStrings << errorString;
}