diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2016-05-24 23:09:11 +0300 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2016-05-25 07:49:30 +0000 |
commit | 28367148ec168b9044e8b6e3b06a2bb48691af63 (patch) | |
tree | 6b1c717c2099cfc4565e6c477d32489a8b523cbc /src/plugins/fakevim | |
parent | 6a3bb079fd4382a474c6ad023adfca0d7e1f38c3 (diff) | |
download | qt-creator-28367148ec168b9044e8b6e3b06a2bb48691af63.tar.gz |
FakeVim: Use Qt5-style connects
Change-Id: I85bc7b6e951515768da8473cadcec02cd58d30d3
Reviewed-by: Lukas Holecek <hluk@email.cz>
Reviewed-by: hjk <hjk@theqtcompany.com>
Diffstat (limited to 'src/plugins/fakevim')
-rw-r--r-- | src/plugins/fakevim/fakevimhandler.cpp | 43 | ||||
-rw-r--r-- | src/plugins/fakevim/fakevimhandler.h | 6 | ||||
-rw-r--r-- | src/plugins/fakevim/fakevimplugin.cpp | 40 | ||||
-rw-r--r-- | src/plugins/fakevim/fakevimplugin.h | 2 |
4 files changed, 50 insertions, 41 deletions
diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 9e90c26067..d0248934b1 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -949,11 +949,12 @@ inline QString msgMarkNotSet(const QString &text) return Tr::tr("Mark \"%1\" not set.").arg(text); } -static void initSingleShotTimer(QTimer *timer, int interval, QObject *receiver, const char *slot) +static void initSingleShotTimer(QTimer *timer, int interval, FakeVimHandler::Private *receiver, + void (FakeVimHandler::Private::*slot)()) { timer->setSingleShot(true); timer->setInterval(interval); - QObject::connect(timer, SIGNAL(timeout()), receiver, slot); + QObject::connect(timer, &QTimer::timeout, receiver, slot); } class Input @@ -1944,12 +1945,12 @@ public: bool canModifyBufferData() const { return m_buffer->currentHandler.data() == this; } - Q_SLOT void onContentsChanged(int position, int charsRemoved, int charsAdded); - Q_SLOT void onCursorPositionChanged(); - Q_SLOT void onUndoCommandAdded(); + void onContentsChanged(int position, int charsRemoved, int charsAdded); + void onCursorPositionChanged(); + void onUndoCommandAdded(); - Q_SLOT void onInputTimeout(); - Q_SLOT void onFixCursorTimeout(); + void onInputTimeout(); + void onFixCursorTimeout(); bool isCommandLineMode() const { return g.mode == ExMode || g.subsubmode == SearchSubSubMode; } bool isInsertMode() const { return g.mode == InsertMode || g.mode == ReplaceMode; } @@ -2284,9 +2285,10 @@ FakeVimHandler::Private::Private(FakeVimHandler *parent, QWidget *widget) init(); if (editor()) { - connect(EDITOR(document()), SIGNAL(contentsChange(int,int,int)), - SLOT(onContentsChanged(int,int,int))); - connect(EDITOR(document()), SIGNAL(undoCommandAdded()), SLOT(onUndoCommandAdded())); + connect(EDITOR(document()), &QTextDocument::contentsChange, + this, &Private::onContentsChanged); + connect(EDITOR(document()), &QTextDocument::undoCommandAdded, + this, &Private::onUndoCommandAdded); m_buffer->lastRevision = revision(); } } @@ -2311,8 +2313,8 @@ void FakeVimHandler::Private::init() m_ctrlVLength = 0; m_ctrlVBase = 0; - initSingleShotTimer(&m_fixCursorTimer, 0, this, SLOT(onFixCursorTimeout())); - initSingleShotTimer(&m_inputTimer, 1000, this, SLOT(onInputTimeout())); + initSingleShotTimer(&m_fixCursorTimer, 0, this, &FakeVimHandler::Private::onFixCursorTimeout); + initSingleShotTimer(&m_inputTimer, 1000, this, &FakeVimHandler::Private::onInputTimeout); pullOrCreateBufferData(); setupCharClass(); @@ -2547,8 +2549,13 @@ void FakeVimHandler::Private::removeEventFilter() void FakeVimHandler::Private::setupWidget() { m_cursorNeedsUpdate = true; - connect(editor(), SIGNAL(cursorPositionChanged()), - SLOT(onCursorPositionChanged()), Qt::UniqueConnection); + if (m_textedit) { + connect(m_textedit, &QTextEdit::cursorPositionChanged, + this, &FakeVimHandler::Private::onCursorPositionChanged, Qt::UniqueConnection); + } else { + connect(m_plaintextedit, &QPlainTextEdit::cursorPositionChanged, + this, &FakeVimHandler::Private::onCursorPositionChanged, Qt::UniqueConnection); + } enterFakeVim(); @@ -2673,7 +2680,13 @@ void FakeVimHandler::Private::restoreWidget(int tabSize) setThinCursor(); updateSelection(); updateHighlights(); - disconnect(editor(), SIGNAL(cursorPositionChanged()), this, SLOT(onCursorPositionChanged())); + if (m_textedit) { + disconnect(m_textedit, &QTextEdit::cursorPositionChanged, + this, &FakeVimHandler::Private::onCursorPositionChanged); + } else { + disconnect(m_plaintextedit, &QPlainTextEdit::cursorPositionChanged, + this, &FakeVimHandler::Private::onCursorPositionChanged); + } } EventResult FakeVimHandler::Private::handleKey(const Input &input) diff --git a/src/plugins/fakevim/fakevimhandler.h b/src/plugins/fakevim/fakevimhandler.h index cd4e17117e..6f218421e0 100644 --- a/src/plugins/fakevim/fakevimhandler.h +++ b/src/plugins/fakevim/fakevimhandler.h @@ -95,7 +95,7 @@ public: static void updateGlobalMarksFilenames(const QString &oldFileName, const QString &newFileName); -public slots: +public: void setCurrentFileName(const QString &fileName); QString currentFileName() const; @@ -131,8 +131,8 @@ public slots: bool eventFilter(QObject *ob, QEvent *ev); signals: - void commandBufferChanged(const QString &msg, int cursorPos, - int anchorPos, int messageLevel, QObject *eventFilter); + void commandBufferChanged(const QString &msg, int cursorPos, int anchorPos, + int messageLevel, FakeVimHandler *eventFilter); void statusDataChanged(const QString &msg); void extraInformationChanged(const QString &msg); void selectionChanged(const QList<QTextEdit::ExtraSelection> &selection); diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 788d87d74f..e5229b7b99 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -134,7 +134,7 @@ public: } void setContents(const QString &contents, int cursorPos, int anchorPos, - int messageLevel, QObject *eventFilter) + int messageLevel, FakeVimHandler *eventFilter) { if (cursorPos != -1) { m_edit->blockSignals(true); @@ -183,12 +183,12 @@ public: if (m_eventFilter != eventFilter) { if (m_eventFilter != 0) { m_edit->removeEventFilter(m_eventFilter); - disconnect(SIGNAL(edited(QString,int,int))); + disconnect(this, &MiniBuffer::edited, 0, 0); } if (eventFilter != 0) { m_edit->installEventFilter(eventFilter); - connect(this, SIGNAL(edited(QString,int,int)), - eventFilter, SLOT(miniBufferTextEdited(QString,int,int))); + connect(this, &MiniBuffer::edited, + eventFilter, &FakeVimHandler::miniBufferTextEdited); } m_eventFilter = eventFilter; } @@ -313,7 +313,7 @@ protected: return false; } -private slots: +private: void followEditorLayout() { QTextCursor tc = m_editor->textCursor(); @@ -336,7 +336,6 @@ private slots: update(); } -private: int m_currentPos = 0; int m_lineSpacing = 0; TextEditorWidget *m_editor; @@ -370,13 +369,12 @@ public: void apply(); void finish(); -private slots: +private: void copyTextEditorSettings(); void setQtStyle(); void setPlainStyle(); void updateVimRcWidgets(); -private: QPointer<QWidget> m_widget; Ui::FakeVimOptionPage m_ui; SavedActionSet m_group; @@ -1033,7 +1031,7 @@ public: bool initialize(); void aboutToShutdown(); -private slots: +private: void onCoreAboutToClose(); void editorOpened(Core::IEditor *); void editorAboutToClose(Core::IEditor *); @@ -1064,7 +1062,7 @@ private slots: void resetCommandBuffer(); void showCommandBuffer(const QString &contents, int cursorPos, int anchorPos, - int messageLevel, QObject *eventFilter); + int messageLevel, FakeVimHandler *eventFilter); void showExtraInformation(const QString &msg); void changeSelection(const QList<QTextEdit::ExtraSelection> &selections); void highlightMatches(const QString &needle); @@ -1205,10 +1203,8 @@ bool FakeVimPluginPrivate::initialize() // Set completion settings and keep them up to date. TextEditorSettings *textEditorSettings = TextEditorSettings::instance(); completion->setCompletionSettings(textEditorSettings->completionSettings()); - connect(textEditorSettings, - SIGNAL(completionSettingsChanged(TextEditor::CompletionSettings)), - completion, - SLOT(setCompletionSettings(TextEditor::CompletionSettings))); + connect(textEditorSettings, &TextEditorSettings::completionSettingsChanged, + completion, &TextEditorWidget::setCompletionSettings); */ Context globalcontext(Core::Constants::C_GLOBAL); @@ -2172,8 +2168,8 @@ void FakeVimPluginPrivate::resetCommandBuffer() showCommandBuffer(QString(), -1, -1, 0, 0); } -void FakeVimPluginPrivate::showCommandBuffer(const QString &contents, - int cursorPos, int anchorPos, int messageLevel, QObject *eventFilter) +void FakeVimPluginPrivate::showCommandBuffer(const QString &contents, int cursorPos, int anchorPos, + int messageLevel, FakeVimHandler *eventFilter) { //qDebug() << "SHOW COMMAND BUFFER" << contents; if (MiniBuffer *w = qobject_cast<MiniBuffer *>(m_statusBar->widget())) @@ -2313,12 +2309,12 @@ void FakeVimPlugin::setupTest(QString *title, FakeVimHandler **handler, QWidget // *handler = new FakeVimHandler(m_plaintextedit); // } -// QObject::connect(*handler, SIGNAL(commandBufferChanged(QString,int)), -// this, SLOT(changeStatusMessage(QString,int))); -// QObject::connect(*handler, SIGNAL(extraInformationChanged(QString)), -// this, SLOT(changeExtraInformation(QString))); -// QObject::connect(*handler, SIGNAL(statusDataChanged(QString)), -// this, SLOT(changeStatusData(QString))); +// connect(*handler, &FakeVimHandler::commandBufferChanged, +// this, &FakeVimPlugin::changeStatusMessage); +// connect(*handler, &FakeVimHandler::extraInformationChanged, +// this, &FakeVimPlugin::changeExtraInformation); +// connect(*handler, &FakeVimHandler::statusDataChanged, +// this, &FakeVimPlugin::changeStatusData); // QCOMPARE(EDITOR(toPlainText()), lines); (*handler)->handleCommand("set iskeyword=@,48-57,_,192-255,a-z,A-Z"); diff --git a/src/plugins/fakevim/fakevimplugin.h b/src/plugins/fakevim/fakevimplugin.h index edbf6ab0b9..60789b8711 100644 --- a/src/plugins/fakevim/fakevimplugin.h +++ b/src/plugins/fakevim/fakevimplugin.h @@ -108,7 +108,7 @@ private slots: void test_vim_ex_join(); void test_advanced_commands(); -//public slots: +//public: // void changeStatusData(const QString &info) { m_statusData = info; } // void changeStatusMessage(const QString &info, int) { m_statusMessage = info; } // void changeExtraInformation(const QString &info) { m_infoMessage = info; } |