forked from qt-creator/qt-creator
Client: Block until editor is closed
Change-Id: I06bd4425008103be3a4c8f64b6dff8f7df30c552 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
225c21a0f2
commit
14e35b5dc4
@@ -119,10 +119,12 @@ bool CorePlugin::delayedInitialize()
|
||||
return true;
|
||||
}
|
||||
|
||||
void CorePlugin::remoteCommand(const QStringList & /* options */, const QStringList &args)
|
||||
QObject *CorePlugin::remoteCommand(const QStringList & /* options */, const QStringList &args)
|
||||
{
|
||||
m_mainWindow->openFiles(args, Core::ICore::OpenFilesFlags(ICore::SwitchMode | ICore::CanContainLineNumbers));
|
||||
IDocument *res = m_mainWindow->openFiles(
|
||||
args, ICore::OpenFilesFlags(ICore::SwitchMode | ICore::CanContainLineNumbers));
|
||||
m_mainWindow->activateWindow();
|
||||
return res;
|
||||
}
|
||||
|
||||
void CorePlugin::fileOpenRequest(const QString &f)
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
void extensionsInitialized();
|
||||
bool delayedInitialize();
|
||||
ShutdownFlag aboutToShutdown();
|
||||
void remoteCommand(const QStringList & /* options */, const QStringList &args);
|
||||
QObject *remoteCommand(const QStringList & /* options */, const QStringList &args);
|
||||
|
||||
public slots:
|
||||
void fileOpenRequest(const QString&);
|
||||
|
||||
@@ -831,31 +831,51 @@ static IDocumentFactory *findDocumentFactory(const QList<IDocumentFactory*> &fil
|
||||
return 0;
|
||||
}
|
||||
|
||||
// opens either an editor or loads a project
|
||||
void MainWindow::openFiles(const QStringList &fileNames, ICore::OpenFilesFlags flags)
|
||||
/*! Either opens \a fileNames with editors or loads a project.
|
||||
*
|
||||
* \a flags can be used to stop on first failure, indicate that a file name
|
||||
* might include line numbers and/or switch mode to edit mode.
|
||||
*
|
||||
* \returns the first opened document. Required to support the -block flag
|
||||
* for client mode.
|
||||
*
|
||||
* \sa IPlugin::remoteArguments()
|
||||
*/
|
||||
IDocument *MainWindow::openFiles(const QStringList &fileNames, ICore::OpenFilesFlags flags)
|
||||
{
|
||||
QList<IDocumentFactory*> nonEditorFileFactories = getNonEditorDocumentFactories();
|
||||
IDocument *res = 0;
|
||||
|
||||
foreach (const QString &fileName, fileNames) {
|
||||
const QFileInfo fi(fileName);
|
||||
const QString absoluteFilePath = fi.absoluteFilePath();
|
||||
if (IDocumentFactory *documentFactory = findDocumentFactory(nonEditorFileFactories, mimeDatabase(), fi)) {
|
||||
Core::IDocument *document = documentFactory->open(absoluteFilePath);
|
||||
if (!document && (flags & ICore::StopOnLoadFail))
|
||||
return;
|
||||
if (document && (flags & ICore::SwitchMode))
|
||||
ModeManager::activateMode(Id(Core::Constants::MODE_EDIT));
|
||||
IDocument *document = documentFactory->open(absoluteFilePath);
|
||||
if (!document) {
|
||||
if (flags & ICore::StopOnLoadFail)
|
||||
return res;
|
||||
} else {
|
||||
if (!res)
|
||||
res = document;
|
||||
if (flags & ICore::SwitchMode)
|
||||
ModeManager::activateMode(Id(Core::Constants::MODE_EDIT));
|
||||
}
|
||||
} else {
|
||||
QFlags<EditorManager::OpenEditorFlag> emFlags;
|
||||
if (flags & ICore::SwitchMode)
|
||||
emFlags = EditorManager::ModeSwitch;
|
||||
if (flags & ICore::CanContainLineNumbers)
|
||||
emFlags |= EditorManager::CanContainLineNumber;
|
||||
Core::IEditor *editor = EditorManager::openEditor(absoluteFilePath, Id(), emFlags);
|
||||
if (!editor && (flags & ICore::StopOnLoadFail))
|
||||
return;
|
||||
IEditor *editor = EditorManager::openEditor(absoluteFilePath, Id(), emFlags);
|
||||
if (!editor) {
|
||||
if (flags & ICore::StopOnLoadFail)
|
||||
return res;
|
||||
} else if (!res) {
|
||||
res = editor->document();
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void MainWindow::setFocusToEditor()
|
||||
|
||||
@@ -53,6 +53,7 @@ class EditorManager;
|
||||
class ExternalToolManager;
|
||||
class DocumentManager;
|
||||
class HelpManager;
|
||||
class IDocument;
|
||||
class IWizard;
|
||||
class MessageManager;
|
||||
class MimeDatabase;
|
||||
@@ -95,7 +96,7 @@ public:
|
||||
void removeContextObject(IContext *contex);
|
||||
void resetContext();
|
||||
|
||||
void openFiles(const QStringList &fileNames, ICore::OpenFilesFlags flags);
|
||||
Core::IDocument *openFiles(const QStringList &fileNames, ICore::OpenFilesFlags flags);
|
||||
|
||||
Core::ActionManager *actionManager() const;
|
||||
Core::MessageManager *messageManager() const;
|
||||
|
||||
Reference in New Issue
Block a user