summaryrefslogtreecommitdiff
path: root/src/plugins/texteditor/textdocument.cpp
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2014-12-21 21:54:30 +0200
committerOrgad Shaneh <orgads@gmail.com>2015-01-12 10:23:37 +0100
commitc6a983d27179ebd26e692918e58d44aa77fc7f8a (patch)
tree6ef23b30a2e6c4a29c14acbb824e38bae026acdb /src/plugins/texteditor/textdocument.cpp
parent9c1b28fec265054ba4a9c13093ebcfc0f5b4c723 (diff)
downloadqt-creator-c6a983d27179ebd26e692918e58d44aa77fc7f8a.tar.gz
Core: Use FileName for file path in IDocument
Change-Id: I85f7398aee59d0d36f0e5c3bf88ff3c96002e394 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Diffstat (limited to 'src/plugins/texteditor/textdocument.cpp')
-rw-r--r--src/plugins/texteditor/textdocument.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/plugins/texteditor/textdocument.cpp b/src/plugins/texteditor/textdocument.cpp
index 9e312eb29c..d9b5e25023 100644
--- a/src/plugins/texteditor/textdocument.cpp
+++ b/src/plugins/texteditor/textdocument.cpp
@@ -231,7 +231,7 @@ QMap<QString, QString> TextDocument::openedTextDocumentContents()
TextDocument *textEditorDocument = qobject_cast<TextDocument *>(document);
if (!textEditorDocument)
continue;
- QString fileName = textEditorDocument->filePath();
+ QString fileName = textEditorDocument->filePath().toString();
workingCopy[fileName] = textEditorDocument->plainText();
}
return workingCopy;
@@ -244,7 +244,7 @@ QMap<QString, QTextCodec *> TextDocument::openedTextDocumentEncodings()
TextDocument *textEditorDocument = qobject_cast<TextDocument *>(document);
if (!textEditorDocument)
continue;
- QString fileName = textEditorDocument->filePath();
+ QString fileName = textEditorDocument->filePath().toString();
workingCopy[fileName] = const_cast<QTextCodec *>(textEditorDocument->codec());
}
return workingCopy;
@@ -466,7 +466,7 @@ bool TextDocument::save(QString *errorString, const QString &saveFileName, bool
cursor.endEditBlock();
}
- QString fName = filePath();
+ QString fName = filePath().toString();
if (!saveFileName.isEmpty())
fName = saveFileName;
@@ -509,7 +509,7 @@ bool TextDocument::save(QString *errorString, const QString &saveFileName, bool
// inform about the new filename
const QFileInfo fi(fName);
d->m_document.setModified(false); // also triggers update of the block revisions
- setFilePath(QDir::cleanPath(fi.absoluteFilePath()));
+ setFilePath(Utils::FileName::fromUserInput(fi.absoluteFilePath()));
emit changed();
return true;
}
@@ -524,12 +524,11 @@ bool TextDocument::shouldAutoSave() const
return d->m_autoSaveRevision != d->m_document.revision();
}
-void TextDocument::setFilePath(const QString &newName)
+void TextDocument::setFilePath(const Utils::FileName &newName)
{
if (newName == filePath())
return;
- const QFileInfo fi(newName);
- IDocument::setFilePath(QDir::cleanPath(fi.absoluteFilePath()));
+ IDocument::setFilePath(Utils::FileName::fromUserInput(newName.toFileInfo().absoluteFilePath()));
}
bool TextDocument::isFileReadOnly() const
@@ -548,8 +547,7 @@ void TextDocument::checkPermissions()
{
bool previousReadOnly = d->m_fileIsReadOnly;
if (!filePath().isEmpty()) {
- const QFileInfo fi(filePath());
- d->m_fileIsReadOnly = !fi.isWritable();
+ d->m_fileIsReadOnly = !filePath().toFileInfo().isWritable();
} else {
d->m_fileIsReadOnly = false;
}
@@ -598,7 +596,7 @@ bool TextDocument::open(QString *errorString, const QString &fileName, const QSt
documentLayout->lastSaveRevision = d->m_autoSaveRevision = d->m_document.revision();
d->updateRevisions();
d->m_document.setModified(fileName != realFileName);
- setFilePath(QDir::cleanPath(fi.absoluteFilePath()));
+ setFilePath(Utils::FileName::fromUserInput(fi.absoluteFilePath()));
}
return readResult == Utils::TextFileFormat::ReadSuccess
|| readResult == Utils::TextFileFormat::ReadEncodingError;
@@ -620,7 +618,7 @@ bool TextDocument::reload(QString *errorString)
if (documentLayout)
marks = documentLayout->documentClosing(); // removes text marks non-permanently
- bool success = open(errorString, filePath(), filePath());
+ bool success = open(errorString, filePath().toString(), filePath().toString());
if (documentLayout)
documentLayout->documentReloaded(marks, this); // re-adds text marks