Commit 474d883e authored by Martin Aumüller's avatar Martin Aumüller Committed by hjk
Browse files

for fakevim mode, terminate incremental search after pressing enter/return



Merge-request: 97
Reviewed-by: default avatarhjk <qtc-committer@nokia.com>
parent de21fef7
......@@ -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
......
......@@ -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),
......
......@@ -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)
......@@ -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;
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment