forked from qt-creator/qt-creator
EditorManger: Move BaseFileFilter::openEditor into EditorManager
Change-Id: I68e41ea041583a5dfbf4a76517af07ecac065039 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
#include "../findplaceholder.h"
|
#include "../findplaceholder.h"
|
||||||
#include "../icore.h"
|
#include "../icore.h"
|
||||||
#include "../iversioncontrol.h"
|
#include "../iversioncontrol.h"
|
||||||
|
#include "../locator/ilocatorfilter.h"
|
||||||
#include "../modemanager.h"
|
#include "../modemanager.h"
|
||||||
#include "../outputpane.h"
|
#include "../outputpane.h"
|
||||||
#include "../outputpanemanager.h"
|
#include "../outputpanemanager.h"
|
||||||
@@ -3157,6 +3158,17 @@ IEditor *EditorManager::openEditorAt(const Link &link,
|
|||||||
newEditor);
|
newEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IEditor *EditorManager::openEditor(const LocatorFilterEntry &entry)
|
||||||
|
{
|
||||||
|
const OpenEditorFlags defaultFlags = EditorManager::AllowExternalEditor;
|
||||||
|
if (entry.linkForEditor)
|
||||||
|
return EditorManager::openEditorAt(*entry.linkForEditor, {}, defaultFlags);
|
||||||
|
else if (!entry.filePath.isEmpty())
|
||||||
|
return EditorManager::openEditor(entry.filePath, {}, defaultFlags);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Opens the document at the position of the search result \a item using the
|
Opens the document at the position of the search result \a item using the
|
||||||
editor type \a editorId and the specified \a flags.
|
editor type \a editorId and the specified \a flags.
|
||||||
|
@@ -18,15 +18,16 @@
|
|||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QMenu)
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QMenu;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils { class MimeType; }
|
||||||
class MimeType;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class IDocument;
|
class IDocument;
|
||||||
|
class LocatorFilterEntry;
|
||||||
class SearchResultItem;
|
class SearchResultItem;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -76,6 +77,7 @@ public:
|
|||||||
Utils::Id editorId = {},
|
Utils::Id editorId = {},
|
||||||
OpenEditorFlags flags = NoFlags,
|
OpenEditorFlags flags = NoFlags,
|
||||||
bool *newEditor = nullptr);
|
bool *newEditor = nullptr);
|
||||||
|
static IEditor *openEditor(const LocatorFilterEntry &entry);
|
||||||
|
|
||||||
static void openEditorAtSearchResult(const SearchResultItem &item,
|
static void openEditorAtSearchResult(const SearchResultItem &item,
|
||||||
Utils::Id editorId = {},
|
Utils::Id editorId = {},
|
||||||
|
@@ -201,16 +201,7 @@ void BaseFileFilter::accept(const LocatorFilterEntry &selection,
|
|||||||
Q_UNUSED(newText)
|
Q_UNUSED(newText)
|
||||||
Q_UNUSED(selectionStart)
|
Q_UNUSED(selectionStart)
|
||||||
Q_UNUSED(selectionLength)
|
Q_UNUSED(selectionLength)
|
||||||
openEditorAt(selection);
|
EditorManager::openEditor(selection);
|
||||||
}
|
|
||||||
|
|
||||||
void BaseFileFilter::openEditorAt(const LocatorFilterEntry &entry)
|
|
||||||
{
|
|
||||||
if (entry.linkForEditor) {
|
|
||||||
EditorManager::openEditorAt(*entry.linkForEditor, {}, EditorManager::AllowExternalEditor);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
EditorManager::openEditor(entry.filePath, {}, EditorManager::AllowExternalEditor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@@ -48,7 +48,6 @@ public:
|
|||||||
const QString &entry) override;
|
const QString &entry) override;
|
||||||
void accept(const LocatorFilterEntry &selection,
|
void accept(const LocatorFilterEntry &selection,
|
||||||
QString *newText, int *selectionStart, int *selectionLength) const override;
|
QString *newText, int *selectionStart, int *selectionLength) const override;
|
||||||
static void openEditorAt(const LocatorFilterEntry &entry);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setFileIterator(Iterator *iterator);
|
void setFileIterator(Iterator *iterator);
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "filesystemfilter.h"
|
#include "filesystemfilter.h"
|
||||||
|
|
||||||
#include "basefilefilter.h"
|
|
||||||
#include "../coreplugintr.h"
|
#include "../coreplugintr.h"
|
||||||
#include "../documentmanager.h"
|
#include "../documentmanager.h"
|
||||||
#include "../editormanager/editormanager.h"
|
#include "../editormanager/editormanager.h"
|
||||||
@@ -192,7 +191,7 @@ void FileSystemFilter::accept(const LocatorFilterEntry &selection,
|
|||||||
file.close();
|
file.close();
|
||||||
VcsManager::promptToAdd(selection.filePath.absolutePath(), {selection.filePath});
|
VcsManager::promptToAdd(selection.filePath.absolutePath(), {selection.filePath});
|
||||||
}
|
}
|
||||||
BaseFileFilter::openEditorAt(selection);
|
EditorManager::openEditor(selection);
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,8 +21,9 @@ namespace Core {
|
|||||||
|
|
||||||
class ILocatorFilter;
|
class ILocatorFilter;
|
||||||
|
|
||||||
struct LocatorFilterEntry
|
class LocatorFilterEntry
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
struct HighlightInfo {
|
struct HighlightInfo {
|
||||||
enum DataType {
|
enum DataType {
|
||||||
DisplayName,
|
DisplayName,
|
||||||
|
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include "opendocumentsfilter.h"
|
#include "opendocumentsfilter.h"
|
||||||
|
|
||||||
#include "basefilefilter.h"
|
|
||||||
#include "../coreplugintr.h"
|
#include "../coreplugintr.h"
|
||||||
|
#include "../editormanager/editormanager.h"
|
||||||
|
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
#include <utils/link.h>
|
#include <utils/link.h>
|
||||||
@@ -123,7 +123,7 @@ void OpenDocumentsFilter::accept(const LocatorFilterEntry &selection,
|
|||||||
Q_UNUSED(newText)
|
Q_UNUSED(newText)
|
||||||
Q_UNUSED(selectionStart)
|
Q_UNUSED(selectionStart)
|
||||||
Q_UNUSED(selectionLength)
|
Q_UNUSED(selectionLength)
|
||||||
BaseFileFilter::openEditorAt(selection);
|
EditorManager::openEditor(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Core::Internal
|
} // Core::Internal
|
||||||
|
Reference in New Issue
Block a user