Commit 4d96fa7a authored by hjk's avatar hjk Committed by Eike Ziller

Core: Merge Find and Locator into Core plugin

Change-Id: I7053310272235d854c9f409670ff52a10a7add8b
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@digia.com>
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 8b854270
......@@ -209,13 +209,13 @@
\row
\li Add a find filter to the \gui Find dialog.
\li Implement any kind of search term based search.
\li \l{Find::IFindFilter}, \l{Find::SearchResultWindow}
\li \l{Find::IFindFilter}, \l{Core::SearchResultWindow}
\row
\li Add support for the find tool bar to a widget.
\li The widget that has focus is asked whether it supports text search. You can
add support for widgets under your control.
\li \l{Find::IFindSupport}, \l{Find::BaseTextFind}
\li \l{Core::IFindSupport}, \l{Find::BaseTextFind}
\row
\li Add a completely new project type.
......@@ -231,7 +231,7 @@
\li Add a new filter to the locator.
\li For a text typed in by the user you provide a list of things to show in the popup.
When the user selects an entry you are requested to do whatever you want.
\li \l{Locator::ILocatorFilter}, \l{Locator::FilterEntry}, \l{Locator::BaseFileFilter}
\li \l{Core::ILocatorFilter}, \l{Core::LocatorFilterEntry}, \l{Locator::BaseFileFilter}
\row
\li Show a progress indicator for a concurrently running task.
......
......@@ -8,10 +8,7 @@ QtcPlugin {
Depends { name: "Qt.widgets" }
Depends { name: "Core" }
Depends { name: "TextEditor" }
Depends { name: "Find" }
Depends { name: "VcsBase" }
Depends { name: "Locator" }
files: [
"annotationhighlighter.cpp",
......
......@@ -2,7 +2,6 @@ QTC_PLUGIN_NAME = Bazaar
QTC_LIB_DEPENDS += \
utils
QTC_PLUGIN_DEPENDS += \
locator \
texteditor \
coreplugin \
vcsbase
......@@ -48,8 +48,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/documentmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <locator/commandlocator.h>
#include <coreplugin/locator/commandlocator.h>
#include <utils/parameteraction.h>
#include <utils/qtcassert.h>
......@@ -149,7 +148,7 @@ bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessag
addAutoReleasedObject(new CloneWizard);
const QString prefix = QLatin1String("bzr");
m_commandLocator = new Locator::CommandLocator("Bazaar", prefix, prefix);
m_commandLocator = new Core::CommandLocator("Bazaar", prefix, prefix);
addAutoReleasedObject(m_commandLocator);
createMenu();
......
......@@ -42,6 +42,7 @@ QT_END_NAMESPACE
namespace Core {
class ActionManager;
class ActionContainer;
class CommandLocator;
class Id;
class IVersionControl;
class IEditorFactory;
......@@ -56,10 +57,6 @@ namespace VcsBase {
class VcsBaseSubmitEditor;
}
namespace Locator {
class CommandLocator;
}
namespace Bazaar {
namespace Internal {
......@@ -132,7 +129,7 @@ private:
OptionsPage *m_optionsPage;
BazaarClient *m_client;
Locator::CommandLocator *m_commandLocator;
Core::CommandLocator *m_commandLocator;
Core::ActionContainer *m_bazaarContainer;
QList<QAction *> m_repositoryActionList;
......
......@@ -8,7 +8,6 @@ QtcPlugin {
Depends { name: "Qt.widgets" }
Depends { name: "Core" }
Depends { name: "TextEditor" }
Depends { name: "Find" }
files: [
"bineditor.cpp",
......
......@@ -2,6 +2,5 @@ QTC_PLUGIN_NAME = BinEditor
QTC_LIB_DEPENDS += \
utils
QTC_PLUGIN_DEPENDS += \
find \
texteditor \
coreplugin
......@@ -53,18 +53,19 @@
#include <coreplugin/id.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/find/ifindsupport.h>
#include <coreplugin/idocument.h>
#include <coreplugin/mimedatabase.h>
#include <extensionsystem/pluginmanager.h>
#include <find/ifindsupport.h>
#include <utils/reloadpromptutils.h>
#include <utils/qtcassert.h>
using namespace Core;
using namespace BINEditor;
using namespace BINEditor::Internal;
class BinEditorFind : public Find::IFindSupport
class BinEditorFind : public Core::IFindSupport
{
Q_OBJECT
......@@ -80,9 +81,9 @@ public:
QString currentFindString() const { return QString(); }
QString completedFindString() const { return QString(); }
Find::FindFlags supportedFindFlags() const
Core::FindFlags supportedFindFlags() const
{
return Find::FindBackward | Find::FindCaseSensitively;
return FindBackward | FindCaseSensitively;
}
void resetIncrementalSearch()
......@@ -91,9 +92,9 @@ public:
m_incrementalWrappedState = false;
}
virtual void highlightAll(const QString &txt, Find::FindFlags findFlags)
virtual void highlightAll(const QString &txt, Core::FindFlags findFlags)
{
m_widget->highlightSearchResults(txt.toLatin1(), Find::textDocumentFlagsForFindFlags(findFlags));
m_widget->highlightSearchResults(txt.toLatin1(), textDocumentFlagsForFindFlags(findFlags));
}
void clearResults()
......@@ -101,7 +102,7 @@ public:
m_widget->highlightSearchResults(QByteArray());
}
int find(const QByteArray &pattern, int pos, Find::FindFlags findFlags, bool *wrapped)
int find(const QByteArray &pattern, int pos, Core::FindFlags findFlags, bool *wrapped)
{
if (wrapped)
*wrapped = false;
......@@ -110,10 +111,10 @@ public:
return pos;
}
int res = m_widget->find(pattern, pos, Find::textDocumentFlagsForFindFlags(findFlags));
int res = m_widget->find(pattern, pos, textDocumentFlagsForFindFlags(findFlags));
if (res < 0) {
pos = (findFlags & Find::FindBackward) ? -1 : 0;
res = m_widget->find(pattern, pos, Find::textDocumentFlagsForFindFlags(findFlags));
pos = (findFlags & FindBackward) ? -1 : 0;
res = m_widget->find(pattern, pos, textDocumentFlagsForFindFlags(findFlags));
if (res < 0)
return res;
if (wrapped)
......@@ -122,7 +123,7 @@ public:
return res;
}
Result findIncremental(const QString &txt, Find::FindFlags findFlags) {
Result findIncremental(const QString &txt, Core::FindFlags findFlags) {
QByteArray pattern = txt.toLatin1();
if (pattern != m_lastPattern)
resetIncrementalSearch(); // Because we don't search for nibbles.
......@@ -140,13 +141,13 @@ public:
Result result;
if (found >= 0) {
result = Found;
m_widget->highlightSearchResults(pattern, Find::textDocumentFlagsForFindFlags(findFlags));
m_widget->highlightSearchResults(pattern, textDocumentFlagsForFindFlags(findFlags));
m_contPos = -1;
} else {
if (found == -2) {
result = NotYetFound;
m_contPos +=
findFlags & Find::FindBackward
findFlags & FindBackward
? -BinEditorWidget::SearchStride : BinEditorWidget::SearchStride;
} else {
result = NotFound;
......@@ -157,12 +158,12 @@ public:
return result;
}
Result findStep(const QString &txt, Find::FindFlags findFlags) {
Result findStep(const QString &txt, Core::FindFlags findFlags) {
QByteArray pattern = txt.toLatin1();
bool wasReset = (m_incrementalStartPos < 0);
if (m_contPos == -1) {
m_contPos = m_widget->cursorPosition();
if (findFlags & Find::FindBackward)
if (findFlags & FindBackward)
m_contPos = m_widget->selectionStart()-1;
}
bool wrapped;
......@@ -175,10 +176,10 @@ public:
m_incrementalStartPos = found;
m_contPos = -1;
if (wasReset)
m_widget->highlightSearchResults(pattern, Find::textDocumentFlagsForFindFlags(findFlags));
m_widget->highlightSearchResults(pattern, textDocumentFlagsForFindFlags(findFlags));
} else if (found == -2) {
result = NotYetFound;
m_contPos += findFlags & Find::FindBackward
m_contPos += findFlags & FindBackward
? -BinEditorWidget::SearchStride : BinEditorWidget::SearchStride;
} else {
result = NotFound;
......@@ -213,7 +214,7 @@ public:
~BinEditorDocument() {}
QString mimeType() const {
return QLatin1String(Constants::C_BINEDITOR_MIMETYPE);
return QLatin1String(BINEditor::Constants::C_BINEDITOR_MIMETYPE);
}
bool setContents(const QByteArray &contents)
......@@ -340,7 +341,7 @@ public:
m_widget = widget;
m_file = new BinEditorDocument(m_widget);
m_context.add(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID);
m_context.add(Constants::C_BINEDITOR);
m_context.add(BINEditor::Constants::C_BINEDITOR);
m_addressEdit = new QLineEdit;
QRegExpValidator * const addressValidator
= new QRegExpValidator(QRegExp(QLatin1String("[0-9a-fA-F]{1,16}")),
......
......@@ -9,8 +9,6 @@ QtcPlugin {
Depends { name: "Core" }
Depends { name: "ProjectExplorer" }
Depends { name: "TextEditor" }
Depends { name: "Find" }
Depends { name: "Locator" }
files: [
"bookmark.cpp",
......
......@@ -68,7 +68,7 @@ void ClangSymbolSearcher::search(const QLinkedList<Symbol> &allSymbols)
? Qt::CaseSensitive : Qt::CaseInsensitive));
const int chunkSize = 10;
QVector<Find::SearchResultItem> resultItems;
QVector<Core::SearchResultItem> resultItems;
resultItems.reserve(100);
m_future->setProgressRange(0, allSymbols.size() % chunkSize);
......@@ -138,7 +138,7 @@ void ClangSymbolSearcher::search(const QLinkedList<Symbol> &allSymbols)
info.line = s.m_location.line();
info.column = s.m_location.column() - 1;
Find::SearchResultItem item;
Core::SearchResultItem item;
item.path << s.m_qualification;
item.text = s.m_name;
item.icon = info.icon;
......
......@@ -47,7 +47,7 @@ class ClangSymbolSearcher: public CppTools::SymbolSearcher
Q_OBJECT
typedef CppTools::SymbolSearcher::Parameters Parameters;
typedef Find::SearchResultItem SearchResultItem;
typedef Core::SearchResultItem SearchResultItem;
public:
ClangSymbolSearcher(ClangIndexer *indexer, const Parameters &parameters, QSet<QString> fileNames, QObject *parent = 0);
......
......@@ -12,9 +12,7 @@ QtcPlugin {
Depends { name: "Core" }
Depends { name: "TextEditor" }
Depends { name: "ProjectExplorer" }
Depends { name: "Find" }
Depends { name: "VcsBase" }
Depends { name: "Locator" }
files: [
"activityselector.cpp",
......
......@@ -2,7 +2,6 @@ QTC_PLUGIN_NAME = ClearCase
QTC_LIB_DEPENDS += \
utils
QTC_PLUGIN_DEPENDS += \
locator \
projectexplorer \
texteditor \
coreplugin \
......
......@@ -52,7 +52,7 @@
#include <coreplugin/messagemanager.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <locator/commandlocator.h>
#include <coreplugin/locator/commandlocator.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/project.h>
#include <projectexplorer/iprojectmanager.h>
......@@ -471,7 +471,7 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er
const QString description = QLatin1String("ClearCase");
const QString prefix = QLatin1String("cc");
// register cc prefix in Locator
m_commandLocator = new Locator::CommandLocator("cc", description, prefix);
m_commandLocator = new Core::CommandLocator("cc", description, prefix);
addAutoReleasedObject(m_commandLocator);
//register actions
......
......@@ -54,13 +54,13 @@ class QTextCodec;
QT_END_NAMESPACE
namespace Core {
class CommandLocator;
class IVersionControl;
class IEditor;
} // namespace Core
namespace Utils { class ParameterAction; }
namespace VcsBase { class VcsBaseSubmitEditor; }
namespace Locator { class CommandLocator; }
namespace ProjectExplorer { class Project; }
namespace ClearCase {
......@@ -277,7 +277,7 @@ private:
QString m_activity;
QString m_diffPrefix;
Locator::CommandLocator *m_commandLocator;
Core::CommandLocator *m_commandLocator;
Utils::ParameterAction *m_checkOutAction;
Utils::ParameterAction *m_checkInCurrentAction;
Utils::ParameterAction *m_undoCheckOutAction;
......
......@@ -64,17 +64,17 @@ CMakeLocatorFilter::~CMakeLocatorFilter()
}
QList<Locator::FilterEntry> CMakeLocatorFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry)
QList<Core::LocatorFilterEntry> CMakeLocatorFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry)
{
Q_UNUSED(future)
QList<Locator::FilterEntry> result;
QList<Core::LocatorFilterEntry> result;
foreach (Project *p, SessionManager::projects()) {
CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(p);
if (cmakeProject) {
foreach (const CMakeBuildTarget &ct, cmakeProject->buildTargets()) {
if (ct.title.contains(entry)) {
Locator::FilterEntry entry(this, ct.title, cmakeProject->projectFilePath());
Core::LocatorFilterEntry entry(this, ct.title, cmakeProject->projectFilePath());
entry.extraInfo = FileUtils::shortNativePath(
FileName::fromString(cmakeProject->projectFilePath()));
result.append(entry);
......@@ -86,7 +86,7 @@ QList<Locator::FilterEntry> CMakeLocatorFilter::matchesFor(QFutureInterface<Loca
return result;
}
void CMakeLocatorFilter::accept(Locator::FilterEntry selection) const
void CMakeLocatorFilter::accept(Core::LocatorFilterEntry selection) const
{
// Get the project containing the target selected
CMakeProject *cmakeProject = 0;
......
......@@ -30,14 +30,14 @@
#ifndef CMAKELOCATORFILTER_H
#define CMAKELOCATORFILTER_H
#include <locator/ilocatorfilter.h>
#include <coreplugin/locator/ilocatorfilter.h>
#include <QIcon>
namespace CMakeProjectManager {
namespace Internal {
class CMakeLocatorFilter : public Locator::ILocatorFilter
class CMakeLocatorFilter : public Core::ILocatorFilter
{
Q_OBJECT
......@@ -45,8 +45,8 @@ public:
CMakeLocatorFilter();
~CMakeLocatorFilter();
QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
void accept(Locator::FilterEntry selection) const;
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
void accept(Core::LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &future);
private slots:
......
......@@ -9,7 +9,6 @@ QtcPlugin {
Depends { name: "Core" }
Depends { name: "CppTools" }
Depends { name: "CPlusPlus" }
Depends { name: "Locator" }
Depends { name: "ProjectExplorer" }
Depends { name: "TextEditor" }
Depends { name: "QtSupport" }
......
QTC_PLUGIN_NAME = CMakeProjectManager
QTC_PLUGIN_DEPENDS += \
coreplugin \
locator \
projectexplorer \
cpptools \
texteditor \
......
......@@ -35,8 +35,11 @@
#include "mimedatabase.h"
#include "modemanager.h"
#include "infobar.h"
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/find/findplugin.h>
#include <coreplugin/locator/locatorplugin.h>
#include <utils/savefile.h>
......@@ -51,10 +54,15 @@ CorePlugin::CorePlugin() : m_editMode(0), m_designMode(0)
{
qRegisterMetaType<Core::Id>();
m_mainWindow = new MainWindow;
m_findPlugin = new FindPlugin;
m_locatorPlugin = new LocatorPlugin;
}
CorePlugin::~CorePlugin()
{
delete m_findPlugin;
delete m_locatorPlugin;
if (m_editMode) {
removeObject(m_editMode);
delete m_editMode;
......@@ -98,6 +106,9 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
// Make sure we respect the process's umask when creating new files
Utils::SaveFile::initializeUmask();
m_findPlugin->initialize(arguments, errorMessage);
m_locatorPlugin->initialize(this, arguments, errorMessage);
return success;
}
......@@ -107,11 +118,14 @@ void CorePlugin::extensionsInitialized()
if (m_designMode->designModeIsRequired())
addObject(m_designMode);
m_mainWindow->extensionsInitialized();
m_findPlugin->extensionsInitialized();
m_locatorPlugin->extensionsInitialized();
}
bool CorePlugin::delayedInitialize()
{
HelpManager::setupHelpManager();
m_locatorPlugin->delayedInitialize();
return true;
}
......
......@@ -33,11 +33,15 @@
#include <extensionsystem/iplugin.h>
namespace Core {
class DesignMode;
class FindPlugin;
namespace Internal {
class EditMode;
class MainWindow;
class LocatorPlugin;
class CorePlugin : public ExtensionSystem::IPlugin
{
......@@ -69,6 +73,8 @@ private:
MainWindow *m_mainWindow;
EditMode *m_editMode;
DesignMode *m_designMode;
FindPlugin *m_findPlugin;
LocatorPlugin *m_locatorPlugin;
};
} // namespace Internal
......
......@@ -206,11 +206,14 @@ FORMS += dialogs/newdialog.ui \
mimetypesettingspage.ui \
mimetypemagicdialog.ui \
removefiledialog.ui \
dialogs/addtovcsdialog.ui
dialogs/addtovcsdialog.ui
RESOURCES += core.qrc \
fancyactionbar.qrc
include(find/find.pri)
include(locator/locator.pri)
win32 {
SOURCES += progressmanager/progressmanager_win.cpp
greaterThan(QT_MAJOR_VERSION, 4): QT += gui-private # Uses QPlatformNativeInterface.
......
import qbs.base 1.0
import qbs.FileInfo
import QtcPlugin
QtcPlugin {
......@@ -183,6 +184,92 @@ QtcPlugin {
files: [
"testdatadir.cpp",
"testdatadir.h",
"locator/locatorfiltertest.cpp",
"locator/locatorfiltertest.h",
"locator/locator_test.cpp"
]
cpp.defines: outer.concat(['SRCDIR="' + FileInfo.path(filePath) + '"'])
}
Group {
name: "Find"
prefix: "find/"
files: [
"basetextfind.cpp",
"basetextfind.h",
"currentdocumentfind.cpp",
"currentdocumentfind.h",
"find.qrc",
"finddialog.ui",
"findplugin.cpp",
"findplugin.h",
"findtoolbar.cpp",
"findtoolbar.h",
"findtoolwindow.cpp",
"findtoolwindow.h",
"findwidget.ui",
"ifindfilter.cpp",
"ifindfilter.h",
"ifindsupport.cpp",
"ifindsupport.h",
"searchresultcolor.h",
"searchresulttreeitemdelegate.cpp",
"searchresulttreeitemdelegate.h",
"searchresulttreeitemroles.h",
"searchresulttreeitems.cpp",
"searchresulttreeitems.h",
"searchresulttreemodel.cpp",
"searchresulttreemodel.h",
"searchresulttreeview.cpp",
"searchresulttreeview.h",
"searchresultwidget.cpp",
"searchresultwidget.h",
"searchresultwindow.cpp",
"searchresultwindow.h",
"textfindconstants.h",
"treeviewfind.cpp",
"treeviewfind.h",
]
}
Group {
name: "Locator"
prefix: "locator/"
files: [
"basefilefilter.cpp",
"basefilefilter.h",
"commandlocator.cpp",
"commandlocator.h",
"directoryfilter.cpp",
"directoryfilter.h",
"directoryfilter.ui",
"executefilter.cpp",
"executefilter.h",
"filesystemfilter.cpp",
"filesystemfilter.h",
"filesystemfilter.ui",
"ilocatorfilter.cpp",
"ilocatorfilter.h",
"locator.qrc",
"locatorconstants.h",
"locatorfiltersfilter.cpp",
"locatorfiltersfilter.h",
"locatormanager.cpp",
"locatormanager.h",
"locatorplugin.cpp",
"locatorplugin.h",
"locatorsearchutils.cpp",
"locatorsearchutils.h",
"locatorwidget.cpp",
"locatorwidget.h",
"opendocumentsfilter.cpp",
"opendocumentsfilter.h",
"settingspage.cpp",
"settingspage.h",
"settingspage.ui",
"images/locator.png",
"images/reload.png",
]
}
......
......@@ -38,7 +38,7 @@
#include <QPlainTextEdit>
#include <QTextCursor>
namespace Find {
namespace Core {