From 1dc68b8f2274f09cf92f0339ff5244f5578ba650 Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Fri, 26 Mar 2010 17:55:43 +0100 Subject: [PATCH] fakevim: hot fix for the 'must change tabsize in fakevim, too'-problem --- src/plugins/fakevim/fakevimhandler.cpp | 11 ++++++----- src/plugins/fakevim/fakevimhandler.h | 4 ++-- src/plugins/fakevim/fakevimplugin.cpp | 10 +++++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 50789ae8273..565ae8a70b8 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -386,7 +386,7 @@ public: void installEventFilter(); void passShortcuts(bool enable); void setupWidget(); - void restoreWidget(); + void restoreWidget(int tabSize); friend class FakeVimHandler; static int shift(int key) { return key + 32; } @@ -815,7 +815,6 @@ EventResult FakeVimHandler::Private::handleEvent(QKeyEvent *ev) void FakeVimHandler::Private::installEventFilter() { EDITOR(installEventFilter(q)); - updateEditor(); } void FakeVimHandler::Private::setupWidget() @@ -855,7 +854,7 @@ void FakeVimHandler::Private::updateEditor() EDITOR(setTabStopWidth(charWidth * config(ConfigTabStop).toInt())); } -void FakeVimHandler::Private::restoreWidget() +void FakeVimHandler::Private::restoreWidget(int tabSize) { //showBlackMessage(QString()); //updateMiniBuffer(); @@ -863,6 +862,8 @@ void FakeVimHandler::Private::restoreWidget() EDITOR(setReadOnly(m_wasReadOnly)); EDITOR(setCursorWidth(m_cursorWidth)); EDITOR(setOverwriteMode(false)); + const int charWidth = QFontMetrics(EDITOR(font())).width(QChar(' ')); + EDITOR(setTabStopWidth(charWidth * tabSize)); if (isVisualLineMode()) { m_tc = EDITOR(textCursor()); @@ -3988,9 +3989,9 @@ void FakeVimHandler::setupWidget() d->setupWidget(); } -void FakeVimHandler::restoreWidget() +void FakeVimHandler::restoreWidget(int tabSize) { - d->restoreWidget(); + d->restoreWidget(tabSize); } void FakeVimHandler::handleCommand(const QString &cmd) diff --git a/src/plugins/fakevim/fakevimhandler.h b/src/plugins/fakevim/fakevimhandler.h index d06422f6e78..e2aa81df8f3 100644 --- a/src/plugins/fakevim/fakevimhandler.h +++ b/src/plugins/fakevim/fakevimhandler.h @@ -57,14 +57,14 @@ public slots: void showRedMessage(const QString &msg); // This executes an "ex" style command taking context - // information from widget; + // information from the current widget. void handleCommand(const QString &cmd); void installEventFilter(); // Convenience void setupWidget(); - void restoreWidget(); + void restoreWidget(int tabSize); // Test only int physicalIndentation(const QString &line) const; diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 01a4afc779f..85fe2ecb9c7 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -757,8 +757,7 @@ void FakeVimPluginPrivate::findNext(bool reverse) triggerAction(Find::Constants::FIND_NEXT); } -// this class defers deletion of a child FakeVimHandler using 'deleteLater' -// - direct children QObject's would be 'delete'ed immediately before their parents +// This class defers deletion of a child FakeVimHandler using deleteLater(). class DeferredDeleter : public QObject { Q_OBJECT @@ -767,8 +766,7 @@ class DeferredDeleter : public QObject public: DeferredDeleter(QObject *parent, FakeVimHandler *handler) - : QObject(parent) - , m_handler(handler) + : QObject(parent), m_handler(handler) {} virtual ~DeferredDeleter() @@ -861,8 +859,10 @@ void FakeVimPluginPrivate::setUseFakeVim(const QVariant &value) } else { Core::EditorManager::instance()->hideEditorStatusBar( QLatin1String(Constants::MINI_BUFFER)); + TextEditor::TabSettings ts = + TextEditor::TextEditorSettings::instance()->tabSettings(); foreach (Core::IEditor *editor, m_editorToHandler.keys()) - m_editorToHandler[editor]->restoreWidget(); + m_editorToHandler[editor]->restoreWidget(ts.m_tabSize); } } -- GitLab