forked from qt-creator/qt-creator
Use nullptr and member initialization in document manager
Change-Id: Iddd446d10cf3fd0a59d46d6ed3ba335f0c93e118 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -153,20 +153,20 @@ public:
|
|||||||
QList<DocumentManager::RecentFile> m_recentFiles;
|
QList<DocumentManager::RecentFile> m_recentFiles;
|
||||||
static const int m_maxRecentFiles = 7;
|
static const int m_maxRecentFiles = 7;
|
||||||
|
|
||||||
QFileSystemWatcher *m_fileWatcher; // Delayed creation.
|
QFileSystemWatcher *m_fileWatcher = nullptr; // Delayed creation.
|
||||||
QFileSystemWatcher *m_linkWatcher; // Delayed creation (only UNIX/if a link is seen).
|
QFileSystemWatcher *m_linkWatcher = nullptr; // Delayed creation (only UNIX/if a link is seen).
|
||||||
bool m_blockActivated;
|
bool m_blockActivated = false;
|
||||||
bool m_checkOnFocusChange = false;
|
bool m_checkOnFocusChange = false;
|
||||||
QString m_lastVisitedDirectory;
|
QString m_lastVisitedDirectory = QDir::currentPath();
|
||||||
QString m_defaultLocationForNewFiles;
|
QString m_defaultLocationForNewFiles;
|
||||||
FileName m_projectsDirectory;
|
FileName m_projectsDirectory;
|
||||||
bool m_useProjectsDirectory;
|
bool m_useProjectsDirectory = true;
|
||||||
QString m_buildDirectory;
|
QString m_buildDirectory;
|
||||||
// When we are calling into an IDocument
|
// When we are calling into an IDocument
|
||||||
// we don't want to receive a changed()
|
// we don't want to receive a changed()
|
||||||
// signal
|
// signal
|
||||||
// That makes the code easier
|
// That makes the code easier
|
||||||
IDocument *m_blockedIDocument;
|
IDocument *m_blockedIDocument = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
static DocumentManager *m_instance;
|
static DocumentManager *m_instance;
|
||||||
@@ -210,13 +210,7 @@ void DocumentManagerPrivate::onApplicationFocusChange()
|
|||||||
m_instance->checkForReload();
|
m_instance->checkForReload();
|
||||||
}
|
}
|
||||||
|
|
||||||
DocumentManagerPrivate::DocumentManagerPrivate() :
|
DocumentManagerPrivate::DocumentManagerPrivate()
|
||||||
m_fileWatcher(0),
|
|
||||||
m_linkWatcher(0),
|
|
||||||
m_blockActivated(false),
|
|
||||||
m_lastVisitedDirectory(QDir::currentPath()),
|
|
||||||
m_useProjectsDirectory(true),
|
|
||||||
m_blockedIDocument(0)
|
|
||||||
{
|
{
|
||||||
connect(qApp, &QApplication::focusChanged, this, &DocumentManagerPrivate::onApplicationFocusChange);
|
connect(qApp, &QApplication::focusChanged, this, &DocumentManagerPrivate::onApplicationFocusChange);
|
||||||
}
|
}
|
||||||
@@ -273,7 +267,7 @@ static void addFileInfo(IDocument *document, const QString &filePath,
|
|||||||
const QString watchedFilePath = d->m_states.value(filePathKey).watchedFilePath;
|
const QString watchedFilePath = d->m_states.value(filePathKey).watchedFilePath;
|
||||||
qCDebug(log) << "adding (" << (isLink ? "link" : "full") << ") watch for"
|
qCDebug(log) << "adding (" << (isLink ? "link" : "full") << ") watch for"
|
||||||
<< watchedFilePath;
|
<< watchedFilePath;
|
||||||
QFileSystemWatcher *watcher = 0;
|
QFileSystemWatcher *watcher = nullptr;
|
||||||
if (isLink)
|
if (isLink)
|
||||||
watcher = d->linkWatcher();
|
watcher = d->linkWatcher();
|
||||||
else
|
else
|
||||||
@@ -432,7 +426,7 @@ void DocumentManager::renamedFile(const QString &from, const QString &to)
|
|||||||
removeFileInfo(document);
|
removeFileInfo(document);
|
||||||
document->setFilePath(FileName::fromString(to));
|
document->setFilePath(FileName::fromString(to));
|
||||||
addFileInfo(document);
|
addFileInfo(document);
|
||||||
d->m_blockedIDocument = 0;
|
d->m_blockedIDocument = nullptr;
|
||||||
}
|
}
|
||||||
emit m_instance->allDocumentsRenamed(from, to);
|
emit m_instance->allDocumentsRenamed(from, to);
|
||||||
}
|
}
|
||||||
@@ -620,7 +614,7 @@ static bool saveModifiedFilesHelper(const QList<IDocument *> &documents,
|
|||||||
// There can be several IDocuments pointing to the same file
|
// There can be several IDocuments pointing to the same file
|
||||||
// Prefer one that is not readonly
|
// Prefer one that is not readonly
|
||||||
// (even though it *should* not happen that the IDocuments are inconsistent with readonly)
|
// (even though it *should* not happen that the IDocuments are inconsistent with readonly)
|
||||||
if (!modifiedDocumentsMap.key(name, 0) || !document->isFileReadOnly())
|
if (!modifiedDocumentsMap.key(name, nullptr) || !document->isFileReadOnly())
|
||||||
modifiedDocumentsMap.insert(document, name);
|
modifiedDocumentsMap.insert(document, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -830,10 +824,17 @@ bool DocumentManager::saveAllModifiedDocumentsSilently(bool *canceled,
|
|||||||
\a FailedToClose will contain a list of documents that could not be saved if passed into the
|
\a FailedToClose will contain a list of documents that could not be saved if passed into the
|
||||||
method.
|
method.
|
||||||
*/
|
*/
|
||||||
bool DocumentManager::saveModifiedDocumentsSilently(const QList<IDocument *> &documents, bool *canceled,
|
bool DocumentManager::saveModifiedDocumentsSilently(const QList<IDocument *> &documents,
|
||||||
|
bool *canceled,
|
||||||
QList<IDocument *> *failedToClose)
|
QList<IDocument *> *failedToClose)
|
||||||
{
|
{
|
||||||
return saveModifiedFilesHelper(documents, QString(), canceled, true, QString(), 0, failedToClose);
|
return saveModifiedFilesHelper(documents,
|
||||||
|
QString(),
|
||||||
|
canceled,
|
||||||
|
true,
|
||||||
|
QString(),
|
||||||
|
nullptr,
|
||||||
|
failedToClose);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -1181,7 +1182,7 @@ void DocumentManager::checkForReload()
|
|||||||
errorStrings << errorString;
|
errorStrings << errorString;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->m_blockedIDocument = 0;
|
d->m_blockedIDocument = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filesToDiff.isEmpty()) {
|
if (!filesToDiff.isEmpty()) {
|
||||||
|
@@ -80,38 +80,47 @@ public:
|
|||||||
static QString cleanAbsoluteFilePath(const QString &filePath, ResolveMode resolveMode);
|
static QString cleanAbsoluteFilePath(const QString &filePath, ResolveMode resolveMode);
|
||||||
static QString filePathKey(const QString &filePath, ResolveMode resolveMode);
|
static QString filePathKey(const QString &filePath, ResolveMode resolveMode);
|
||||||
|
|
||||||
static bool saveDocument(IDocument *document, const QString &fileName = QString(), bool *isReadOnly = 0);
|
static bool saveDocument(IDocument *document,
|
||||||
|
const QString &fileName = QString(),
|
||||||
|
bool *isReadOnly = nullptr);
|
||||||
|
|
||||||
static QStringList getOpenFileNames(const QString &filters,
|
static QStringList getOpenFileNames(const QString &filters,
|
||||||
const QString &path = QString(),
|
const QString &path = QString(),
|
||||||
QString *selectedFilter = 0);
|
QString *selectedFilter = nullptr);
|
||||||
static QString getSaveFileName(const QString &title, const QString &pathIn,
|
static QString getSaveFileName(const QString &title,
|
||||||
const QString &filter = QString(), QString *selectedFilter = 0);
|
const QString &pathIn,
|
||||||
|
const QString &filter = QString(),
|
||||||
|
QString *selectedFilter = nullptr);
|
||||||
static QString getSaveFileNameWithExtension(const QString &title, const QString &pathIn,
|
static QString getSaveFileNameWithExtension(const QString &title, const QString &pathIn,
|
||||||
const QString &filter);
|
const QString &filter);
|
||||||
static QString getSaveAsFileName(const IDocument *document);
|
static QString getSaveAsFileName(const IDocument *document);
|
||||||
|
|
||||||
static bool saveAllModifiedDocumentsSilently(bool *canceled = 0,
|
static bool saveAllModifiedDocumentsSilently(bool *canceled = nullptr,
|
||||||
QList<IDocument *> *failedToClose = 0);
|
QList<IDocument *> *failedToClose = nullptr);
|
||||||
static bool saveModifiedDocumentsSilently(const QList<IDocument *> &documents, bool *canceled = 0,
|
static bool saveModifiedDocumentsSilently(const QList<IDocument *> &documents,
|
||||||
QList<IDocument *> *failedToClose = 0);
|
bool *canceled = nullptr,
|
||||||
static bool saveModifiedDocumentSilently(IDocument *document, bool *canceled = 0,
|
QList<IDocument *> *failedToClose = nullptr);
|
||||||
QList<IDocument *> *failedToClose = 0);
|
static bool saveModifiedDocumentSilently(IDocument *document,
|
||||||
|
bool *canceled = nullptr,
|
||||||
|
QList<IDocument *> *failedToClose = nullptr);
|
||||||
|
|
||||||
static bool saveAllModifiedDocuments(const QString &message = QString(), bool *canceled = 0,
|
static bool saveAllModifiedDocuments(const QString &message = QString(),
|
||||||
|
bool *canceled = nullptr,
|
||||||
const QString &alwaysSaveMessage = QString(),
|
const QString &alwaysSaveMessage = QString(),
|
||||||
bool *alwaysSave = 0,
|
bool *alwaysSave = nullptr,
|
||||||
QList<IDocument *> *failedToClose = 0);
|
QList<IDocument *> *failedToClose = nullptr);
|
||||||
static bool saveModifiedDocuments(const QList<IDocument *> &documents,
|
static bool saveModifiedDocuments(const QList<IDocument *> &documents,
|
||||||
const QString &message = QString(), bool *canceled = 0,
|
const QString &message = QString(),
|
||||||
|
bool *canceled = nullptr,
|
||||||
const QString &alwaysSaveMessage = QString(),
|
const QString &alwaysSaveMessage = QString(),
|
||||||
bool *alwaysSave = 0,
|
bool *alwaysSave = nullptr,
|
||||||
QList<IDocument *> *failedToClose = 0);
|
QList<IDocument *> *failedToClose = nullptr);
|
||||||
static bool saveModifiedDocument(IDocument *document,
|
static bool saveModifiedDocument(IDocument *document,
|
||||||
const QString &message = QString(), bool *canceled = 0,
|
const QString &message = QString(),
|
||||||
|
bool *canceled = nullptr,
|
||||||
const QString &alwaysSaveMessage = QString(),
|
const QString &alwaysSaveMessage = QString(),
|
||||||
bool *alwaysSave = 0,
|
bool *alwaysSave = nullptr,
|
||||||
QList<IDocument *> *failedToClose = 0);
|
QList<IDocument *> *failedToClose = nullptr);
|
||||||
|
|
||||||
static QString fileDialogLastVisitedDirectory();
|
static QString fileDialogLastVisitedDirectory();
|
||||||
static void setFileDialogLastVisitedDirectory(const QString &);
|
static void setFileDialogLastVisitedDirectory(const QString &);
|
||||||
|
Reference in New Issue
Block a user