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 "../icore.h"
|
||||
#include "../iversioncontrol.h"
|
||||
#include "../locator/ilocatorfilter.h"
|
||||
#include "../modemanager.h"
|
||||
#include "../outputpane.h"
|
||||
#include "../outputpanemanager.h"
|
||||
@@ -3157,6 +3158,17 @@ IEditor *EditorManager::openEditorAt(const Link &link,
|
||||
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
|
||||
editor type \a editorId and the specified \a flags.
|
||||
|
@@ -18,15 +18,16 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QMenu)
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMenu;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
class MimeType;
|
||||
}
|
||||
namespace Utils { class MimeType; }
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IDocument;
|
||||
class LocatorFilterEntry;
|
||||
class SearchResultItem;
|
||||
|
||||
namespace Internal {
|
||||
@@ -76,6 +77,7 @@ public:
|
||||
Utils::Id editorId = {},
|
||||
OpenEditorFlags flags = NoFlags,
|
||||
bool *newEditor = nullptr);
|
||||
static IEditor *openEditor(const LocatorFilterEntry &entry);
|
||||
|
||||
static void openEditorAtSearchResult(const SearchResultItem &item,
|
||||
Utils::Id editorId = {},
|
||||
|
@@ -201,16 +201,7 @@ void BaseFileFilter::accept(const LocatorFilterEntry &selection,
|
||||
Q_UNUSED(newText)
|
||||
Q_UNUSED(selectionStart)
|
||||
Q_UNUSED(selectionLength)
|
||||
openEditorAt(selection);
|
||||
}
|
||||
|
||||
void BaseFileFilter::openEditorAt(const LocatorFilterEntry &entry)
|
||||
{
|
||||
if (entry.linkForEditor) {
|
||||
EditorManager::openEditorAt(*entry.linkForEditor, {}, EditorManager::AllowExternalEditor);
|
||||
return;
|
||||
}
|
||||
EditorManager::openEditor(entry.filePath, {}, EditorManager::AllowExternalEditor);
|
||||
EditorManager::openEditor(selection);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@@ -48,7 +48,6 @@ public:
|
||||
const QString &entry) override;
|
||||
void accept(const LocatorFilterEntry &selection,
|
||||
QString *newText, int *selectionStart, int *selectionLength) const override;
|
||||
static void openEditorAt(const LocatorFilterEntry &entry);
|
||||
|
||||
protected:
|
||||
void setFileIterator(Iterator *iterator);
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "filesystemfilter.h"
|
||||
|
||||
#include "basefilefilter.h"
|
||||
#include "../coreplugintr.h"
|
||||
#include "../documentmanager.h"
|
||||
#include "../editormanager/editormanager.h"
|
||||
@@ -192,7 +191,7 @@ void FileSystemFilter::accept(const LocatorFilterEntry &selection,
|
||||
file.close();
|
||||
VcsManager::promptToAdd(selection.filePath.absolutePath(), {selection.filePath});
|
||||
}
|
||||
BaseFileFilter::openEditorAt(selection);
|
||||
EditorManager::openEditor(selection);
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
@@ -21,8 +21,9 @@ namespace Core {
|
||||
|
||||
class ILocatorFilter;
|
||||
|
||||
struct LocatorFilterEntry
|
||||
class LocatorFilterEntry
|
||||
{
|
||||
public:
|
||||
struct HighlightInfo {
|
||||
enum DataType {
|
||||
DisplayName,
|
||||
|
@@ -3,8 +3,8 @@
|
||||
|
||||
#include "opendocumentsfilter.h"
|
||||
|
||||
#include "basefilefilter.h"
|
||||
#include "../coreplugintr.h"
|
||||
#include "../editormanager/editormanager.h"
|
||||
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/link.h>
|
||||
@@ -123,7 +123,7 @@ void OpenDocumentsFilter::accept(const LocatorFilterEntry &selection,
|
||||
Q_UNUSED(newText)
|
||||
Q_UNUSED(selectionStart)
|
||||
Q_UNUSED(selectionLength)
|
||||
BaseFileFilter::openEditorAt(selection);
|
||||
EditorManager::openEditor(selection);
|
||||
}
|
||||
|
||||
} // Core::Internal
|
||||
|
Reference in New Issue
Block a user