Core: Merge Find and Locator into Core plugin

Change-Id: I7053310272235d854c9f409670ff52a10a7add8b
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
hjk
2014-01-13 16:17:34 +01:00
committed by Eike Ziller
parent 8b854270a6
commit 4d96fa7aba
239 changed files with 1625 additions and 1787 deletions
+3 -3
View File
@@ -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.
-3
View File
@@ -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
+2 -3
View File
@@ -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();
+2 -5
View File
@@ -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;
-1
View File
@@ -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
+20 -19
View File
@@ -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}")),
-2
View File
@@ -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);
-2
View File
@@ -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 \
+2 -2
View File
@@ -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
+2 -2
View File
@@ -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" }
@@ -1,7 +1,6 @@
QTC_PLUGIN_NAME = CMakeProjectManager
QTC_PLUGIN_DEPENDS += \
coreplugin \
locator \
projectexplorer \
cpptools \
texteditor \
+14
View File
@@ -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;
}
+6
View File
@@ -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
+3
View File
@@ -211,6 +211,9 @@ FORMS += dialogs/newdialog.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.
+87
View File
@@ -1,4 +1,5 @@
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 {
struct BaseTextFindPrivate
{
@@ -424,4 +424,4 @@ void BaseTextFind::clearFindScope()
d->m_findScopeVerticalBlockSelectionLastColumn);
}
} // namespace Find
} // namespace Core
@@ -30,7 +30,6 @@
#ifndef BASETEXTFIND_H
#define BASETEXTFIND_H
#include "find_global.h"
#include "ifindsupport.h"
QT_BEGIN_NAMESPACE
@@ -39,10 +38,10 @@ class QTextEdit;
class QTextCursor;
QT_END_NAMESPACE
namespace Find {
namespace Core {
struct BaseTextFindPrivate;
class FIND_EXPORT BaseTextFind : public IFindSupport
class CORE_EXPORT BaseTextFind : public IFindSupport
{
Q_OBJECT
@@ -68,7 +67,7 @@ public:
void clearFindScope();
signals:
void highlightAll(const QString &txt, Find::FindFlags findFlags);
void highlightAll(const QString &txt, Core::FindFlags findFlags);
void findScopeChanged(const QTextCursor &start, const QTextCursor &end,
int verticalBlockSelectionFirstColumn,
int verticalBlockSelectionLastColumn);
@@ -87,6 +86,6 @@ private:
BaseTextFindPrivate *d;
};
} // namespace Find
} // namespace Core
#endif // BASETEXTFIND_H
@@ -38,8 +38,8 @@
#include <QWidget>
using namespace Core;
using namespace Find;
using namespace Find::Internal;
using namespace Core;
using namespace Core::Internal;
CurrentDocumentFind::CurrentDocumentFind()
: m_currentFind(0)
@@ -34,7 +34,7 @@
#include <QPointer>
namespace Find {
namespace Core {
namespace Internal {
class CurrentDocumentFind : public QObject
@@ -88,6 +88,6 @@ private:
};
} // namespace Internal
} // namespace Find
} // namespace Core
#endif // CURRENTDOCUMENTFIND_H
+42
View File
@@ -0,0 +1,42 @@
HEADERS += \
$$PWD/findtoolwindow.h \
$$PWD/textfindconstants.h \
$$PWD/ifindsupport.h \
$$PWD/ifindfilter.h \
$$PWD/currentdocumentfind.h \
$$PWD/basetextfind.h \
$$PWD/findtoolbar.h \
$$PWD/findplugin.h \
$$PWD/searchresultcolor.h \
$$PWD/searchresulttreeitemdelegate.h \
$$PWD/searchresulttreeitemroles.h \
$$PWD/searchresulttreeitems.h \
$$PWD/searchresulttreemodel.h \
$$PWD/searchresulttreeview.h \
$$PWD/searchresultwindow.h \
$$PWD/searchresultwidget.h \
$$PWD/treeviewfind.h
SOURCES += \
$$PWD/findtoolwindow.cpp \
$$PWD/currentdocumentfind.cpp \
$$PWD/basetextfind.cpp \
$$PWD/findtoolbar.cpp \
$$PWD/findplugin.cpp \
$$PWD/searchresulttreeitemdelegate.cpp \
$$PWD/searchresulttreeitems.cpp \
$$PWD/searchresulttreemodel.cpp \
$$PWD/searchresulttreeview.cpp \
$$PWD/searchresultwindow.cpp \
$$PWD/ifindfilter.cpp \
$$PWD/ifindsupport.cpp \
$$PWD/searchresultwidget.cpp \
$$PWD/treeviewfind.cpp
FORMS += \
$$PWD/findwidget.ui \
$$PWD/finddialog.ui
RESOURCES += \
$$PWD/find.qrc
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Find::Internal::FindDialog</class>
<widget class="QWidget" name="Find::Internal::FindDialog">
<class>Core::Internal::FindDialog</class>
<widget class="QWidget" name="Core::Internal::FindDialog">
<property name="geometry">
<rect>
<x>0</x>
+394
View File
@@ -0,0 +1,394 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "findplugin.h"
#include "currentdocumentfind.h"
#include "findtoolbar.h"
#include "findtoolwindow.h"
#include "searchresultwindow.h"
#include "ifindfilter.h"
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
#include <coreplugin/id.h>
#include <coreplugin/coreplugin.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h>
#include <QMenu>
#include <QStringListModel>
#include <QAction>
#include <QtPlugin>
#include <QSettings>
/*!
\namespace Core::Internal
\internal
*/
/*!
\namespace Core::Internal::ItemDataRoles
\internal
*/
Q_DECLARE_METATYPE(Core::IFindFilter*)
namespace {
const int MAX_COMPLETIONS = 50;
}
namespace Core {
class FindPluginPrivate {
public:
explicit FindPluginPrivate(FindPlugin *q);
//variables
static FindPlugin *m_instance;
QHash<IFindFilter *, QAction *> m_filterActions;
Internal::CurrentDocumentFind *m_currentDocumentFind;
Internal::FindToolBar *m_findToolBar;
Internal::FindToolWindow *m_findDialog;
SearchResultWindow *m_searchResultWindow;
FindFlags m_findFlags;
QStringListModel *m_findCompletionModel;
QStringListModel *m_replaceCompletionModel;
QStringList m_findCompletions;
QStringList m_replaceCompletions;
QAction *m_openFindDialog;
};
FindPluginPrivate::FindPluginPrivate(FindPlugin *q) :
m_currentDocumentFind(0), m_findToolBar(0), m_findDialog(0),
m_findCompletionModel(new QStringListModel(q)),
m_replaceCompletionModel(new QStringListModel(q))
{
}
FindPlugin *FindPluginPrivate::m_instance = 0;
FindPlugin::FindPlugin() : d(new FindPluginPrivate(this))
{
QTC_ASSERT(!FindPluginPrivate::m_instance, return);
FindPluginPrivate::m_instance = this;
}
FindPlugin::~FindPlugin()
{
FindPluginPrivate::m_instance = 0;
delete d->m_currentDocumentFind;
delete d->m_findToolBar;
delete d->m_findDialog;
ExtensionSystem::PluginManager::removeObject(d->m_searchResultWindow);
delete d->m_searchResultWindow;
delete d;
}
FindPlugin *FindPlugin::instance()
{
return FindPluginPrivate::m_instance;
}
void FindPlugin::initialize(const QStringList &, QString *)
{
setupMenu();
d->m_currentDocumentFind = new Internal::CurrentDocumentFind;
d->m_findToolBar = new Internal::FindToolBar(this, d->m_currentDocumentFind);
d->m_findDialog = new Internal::FindToolWindow(this);
d->m_searchResultWindow = new SearchResultWindow(d->m_findDialog);
ExtensionSystem::PluginManager::addObject(d->m_searchResultWindow);
}
void FindPlugin::extensionsInitialized()
{
setupFilterMenuItems();
readSettings();
}
void FindPlugin::aboutToShutdown()
{
d->m_findToolBar->setVisible(false);
d->m_findToolBar->setParent(0);
d->m_currentDocumentFind->removeConnections();
writeSettings();
}
void FindPlugin::filterChanged()
{
IFindFilter *changedFilter = qobject_cast<IFindFilter *>(sender());
QAction *action = d->m_filterActions.value(changedFilter);
QTC_ASSERT(changedFilter, return);
QTC_ASSERT(action, return);
action->setEnabled(changedFilter->isEnabled());
bool haveEnabledFilters = false;
foreach (const IFindFilter *filter, d->m_filterActions.keys()) {
if (filter->isEnabled()) {
haveEnabledFilters = true;
break;
}
}
d->m_openFindDialog->setEnabled(haveEnabledFilters);
}
void FindPlugin::openFindFilter()
{
QAction *action = qobject_cast<QAction*>(sender());
QTC_ASSERT(action, return);
IFindFilter *filter = action->data().value<IFindFilter *>();
openFindDialog(filter);
}
void FindPlugin::openFindDialog(IFindFilter *filter)
{
if (d->m_currentDocumentFind->candidateIsEnabled())
d->m_currentDocumentFind->acceptCandidate();
const QString currentFindString =
d->m_currentDocumentFind->isEnabled() ?
d->m_currentDocumentFind->currentFindString() : QString();
if (!currentFindString.isEmpty())
d->m_findDialog->setFindText(currentFindString);
d->m_findDialog->setCurrentFilter(filter);
SearchResultWindow::instance()->openNewSearchPanel();
}
void FindPlugin::setupMenu()
{
Core::ActionContainer *medit = Core::ActionManager::actionContainer(Core::Constants::M_EDIT);
Core::ActionContainer *mfind = Core::ActionManager::createMenu(Constants::M_FIND);
medit->addMenu(mfind, Core::Constants::G_EDIT_FIND);
mfind->menu()->setTitle(tr("&Find/Replace"));
mfind->appendGroup(Constants::G_FIND_CURRENTDOCUMENT);
mfind->appendGroup(Constants::G_FIND_FILTERS);
mfind->appendGroup(Constants::G_FIND_FLAGS);
mfind->appendGroup(Constants::G_FIND_ACTIONS);
Core::Context globalcontext(Core::Constants::C_GLOBAL);
Core::Command *cmd;
mfind->addSeparator(globalcontext, Constants::G_FIND_FLAGS);
mfind->addSeparator(globalcontext, Constants::G_FIND_ACTIONS);
Core::ActionContainer *mfindadvanced = Core::ActionManager::createMenu(Constants::M_FIND_ADVANCED);
mfindadvanced->menu()->setTitle(tr("Advanced Find"));
mfind->addMenu(mfindadvanced, Constants::G_FIND_FILTERS);
d->m_openFindDialog = new QAction(tr("Open Advanced Find..."), this);
d->m_openFindDialog->setIconText(tr("Advanced..."));
cmd = Core::ActionManager::registerAction(d->m_openFindDialog, Constants::ADVANCED_FIND, globalcontext);
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F")));
mfindadvanced->addAction(cmd);
connect(d->m_openFindDialog, SIGNAL(triggered()), this, SLOT(openFindFilter()));
}
void FindPlugin::setupFilterMenuItems()
{
QList<IFindFilter*> findInterfaces =
ExtensionSystem::PluginManager::getObjects<IFindFilter>();
Core::Command *cmd;
Core::Context globalcontext(Core::Constants::C_GLOBAL);
Core::ActionContainer *mfindadvanced = Core::ActionManager::actionContainer(Constants::M_FIND_ADVANCED);
d->m_filterActions.clear();
bool haveEnabledFilters = false;
const Core::Id base("FindFilter.");
foreach (IFindFilter *filter, findInterfaces) {
QAction *action = new QAction(QLatin1String(" ") + filter->displayName(), this);
bool isEnabled = filter->isEnabled();
if (isEnabled)
haveEnabledFilters = true;
action->setEnabled(isEnabled);
action->setData(qVariantFromValue(filter));
cmd = Core::ActionManager::registerAction(action,
base.withSuffix(filter->id()), globalcontext);
cmd->setDefaultKeySequence(filter->defaultShortcut());
mfindadvanced->addAction(cmd);
d->m_filterActions.insert(filter, action);
connect(action, SIGNAL(triggered(bool)), this, SLOT(openFindFilter()));
connect(filter, SIGNAL(enabledChanged(bool)), this, SLOT(filterChanged()));
}
d->m_findDialog->setFindFilters(findInterfaces);
d->m_openFindDialog->setEnabled(haveEnabledFilters);
}
FindFlags FindPlugin::findFlags() const
{
return d->m_findFlags;
}
void FindPlugin::setCaseSensitive(bool sensitive)
{
setFindFlag(FindCaseSensitively, sensitive);
}
void FindPlugin::setWholeWord(bool wholeOnly)
{
setFindFlag(FindWholeWords, wholeOnly);
}
void FindPlugin::setBackward(bool backward)
{
setFindFlag(FindBackward, backward);
}
void FindPlugin::setRegularExpression(bool regExp)
{
setFindFlag(FindRegularExpression, regExp);
}
void FindPlugin::setPreserveCase(bool preserveCase)
{
setFindFlag(FindPreserveCase, preserveCase);
}
void FindPlugin::setFindFlag(FindFlag flag, bool enabled)
{
bool hasFlag = hasFindFlag(flag);
if ((hasFlag && enabled) || (!hasFlag && !enabled))
return;
if (enabled)
d->m_findFlags |= flag;
else
d->m_findFlags &= ~flag;
if (flag != FindBackward)
emit findFlagsChanged();
}
bool FindPlugin::hasFindFlag(FindFlag flag)
{
return d->m_findFlags & flag;
}
void FindPlugin::writeSettings()
{
QSettings *settings = Core::ICore::settings();
settings->beginGroup(QLatin1String("Find"));
settings->setValue(QLatin1String("Backward"), hasFindFlag(FindBackward));
settings->setValue(QLatin1String("CaseSensitively"), hasFindFlag(FindCaseSensitively));
settings->setValue(QLatin1String("WholeWords"), hasFindFlag(FindWholeWords));
settings->setValue(QLatin1String("RegularExpression"), hasFindFlag(FindRegularExpression));
settings->setValue(QLatin1String("PreserveCase"), hasFindFlag(FindPreserveCase));
settings->setValue(QLatin1String("FindStrings"), d->m_findCompletions);
settings->setValue(QLatin1String("ReplaceStrings"), d->m_replaceCompletions);
settings->endGroup();
d->m_findToolBar->writeSettings();
d->m_findDialog->writeSettings();
d->m_searchResultWindow->writeSettings();
}
void FindPlugin::readSettings()
{
QSettings *settings = Core::ICore::settings();
settings->beginGroup(QLatin1String("Find"));
bool block = blockSignals(true);
setBackward(settings->value(QLatin1String("Backward"), false).toBool());
setCaseSensitive(settings->value(QLatin1String("CaseSensitively"), false).toBool());
setWholeWord(settings->value(QLatin1String("WholeWords"), false).toBool());
setRegularExpression(settings->value(QLatin1String("RegularExpression"), false).toBool());
setPreserveCase(settings->value(QLatin1String("PreserveCase"), false).toBool());
blockSignals(block);
d->m_findCompletions = settings->value(QLatin1String("FindStrings")).toStringList();
d->m_replaceCompletions = settings->value(QLatin1String("ReplaceStrings")).toStringList();
d->m_findCompletionModel->setStringList(d->m_findCompletions);
d->m_replaceCompletionModel->setStringList(d->m_replaceCompletions);
settings->endGroup();
d->m_findToolBar->readSettings();
d->m_findDialog->readSettings();
emit findFlagsChanged(); // would have been done in the setXXX methods above
}
void FindPlugin::updateFindCompletion(const QString &text)
{
updateCompletion(text, d->m_findCompletions, d->m_findCompletionModel);
}
void FindPlugin::updateReplaceCompletion(const QString &text)
{
updateCompletion(text, d->m_replaceCompletions, d->m_replaceCompletionModel);
}
void FindPlugin::updateCompletion(const QString &text, QStringList &completions, QStringListModel *model)
{
if (text.isEmpty())
return;
completions.removeAll(text);
completions.prepend(text);
while (completions.size() > MAX_COMPLETIONS)
completions.removeLast();
model->setStringList(completions);
}
void FindPlugin::setUseFakeVim(bool on)
{
if (d->m_findToolBar)
d->m_findToolBar->setUseFakeVim(on);
}
void FindPlugin::openFindToolBar(FindDirection direction)
{
if (d->m_findToolBar) {
d->m_findToolBar->setBackward(direction == FindBackwardDirection);
d->m_findToolBar->openFindToolBar();
}
}
QStringListModel *FindPlugin::findCompletionModel() const
{
return d->m_findCompletionModel;
}
QStringListModel *FindPlugin::replaceCompletionModel() const
{
return d->m_replaceCompletionModel;
}
QKeySequence IFindFilter::defaultShortcut() const
{
return QKeySequence();
}
// declared in textfindconstants.h
QTextDocument::FindFlags textDocumentFlagsForFindFlags(FindFlags flags)
{
QTextDocument::FindFlags textDocFlags;
if (flags & FindBackward)
textDocFlags |= QTextDocument::FindBackward;
if (flags & FindCaseSensitively)
textDocFlags |= QTextDocument::FindCaseSensitively;
if (flags & FindWholeWords)
textDocFlags |= QTextDocument::FindWholeWords;
return textDocFlags;
}
} // namespace Core
@@ -30,7 +30,6 @@
#ifndef FINDPLUGIN_H
#define FINDPLUGIN_H
#include "find_global.h"
#include "textfindconstants.h"
#include <extensionsystem/iplugin.h>
@@ -39,23 +38,24 @@ QT_BEGIN_NAMESPACE
class QStringListModel;
QT_END_NAMESPACE
namespace Find {
namespace Core {
class IFindFilter;
class FindPluginPrivate;
namespace Internal {
class CorePlugin;
class FindToolBar;
class CurrentDocumentFind;
} // namespace Internal
class FIND_EXPORT FindPlugin : public ExtensionSystem::IPlugin
class CORE_EXPORT FindPlugin : public QObject
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Find.json")
public:
FindPlugin();
virtual ~FindPlugin();
static FindPlugin *instance();
enum FindDirection {
@@ -63,13 +63,8 @@ public:
FindBackwardDirection
};
// IPlugin
bool initialize(const QStringList &arguments, QString *errorMessage);
void extensionsInitialized();
ShutdownFlag aboutToShutdown();
FindFlags findFlags() const;
bool hasFindFlag(FindFlag flag);
Core::FindFlags findFlags() const;
bool hasFindFlag(Core::FindFlag flag);
void updateFindCompletion(const QString &text);
void updateReplaceCompletion(const QString &text);
QStringListModel *findCompletionModel() const;
@@ -78,6 +73,10 @@ public:
void openFindToolBar(FindDirection direction);
void openFindDialog(IFindFilter *filter);
void initialize(const QStringList &, QString *);
void extensionsInitialized();
void aboutToShutdown();
public slots:
void setCaseSensitive(bool sensitive);
void setWholeWord(bool wholeOnly);
@@ -93,7 +92,7 @@ private slots:
void openFindFilter();
private:
void setFindFlag(FindFlag flag, bool enabled);
void setFindFlag(Core::FindFlag flag, bool enabled);
void updateCompletion(const QString &text, QStringList &completions, QStringListModel *model);
void setupMenu();
void setupFilterMenuItems();
@@ -104,6 +103,6 @@ private:
FindPluginPrivate *d;
};
} // namespace Find
} // namespace Core
#endif // FINDPLUGIN_H
@@ -28,10 +28,11 @@
****************************************************************************/
#include "findtoolbar.h"
#include "findplugin.h"
#include "ifindfilter.h"
#include "findplugin.h"
#include <coreplugin/coreconstants.h>
#include <coreplugin/coreplugin.h>
#include <coreplugin/icore.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
@@ -53,10 +54,10 @@
#include <QStringListModel>
Q_DECLARE_METATYPE(QStringList)
Q_DECLARE_METATYPE(Find::IFindFilter*)
Q_DECLARE_METATYPE(Core::IFindFilter*)
using namespace Find;
using namespace Find::Internal;
using namespace Core;
using namespace Core::Internal;
FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumentFind)
: m_plugin(plugin),
@@ -38,10 +38,8 @@
#include <QTimer>
namespace Core {
class FindToolBarPlaceHolder;
}
namespace Find {
class FindToolBarPlaceHolder;
class FindPlugin;
namespace Internal {
@@ -146,6 +144,6 @@ private:
};
} // namespace Internal
} // namespace Find
} // namespace Core
#endif // FINDTOOLBAR_H
@@ -39,8 +39,8 @@
#include <QKeyEvent>
#include <QScrollArea>
using namespace Find;
using namespace Find::Internal;
using namespace Core;
using namespace Core::Internal;
static FindToolWindow *m_instance = 0;
@@ -31,13 +31,13 @@
#define FINDTOOLWINDOW_H
#include "ui_finddialog.h"
#include "findplugin.h"
#include <QList>
QT_FORWARD_DECLARE_CLASS(QCompleter)
namespace Find {
class FindPlugin;
namespace Core {
class IFindFilter;
namespace Internal {
@@ -82,6 +82,6 @@ private:
};
} // namespace Internal
} // namespace Find
} // namespace Core
#endif // FINDTOOLWINDOW_H
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Find::Internal::FindWidget</class>
<widget class="QWidget" name="Find::Internal::FindWidget">
<class>Core::Internal::FindWidget</class>
<widget class="QWidget" name="Core::Internal::FindWidget">
<property name="geometry">
<rect>
<x>0</x>
@@ -85,7 +85,7 @@
In the find filter's find/replaceAll function, get the shared
\gui{Search Results} window, initiate a new search and connect the
signals for handling selection of results and the replace action
(see the Find::SearchResultWindow class for details).
(see the Core::SearchResultWindow class for details).
Start your search implementation via the corresponding QtConcurrent
functions. Add the returned QFuture object to the Core::ProgressManager.
Use a QFutureWatcher on the returned QFuture object to receive a signal
@@ -143,7 +143,7 @@
*/
/*!
\fn void IFindFilter::findAll(const QString &txt, Find::FindFlags findFlags)
\fn void IFindFilter::findAll(const QString &txt, Core::FindFlags findFlags)
This function is called when the user selected this find scope and
initiated a search.
@@ -152,15 +152,15 @@
(add it to Core::ProgressManager for a progress bar!) and presents the
search results to the user (using the \gui{Search Results} output pane).
For more information, see the descriptions of this class,
Core::ProgressManager, and Find::SearchResultWindow.
Core::ProgressManager, and Core::SearchResultWindow.
\sa replaceAll()
\sa Core::ProgressManager
\sa Find::SearchResultWindow
\sa Core::SearchResultWindow
*/
/*!
\fn void IFindFilter::replaceAll(const QString &txt, Find::FindFlags findFlags)
\fn void IFindFilter::replaceAll(const QString &txt, Core::FindFlags findFlags)
Override this function if you want to support search and replace.
This function is called when the user selected this find scope and
@@ -172,11 +172,11 @@
(add it to Core::ProgressManager for a progress bar!) and presents the
search results to the user (using the \gui{Search Results} output pane).
For more information see the descriptions of this class,
Core::ProgressManager, and Find::SearchResultWindow.
Core::ProgressManager, and Core::SearchResultWindow.
\sa findAll()
\sa Core::ProgressManager
\sa Find::SearchResultWindow
\sa Core::SearchResultWindow
*/
/*!
@@ -207,7 +207,7 @@
*/
/*!
\fn Find::FindFlags BaseTextFind::supportedFindFlags() const
\fn Core::FindFlags BaseTextFind::supportedFindFlags() const
Returns the find flags, like whole words or regular expressions,
that this find filter supports.
@@ -217,7 +217,7 @@
and Find::FindWholeWords
*/
namespace Find {
namespace Core {
FindFlags IFindFilter::supportedFindFlags() const
{
@@ -282,4 +282,4 @@ QString IFindFilter::descriptionForFindFlags(FindFlags flags)
return description;
}
} // namespace Find
} // namespace Core
@@ -30,7 +30,6 @@
#ifndef IFINDFILTER_H
#define IFINDFILTER_H
#include "find_global.h"
#include "textfindconstants.h"
QT_BEGIN_NAMESPACE
@@ -40,9 +39,9 @@ class QKeySequence;
class Pixmap;
QT_END_NAMESPACE
namespace Find {
namespace Core {
class FIND_EXPORT IFindFilter : public QObject
class CORE_EXPORT IFindFilter : public QObject
{
Q_OBJECT
public:
@@ -71,6 +70,6 @@ signals:
void enabledChanged(bool enabled);
};
} // namespace Find
} // namespace Core
#endif // IFINDFILTER_H
@@ -35,7 +35,7 @@
#include <QPaintEvent>
#include <QPainter>
namespace Find {
namespace Core {
namespace Internal {
class WrapIndicator : public QWidget
@@ -88,7 +88,7 @@ private:
} // Internal
} // Find
using namespace Find;
using namespace Core;
void IFindSupport::replace(const QString &before, const QString &after, FindFlags findFlags)
{
@@ -30,15 +30,14 @@
#ifndef IFINDSUPPORT_H
#define IFINDSUPPORT_H
#include "find_global.h"
#include "textfindconstants.h"
#include <QObject>
#include <QString>
namespace Find {
namespace Core {
class FIND_EXPORT IFindSupport : public QObject
class CORE_EXPORT IFindSupport : public QObject
{
Q_OBJECT
@@ -76,6 +75,6 @@ signals:
inline void IFindSupport::highlightAll(const QString &, FindFlags) {}
} // namespace Find
} // namespace Core
#endif // IFINDSUPPORT_H

Before

Width:  |  Height:  |  Size: 108 B

After

Width:  |  Height:  |  Size: 108 B

Before

Width:  |  Height:  |  Size: 153 B

After

Width:  |  Height:  |  Size: 153 B

Before

Width:  |  Height:  |  Size: 75 B

After

Width:  |  Height:  |  Size: 75 B

Before

Width:  |  Height:  |  Size: 931 B

After

Width:  |  Height:  |  Size: 931 B

Before

Width:  |  Height:  |  Size: 109 B

After

Width:  |  Height:  |  Size: 109 B

Before

Width:  |  Height:  |  Size: 196 B

After

Width:  |  Height:  |  Size: 196 B

Before

Width:  |  Height:  |  Size: 103 B

After

Width:  |  Height:  |  Size: 103 B

Before

Width:  |  Height:  |  Size: 152 B

After

Width:  |  Height:  |  Size: 152 B

Before

Width:  |  Height:  |  Size: 934 B

After

Width:  |  Height:  |  Size: 934 B

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 146 B

Before

Width:  |  Height:  |  Size: 198 B

After

Width:  |  Height:  |  Size: 198 B

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

@@ -3,7 +3,7 @@
#include <QColor>
namespace Find {
namespace Core {
namespace Internal {
class SearchResultColor{
@@ -15,6 +15,6 @@ public:
};
} // namespace Internal
} // namespace Find
} // namespace Core
#endif // SEARCHRESULTCOLOR_H
@@ -36,7 +36,7 @@
#include <QModelIndex>
#include <QDebug>
using namespace Find::Internal;
using namespace Core::Internal;
SearchResultTreeItemDelegate::SearchResultTreeItemDelegate(QObject *parent)
: QItemDelegate(parent)
@@ -32,7 +32,7 @@
#include <QItemDelegate>
namespace Find {
namespace Core {
namespace Internal {
class SearchResultTreeItemDelegate: public QItemDelegate
@@ -50,6 +50,6 @@ private:
};
} // namespace Internal
} // namespace Find
} // namespace Core
#endif // SEARCHRESULTTREEITEMDELEGATE_H
@@ -32,7 +32,7 @@
#include <QAbstractItemView>
namespace Find {
namespace Core {
namespace Internal {
namespace ItemDataRoles {
@@ -50,7 +50,7 @@ enum Roles
};
} // namespace Internal
} // namespace Find
} // namespace Core
} // namespace ItemDataRoles
#endif // SEARCHRESULTTREEITEMROLES_H
@@ -29,7 +29,7 @@
#include "searchresulttreeitems.h"
namespace Find {
namespace Core {
namespace Internal {
SearchResultTreeItem::SearchResultTreeItem(const SearchResultItem &item,
@@ -142,4 +142,4 @@ void SearchResultTreeItem::appendChild(const SearchResultItem &item)
}
} // namespace Internal
} // namespace Find
} // namespace Core
@@ -35,7 +35,7 @@
#include <QString>
#include <QList>
namespace Find {
namespace Core {
namespace Internal {
class SearchResultTreeItem
@@ -77,6 +77,6 @@ private:
};
} // namespace Internal
} // namespace Find
} // namespace Core
#endif // SEARCHRESULTTREEITEMS_H
@@ -36,8 +36,8 @@
#include <QFontMetrics>
#include <QDebug>
using namespace Find;
using namespace Find::Internal;
using namespace Core;
using namespace Core::Internal;
SearchResultTreeModel::SearchResultTreeModel(QObject *parent)
: QAbstractItemModel(parent)
@@ -36,7 +36,7 @@
#include <QAbstractItemModel>
#include <QFont>
namespace Find {
namespace Core {
namespace Internal {
class SearchResultTreeItem;
@@ -94,6 +94,6 @@ private:
};
} // namespace Internal
} // namespace Find
} // namespace Core
#endif // SEARCHRESULTTREEMODEL_H
@@ -35,7 +35,7 @@
#include <QHeaderView>
#include <QKeyEvent>
namespace Find {
namespace Core {
namespace Internal {
SearchResultTreeView::SearchResultTreeView(QWidget *parent)
@@ -106,4 +106,4 @@ SearchResultTreeModel *SearchResultTreeView::model() const
}
} // namespace Internal
} // namespace Find
} // namespace Core
@@ -34,7 +34,7 @@
#include <QTreeView>
namespace Find {
namespace Core {
namespace Internal {
class SearchResultTreeModel;
@@ -68,6 +68,6 @@ protected:
};
} // namespace Internal
} // namespace Find
} // namespace Core
#endif // SEARCHRESULTTREEVIEW_H
@@ -37,6 +37,7 @@
#include "treeviewfind.h"
#include <aggregation/aggregate.h>
#include <coreplugin/coreplugin.h>
#include <QDir>
#include <QFrame>
@@ -50,7 +51,7 @@
static const int SEARCHRESULT_WARNING_LIMIT = 200000;
static const char SIZE_WARNING_ID[] = "sizeWarningLabel";
namespace Find {
namespace Core {
namespace Internal {
class WideEnoughLineEdit : public QLineEdit {
@@ -71,11 +72,11 @@ public slots:
void updateGeometry() { QLineEdit::updateGeometry(); }
};
} // Internal
} // Find
} // namespace Internal
} // namespace Core
using namespace Find;
using namespace Find::Internal;
using namespace Core;
using namespace Core::Internal;
SearchResultWidget::SearchResultWidget(QWidget *parent) :
QWidget(parent),
@@ -44,7 +44,7 @@ class QToolButton;
class QCheckBox;
QT_END_NAMESPACE
namespace Find {
namespace Core {
namespace Internal {
class SearchResultTreeView;
@@ -97,8 +97,8 @@ public slots:
void sendRequestPopup();
signals:
void activated(const Find::SearchResultItem &item);
void replaceButtonClicked(const QString &replaceText, const QList<Find::SearchResultItem> &checkedItems, bool preserveCase);
void activated(const Core::SearchResultItem &item);
void replaceButtonClicked(const QString &replaceText, const QList<Core::SearchResultItem> &checkedItems, bool preserveCase);
void searchAgainRequested();
void cancelled();
void paused(bool paused);
@@ -50,7 +50,7 @@ static const char SETTINGSKEYSECTIONNAME[] = "SearchResults";
static const char SETTINGSKEYEXPANDRESULTS[] = "ExpandResults";
static const int MAX_SEARCH_HISTORY = 12;
namespace Find {
namespace Core {
namespace Internal {
@@ -83,6 +83,7 @@ namespace Internal {
int visibleSearchIndex() const;
void setCurrentIndex(int index, bool focus);
FindPlugin *m_plugin;
SearchResultWindow *q;
QList<Internal::SearchResultWidget *> m_searchResultWidgets;
QToolButton *m_expandCollapseButton;
@@ -187,10 +188,10 @@ namespace Internal {
}
}
using namespace Find::Internal;
using namespace Core::Internal;
/*!
\enum Find::SearchResultWindow::SearchMode
\enum Core::SearchResultWindow::SearchMode
This enum type specifies whether a search should show the replace UI or not:
\value SearchOnly
@@ -200,7 +201,7 @@ using namespace Find::Internal;
*/
/*!
\class Find::SearchResult
\class Core::SearchResult
\brief The SearchResult class reports user interaction, such as the
activation of a search result item.
@@ -210,13 +211,13 @@ using namespace Find::Internal;
*/
/*!
\fn void SearchResult::activated(const Find::SearchResultItem &item)
\fn void SearchResult::activated(const Core::SearchResultItem &item)
Indicates that the user activated the search result \a item by
double-clicking it, for example.
*/
/*!
\fn void SearchResult::replaceButtonClicked(const QString &replaceText, const QList<Find::SearchResultItem> &checkedItems, bool preserveCase)
\fn void SearchResult::replaceButtonClicked(const QString &replaceText, const QList<Core::SearchResultItem> &checkedItems, bool preserveCase)
Indicates that the user initiated a text replace by selecting
\gui {Replace All}, for example.
@@ -228,7 +229,7 @@ using namespace Find::Internal;
*/
/*!
\class Find::SearchResultWindow
\class Core::SearchResultWindow
\brief The SearchResultWindow class is the implementation of a commonly
shared \gui{Search Results} output pane. Use it to show search results
to a user.
@@ -272,6 +273,7 @@ SearchResultWindow::SearchResultWindow(QWidget *newSearchPanel)
: d(new SearchResultWindowPrivate(this))
{
m_instance = this;
d->m_spacer = new QWidget;
d->m_spacer->setMinimumWidth(30);
d->m_recentSearchesBox = new QComboBox;
@@ -309,7 +311,6 @@ SearchResultWindow::SearchResultWindow(QWidget *newSearchPanel)
*/
SearchResultWindow::~SearchResultWindow()
{
writeSettings();
qDeleteAll(d->m_searchResults);
delete d->m_widget;
d->m_widget = 0;
@@ -586,10 +587,10 @@ bool SearchResultWindow::canNavigate() const
SearchResult::SearchResult(SearchResultWidget *widget)
: m_widget(widget)
{
connect(widget, SIGNAL(activated(Find::SearchResultItem)),
this, SIGNAL(activated(Find::SearchResultItem)));
connect(widget, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)),
this, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)));
connect(widget, SIGNAL(activated(Core::SearchResultItem)),
this, SIGNAL(activated(Core::SearchResultItem)));
connect(widget, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)),
this, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)));
connect(widget, SIGNAL(cancelled()),
this, SIGNAL(cancelled()));
connect(widget, SIGNAL(paused(bool)),
@@ -709,6 +710,6 @@ void SearchResult::popup()
m_widget->sendRequestPopup();
}
} // namespace Find
} // namespace Core
#include "searchresultwindow.moc"
@@ -30,8 +30,6 @@
#ifndef SEARCHRESULTWINDOW_H
#define SEARCHRESULTWINDOW_H
#include "find_global.h"
#include <coreplugin/ioutputpane.h>
#include <QVariant>
@@ -42,15 +40,16 @@ QT_BEGIN_NAMESPACE
class QFont;
QT_END_NAMESPACE
namespace Find {
namespace Core {
namespace Internal {
class SearchResultTreeView;
class SearchResultWindowPrivate;
class SearchResultWidget;
}
class FindPlugin;
class SearchResultWindow;
class FIND_EXPORT SearchResultItem
class CORE_EXPORT SearchResultItem
{
public:
SearchResultItem()
@@ -83,7 +82,7 @@ public:
QVariant userData; // user data for identification of the item
};
class FIND_EXPORT SearchResult : public QObject
class CORE_EXPORT SearchResult : public QObject
{
Q_OBJECT
@@ -110,8 +109,8 @@ public slots:
void popup();
signals:
void activated(const Find::SearchResultItem &item);
void replaceButtonClicked(const QString &replaceText, const QList<Find::SearchResultItem> &checkedItems, bool preserveCase);
void activated(const Core::SearchResultItem &item);
void replaceButtonClicked(const QString &replaceText, const QList<Core::SearchResultItem> &checkedItems, bool preserveCase);
void cancelled();
void paused(bool paused);
void visibilityChanged(bool visible);
@@ -128,7 +127,7 @@ private:
QVariant m_userData;
};
class FIND_EXPORT SearchResultWindow : public Core::IOutputPane
class CORE_EXPORT SearchResultWindow : public Core::IOutputPane
{
Q_OBJECT
@@ -182,16 +181,18 @@ public slots:
private slots:
void handleExpandCollapseToolButton(bool checked);
public: // Used by plugin, do not use
void writeSettings();
private:
void readSettings();
void writeSettings();
Internal::SearchResultWindowPrivate *d;
static SearchResultWindow *m_instance;
};
} // namespace Find
} // namespace Core
Q_DECLARE_METATYPE(Find::SearchResultItem)
Q_DECLARE_METATYPE(Core::SearchResultItem)
#endif // SEARCHRESULTWINDOW_H
@@ -30,13 +30,13 @@
#ifndef TEXTFINDCONSTANTS_H
#define TEXTFINDCONSTANTS_H
#include "find_global.h"
#include <coreplugin/core_global.h>
#include <QMetaType>
#include <QFlags>
#include <QTextDocument>
namespace Find {
namespace Core {
namespace Constants {
const char M_FIND[] = "Find.FindMenu";
@@ -74,11 +74,11 @@ enum FindFlag {
Q_DECLARE_FLAGS(FindFlags, FindFlag)
// defined in findplugin.cpp
QTextDocument::FindFlags FIND_EXPORT textDocumentFlagsForFindFlags(FindFlags flags);
QTextDocument::FindFlags CORE_EXPORT textDocumentFlagsForFindFlags(FindFlags flags);
} // namespace Find
} // namespace Core
Q_DECLARE_OPERATORS_FOR_FLAGS(Find::FindFlags)
Q_DECLARE_METATYPE(Find::FindFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::FindFlags)
Q_DECLARE_METATYPE(Core::FindFlags)
#endif // TEXTFINDCONSTANTS_H
@@ -33,7 +33,7 @@
#include <QTextCursor>
#include <QModelIndex>
namespace Find {
namespace Core {
class ItemModelFindPrivate
{
@@ -274,4 +274,4 @@ QModelIndex TreeViewFind::followingIndex(const QModelIndex &idx, bool backward,
return nextIndex(idx, wrapped);
}
} // namespace Find
} // namespace Core
@@ -37,10 +37,10 @@ class QTreeView;
class QModelIndex;
QT_END_NAMESPACE
namespace Find {
namespace Core {
class ItemModelFindPrivate;
class FIND_EXPORT TreeViewFind : public IFindSupport
class CORE_EXPORT TreeViewFind : public IFindSupport
{
Q_OBJECT
public:
@@ -70,6 +70,6 @@ private:
ItemModelFindPrivate *d;
};
} // namespace Find
} // namespace Core
#endif // TREEVIEWFIND_H
@@ -36,7 +36,7 @@
#include <QStringMatcher>
using namespace Core;
using namespace Locator;
using namespace Core;
using namespace Utils;
BaseFileFilter::BaseFileFilter()
@@ -44,11 +44,11 @@ BaseFileFilter::BaseFileFilter()
{
}
QList<FilterEntry> BaseFileFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &origEntry)
QList<LocatorFilterEntry> BaseFileFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &origEntry)
{
updateFiles();
QList<FilterEntry> betterEntries;
QList<FilterEntry> goodEntries;
QList<LocatorFilterEntry> betterEntries;
QList<LocatorFilterEntry> goodEntries;
QString needle = trimWildcards(origEntry);
const QString lineNoSuffix = EditorManager::splitLineNumber(&needle);
QStringMatcher matcher(needle, Qt::CaseInsensitive);
@@ -89,7 +89,7 @@ QList<FilterEntry> BaseFileFilter::matchesFor(QFutureInterface<Locator::FilterEn
if ((hasWildcard && regexp.exactMatch(matchText))
|| (!hasWildcard && matcher.indexIn(matchText) != -1)) {
QFileInfo fi(path);
FilterEntry entry(this, fi.fileName(), QString(path + lineNoSuffix));
LocatorFilterEntry entry(this, fi.fileName(), QString(path + lineNoSuffix));
entry.extraInfo = FileUtils::shortNativePath(FileName(fi));
entry.fileName = path;
if (matchText.startsWith(needle, caseSensitivityForPrefix))
@@ -105,7 +105,7 @@ QList<FilterEntry> BaseFileFilter::matchesFor(QFutureInterface<Locator::FilterEn
return betterEntries;
}
void BaseFileFilter::accept(Locator::FilterEntry selection) const
void BaseFileFilter::accept(Core::LocatorFilterEntry selection) const
{
EditorManager::openEditor(selection.internalData.toString(), Id(),
EditorManager::CanContainLineNumber);
@@ -30,21 +30,20 @@
#ifndef BASEFILEFILTER_H
#define BASEFILEFILTER_H
#include "locator_global.h"
#include "ilocatorfilter.h"
#include <QStringList>
namespace Locator {
namespace Core {
class LOCATOR_EXPORT BaseFileFilter : public Locator::ILocatorFilter
class CORE_EXPORT BaseFileFilter : public Core::ILocatorFilter
{
Q_OBJECT
public:
BaseFileFilter();
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;
protected:
virtual void updateFiles();
@@ -62,6 +61,6 @@ private:
QString m_previousEntry;
};
} // namespace Locator
} // namespace Core
#endif // BASEFILEFILTER_H
@@ -35,7 +35,7 @@
#include <QAction>
namespace Locator {
namespace Core {
struct CommandLocatorPrivate
{
@@ -46,7 +46,7 @@ CommandLocator::CommandLocator(Core::Id id,
const QString &displayName,
const QString &shortCutString,
QObject *parent) :
Locator::ILocatorFilter(parent),
Core::ILocatorFilter(parent),
d(new CommandLocatorPrivate)
{
setId(id);
@@ -64,10 +64,10 @@ void CommandLocator::appendCommand(Core::Command *cmd)
d->commands.push_back(cmd);
}
QList<Locator::FilterEntry> CommandLocator::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry)
QList<Core::LocatorFilterEntry> CommandLocator::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry)
{
QList<FilterEntry> goodEntries;
QList<FilterEntry> betterEntries;
QList<LocatorFilterEntry> goodEntries;
QList<LocatorFilterEntry> betterEntries;
// Get active, enabled actions matching text, store in list.
// Reference via index in extraInfo.
const QChar ampersand = QLatin1Char('&');
@@ -82,9 +82,9 @@ QList<Locator::FilterEntry> CommandLocator::matchesFor(QFutureInterface<Locator:
QString text = action->text();
text.remove(ampersand);
if (text.startsWith(entry, caseSensitivity_))
betterEntries.append(FilterEntry(this, text, QVariant(i)));
betterEntries.append(LocatorFilterEntry(this, text, QVariant(i)));
else if (text.contains(entry, caseSensitivity_))
goodEntries.append(FilterEntry(this, text, QVariant(i)));
goodEntries.append(LocatorFilterEntry(this, text, QVariant(i)));
}
}
}
@@ -92,7 +92,7 @@ QList<Locator::FilterEntry> CommandLocator::matchesFor(QFutureInterface<Locator:
return betterEntries;
}
void CommandLocator::accept(Locator::FilterEntry entry) const
void CommandLocator::accept(Core::LocatorFilterEntry entry) const
{
// Retrieve action via index.
const int index = entry.internalData.toInt();
@@ -106,4 +106,4 @@ void CommandLocator::refresh(QFutureInterface<void> &)
{
}
} // namespace Locator
} // namespace Core
@@ -30,18 +30,16 @@
#ifndef COMMANDLOCATOR_H
#define COMMANDLOCATOR_H
#include "locator_global.h"
#include "ilocatorfilter.h"
namespace Core { class Command; }
namespace Core {
namespace Locator {
/* Command locators: Provides completion for a set of
* Core::Command's by sub-string of their action's text. */
class Command;
struct CommandLocatorPrivate;
class LOCATOR_EXPORT CommandLocator : public Locator::ILocatorFilter
class CORE_EXPORT CommandLocator : public Core::ILocatorFilter
{
Q_OBJECT
@@ -52,14 +50,14 @@ public:
void appendCommand(Core::Command *cmd);
QList<FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
void accept(FilterEntry selection) const;
QList<LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
void accept(LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &future);
private:
CommandLocatorPrivate *d;
};
} // namespace Locator
} // namespace Core
#endif // COMMANDLOCATOR_H
@@ -32,8 +32,8 @@
#include <QFileDialog>
#include <utils/filesearch.h>
using namespace Locator;
using namespace Locator::Internal;
using namespace Core;
using namespace Core::Internal;
DirectoryFilter::DirectoryFilter()
: m_name(tr("Generic Directory Filter")),
@@ -38,7 +38,7 @@
#include <QFutureInterface>
#include <QMutex>
namespace Locator {
namespace Core {
namespace Internal {
class DirectoryFilter : public BaseFileFilter
@@ -70,6 +70,6 @@ private:
};
} // namespace Internal
} // namespace Locator
} // namespace Core
#endif // DIRECTORYFILTER_H
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Locator::Internal::DirectoryFilterOptions</class>
<widget class="QDialog" name="Locator::Internal::DirectoryFilterOptions">
<class>Core::Internal::DirectoryFilterOptions</class>
<widget class="QDialog" name="Core::Internal::DirectoryFilterOptions">
<property name="geometry">
<rect>
<x>0</x>
@@ -162,7 +162,7 @@ To do this, you type this shortcut and a space in the Locator entry field, and t
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Locator::Internal::DirectoryFilterOptions</receiver>
<receiver>Core::Internal::DirectoryFilterOptions</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
@@ -178,7 +178,7 @@ To do this, you type this shortcut and a space in the Locator entry field, and t
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Locator::Internal::DirectoryFilterOptions</receiver>
<receiver>Core::Internal::DirectoryFilterOptions</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
@@ -36,8 +36,8 @@
#include <QMessageBox>
using namespace Core;
using namespace Locator;
using namespace Locator::Internal;
using namespace Core;
using namespace Core::Internal;
ExecuteFilter::ExecuteFilter()
{
@@ -57,13 +57,13 @@ ExecuteFilter::ExecuteFilter()
connect(&m_runTimer, SIGNAL(timeout()), this, SLOT(runHeadCommand()));
}
QList<FilterEntry> ExecuteFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future,
QList<LocatorFilterEntry> ExecuteFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
const QString &entry)
{
QList<FilterEntry> value;
QList<LocatorFilterEntry> value;
if (!entry.isEmpty()) // avoid empty entry
value.append(FilterEntry(this, entry, QVariant()));
QList<FilterEntry> others;
value.append(LocatorFilterEntry(this, entry, QVariant()));
QList<LocatorFilterEntry> others;
const Qt::CaseSensitivity caseSensitivityForPrefix = caseSensitivity(entry);
foreach (const QString &i, m_commandHistory) {
if (future.isCanceled())
@@ -71,15 +71,15 @@ QList<FilterEntry> ExecuteFilter::matchesFor(QFutureInterface<Locator::FilterEnt
if (i == entry) // avoid repeated entry
continue;
if (i.startsWith(entry, caseSensitivityForPrefix))
value.append(FilterEntry(this, i, QVariant()));
value.append(LocatorFilterEntry(this, i, QVariant()));
else
others.append(FilterEntry(this, i, QVariant()));
others.append(LocatorFilterEntry(this, i, QVariant()));
}
value.append(others);
return value;
}
void ExecuteFilter::accept(FilterEntry selection) const
void ExecuteFilter::accept(LocatorFilterEntry selection) const
{
ExecuteFilter *p = const_cast<ExecuteFilter *>(this);
@@ -39,10 +39,10 @@
#include <QTimer>
#include <QTextCodec>
namespace Locator {
namespace Core {
namespace Internal {
class ExecuteFilter : public Locator::ILocatorFilter
class ExecuteFilter : public Core::ILocatorFilter
{
Q_OBJECT
struct ExecuteData
@@ -54,9 +54,9 @@ class ExecuteFilter : public Locator::ILocatorFilter
public:
ExecuteFilter();
QList<Locator::FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future,
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
const QString &entry);
void accept(Locator::FilterEntry selection) const;
void accept(Core::LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &) {}
private slots:
@@ -78,6 +78,6 @@ private:
};
} // namespace Internal
} // namespace Locator
} // namespace Core
#endif // EXECUTEFILTER_H
@@ -35,14 +35,14 @@
#include <QDir>
using namespace Core;
using namespace Locator;
using namespace Locator::Internal;
using namespace Core;
using namespace Core::Internal;
namespace {
QList<FilterEntry> *categorize(const QString &entry, const QString &candidate,
QList<LocatorFilterEntry> *categorize(const QString &entry, const QString &candidate,
Qt::CaseSensitivity caseSensitivity,
QList<FilterEntry> *betterEntries, QList<FilterEntry> *goodEntries)
QList<LocatorFilterEntry> *betterEntries, QList<LocatorFilterEntry> *goodEntries)
{
if (entry.isEmpty() || candidate.startsWith(entry, caseSensitivity))
return betterEntries;
@@ -62,10 +62,10 @@ FileSystemFilter::FileSystemFilter(LocatorWidget *locatorWidget)
setIncludedByDefault(false);
}
QList<FilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry)
QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry)
{
QList<FilterEntry> goodEntries;
QList<FilterEntry> betterEntries;
QList<LocatorFilterEntry> goodEntries;
QList<LocatorFilterEntry> betterEntries;
QFileInfo entryInfo(entry);
QString name = entryInfo.fileName();
QString directory = entryInfo.path();
@@ -96,10 +96,10 @@ QList<FilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Locator::Filter
foreach (const QString &dir, dirs) {
if (future.isCanceled())
break;
if (QList<FilterEntry> *category = categorize(name, dir, caseSensitivity_, &betterEntries,
if (QList<LocatorFilterEntry> *category = categorize(name, dir, caseSensitivity_, &betterEntries,
&goodEntries)) {
const QString fullPath = dirInfo.filePath(dir);
FilterEntry filterEntry(this, dir, QVariant());
LocatorFilterEntry filterEntry(this, dir, QVariant());
filterEntry.fileName = fullPath;
category->append(filterEntry);
}
@@ -111,10 +111,10 @@ QList<FilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Locator::Filter
foreach (const QString &file, files) {
if (future.isCanceled())
break;
if (QList<FilterEntry> *category = categorize(name, file, caseSensitivity_, &betterEntries,
if (QList<LocatorFilterEntry> *category = categorize(name, file, caseSensitivity_, &betterEntries,
&goodEntries)) {
const QString fullPath = dirInfo.filePath(file);
FilterEntry filterEntry(this, file, QString(fullPath + lineNoSuffix));
LocatorFilterEntry filterEntry(this, file, QString(fullPath + lineNoSuffix));
filterEntry.fileName = fullPath;
category->append(filterEntry);
}
@@ -123,7 +123,7 @@ QList<FilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Locator::Filter
return betterEntries;
}
void FileSystemFilter::accept(FilterEntry selection) const
void FileSystemFilter::accept(LocatorFilterEntry selection) const
{
QString fileName = selection.fileName;
QFileInfo info(fileName);
@@ -38,19 +38,19 @@
#include <QByteArray>
#include <QFutureInterface>
namespace Locator {
namespace Core {
namespace Internal {
class LocatorWidget;
class FileSystemFilter : public Locator::ILocatorFilter
class FileSystemFilter : public Core::ILocatorFilter
{
Q_OBJECT
public:
explicit FileSystemFilter(LocatorWidget *locatorWidget);
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;
QByteArray saveState() const;
bool restoreState(const QByteArray &state);
bool openConfigDialog(QWidget *parent, bool &needsRefresh);
@@ -62,6 +62,6 @@ private:
};
} // namespace Internal
} // namespace Locator
} // namespace Core
#endif // FILESYSTEMFILTER_H
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Locator::Internal::FileSystemFilterOptions</class>
<widget class="QDialog" name="Locator::Internal::FileSystemFilterOptions">
<class>Core::Internal::FileSystemFilterOptions</class>
<widget class="QDialog" name="Core::Internal::FileSystemFilterOptions">
<property name="geometry">
<rect>
<x>0</x>
@@ -78,7 +78,7 @@
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Locator::Internal::FileSystemFilterOptions</receiver>
<receiver>Core::Internal::FileSystemFilterOptions</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
@@ -94,7 +94,7 @@
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Locator::Internal::FileSystemFilterOptions</receiver>
<receiver>Core::Internal::FileSystemFilterOptions</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
@@ -36,7 +36,7 @@
#include <QLabel>
#include <QLineEdit>
using namespace Locator;
using namespace Core;
ILocatorFilter::ILocatorFilter(QObject *parent):
QObject(parent),
@@ -30,26 +30,24 @@
#ifndef ILOCATORFILTER_H
#define ILOCATORFILTER_H
#include "locator_global.h"
#include <coreplugin/id.h>
#include <QVariant>
#include <QFutureInterface>
#include <QIcon>
namespace Locator {
namespace Core {
class ILocatorFilter;
struct FilterEntry
struct LocatorFilterEntry
{
FilterEntry()
LocatorFilterEntry()
: filter(0)
, fileIconResolved(false)
{}
FilterEntry(ILocatorFilter *fromFilter, const QString &name, const QVariant &data,
LocatorFilterEntry(ILocatorFilter *fromFilter, const QString &name, const QVariant &data,
const QIcon &icon = QIcon())
: filter(fromFilter)
, displayName(name)
@@ -58,7 +56,7 @@ struct FilterEntry
, fileIconResolved(false)
{}
bool operator==(const FilterEntry &other) const {
bool operator==(const LocatorFilterEntry &other) const {
if (internalData.canConvert(QVariant::String))
return (internalData.toString() == other.internalData.toString());
return internalData.constData() == other.internalData.constData();
@@ -80,7 +78,7 @@ struct FilterEntry
bool fileIconResolved;
};
class LOCATOR_EXPORT ILocatorFilter : public QObject
class CORE_EXPORT ILocatorFilter : public QObject
{
Q_OBJECT
@@ -103,10 +101,10 @@ public:
QString shortcutString() const;
/* List of matches for the given user entry. */
virtual QList<FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry) = 0;
virtual QList<LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry) = 0;
/* User has selected the given entry that belongs to this filter. */
virtual void accept(FilterEntry selection) const = 0;
virtual void accept(LocatorFilterEntry selection) const = 0;
/* Implement to update caches on user request, if that's a long operation. */
virtual void refresh(QFutureInterface<void> &future) = 0;
@@ -164,6 +162,6 @@ private:
bool m_isConfigurable;
};
} // namespace Locator
} // namespace Core
#endif // ILOCATORFILTER_H

Before

Width:  |  Height:  |  Size: 767 B

After

Width:  |  Height:  |  Size: 767 B

Before

Width:  |  Height:  |  Size: 735 B

After

Width:  |  Height:  |  Size: 735 B

@@ -0,0 +1,46 @@
HEADERS += \
$$PWD/locatorplugin.h \
$$PWD/commandlocator.h \
$$PWD/locatorwidget.h \
$$PWD/locatorfiltersfilter.h \
$$PWD/settingspage.h \
$$PWD/ilocatorfilter.h \
$$PWD/opendocumentsfilter.h \
$$PWD/filesystemfilter.h \
$$PWD/locatorconstants.h \
$$PWD/directoryfilter.h \
$$PWD/locatormanager.h \
$$PWD/basefilefilter.h \
$$PWD/executefilter.h \
$$PWD/locatorsearchutils.h
SOURCES += \
$$PWD/locatorplugin.cpp \
$$PWD/commandlocator.cpp \
$$PWD/locatorwidget.cpp \
$$PWD/locatorfiltersfilter.cpp \
$$PWD/opendocumentsfilter.cpp \
$$PWD/filesystemfilter.cpp \
$$PWD/settingspage.cpp \
$$PWD/directoryfilter.cpp \
$$PWD/locatormanager.cpp \
$$PWD/basefilefilter.cpp \
$$PWD/ilocatorfilter.cpp \
$$PWD/executefilter.cpp \
$$PWD/locatorsearchutils.cpp
FORMS += \
$$PWD/settingspage.ui \
$$PWD/filesystemfilter.ui \
$$PWD/directoryfilter.ui
RESOURCES += \
$$PWD/locator.qrc
equals(TEST, 1) {
HEADERS += $$PWD/locatorfiltertest.h
SOURCES += \
$$PWD/locatorfiltertest.cpp \
$$PWD/locator_test.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
}
@@ -40,13 +40,13 @@
#include <QTextStream>
#include <QtTest>
using namespace Locator::Tests;
using namespace Core::Tests;
namespace {
QTC_DECLARE_MYTESTDATADIR("../../../tests/locators/")
class MyBaseFileFilter : public Locator::BaseFileFilter
class MyBaseFileFilter : public Core::BaseFileFilter
{
public:
MyBaseFileFilter(const QStringList &theFiles)
@@ -80,7 +80,7 @@ public:
Q_DECLARE_METATYPE(ReferenceData)
Q_DECLARE_METATYPE(QList<ReferenceData>)
void Locator::Internal::LocatorPlugin::test_basefilefilter()
void Core::Internal::LocatorPlugin::test_basefilefilter()
{
QFETCH(QStringList, testFiles);
QFETCH(QList<ReferenceData>, referenceDataList);
@@ -89,7 +89,7 @@ void Locator::Internal::LocatorPlugin::test_basefilefilter()
BasicLocatorFilterTest test(&filter);
foreach (const ReferenceData &reference, referenceDataList) {
const QList<FilterEntry> filterEntries = test.matchesFor(reference.searchText);
const QList<LocatorFilterEntry> filterEntries = test.matchesFor(reference.searchText);
const ResultDataList results = ResultData::fromFilterEntryList(filterEntries);
// QTextStream(stdout) << "----" << endl;
// ResultData::printFilterEntries(results);
@@ -97,7 +97,7 @@ void Locator::Internal::LocatorPlugin::test_basefilefilter()
}
}
void Locator::Internal::LocatorPlugin::test_basefilefilter_data()
void Core::Internal::LocatorPlugin::test_basefilefilter_data()
{
QTest::addColumn<QStringList>("testFiles");
QTest::addColumn<QList<ReferenceData> >("referenceDataList");
@@ -32,13 +32,13 @@
#include <QtGlobal>
namespace Locator {
namespace Core {
namespace Constants {
const char FILTER_OPTIONS_PAGE[] = QT_TRANSLATE_NOOP("Locator", "Locator");
const char TASK_INDEX[] = "Locator.Task.Index";
} // namespace Constants
} // namespace Locator
} // namespace Core
#endif // LOCATORCONSTANTS_H
@@ -33,8 +33,8 @@
#include <coreplugin/coreconstants.h>
using namespace Locator;
using namespace Locator::Internal;
using namespace Core;
using namespace Core::Internal;
Q_DECLARE_METATYPE(ILocatorFilter*)
@@ -52,9 +52,9 @@ LocatorFiltersFilter::LocatorFiltersFilter(LocatorPlugin *plugin,
setConfigurable(false);
}
QList<FilterEntry> LocatorFiltersFilter::matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry)
QList<LocatorFilterEntry> LocatorFiltersFilter::matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry)
{
QList<FilterEntry> entries;
QList<LocatorFilterEntry> entries;
if (!entry.isEmpty())
return entries;
@@ -68,7 +68,7 @@ QList<FilterEntry> LocatorFiltersFilter::matchesFor(QFutureInterface<Locator::Fi
if (future.isCanceled())
break;
if (!filter->shortcutString().isEmpty() && !filter->isHidden() && filter->isEnabled()) {
FilterEntry filterEntry(this,
LocatorFilterEntry filterEntry(this,
filter->shortcutString(),
QVariant::fromValue(filter),
m_icon);
@@ -80,7 +80,7 @@ QList<FilterEntry> LocatorFiltersFilter::matchesFor(QFutureInterface<Locator::Fi
return entries;
}
void LocatorFiltersFilter::accept(FilterEntry selection) const
void LocatorFiltersFilter::accept(LocatorFilterEntry selection) const
{
ILocatorFilter *filter = selection.internalData.value<ILocatorFilter *>();
if (filter)
@@ -34,7 +34,7 @@
#include <QIcon>
namespace Locator {
namespace Core {
namespace Internal {
class LocatorPlugin;
@@ -53,8 +53,8 @@ public:
LocatorWidget *locatorWidget);
// ILocatorFilter
QList<FilterEntry> matchesFor(QFutureInterface<Locator::FilterEntry> &future, const QString &entry);
void accept(FilterEntry selection) const;
QList<LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry);
void accept(LocatorFilterEntry selection) const;
void refresh(QFutureInterface<void> &future);
private:
@@ -64,6 +64,6 @@ private:
};
} // namespace Internal
} // namespace Locator
} // namespace Core
#endif // LOCATORFILTERSFILTER_H
@@ -38,18 +38,18 @@
#include <QString>
#include <QTextStream>
using namespace Locator;
using namespace Locator::Tests;
using namespace Core;
using namespace Core::Tests;
BasicLocatorFilterTest::BasicLocatorFilterTest(ILocatorFilter *filter) : m_filter(filter)
{
}
QList<FilterEntry> BasicLocatorFilterTest::matchesFor(const QString &searchText)
QList<LocatorFilterEntry> BasicLocatorFilterTest::matchesFor(const QString &searchText)
{
doBeforeLocatorRun();
const QList<ILocatorFilter *> filters = QList<ILocatorFilter *>() << m_filter;
QFuture<FilterEntry> locatorSearch = QtConcurrent::run(Locator::Internal::runSearch,
QFuture<LocatorFilterEntry> locatorSearch = QtConcurrent::run(Core::Internal::runSearch,
filters, searchText);
locatorSearch.waitForFinished();
doAfterLocatorRun();
@@ -70,10 +70,10 @@ bool ResultData::operator==(const ResultData &other) const
return textColumn1 == other.textColumn1 && textColumn2 == other.textColumn2;
}
ResultData::ResultDataList ResultData::fromFilterEntryList(const QList<FilterEntry> &entries)
ResultData::ResultDataList ResultData::fromFilterEntryList(const QList<LocatorFilterEntry> &entries)
{
ResultDataList result;
foreach (const FilterEntry &entry, entries)
foreach (const LocatorFilterEntry &entry, entries)
result << ResultData(entry.displayName, entry.extraInfo);
return result;
}
@@ -31,30 +31,29 @@
#ifndef LOCATORFILTERTEST_H
#define LOCATORFILTERTEST_H
#include "locator_global.h"
#include "ilocatorfilter.h"
#include <QTest>
namespace Locator {
namespace Core {
namespace Tests {
/// Runs a locator filter for a search text and returns the results.
class LOCATOR_EXPORT BasicLocatorFilterTest
class CORE_EXPORT BasicLocatorFilterTest
{
public:
BasicLocatorFilterTest(Locator::ILocatorFilter *filter);
BasicLocatorFilterTest(Core::ILocatorFilter *filter);
QList<Locator::FilterEntry> matchesFor(const QString &searchText = QString());
QList<Core::LocatorFilterEntry> matchesFor(const QString &searchText = QString());
private:
virtual void doBeforeLocatorRun() {}
virtual void doAfterLocatorRun() {}
Locator::ILocatorFilter *m_filter;
Core::ILocatorFilter *m_filter;
};
class LOCATOR_EXPORT ResultData
class CORE_EXPORT ResultData
{
public:
typedef QList<ResultData> ResultDataList;
@@ -64,7 +63,7 @@ public:
bool operator==(const ResultData &other) const;
static ResultDataList fromFilterEntryList(const QList<FilterEntry> &entries);
static ResultDataList fromFilterEntryList(const QList<LocatorFilterEntry> &entries);
/// For debugging and creating reference data
static void printFilterEntries(const ResultDataList &entries);
@@ -76,15 +75,15 @@ public:
typedef ResultData::ResultDataList ResultDataList;
} // namespace Tests
} // namespace Locator
} // namespace Core
Q_DECLARE_METATYPE(Locator::Tests::ResultData)
Q_DECLARE_METATYPE(Locator::Tests::ResultDataList)
Q_DECLARE_METATYPE(Core::Tests::ResultData)
Q_DECLARE_METATYPE(Core::Tests::ResultDataList)
QT_BEGIN_NAMESPACE
namespace QTest {
template<> inline char *toString(const Locator::Tests::ResultData &data)
template<> inline char *toString(const Core::Tests::ResultData &data)
{
QByteArray ba = "\"" + data.textColumn1.toUtf8() + "\", \"" + data.textColumn2.toUtf8() + "\"";
return qstrdup(ba.data());
@@ -33,7 +33,7 @@
#include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h>
namespace Locator {
namespace Core {
static Internal::LocatorWidget *m_locatorWidget = 0;
@@ -30,15 +30,15 @@
#ifndef LOCATORMANAGER_H
#define LOCATORMANAGER_H
#include "locator_global.h"
#include <coreplugin/core_global.h>
#include <QObject>
namespace Locator {
namespace Core {
namespace Internal { class LocatorWidget; }
class LOCATOR_EXPORT LocatorManager : public QObject
class CORE_EXPORT LocatorManager : public QObject
{
Q_OBJECT
@@ -49,6 +49,6 @@ public:
static void show(const QString &text, int selectionStart = -1, int selectionLength = 0);
};
} // namespace Locator
} // namespace Core
#endif // LOCATORMANAGER_H
@@ -0,0 +1,261 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "locatorplugin.h"
#include "locatorconstants.h"
#include "locatorfiltersfilter.h"
#include "locatormanager.h"
#include "locatorwidget.h"
#include "opendocumentsfilter.h"
#include "filesystemfilter.h"
#include "settingspage.h"
#include <coreplugin/coreplugin.h>
#include <coreplugin/statusbarwidget.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/settingsdatabase.h>
#include <coreplugin/icore.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/progressmanager/futureprogress.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/QtConcurrentTools>
#include <utils/qtcassert.h>
#include <QSettings>
#include <QtPlugin>
#include <QFuture>
#include <QAction>
namespace Core {
namespace Internal {
namespace {
static bool filterLessThan(const ILocatorFilter *first, const ILocatorFilter *second)
{
if (first->priority() < second->priority())
return true;
if (first->priority() > second->priority())
return false;
return first->id().alphabeticallyBefore(second->id());
}
}
LocatorPlugin::LocatorPlugin()
: m_settingsInitialized(false)
{
m_corePlugin = 0;
m_refreshTimer.setSingleShot(false);
connect(&m_refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
}
LocatorPlugin::~LocatorPlugin()
{
m_corePlugin->removeObject(m_openDocumentsFilter);
m_corePlugin->removeObject(m_fileSystemFilter);
m_corePlugin->removeObject(m_executeFilter);
m_corePlugin->removeObject(m_settingsPage);
delete m_openDocumentsFilter;
delete m_fileSystemFilter;
delete m_executeFilter;
delete m_settingsPage;
qDeleteAll(m_customFilters);
}
void LocatorPlugin::initialize(CorePlugin *corePlugin, const QStringList &, QString *)
{
m_corePlugin = corePlugin;
m_settingsPage = new SettingsPage(this);
m_corePlugin->addObject(m_settingsPage);
m_locatorWidget = new LocatorWidget(this);
m_locatorWidget->setEnabled(false);
StatusBarWidget *view = new StatusBarWidget;
view->setWidget(m_locatorWidget);
view->setContext(Context("LocatorWidget"));
view->setPosition(StatusBarWidget::First);
m_corePlugin->addAutoReleasedObject(view);
QAction *action = new QAction(m_locatorWidget->windowIcon(), m_locatorWidget->windowTitle(), this);
Command *cmd = ActionManager::registerAction(action, "QtCreator.Locate",
Context(Core::Constants::C_GLOBAL));
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+K")));
connect(action, SIGNAL(triggered()), this, SLOT(openLocator()));
connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updatePlaceholderText()));
updatePlaceholderText(cmd);
ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
mtools->addAction(cmd);
m_corePlugin->addObject(new LocatorManager(m_locatorWidget));
m_openDocumentsFilter = new OpenDocumentsFilter;
m_corePlugin->addObject(m_openDocumentsFilter);
m_fileSystemFilter = new FileSystemFilter(m_locatorWidget);
m_corePlugin->addObject(m_fileSystemFilter);
m_executeFilter = new ExecuteFilter();
m_corePlugin->addObject(m_executeFilter);
m_corePlugin->addAutoReleasedObject(new LocatorFiltersFilter(this, m_locatorWidget));
}
void LocatorPlugin::updatePlaceholderText(Command *command)
{
if (!command)
command = qobject_cast<Command *>(sender());
QTC_ASSERT(command, return);
if (command->keySequence().isEmpty())
m_locatorWidget->setPlaceholderText(tr("Type to locate"));
else
m_locatorWidget->setPlaceholderText(tr("Type to locate (%1)").arg(
command->keySequence().toString(QKeySequence::NativeText)));
}
void LocatorPlugin::openLocator()
{
m_locatorWidget->show(QString());
}
void LocatorPlugin::extensionsInitialized()
{
m_filters = ExtensionSystem::PluginManager::getObjects<ILocatorFilter>();
qSort(m_filters.begin(), m_filters.end(), filterLessThan);
setFilters(m_filters);
}
bool LocatorPlugin::delayedInitialize()
{
loadSettings();
return true;
}
void LocatorPlugin::loadSettings()
{
QSettings *qs = ICore::settings();
// Backwards compatibility to old settings location
if (qs->contains(QLatin1String("QuickOpen/FiltersFilter"))) {
loadSettingsHelper(qs);
} else {
SettingsDatabase *settings = ICore::settingsDatabase();
loadSettingsHelper(settings);
}
qs->remove(QLatin1String("QuickOpen"));
m_locatorWidget->updateFilterList();
m_locatorWidget->setEnabled(true);
if (m_refreshTimer.interval() > 0)
m_refreshTimer.start();
m_settingsInitialized = true;
}
void LocatorPlugin::saveSettings()
{
if (m_settingsInitialized) {
SettingsDatabase *s = ICore::settingsDatabase();
s->beginGroup(QLatin1String("QuickOpen"));
s->remove(QString());
s->setValue(QLatin1String("RefreshInterval"), refreshInterval());
foreach (ILocatorFilter *filter, m_filters) {
if (!m_customFilters.contains(filter))
s->setValue(filter->id().toString(), filter->saveState());
}
s->beginGroup(QLatin1String("CustomFilters"));
int i = 0;
foreach (ILocatorFilter *filter, m_customFilters) {
s->setValue(QLatin1String("directory") + QString::number(i),
filter->saveState());
++i;
}
s->endGroup();
s->endGroup();
}
}
/*!
Return all filters, including the ones created by the user.
*/
QList<ILocatorFilter *> LocatorPlugin::filters()
{
return m_filters;
}
/*!
This returns a subset of all the filters, that contains only the filters that
have been created by the user at some point (maybe in a previous session).
*/
QList<ILocatorFilter *> LocatorPlugin::customFilters()
{
return m_customFilters;
}
void LocatorPlugin::setFilters(QList<ILocatorFilter *> f)
{
m_filters = f;
m_locatorWidget->updateFilterList();
}
void LocatorPlugin::setCustomFilters(QList<ILocatorFilter *> filters)
{
m_customFilters = filters;
}
int LocatorPlugin::refreshInterval()
{
return m_refreshTimer.interval() / 60000;
}
void LocatorPlugin::setRefreshInterval(int interval)
{
if (interval < 1) {
m_refreshTimer.stop();
m_refreshTimer.setInterval(0);
return;
}
m_refreshTimer.setInterval(interval * 60000);
m_refreshTimer.start();
}
void LocatorPlugin::refresh(QList<ILocatorFilter *> filters)
{
if (filters.isEmpty())
filters = m_filters;
QFuture<void> task = QtConcurrent::run(&ILocatorFilter::refresh, filters);
FutureProgress *progress =
ProgressManager::addTask(task, tr("Indexing"), Core::Constants::TASK_INDEX);
connect(progress, SIGNAL(finished()), this, SLOT(saveSettings()));
}
} // namespace Internal
} // namespace Core
@@ -40,29 +40,24 @@
#include <QTimer>
#include <QFutureWatcher>
#if QT_VERSION >= 0x050000
# include <QtPlugin>
#endif
namespace Locator {
namespace Core {
namespace Internal {
class CorePlugin;
class LocatorWidget;
class OpenDocumentsFilter;
class FileSystemFilter;
class SettingsPage;
class LocatorPlugin;
class LocatorPlugin : public ExtensionSystem::IPlugin
class LocatorPlugin : public QObject
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Locator.json")
public:
LocatorPlugin();
~LocatorPlugin();
bool initialize(const QStringList &arguments, QString *errorMessage);
void initialize(CorePlugin *corePlugin, const QStringList &arguments, QString *errorMessage);
void extensionsInitialized();
bool delayedInitialize();
@@ -103,6 +98,7 @@ private:
OpenDocumentsFilter *m_openDocumentsFilter;
FileSystemFilter *m_fileSystemFilter;
ExecuteFilter *m_executeFilter;
CorePlugin *m_corePlugin;
};
template <typename S>
@@ -133,6 +129,6 @@ void LocatorPlugin::loadSettingsHelper(S *settings)
}
} // namespace Internal
} // namespace Locator
} // namespace Core
#endif // LOCATORPLUGIN_H
@@ -34,27 +34,27 @@
#include <QString>
#include <QVariant>
namespace Locator {
namespace Core {
uint qHash(const Locator::FilterEntry &entry)
uint qHash(const Core::LocatorFilterEntry &entry)
{
if (entry.internalData.canConvert(QVariant::String))
return QT_PREPEND_NAMESPACE(qHash)(entry.internalData.toString());
return QT_PREPEND_NAMESPACE(qHash)(entry.internalData.constData());
}
} // namespace Locator
} // namespace Core
void Locator::Internal::runSearch(QFutureInterface<Locator::FilterEntry> &entries,
void Core::Internal::runSearch(QFutureInterface<Core::LocatorFilterEntry> &entries,
QList<ILocatorFilter *> filters, QString searchText)
{
QSet<FilterEntry> alreadyAdded;
QSet<LocatorFilterEntry> alreadyAdded;
const bool checkDuplicates = (filters.size() > 1);
foreach (ILocatorFilter *filter, filters) {
if (entries.isCanceled())
break;
foreach (const FilterEntry &entry, filter->matchesFor(entries, searchText)) {
foreach (const LocatorFilterEntry &entry, filter->matchesFor(entries, searchText)) {
if (checkDuplicates && alreadyAdded.contains(entry))
continue;
entries.reportResult(entry);
@@ -30,18 +30,17 @@
#ifndef LOCATORSEARCHUTILS_H
#define LOCATORSEARCHUTILS_H
#include "locator_global.h"
#include "ilocatorfilter.h"
namespace Locator {
namespace Core {
namespace Internal {
void LOCATOR_EXPORT runSearch(QFutureInterface<Locator::FilterEntry> &entries,
void CORE_EXPORT runSearch(QFutureInterface<LocatorFilterEntry> &entries,
QList<ILocatorFilter *> filters,
QString searchText);
} // namespace Internal
} // namespace Locator
} // namespace Core
#endif // LOCATORSEARCHUTILS_H

Some files were not shown because too many files have changed in this diff Show More