forked from qt-creator/qt-creator
FakeVim: Use Qt5-style connects
Change-Id: I85bc7b6e951515768da8473cadcec02cd58d30d3 Reviewed-by: Lukas Holecek <hluk@email.cz> Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
6a3bb079fd
commit
28367148ec
@@ -949,11 +949,12 @@ inline QString msgMarkNotSet(const QString &text)
|
|||||||
return Tr::tr("Mark \"%1\" not set.").arg(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->setSingleShot(true);
|
||||||
timer->setInterval(interval);
|
timer->setInterval(interval);
|
||||||
QObject::connect(timer, SIGNAL(timeout()), receiver, slot);
|
QObject::connect(timer, &QTimer::timeout, receiver, slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Input
|
class Input
|
||||||
@@ -1944,12 +1945,12 @@ public:
|
|||||||
|
|
||||||
bool canModifyBufferData() const { return m_buffer->currentHandler.data() == this; }
|
bool canModifyBufferData() const { return m_buffer->currentHandler.data() == this; }
|
||||||
|
|
||||||
Q_SLOT void onContentsChanged(int position, int charsRemoved, int charsAdded);
|
void onContentsChanged(int position, int charsRemoved, int charsAdded);
|
||||||
Q_SLOT void onCursorPositionChanged();
|
void onCursorPositionChanged();
|
||||||
Q_SLOT void onUndoCommandAdded();
|
void onUndoCommandAdded();
|
||||||
|
|
||||||
Q_SLOT void onInputTimeout();
|
void onInputTimeout();
|
||||||
Q_SLOT void onFixCursorTimeout();
|
void onFixCursorTimeout();
|
||||||
|
|
||||||
bool isCommandLineMode() const { return g.mode == ExMode || g.subsubmode == SearchSubSubMode; }
|
bool isCommandLineMode() const { return g.mode == ExMode || g.subsubmode == SearchSubSubMode; }
|
||||||
bool isInsertMode() const { return g.mode == InsertMode || g.mode == ReplaceMode; }
|
bool isInsertMode() const { return g.mode == InsertMode || g.mode == ReplaceMode; }
|
||||||
@@ -2284,9 +2285,10 @@ FakeVimHandler::Private::Private(FakeVimHandler *parent, QWidget *widget)
|
|||||||
init();
|
init();
|
||||||
|
|
||||||
if (editor()) {
|
if (editor()) {
|
||||||
connect(EDITOR(document()), SIGNAL(contentsChange(int,int,int)),
|
connect(EDITOR(document()), &QTextDocument::contentsChange,
|
||||||
SLOT(onContentsChanged(int,int,int)));
|
this, &Private::onContentsChanged);
|
||||||
connect(EDITOR(document()), SIGNAL(undoCommandAdded()), SLOT(onUndoCommandAdded()));
|
connect(EDITOR(document()), &QTextDocument::undoCommandAdded,
|
||||||
|
this, &Private::onUndoCommandAdded);
|
||||||
m_buffer->lastRevision = revision();
|
m_buffer->lastRevision = revision();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2311,8 +2313,8 @@ void FakeVimHandler::Private::init()
|
|||||||
m_ctrlVLength = 0;
|
m_ctrlVLength = 0;
|
||||||
m_ctrlVBase = 0;
|
m_ctrlVBase = 0;
|
||||||
|
|
||||||
initSingleShotTimer(&m_fixCursorTimer, 0, this, SLOT(onFixCursorTimeout()));
|
initSingleShotTimer(&m_fixCursorTimer, 0, this, &FakeVimHandler::Private::onFixCursorTimeout);
|
||||||
initSingleShotTimer(&m_inputTimer, 1000, this, SLOT(onInputTimeout()));
|
initSingleShotTimer(&m_inputTimer, 1000, this, &FakeVimHandler::Private::onInputTimeout);
|
||||||
|
|
||||||
pullOrCreateBufferData();
|
pullOrCreateBufferData();
|
||||||
setupCharClass();
|
setupCharClass();
|
||||||
@@ -2547,8 +2549,13 @@ void FakeVimHandler::Private::removeEventFilter()
|
|||||||
void FakeVimHandler::Private::setupWidget()
|
void FakeVimHandler::Private::setupWidget()
|
||||||
{
|
{
|
||||||
m_cursorNeedsUpdate = true;
|
m_cursorNeedsUpdate = true;
|
||||||
connect(editor(), SIGNAL(cursorPositionChanged()),
|
if (m_textedit) {
|
||||||
SLOT(onCursorPositionChanged()), Qt::UniqueConnection);
|
connect(m_textedit, &QTextEdit::cursorPositionChanged,
|
||||||
|
this, &FakeVimHandler::Private::onCursorPositionChanged, Qt::UniqueConnection);
|
||||||
|
} else {
|
||||||
|
connect(m_plaintextedit, &QPlainTextEdit::cursorPositionChanged,
|
||||||
|
this, &FakeVimHandler::Private::onCursorPositionChanged, Qt::UniqueConnection);
|
||||||
|
}
|
||||||
|
|
||||||
enterFakeVim();
|
enterFakeVim();
|
||||||
|
|
||||||
@@ -2673,7 +2680,13 @@ void FakeVimHandler::Private::restoreWidget(int tabSize)
|
|||||||
setThinCursor();
|
setThinCursor();
|
||||||
updateSelection();
|
updateSelection();
|
||||||
updateHighlights();
|
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)
|
EventResult FakeVimHandler::Private::handleKey(const Input &input)
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public:
|
|||||||
|
|
||||||
static void updateGlobalMarksFilenames(const QString &oldFileName, const QString &newFileName);
|
static void updateGlobalMarksFilenames(const QString &oldFileName, const QString &newFileName);
|
||||||
|
|
||||||
public slots:
|
public:
|
||||||
void setCurrentFileName(const QString &fileName);
|
void setCurrentFileName(const QString &fileName);
|
||||||
QString currentFileName() const;
|
QString currentFileName() const;
|
||||||
|
|
||||||
@@ -131,8 +131,8 @@ public slots:
|
|||||||
bool eventFilter(QObject *ob, QEvent *ev);
|
bool eventFilter(QObject *ob, QEvent *ev);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void commandBufferChanged(const QString &msg, int cursorPos,
|
void commandBufferChanged(const QString &msg, int cursorPos, int anchorPos,
|
||||||
int anchorPos, int messageLevel, QObject *eventFilter);
|
int messageLevel, FakeVimHandler *eventFilter);
|
||||||
void statusDataChanged(const QString &msg);
|
void statusDataChanged(const QString &msg);
|
||||||
void extraInformationChanged(const QString &msg);
|
void extraInformationChanged(const QString &msg);
|
||||||
void selectionChanged(const QList<QTextEdit::ExtraSelection> &selection);
|
void selectionChanged(const QList<QTextEdit::ExtraSelection> &selection);
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setContents(const QString &contents, int cursorPos, int anchorPos,
|
void setContents(const QString &contents, int cursorPos, int anchorPos,
|
||||||
int messageLevel, QObject *eventFilter)
|
int messageLevel, FakeVimHandler *eventFilter)
|
||||||
{
|
{
|
||||||
if (cursorPos != -1) {
|
if (cursorPos != -1) {
|
||||||
m_edit->blockSignals(true);
|
m_edit->blockSignals(true);
|
||||||
@@ -183,12 +183,12 @@ public:
|
|||||||
if (m_eventFilter != eventFilter) {
|
if (m_eventFilter != eventFilter) {
|
||||||
if (m_eventFilter != 0) {
|
if (m_eventFilter != 0) {
|
||||||
m_edit->removeEventFilter(m_eventFilter);
|
m_edit->removeEventFilter(m_eventFilter);
|
||||||
disconnect(SIGNAL(edited(QString,int,int)));
|
disconnect(this, &MiniBuffer::edited, 0, 0);
|
||||||
}
|
}
|
||||||
if (eventFilter != 0) {
|
if (eventFilter != 0) {
|
||||||
m_edit->installEventFilter(eventFilter);
|
m_edit->installEventFilter(eventFilter);
|
||||||
connect(this, SIGNAL(edited(QString,int,int)),
|
connect(this, &MiniBuffer::edited,
|
||||||
eventFilter, SLOT(miniBufferTextEdited(QString,int,int)));
|
eventFilter, &FakeVimHandler::miniBufferTextEdited);
|
||||||
}
|
}
|
||||||
m_eventFilter = eventFilter;
|
m_eventFilter = eventFilter;
|
||||||
}
|
}
|
||||||
@@ -313,7 +313,7 @@ protected:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private slots:
|
private:
|
||||||
void followEditorLayout()
|
void followEditorLayout()
|
||||||
{
|
{
|
||||||
QTextCursor tc = m_editor->textCursor();
|
QTextCursor tc = m_editor->textCursor();
|
||||||
@@ -336,7 +336,6 @@ private slots:
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
int m_currentPos = 0;
|
int m_currentPos = 0;
|
||||||
int m_lineSpacing = 0;
|
int m_lineSpacing = 0;
|
||||||
TextEditorWidget *m_editor;
|
TextEditorWidget *m_editor;
|
||||||
@@ -370,13 +369,12 @@ public:
|
|||||||
void apply();
|
void apply();
|
||||||
void finish();
|
void finish();
|
||||||
|
|
||||||
private slots:
|
private:
|
||||||
void copyTextEditorSettings();
|
void copyTextEditorSettings();
|
||||||
void setQtStyle();
|
void setQtStyle();
|
||||||
void setPlainStyle();
|
void setPlainStyle();
|
||||||
void updateVimRcWidgets();
|
void updateVimRcWidgets();
|
||||||
|
|
||||||
private:
|
|
||||||
QPointer<QWidget> m_widget;
|
QPointer<QWidget> m_widget;
|
||||||
Ui::FakeVimOptionPage m_ui;
|
Ui::FakeVimOptionPage m_ui;
|
||||||
SavedActionSet m_group;
|
SavedActionSet m_group;
|
||||||
@@ -1033,7 +1031,7 @@ public:
|
|||||||
bool initialize();
|
bool initialize();
|
||||||
void aboutToShutdown();
|
void aboutToShutdown();
|
||||||
|
|
||||||
private slots:
|
private:
|
||||||
void onCoreAboutToClose();
|
void onCoreAboutToClose();
|
||||||
void editorOpened(Core::IEditor *);
|
void editorOpened(Core::IEditor *);
|
||||||
void editorAboutToClose(Core::IEditor *);
|
void editorAboutToClose(Core::IEditor *);
|
||||||
@@ -1064,7 +1062,7 @@ private slots:
|
|||||||
|
|
||||||
void resetCommandBuffer();
|
void resetCommandBuffer();
|
||||||
void showCommandBuffer(const QString &contents, int cursorPos, int anchorPos,
|
void showCommandBuffer(const QString &contents, int cursorPos, int anchorPos,
|
||||||
int messageLevel, QObject *eventFilter);
|
int messageLevel, FakeVimHandler *eventFilter);
|
||||||
void showExtraInformation(const QString &msg);
|
void showExtraInformation(const QString &msg);
|
||||||
void changeSelection(const QList<QTextEdit::ExtraSelection> &selections);
|
void changeSelection(const QList<QTextEdit::ExtraSelection> &selections);
|
||||||
void highlightMatches(const QString &needle);
|
void highlightMatches(const QString &needle);
|
||||||
@@ -1205,10 +1203,8 @@ bool FakeVimPluginPrivate::initialize()
|
|||||||
// Set completion settings and keep them up to date.
|
// Set completion settings and keep them up to date.
|
||||||
TextEditorSettings *textEditorSettings = TextEditorSettings::instance();
|
TextEditorSettings *textEditorSettings = TextEditorSettings::instance();
|
||||||
completion->setCompletionSettings(textEditorSettings->completionSettings());
|
completion->setCompletionSettings(textEditorSettings->completionSettings());
|
||||||
connect(textEditorSettings,
|
connect(textEditorSettings, &TextEditorSettings::completionSettingsChanged,
|
||||||
SIGNAL(completionSettingsChanged(TextEditor::CompletionSettings)),
|
completion, &TextEditorWidget::setCompletionSettings);
|
||||||
completion,
|
|
||||||
SLOT(setCompletionSettings(TextEditor::CompletionSettings)));
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Context globalcontext(Core::Constants::C_GLOBAL);
|
Context globalcontext(Core::Constants::C_GLOBAL);
|
||||||
@@ -2172,8 +2168,8 @@ void FakeVimPluginPrivate::resetCommandBuffer()
|
|||||||
showCommandBuffer(QString(), -1, -1, 0, 0);
|
showCommandBuffer(QString(), -1, -1, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::showCommandBuffer(const QString &contents,
|
void FakeVimPluginPrivate::showCommandBuffer(const QString &contents, int cursorPos, int anchorPos,
|
||||||
int cursorPos, int anchorPos, int messageLevel, QObject *eventFilter)
|
int messageLevel, FakeVimHandler *eventFilter)
|
||||||
{
|
{
|
||||||
//qDebug() << "SHOW COMMAND BUFFER" << contents;
|
//qDebug() << "SHOW COMMAND BUFFER" << contents;
|
||||||
if (MiniBuffer *w = qobject_cast<MiniBuffer *>(m_statusBar->widget()))
|
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);
|
// *handler = new FakeVimHandler(m_plaintextedit);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// QObject::connect(*handler, SIGNAL(commandBufferChanged(QString,int)),
|
// connect(*handler, &FakeVimHandler::commandBufferChanged,
|
||||||
// this, SLOT(changeStatusMessage(QString,int)));
|
// this, &FakeVimPlugin::changeStatusMessage);
|
||||||
// QObject::connect(*handler, SIGNAL(extraInformationChanged(QString)),
|
// connect(*handler, &FakeVimHandler::extraInformationChanged,
|
||||||
// this, SLOT(changeExtraInformation(QString)));
|
// this, &FakeVimPlugin::changeExtraInformation);
|
||||||
// QObject::connect(*handler, SIGNAL(statusDataChanged(QString)),
|
// connect(*handler, &FakeVimHandler::statusDataChanged,
|
||||||
// this, SLOT(changeStatusData(QString)));
|
// this, &FakeVimPlugin::changeStatusData);
|
||||||
|
|
||||||
// QCOMPARE(EDITOR(toPlainText()), lines);
|
// QCOMPARE(EDITOR(toPlainText()), lines);
|
||||||
(*handler)->handleCommand("set iskeyword=@,48-57,_,192-255,a-z,A-Z");
|
(*handler)->handleCommand("set iskeyword=@,48-57,_,192-255,a-z,A-Z");
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ private slots:
|
|||||||
void test_vim_ex_join();
|
void test_vim_ex_join();
|
||||||
void test_advanced_commands();
|
void test_advanced_commands();
|
||||||
|
|
||||||
//public slots:
|
//public:
|
||||||
// void changeStatusData(const QString &info) { m_statusData = info; }
|
// void changeStatusData(const QString &info) { m_statusData = info; }
|
||||||
// void changeStatusMessage(const QString &info, int) { m_statusMessage = info; }
|
// void changeStatusMessage(const QString &info, int) { m_statusMessage = info; }
|
||||||
// void changeExtraInformation(const QString &info) { m_infoMessage = info; }
|
// void changeExtraInformation(const QString &info) { m_infoMessage = info; }
|
||||||
|
|||||||
Reference in New Issue
Block a user