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;
|
||||
static const int m_maxRecentFiles = 7;
|
||||
|
||||
QFileSystemWatcher *m_fileWatcher; // Delayed creation.
|
||||
QFileSystemWatcher *m_linkWatcher; // Delayed creation (only UNIX/if a link is seen).
|
||||
bool m_blockActivated;
|
||||
QFileSystemWatcher *m_fileWatcher = nullptr; // Delayed creation.
|
||||
QFileSystemWatcher *m_linkWatcher = nullptr; // Delayed creation (only UNIX/if a link is seen).
|
||||
bool m_blockActivated = false;
|
||||
bool m_checkOnFocusChange = false;
|
||||
QString m_lastVisitedDirectory;
|
||||
QString m_lastVisitedDirectory = QDir::currentPath();
|
||||
QString m_defaultLocationForNewFiles;
|
||||
FileName m_projectsDirectory;
|
||||
bool m_useProjectsDirectory;
|
||||
bool m_useProjectsDirectory = true;
|
||||
QString m_buildDirectory;
|
||||
// When we are calling into an IDocument
|
||||
// we don't want to receive a changed()
|
||||
// signal
|
||||
// That makes the code easier
|
||||
IDocument *m_blockedIDocument;
|
||||
IDocument *m_blockedIDocument = nullptr;
|
||||
};
|
||||
|
||||
static DocumentManager *m_instance;
|
||||
@@ -210,13 +210,7 @@ void DocumentManagerPrivate::onApplicationFocusChange()
|
||||
m_instance->checkForReload();
|
||||
}
|
||||
|
||||
DocumentManagerPrivate::DocumentManagerPrivate() :
|
||||
m_fileWatcher(0),
|
||||
m_linkWatcher(0),
|
||||
m_blockActivated(false),
|
||||
m_lastVisitedDirectory(QDir::currentPath()),
|
||||
m_useProjectsDirectory(true),
|
||||
m_blockedIDocument(0)
|
||||
DocumentManagerPrivate::DocumentManagerPrivate()
|
||||
{
|
||||
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;
|
||||
qCDebug(log) << "adding (" << (isLink ? "link" : "full") << ") watch for"
|
||||
<< watchedFilePath;
|
||||
QFileSystemWatcher *watcher = 0;
|
||||
QFileSystemWatcher *watcher = nullptr;
|
||||
if (isLink)
|
||||
watcher = d->linkWatcher();
|
||||
else
|
||||
@@ -432,7 +426,7 @@ void DocumentManager::renamedFile(const QString &from, const QString &to)
|
||||
removeFileInfo(document);
|
||||
document->setFilePath(FileName::fromString(to));
|
||||
addFileInfo(document);
|
||||
d->m_blockedIDocument = 0;
|
||||
d->m_blockedIDocument = nullptr;
|
||||
}
|
||||
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
|
||||
// Prefer one that is not 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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
method.
|
||||
*/
|
||||
bool DocumentManager::saveModifiedDocumentsSilently(const QList<IDocument *> &documents, bool *canceled,
|
||||
bool DocumentManager::saveModifiedDocumentsSilently(const QList<IDocument *> &documents,
|
||||
bool *canceled,
|
||||
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;
|
||||
}
|
||||
|
||||
d->m_blockedIDocument = 0;
|
||||
d->m_blockedIDocument = nullptr;
|
||||
}
|
||||
|
||||
if (!filesToDiff.isEmpty()) {
|
||||
|
@@ -80,38 +80,47 @@ public:
|
||||
static QString cleanAbsoluteFilePath(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,
|
||||
const QString &path = QString(),
|
||||
QString *selectedFilter = 0);
|
||||
static QString getSaveFileName(const QString &title, const QString &pathIn,
|
||||
const QString &filter = QString(), QString *selectedFilter = 0);
|
||||
QString *selectedFilter = nullptr);
|
||||
static QString getSaveFileName(const QString &title,
|
||||
const QString &pathIn,
|
||||
const QString &filter = QString(),
|
||||
QString *selectedFilter = nullptr);
|
||||
static QString getSaveFileNameWithExtension(const QString &title, const QString &pathIn,
|
||||
const QString &filter);
|
||||
static QString getSaveAsFileName(const IDocument *document);
|
||||
|
||||
static bool saveAllModifiedDocumentsSilently(bool *canceled = 0,
|
||||
QList<IDocument *> *failedToClose = 0);
|
||||
static bool saveModifiedDocumentsSilently(const QList<IDocument *> &documents, bool *canceled = 0,
|
||||
QList<IDocument *> *failedToClose = 0);
|
||||
static bool saveModifiedDocumentSilently(IDocument *document, bool *canceled = 0,
|
||||
QList<IDocument *> *failedToClose = 0);
|
||||
static bool saveAllModifiedDocumentsSilently(bool *canceled = nullptr,
|
||||
QList<IDocument *> *failedToClose = nullptr);
|
||||
static bool saveModifiedDocumentsSilently(const QList<IDocument *> &documents,
|
||||
bool *canceled = nullptr,
|
||||
QList<IDocument *> *failedToClose = nullptr);
|
||||
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(),
|
||||
bool *alwaysSave = 0,
|
||||
QList<IDocument *> *failedToClose = 0);
|
||||
bool *alwaysSave = nullptr,
|
||||
QList<IDocument *> *failedToClose = nullptr);
|
||||
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(),
|
||||
bool *alwaysSave = 0,
|
||||
QList<IDocument *> *failedToClose = 0);
|
||||
bool *alwaysSave = nullptr,
|
||||
QList<IDocument *> *failedToClose = nullptr);
|
||||
static bool saveModifiedDocument(IDocument *document,
|
||||
const QString &message = QString(), bool *canceled = 0,
|
||||
const QString &message = QString(),
|
||||
bool *canceled = nullptr,
|
||||
const QString &alwaysSaveMessage = QString(),
|
||||
bool *alwaysSave = 0,
|
||||
QList<IDocument *> *failedToClose = 0);
|
||||
bool *alwaysSave = nullptr,
|
||||
QList<IDocument *> *failedToClose = nullptr);
|
||||
|
||||
static QString fileDialogLastVisitedDirectory();
|
||||
static void setFileDialogLastVisitedDirectory(const QString &);
|
||||
|
Reference in New Issue
Block a user