Commit c6a983d2 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

Core: Use FileName for file path in IDocument

Change-Id: I85f7398aee59d0d36f0e5c3bf88ff3c96002e394
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 9c1b28fe
......@@ -74,7 +74,7 @@ CPlusPlus::Symbol *AnalyzerUtils::findSymbolUnderCursor()
widget->convertPosition(pos, &line, &column);
const CPlusPlus::Snapshot &snapshot = CppTools::CppModelManager::instance()->snapshot();
CPlusPlus::Document::Ptr doc = snapshot.document(widget->textDocument()->filePath());
CPlusPlus::Document::Ptr doc = snapshot.document(widget->textDocument()->filePath().toString());
QTC_ASSERT(doc, return 0);
// fetch the expression's code
......
......@@ -56,14 +56,12 @@ bool AndroidManifestDocument::save(QString *errorString, const QString &fileName
QString AndroidManifestDocument::defaultPath() const
{
QFileInfo fi(filePath());
return fi.absolutePath();
return filePath().toFileInfo().absolutePath();
}
QString AndroidManifestDocument::suggestedFileName() const
{
QFileInfo fi(filePath());
return fi.fileName();
return filePath().toFileInfo().fileName();
}
bool AndroidManifestDocument::isModified() const
......
......@@ -476,7 +476,7 @@ bool AndroidManifestEditorWidget::eventFilter(QObject *obj, QEvent *event)
void AndroidManifestEditorWidget::updateTargetComboBox()
{
const QString docPath(m_textEditorWidget->textDocument()->filePath());
const QString docPath(m_textEditorWidget->textDocument()->filePath().toString());
ProjectExplorer::Project *project = androidProject(docPath);
QStringList items;
if (project) {
......@@ -577,7 +577,7 @@ void AndroidManifestEditorWidget::preSave()
syncToEditor();
if (m_setAppName && m_appNameInStringsXml) {
QString baseDir = QFileInfo(m_textEditorWidget->textDocument()->filePath()).absolutePath();
QString baseDir = m_textEditorWidget->textDocument()->filePath().toFileInfo().absolutePath();
QString fileName = baseDir + QLatin1String("/res/values/strings.xml");
QFile f(fileName);
if (f.open(QIODevice::ReadOnly)) {
......@@ -601,7 +601,7 @@ void AndroidManifestEditorWidget::preSave()
m_setAppName = false;
}
QString baseDir = QFileInfo(m_textEditorWidget->textDocument()->filePath()).absolutePath();
QString baseDir = m_textEditorWidget->textDocument()->filePath().toFileInfo().absolutePath();
if (!m_lIconPath.isEmpty()) {
copyIcon(LowDPI, baseDir, m_lIconPath);
m_lIconPath.clear();
......@@ -695,7 +695,7 @@ void AndroidManifestEditorWidget::updateInfoBar()
void AndroidManifestEditorWidget::updateSdkVersions()
{
const QString docPath(m_textEditorWidget->textDocument()->filePath());
const QString docPath(m_textEditorWidget->textDocument()->filePath().toString());
QPair<int, int> apiLevels = AndroidManager::apiLevelRange();
for (int i = apiLevels.first; i < apiLevels.second + 1; ++i)
m_androidMinSdkVersion->addItem(tr("API %1: %2")
......@@ -766,7 +766,7 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
setApiLevel(m_androidMinSdkVersion, usesSdkElement, QLatin1String("android:minSdkVersion"));
setApiLevel(m_androidTargetSdkVersion, usesSdkElement, QLatin1String("android:targetSdkVersion"));
QString baseDir = QFileInfo(m_textEditorWidget->textDocument()->filePath()).absolutePath();
QString baseDir = m_textEditorWidget->textDocument()->filePath().toFileInfo().absolutePath();
QString fileName = baseDir + QLatin1String("/res/values/strings.xml");
QDomElement applicationElement = manifest.firstChildElement(QLatin1String("application"));
......
......@@ -71,14 +71,12 @@ JavaDocument::JavaDocument()
QString JavaDocument::defaultPath() const
{
QFileInfo fi(filePath());
return fi.absolutePath();
return filePath().toFileInfo().absolutePath();
}
QString JavaDocument::suggestedFileName() const
{
QFileInfo fi(filePath());
return fi.fileName();
return filePath().toFileInfo().fileName();
}
......
......@@ -43,7 +43,7 @@ AutotoolsProjectFile::AutotoolsProjectFile(AutotoolsProject *project, const QStr
{
setId("Autotools.ProjectFile");
setMimeType(QLatin1String(Constants::MAKEFILE_MIMETYPE));
setFilePath(fileName);
setFilePath(Utils::FileName::fromString(fileName));
}
bool AutotoolsProjectFile::save(QString *errorString, const QString &fileName, bool autoSave)
......
......@@ -40,7 +40,7 @@ using namespace AutotoolsProjectManager::Internal;
using namespace ProjectExplorer;
AutotoolsProjectNode::AutotoolsProjectNode(AutotoolsProject *project, Core::IDocument *projectFile) :
ProjectNode(projectFile->filePath()),
ProjectNode(projectFile->filePath().toString()),
m_project(project),
m_projectFile(projectFile)
{
......
......@@ -746,7 +746,7 @@ bool BazaarPlugin::submitEditorAboutToClose()
// Whether local commit or not
if (commitWidget->isLocalOptionEnabled())
extraOptions += QLatin1String("--local");
m_client->commit(m_submitRepository, files, editorDocument->filePath(), extraOptions);
m_client->commit(m_submitRepository, files, editorDocument->filePath().toString(), extraOptions);
}
return true;
}
......
......@@ -233,7 +233,7 @@ void BeautifierPlugin::formatCurrentFile(const Command &command)
watcher, &QFutureWatcher<FormatTask>::cancel);
connect(watcher, SIGNAL(finished()), m_asyncFormatMapper, SLOT(map()));
m_asyncFormatMapper->setMapping(watcher, watcher);
const QString filePath = widget->textDocument()->filePath();
const QString filePath = widget->textDocument()->filePath().toString();
watcher->setFuture(QtConcurrent::run(&BeautifierPlugin::formatAsync, this,
FormatTask(widget, filePath, sourceData, command)));
}
......
......@@ -61,6 +61,7 @@
#include <utils/reloadpromptutils.h>
#include <utils/qtcassert.h>
using namespace Utils;
using namespace Core;
namespace BinEditor {
......@@ -256,9 +257,8 @@ public:
bool save(QString *errorString, const QString &fn, bool autoSave)
{
QTC_ASSERT(!autoSave, return true); // bineditor does not support autosave - it would be a bit expensive
const QString fileNameToUse
= fn.isEmpty() ? filePath() : fn;
if (m_widget->save(errorString, filePath(), fileNameToUse)) {
const FileName fileNameToUse = fn.isEmpty() ? filePath() : FileName::fromString(fn);
if (m_widget->save(errorString, filePath().toString(), fileNameToUse.toString())) {
setFilePath(fileNameToUse);
return true;
} else {
......@@ -281,7 +281,7 @@ public:
return false;
if (file.open(QIODevice::ReadOnly)) {
file.close();
setFilePath(fileName);
setFilePath(Utils::FileName::fromString(fileName));
m_widget->setSizes(offset, file.size());
return true;
}
......@@ -297,10 +297,10 @@ public:
private slots:
void provideData(quint64 block)
{
const QString fn = filePath();
const FileName fn = filePath();
if (fn.isEmpty())
return;
QFile file(fn);
QFile file(fn.toString());
if (file.open(QIODevice::ReadOnly)) {
int blockSize = m_widget->dataBlockSize();
file.seek(block * blockSize);
......@@ -313,13 +313,13 @@ private slots:
} else {
QMessageBox::critical(Core::ICore::mainWindow(), tr("File Error"),
tr("Cannot open %1: %2").arg(
QDir::toNativeSeparators(fn), file.errorString()));
fn.toUserOutput(), file.errorString()));
}
}
void provideNewRange(quint64 offset)
{
open(0, filePath(), offset);
open(0, filePath().toString(), offset);
}
public:
......@@ -332,11 +332,10 @@ public:
: m_widget->isModified(); }
bool isFileReadOnly() const {
const QString fn = filePath();
const FileName fn = filePath();
if (fn.isEmpty())
return false;
const QFileInfo fi(fn);
return !fi.isWritable();
return !fn.toFileInfo().isWritable();
}
bool isSaveAsAllowed() const { return true; }
......@@ -350,7 +349,7 @@ public:
emit aboutToReload();
int cPos = m_widget->cursorPosition();
m_widget->clear();
const bool success = open(errorString, filePath());
const bool success = open(errorString, filePath().toString());
m_widget->setCursorPosition(cPos);
emit reloadFinished(success);
return success;
......
......@@ -437,7 +437,7 @@ void BookmarkManager::toggleBookmark(bool)
if (!editor)
return;
toggleBookmark(editor->document()->filePath(), editor->currentLine());
toggleBookmark(editor->document()->filePath().toString(), editor->currentLine());
}
void BookmarkManager::toggleBookmark(const QString &fileName, int lineNumber)
......@@ -555,7 +555,7 @@ void BookmarkManager::documentPrevNext(bool next)
if (editorLine <= 0)
return;
QFileInfo fi(editor->document()->filePath());
const QFileInfo fi = editor->document()->filePath().toFileInfo();
if (!m_bookmarksMap.contains(fi.path()))
return;
......@@ -646,7 +646,7 @@ BookmarkManager::State BookmarkManager::state() const
if (!editor)
return HasBookMarks;
const QFileInfo fi(editor->document()->filePath());
const QFileInfo fi = editor->document()->filePath().toFileInfo();
const DirectoryFileBookmarksMap::const_iterator dit = m_bookmarksMap.constFind(fi.path());
if (dit == m_bookmarksMap.constEnd())
......@@ -849,7 +849,7 @@ void BookmarkManager::loadBookmarks()
void BookmarkManager::handleBookmarkTooltipRequest(IEditor *editor, const QPoint &pos, int line)
{
Bookmark *mark = findBookmark(editor->document()->filePath(), line);
Bookmark *mark = findBookmark(editor->document()->filePath().toString(), line);
operateTooltip(editor->widget(), pos, mark);
}
......
......@@ -110,7 +110,7 @@ bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *)
connect(m_toggleAction, &QAction::triggered, [this]() {
if (BaseTextEditor *editor = BaseTextEditor::currentTextEditor())
m_bookmarkManager->toggleBookmark(editor->document()->filePath(), editor->currentLine());
m_bookmarkManager->toggleBookmark(editor->document()->filePath().toString(), editor->currentLine());
});
connect(m_prevAction, &QAction::triggered, m_bookmarkManager, &BookmarkManager::prev);
......@@ -165,7 +165,7 @@ void BookmarksPlugin::editorOpened(IEditor *editor)
connect(widget, &TextEditorWidget::markRequested, m_bookmarkManager,
[this, editor](TextEditorWidget *, int line, TextMarkRequestKind kind) {
if (kind == BookmarkRequest && editor->document())
m_bookmarkManager->toggleBookmark(editor->document()->filePath(), line);
m_bookmarkManager->toggleBookmark(editor->document()->filePath().toString(), line);
});
......@@ -196,7 +196,7 @@ void BookmarksPlugin::requestContextMenu(TextEditorWidget *widget,
return;
m_bookmarkMarginActionLineNumber = lineNumber;
m_bookmarkMarginActionFileName = widget->textDocument()->filePath();
m_bookmarkMarginActionFileName = widget->textDocument()->filePath().toString();
menu->addAction(m_bookmarkMarginAction);
if (m_bookmarkManager->hasBookmarkInPosition(m_bookmarkMarginActionFileName, m_bookmarkMarginActionLineNumber))
......
......@@ -94,7 +94,7 @@ namespace ClangCodeModel {
ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(TextEditor::TextDocument *document)
: BaseEditorDocumentProcessor(document)
, m_parser(document->filePath())
, m_parser(document->filePath().toString())
, m_parserRevision(0)
, m_semanticHighlighter(document)
, m_builtinProcessor(document, /*enableSemanticHighlighter=*/ false)
......@@ -112,7 +112,7 @@ ClangEditorDocumentProcessor::ClangEditorDocumentProcessor(TextEditor::TextDocum
const int lastLine = baseTextDocument()->document()->blockCount();
CreateMarkers *createMarkers = CreateMarkers::create(m_parser.semanticMarker(),
baseTextDocument()->filePath(),
baseTextDocument()->filePath().toString(),
firstLine, lastLine);
return createMarkers->start();
});
......
......@@ -76,7 +76,7 @@ UnsavedFiles createUnsavedFiles(WorkingCopy workingCopy)
QSet< ::Utils::FileName> modifiedFiles;
foreach (IDocument *doc, Core::DocumentManager::modifiedDocuments())
modifiedFiles.insert(::Utils::FileName::fromString(doc->filePath()));
modifiedFiles.insert(doc->filePath());
UnsavedFiles result;
QHashIterator< ::Utils::FileName, QPair<QByteArray, unsigned> > wcIter = workingCopy.iterator();
......
......@@ -455,7 +455,7 @@ void Manager::gotoLocations(const QList<QVariant> &list)
auto textEditor = qobject_cast<TextEditor::BaseTextEditor *>(EditorManager::currentEditor());
if (textEditor) {
// check if current cursor position is a known location of the symbol
const QString fileName = textEditor->document()->filePath();
const QString fileName = textEditor->document()->filePath().toString();
int line;
int column;
textEditor->convertPosition(textEditor->position(), &line, &column);
......
......@@ -633,7 +633,7 @@ bool ClearCasePlugin::submitEditorAboutToClose()
// Submit editor closing. Make it write out the check in message
// and retrieve files
const QFileInfo editorFile(editorDocument->filePath());
const QFileInfo editorFile = editorDocument->filePath().toFileInfo();
const QFileInfo changeFile(m_checkInMessageFileName);
if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath())
return true; // Oops?!
......
......@@ -85,7 +85,7 @@ void CMakeEditor::finalizeInitialization()
info.setCustomButtonInfo(tr("Build now"), [document]() {
foreach (Project *p, SessionManager::projects()) {
if (CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(p)) {
if (cmakeProject->isProjectFile(document->filePath())) {
if (cmakeProject->isProjectFile(document->filePath().toString())) {
ProjectExplorerPlugin::buildProject(cmakeProject);
break;
}
......@@ -212,7 +212,7 @@ CMakeEditorWidget::Link CMakeEditorWidget::findLinkAt(const QTextCursor &cursor,
// TODO: Resolve variables
QDir dir(QFileInfo(textDocument()->filePath()).absolutePath());
QDir dir(textDocument()->filePath().toFileInfo().absolutePath());
QString fileName = dir.filePath(buffer);
QFileInfo fi(fileName);
if (fi.exists()) {
......@@ -252,14 +252,12 @@ CMakeDocument::CMakeDocument()
QString CMakeDocument::defaultPath() const
{
QFileInfo fi(filePath());
return fi.absolutePath();
return filePath().toFileInfo().absolutePath();
}
QString CMakeDocument::suggestedFileName() const
{
QFileInfo fi(filePath());
return fi.fileName();
return filePath().toFileInfo().fileName();
}
//
......
......@@ -233,7 +233,7 @@ bool CMakeProject::parseCMakeLists()
CMakeBuildConfiguration *activeBC = static_cast<CMakeBuildConfiguration *>(activeTarget()->activeBuildConfiguration());
foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments())
if (isProjectFile(document->filePath()))
if (isProjectFile(document->filePath().toString()))
document->infoBar()->removeInfo("CMakeEditor.RunCMake");
// Find cbp file
......@@ -741,7 +741,7 @@ CMakeFile::CMakeFile(CMakeProject *parent, QString fileName)
{
setId("Cmake.ProjectFile");
setMimeType(QLatin1String(Constants::CMAKEPROJECTMIMETYPE));
setFilePath(fileName);
setFilePath(Utils::FileName::fromString(fileName));
}
bool CMakeFile::save(QString *errorString, const QString &fileName, bool autoSave)
......
......@@ -162,7 +162,7 @@ ReadOnlyFilesDialog::ReadOnlyFilesDialog(IDocument *document, QWidget *parent,
: QDialog(parent)
, d(new ReadOnlyFilesDialogPrivate(this, document, displaySaveAs))
{
d->initDialog(QStringList(document->filePath()));
d->initDialog(QStringList(document->filePath().toString()));
}
ReadOnlyFilesDialog::ReadOnlyFilesDialog(const QList<IDocument *> &documents, QWidget *parent)
......@@ -171,7 +171,7 @@ ReadOnlyFilesDialog::ReadOnlyFilesDialog(const QList<IDocument *> &documents, QW
{
QStringList files;
foreach (IDocument *document, documents)
files << document->filePath();
files << document->filePath().toString();
d->initDialog(files);
}
......
......@@ -63,7 +63,7 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent,
foreach (IDocument *document, items) {
QString visibleName;
QString directory;
QString fileName = document->filePath();
QString fileName = document->filePath().toString();
if (fileName.isEmpty()) {
visibleName = document->suggestedFileName();
} else {
......
......@@ -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;
}
......
......@@ -43,6 +43,8 @@ class QMainWindow;
class QMenu;
QT_END_NAMESPACE
namespace Utils { class FileName; }
namespace Core {
class IContext;
......@@ -160,7 +162,6 @@ protected:
private slots:
void documentDestroyed(QObject *obj);
void filePathChanged(const QString &oldName, const QString &newName);
void checkForNewFileName();
void checkForReload();
void changedFile(const QString &file);
......@@ -169,6 +170,8 @@ private:
explicit DocumentManager(QObject *parent);
~DocumentManager();
void filePathChanged(const Utils::FileName &oldName, const Utils::FileName &newName);
friend class Core::Internal::MainWindow;
};
......
......@@ -130,7 +130,7 @@ QAbstractItemModel *DocumentModel::model()
QString DocumentModel::Entry::fileName() const
{
return document ? document->filePath() : m_fileName;
return document ? document->filePath().toString() : m_fileName;
}
QString DocumentModel::Entry::displayName() const
......@@ -400,13 +400,10 @@ QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const
case Qt::DecorationRole:
{
bool showLock = false;
if (e->document) {
showLock = e->document->filePath().isEmpty()
? false
: e->document->isFileReadOnly();
} else {
if (e->document)
showLock = e->document->filePath().isEmpty() ? false : e->document->isFileReadOnly();
else
showLock = !QFileInfo(e->m_fileName).isWritable();
}