From 474d883eac6576b9be74d3a06051e12bdb769d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Aum=C3=BCller?= <aumuell@reserv.at> Date: Thu, 21 Jan 2010 17:23:31 +0100 Subject: [PATCH] for fakevim mode, terminate incremental search after pressing enter/return Merge-request: 97 Reviewed-by: hjk <qtc-committer@nokia.com> --- src/plugins/fakevim/fakevim.pro | 1 + src/plugins/fakevim/fakevimplugin.cpp | 5 +++++ src/plugins/find/findplugin.cpp | 17 +++++++++++++++++ src/plugins/find/findplugin.h | 10 ++++++++-- src/plugins/find/findtoolbar.cpp | 13 +++++++++++-- src/plugins/find/findtoolbar.h | 3 +++ 6 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/plugins/fakevim/fakevim.pro b/src/plugins/fakevim/fakevim.pro index 1ebc95c2dc6..3d7195412a6 100644 --- a/src/plugins/fakevim/fakevim.pro +++ b/src/plugins/fakevim/fakevim.pro @@ -8,6 +8,7 @@ include(../../plugins/projectexplorer/projectexplorer.pri) include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/texteditor/texteditor.pri) include(../../plugins/cppeditor/cppeditor.pri) +include(../../plugins/find/find.pri) include(../../shared/indenter/indenter.pri) # DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 9b54765fb46..a3d7f549973 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -56,6 +56,7 @@ #include <texteditor/texteditorsettings.h> #include <texteditor/textblockiterator.h> +#include <find/findplugin.h> #include <find/textfindconstants.h> #include <utils/qtcassert.h> @@ -416,6 +417,8 @@ void FakeVimPluginPrivate::windowCommand(int key) void FakeVimPluginPrivate::find(bool reverse) { Q_UNUSED(reverse) // TODO: Creator needs an action for find in reverse. + if (Find::Internal::FindPlugin::instance()) + Find::Internal::FindPlugin::instance()->setUseFakeVim(true); triggerAction(Find::Constants::FIND_IN_DOCUMENT); } @@ -490,6 +493,8 @@ void FakeVimPluginPrivate::setUseFakeVim(const QVariant &value) { //qDebug() << "SET USE FAKEVIM" << value; bool on = value.toBool(); + if (Find::Internal::FindPlugin::instance()) + Find::Internal::FindPlugin::instance()->setUseFakeVim(on); if (on) { Core::EditorManager::instance()->showEditorStatusBar( QLatin1String(Constants::MINI_BUFFER), diff --git a/src/plugins/find/findplugin.cpp b/src/plugins/find/findplugin.cpp index 1419196875b..20f318fdaa8 100644 --- a/src/plugins/find/findplugin.cpp +++ b/src/plugins/find/findplugin.cpp @@ -31,6 +31,7 @@ #include "textfindconstants.h" #include "currentdocumentfind.h" +#include "findtoolbar.h" #include "findtoolwindow.h" #include "searchresultwindow.h" @@ -70,6 +71,8 @@ namespace { using namespace Find; using namespace Find::Internal; +FindPlugin *FindPlugin::m_instance = 0; + FindPlugin::FindPlugin() : m_currentDocumentFind(0), m_findToolBar(0), @@ -77,15 +80,23 @@ FindPlugin::FindPlugin() m_findCompletionModel(new QStringListModel(this)), m_replaceCompletionModel(new QStringListModel(this)) { + QTC_ASSERT(!m_instance, return); + m_instance = this; } FindPlugin::~FindPlugin() { + m_instance = 0; delete m_currentDocumentFind; delete m_findToolBar; delete m_findDialog; } +FindPlugin *FindPlugin::instance() +{ + return m_instance; +} + bool FindPlugin::initialize(const QStringList &, QString *) { setupMenu(); @@ -297,4 +308,10 @@ void FindPlugin::updateCompletion(const QString &text, QStringList &completions, model->setStringList(completions); } +void FindPlugin::setUseFakeVim(bool on) +{ + if (m_findToolBar) + m_findToolBar->setUseFakeVim(on); +} + Q_EXPORT_PLUGIN(FindPlugin) diff --git a/src/plugins/find/findplugin.h b/src/plugins/find/findplugin.h index 074e9cb745e..2183745bab0 100644 --- a/src/plugins/find/findplugin.h +++ b/src/plugins/find/findplugin.h @@ -31,7 +31,6 @@ #define FINDPLUGIN_H #include "ifindfilter.h" -#include "findtoolbar.h" #include <extensionsystem/iplugin.h> @@ -39,19 +38,23 @@ #include <QtCore/QStringList> #include <QtGui/QAction> #include <QtGui/QTextDocument> +#include <QtGui/QStringListModel> namespace Find { namespace Internal { +class FindToolBar; class FindToolWindow; +class CurrentDocumentFind; -class FindPlugin : public ExtensionSystem::IPlugin +class FIND_EXPORT FindPlugin : public ExtensionSystem::IPlugin { Q_OBJECT public: FindPlugin(); virtual ~FindPlugin(); + static FindPlugin *instance(); // IPlugin bool initialize(const QStringList &arguments, QString *error_message); @@ -63,6 +66,7 @@ public: void updateReplaceCompletion(const QString &text); QStringListModel *findCompletionModel() { return m_findCompletionModel; } QStringListModel *replaceCompletionModel() { return m_replaceCompletionModel; } + void setUseFakeVim(bool on); public slots: void setCaseSensitive(bool sensitive); @@ -86,6 +90,8 @@ private: void readSettings(); //variables + static FindPlugin *m_instance; + QHash<IFindFilter *, QAction *> m_filterActions; CurrentDocumentFind *m_currentDocumentFind; diff --git a/src/plugins/find/findtoolbar.cpp b/src/plugins/find/findtoolbar.cpp index 546c1531314..0ca3b43e684 100644 --- a/src/plugins/find/findtoolbar.cpp +++ b/src/plugins/find/findtoolbar.cpp @@ -70,7 +70,8 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen m_casesensitiveIcon(":/find/images/casesensitively.png"), m_regexpIcon(":/find/images/regexp.png"), m_wholewordsIcon(":/find/images/wholewords.png"), - m_findIncrementalTimer(this), m_findStepTimer(this) + m_findIncrementalTimer(this), m_findStepTimer(this), + m_useFakeVim(false) { //setup ui m_ui.setupUi(this); @@ -332,7 +333,10 @@ void FindToolBar::updateToolBar() void FindToolBar::invokeFindEnter() { if (m_currentDocumentFind->isEnabled()) { - invokeFindNext(); + if (m_useFakeVim) + setFocusToCurrentFindSupport(); + else + invokeFindNext(); } } @@ -635,6 +639,11 @@ void FindToolBar::readSettings() findFlagsChanged(); } +void FindToolBar::setUseFakeVim(bool on) +{ + m_useFakeVim = on; +} + void FindToolBar::setFindFlag(IFindSupport::FindFlag flag, bool enabled) { bool hasFlag = hasFindFlag(flag); diff --git a/src/plugins/find/findtoolbar.h b/src/plugins/find/findtoolbar.h index ac531defdf7..f8afe821068 100644 --- a/src/plugins/find/findtoolbar.h +++ b/src/plugins/find/findtoolbar.h @@ -59,6 +59,8 @@ public: void readSettings(); void writeSettings(); + void setUseFakeVim(bool on); + private slots: void invokeFindNext(); void invokeFindPrevious(); @@ -129,6 +131,7 @@ private: QTimer m_findIncrementalTimer; QTimer m_findStepTimer; + bool m_useFakeVim; }; } // namespace Internal -- GitLab