forked from qt-creator/qt-creator
Core: De-noise DocumentManager
Change-Id: I5b78e5ac76829a8921039663edab2b8f836c0c7e Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
@@ -104,6 +104,8 @@ static const char projectDirectoryKeyC[] = "Projects";
|
|||||||
static const char useProjectDirectoryKeyC[] = "UseProjectsDirectory";
|
static const char useProjectDirectoryKeyC[] = "UseProjectsDirectory";
|
||||||
static const char buildDirectoryKeyC[] = "BuildDirectory.Template";
|
static const char buildDirectoryKeyC[] = "BuildDirectory.Template";
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
static void readSettings();
|
static void readSettings();
|
||||||
@@ -182,7 +184,7 @@ QFileSystemWatcher *DocumentManagerPrivate::fileWatcher()
|
|||||||
|
|
||||||
QFileSystemWatcher *DocumentManagerPrivate::linkWatcher()
|
QFileSystemWatcher *DocumentManagerPrivate::linkWatcher()
|
||||||
{
|
{
|
||||||
if (Utils::HostOsInfo::isAnyUnixHost()) {
|
if (HostOsInfo::isAnyUnixHost()) {
|
||||||
if (!m_linkWatcher) {
|
if (!m_linkWatcher) {
|
||||||
m_linkWatcher = new QFileSystemWatcher(m_instance);
|
m_linkWatcher = new QFileSystemWatcher(m_instance);
|
||||||
m_linkWatcher->setObjectName(QLatin1String("_qt_autotest_force_engine_poller"));
|
m_linkWatcher->setObjectName(QLatin1String("_qt_autotest_force_engine_poller"));
|
||||||
@@ -388,14 +390,14 @@ void DocumentManager::renamedFile(const QString &from, const QString &to)
|
|||||||
foreach (IDocument *document, documentsToRename) {
|
foreach (IDocument *document, documentsToRename) {
|
||||||
d->m_blockedIDocument = document;
|
d->m_blockedIDocument = document;
|
||||||
removeFileInfo(document);
|
removeFileInfo(document);
|
||||||
document->setFilePath(Utils::FileName::fromString(to));
|
document->setFilePath(FileName::fromString(to));
|
||||||
addFileInfo(document);
|
addFileInfo(document);
|
||||||
d->m_blockedIDocument = 0;
|
d->m_blockedIDocument = 0;
|
||||||
}
|
}
|
||||||
emit m_instance->allDocumentsRenamed(from, to);
|
emit m_instance->allDocumentsRenamed(from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentManager::filePathChanged(const Utils::FileName &oldName, const Utils::FileName &newName)
|
void DocumentManager::filePathChanged(const FileName &oldName, const FileName &newName)
|
||||||
{
|
{
|
||||||
IDocument *doc = qobject_cast<IDocument *>(sender());
|
IDocument *doc = qobject_cast<IDocument *>(sender());
|
||||||
QTC_ASSERT(doc, return);
|
QTC_ASSERT(doc, return);
|
||||||
@@ -480,7 +482,7 @@ QString DocumentManager::fixFileName(const QString &fileName, FixMode fixmode)
|
|||||||
s = QDir::cleanPath(s);
|
s = QDir::cleanPath(s);
|
||||||
}
|
}
|
||||||
s = QDir::toNativeSeparators(s);
|
s = QDir::toNativeSeparators(s);
|
||||||
if (Utils::HostOsInfo::fileNameCaseSensitivity() == Qt::CaseInsensitive)
|
if (HostOsInfo::fileNameCaseSensitivity() == Qt::CaseInsensitive)
|
||||||
s = s.toLower();
|
s = s.toLower();
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -922,8 +924,8 @@ void DocumentManager::checkForReload()
|
|||||||
d->m_blockActivated = true;
|
d->m_blockActivated = true;
|
||||||
|
|
||||||
IDocument::ReloadSetting defaultBehavior = EditorManagerPrivate::reloadSetting();
|
IDocument::ReloadSetting defaultBehavior = EditorManagerPrivate::reloadSetting();
|
||||||
Utils::ReloadPromptAnswer previousReloadAnswer = Utils::ReloadCurrent;
|
ReloadPromptAnswer previousReloadAnswer = ReloadCurrent;
|
||||||
Utils::FileDeletedPromptAnswer previousDeletedAnswer = Utils::FileDeletedSave;
|
FileDeletedPromptAnswer previousDeletedAnswer = FileDeletedSave;
|
||||||
|
|
||||||
QList<IDocument *> documentsToClose;
|
QList<IDocument *> documentsToClose;
|
||||||
QMap<IDocument*, QString> documentsToSave;
|
QMap<IDocument*, QString> documentsToSave;
|
||||||
@@ -1056,26 +1058,26 @@ void DocumentManager::checkForReload()
|
|||||||
// IDocument wants us to ask
|
// IDocument wants us to ask
|
||||||
} else if (type == IDocument::TypeContents) {
|
} else if (type == IDocument::TypeContents) {
|
||||||
// content change, IDocument wants to ask user
|
// content change, IDocument wants to ask user
|
||||||
if (previousReloadAnswer == Utils::ReloadNone) {
|
if (previousReloadAnswer == ReloadNone) {
|
||||||
// answer already given, ignore
|
// answer already given, ignore
|
||||||
success = document->reload(&errorString, IDocument::FlagIgnore, IDocument::TypeContents);
|
success = document->reload(&errorString, IDocument::FlagIgnore, IDocument::TypeContents);
|
||||||
} else if (previousReloadAnswer == Utils::ReloadAll) {
|
} else if (previousReloadAnswer == ReloadAll) {
|
||||||
// answer already given, reload
|
// answer already given, reload
|
||||||
success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents);
|
success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents);
|
||||||
} else {
|
} else {
|
||||||
// Ask about content change
|
// Ask about content change
|
||||||
previousReloadAnswer = Utils::reloadPrompt(document->filePath(), document->isModified(),
|
previousReloadAnswer = reloadPrompt(document->filePath(), document->isModified(),
|
||||||
ICore::dialogParent());
|
ICore::dialogParent());
|
||||||
switch (previousReloadAnswer) {
|
switch (previousReloadAnswer) {
|
||||||
case Utils::ReloadAll:
|
case ReloadAll:
|
||||||
case Utils::ReloadCurrent:
|
case ReloadCurrent:
|
||||||
success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents);
|
success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents);
|
||||||
break;
|
break;
|
||||||
case Utils::ReloadSkipCurrent:
|
case ReloadSkipCurrent:
|
||||||
case Utils::ReloadNone:
|
case ReloadNone:
|
||||||
success = document->reload(&errorString, IDocument::FlagIgnore, IDocument::TypeContents);
|
success = document->reload(&errorString, IDocument::FlagIgnore, IDocument::TypeContents);
|
||||||
break;
|
break;
|
||||||
case Utils::CloseCurrent:
|
case CloseCurrent:
|
||||||
documentsToClose << document;
|
documentsToClose << document;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1085,18 +1087,18 @@ void DocumentManager::checkForReload()
|
|||||||
// Ask about removed file
|
// Ask about removed file
|
||||||
bool unhandled = true;
|
bool unhandled = true;
|
||||||
while (unhandled) {
|
while (unhandled) {
|
||||||
if (previousDeletedAnswer != Utils::FileDeletedCloseAll) {
|
if (previousDeletedAnswer != FileDeletedCloseAll) {
|
||||||
previousDeletedAnswer =
|
previousDeletedAnswer =
|
||||||
Utils::fileDeletedPrompt(document->filePath().toString(),
|
fileDeletedPrompt(document->filePath().toString(),
|
||||||
trigger == IDocument::TriggerExternal,
|
trigger == IDocument::TriggerExternal,
|
||||||
QApplication::activeWindow());
|
QApplication::activeWindow());
|
||||||
}
|
}
|
||||||
switch (previousDeletedAnswer) {
|
switch (previousDeletedAnswer) {
|
||||||
case Utils::FileDeletedSave:
|
case FileDeletedSave:
|
||||||
documentsToSave.insert(document, document->filePath().toString());
|
documentsToSave.insert(document, document->filePath().toString());
|
||||||
unhandled = false;
|
unhandled = false;
|
||||||
break;
|
break;
|
||||||
case Utils::FileDeletedSaveAs:
|
case FileDeletedSaveAs:
|
||||||
{
|
{
|
||||||
const QString &saveFileName = getSaveAsFileName(document);
|
const QString &saveFileName = getSaveAsFileName(document);
|
||||||
if (!saveFileName.isEmpty()) {
|
if (!saveFileName.isEmpty()) {
|
||||||
@@ -1105,8 +1107,8 @@ void DocumentManager::checkForReload()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Utils::FileDeletedClose:
|
case FileDeletedClose:
|
||||||
case Utils::FileDeletedCloseAll:
|
case FileDeletedCloseAll:
|
||||||
documentsToClose << document;
|
documentsToClose << document;
|
||||||
unhandled = false;
|
unhandled = false;
|
||||||
break;
|
break;
|
||||||
@@ -1227,7 +1229,7 @@ void readSettings()
|
|||||||
if (!settingsProjectDir.isEmpty() && QFileInfo(settingsProjectDir).isDir())
|
if (!settingsProjectDir.isEmpty() && QFileInfo(settingsProjectDir).isDir())
|
||||||
d->m_projectsDirectory = settingsProjectDir;
|
d->m_projectsDirectory = settingsProjectDir;
|
||||||
else
|
else
|
||||||
d->m_projectsDirectory = Utils::PathChooser::homePath();
|
d->m_projectsDirectory = PathChooser::homePath();
|
||||||
d->m_useProjectsDirectory = s->value(QLatin1String(useProjectDirectoryKeyC),
|
d->m_useProjectsDirectory = s->value(QLatin1String(useProjectDirectoryKeyC),
|
||||||
d->m_useProjectsDirectory).toBool();
|
d->m_useProjectsDirectory).toBool();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user