diff options
Diffstat (limited to 'src/plugins/fakevim/fakevimplugin.cpp')
-rw-r--r-- | src/plugins/fakevim/fakevimplugin.cpp | 77 |
1 files changed, 30 insertions, 47 deletions
diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 1ecf1934f6..f8e79162f2 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -41,7 +41,7 @@ #include <coreplugin/coreconstants.h> #include <coreplugin/dialogs/ioptionspage.h> #include <coreplugin/editormanager/editormanager.h> -#include <coreplugin/editormanager/openeditorsmodel.h> +#include <coreplugin/editormanager/documentmodel.h> #include <coreplugin/documentmanager.h> #include <coreplugin/icore.h> #include <coreplugin/idocument.h> @@ -122,7 +122,6 @@ class MiniBuffer : public QStackedWidget public: MiniBuffer() : m_label(new QLabel(this)), m_edit(new QLineEdit(this)), m_eventFilter(0) { - m_edit->installEventFilter(this); connect(m_edit, SIGNAL(textEdited(QString)), SLOT(changed())); connect(m_edit, SIGNAL(cursorPositionChanged(int,int)), SLOT(changed())); connect(m_edit, SIGNAL(selectionChanged()), SLOT(changed())); @@ -206,18 +205,6 @@ private slots: emit edited(m_edit->text(), cursorPos, anchorPos); } - bool eventFilter(QObject *ob, QEvent *ev) - { - // cancel editing on escape - if (m_eventFilter != 0 && ob == m_edit && ev->type() == QEvent::ShortcutOverride - && static_cast<QKeyEvent*>(ev)->key() == Qt::Key_Escape) { - emit edited(QString(), -1, -1); - ev->accept(); - return true; - } - return false; - } - private: QLabel *m_label; QLineEdit *m_edit; @@ -372,8 +359,8 @@ QWidget *FakeVimOptionPage::createPage(QWidget *parent) void FakeVimOptionPage::copyTextEditorSettings() { - TabSettings ts = TextEditorSettings::instance()->codeStyle()->tabSettings(); - TypingSettings tps = TextEditorSettings::instance()->typingSettings(); + TabSettings ts = TextEditorSettings::codeStyle()->tabSettings(); + TypingSettings tps = TextEditorSettings::typingSettings(); m_ui.checkBoxExpandTab->setChecked(ts.m_tabPolicy != TabSettings::TabsOnlyTabPolicy); m_ui.spinBoxTabStop->setValue(ts.m_tabSize); m_ui.spinBoxShiftWidth->setValue(ts.m_indentSize); @@ -1041,7 +1028,7 @@ FakeVimPluginPrivate::~FakeVimPluginPrivate() void FakeVimPluginPrivate::onCoreAboutToClose() { // Don't attach to editors anymore. - disconnect(ICore::editorManager(), SIGNAL(editorOpened(Core::IEditor*)), + disconnect(EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)), this, SLOT(editorOpened(Core::IEditor*))); } @@ -1051,8 +1038,6 @@ void FakeVimPluginPrivate::aboutToShutdown() bool FakeVimPluginPrivate::initialize() { - EditorManager *editorManager = ICore::editorManager(); - //m_wordCompletion = new WordCompletion; //q->addAutoReleasedObject(m_wordCompletion); m_wordProvider = new FakeVimCompletionAssistProvider; @@ -1089,7 +1074,7 @@ bool FakeVimPluginPrivate::initialize() ActionManager::actionContainer(Core::Constants::M_EDIT_ADVANCED); advancedMenu->addAction(cmd, Core::Constants::G_EDIT_EDITOR); - const Id base = Id("FakeVim.UserAction"); + const Id base = "FakeVim.UserAction"; for (int i = 1; i < 10; ++i) { QAction *act = new QAction(this); act->setText(tr("Execute User Action #%1").arg(i)); @@ -1102,9 +1087,9 @@ bool FakeVimPluginPrivate::initialize() connect(ICore::instance(), SIGNAL(coreAboutToClose()), this, SLOT(onCoreAboutToClose())); // EditorManager - connect(editorManager, SIGNAL(editorAboutToClose(Core::IEditor*)), + connect(EditorManager::instance(), SIGNAL(editorAboutToClose(Core::IEditor*)), this, SLOT(editorAboutToClose(Core::IEditor*))); - connect(editorManager, SIGNAL(editorOpened(Core::IEditor*)), + connect(EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)), this, SLOT(editorOpened(Core::IEditor*))); connect(theFakeVimSetting(ConfigUseFakeVim), SIGNAL(valueChanged(QVariant)), @@ -1326,6 +1311,8 @@ void FakeVimPluginPrivate::windowCommand(const QString &map, int count) triggerAction(Core::Constants::GOTOPREV); else if (key == _("S") || key == _("<C-S>")) triggerAction(Core::Constants::SPLIT); + else if (key == _("V") || key == _("<C-V>")) + triggerAction(Core::Constants::SPLIT_SIDE_BY_SIDE); else if (key == _("W") || key == _("<C-W>")) triggerAction(Core::Constants::GOTO_NEXT_SPLIT); else if (key.contains(_("RIGHT")) || key == _("L") || key == _("<S-L>")) @@ -1354,7 +1341,7 @@ void FakeVimPluginPrivate::moveSomewhere(DistFunction f, int count) IEditor *bestEditor = 0; int repeat = count; - QList<IEditor *> editors = EditorManager::instance()->visibleEditors(); + QList<IEditor *> editors = EditorManager::visibleEditors(); while (repeat < 0 || repeat-- > 0) { editors.removeOne(currentEditor); int bestValue = -1; @@ -1387,7 +1374,7 @@ void FakeVimPluginPrivate::moveSomewhere(DistFunction f, int count) void FakeVimPluginPrivate::keepOnlyWindow() { IEditor *currentEditor = EditorManager::currentEditor(); - QList<IEditor *> editors = EditorManager::instance()->visibleEditors(); + QList<IEditor *> editors = EditorManager::visibleEditors(); editors.removeOne(currentEditor); foreach (IEditor *editor, editors) { @@ -1401,8 +1388,8 @@ void FakeVimPluginPrivate::find(bool reverse) if (Find::FindPlugin *plugin = Find::FindPlugin::instance()) { plugin->setUseFakeVim(true); plugin->openFindToolBar(reverse - ? Find::FindPlugin::FindBackward - : Find::FindPlugin::FindForward); + ? Find::FindPlugin::FindBackwardDirection + : Find::FindPlugin::FindForwardDirection); } } @@ -1663,7 +1650,7 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor) connect(ICore::instance(), SIGNAL(saveSettingsRequested()), SLOT(writeSettings())); - handler->setCurrentFileName(editor->document()->fileName()); + handler->setCurrentFileName(editor->document()->filePath()); handler->installEventFilter(); // pop up the bar @@ -1774,7 +1761,7 @@ void FakeVimPluginPrivate::handleExCommand(bool *handled, const ExCommand &cmd) // :w[rite] IEditor *editor = m_editorToHandler.key(handler); const QString fileName = handler->currentFileName(); - if (editor && editor->document()->fileName() == fileName) { + if (editor && editor->document()->filePath() == fileName) { // Handle that as a special case for nicer interaction with core DocumentManager::saveDocument(editor->document()); // Check result by reading back. @@ -1865,20 +1852,16 @@ void FakeVimPluginPrivate::handleDelayedQuit(bool forced, IEditor *editor) { // This tries to simulate vim behaviour. But the models of vim and // Qt Creator core do not match well... - EditorManager *editorManager = ICore::editorManager(); - if (editorManager->hasSplitter()) { + if (EditorManager::hasSplitter()) triggerAction(Core::Constants::REMOVE_CURRENT_SPLIT); - } else { - QList<IEditor *> editors; - editors.append(editor); - editorManager->closeEditors(editors, !forced); - } + else + EditorManager::closeEditor(editor, !forced); } void FakeVimPluginPrivate::handleDelayedQuitAll(bool forced) { triggerAction(Core::Constants::REMOVE_ALL_SPLITS); - ICore::editorManager()->closeAllEditors(!forced); + EditorManager::closeAllEditors(!forced); } void FakeVimPluginPrivate::moveToMatchingParenthesis(bool *moved, bool *forward, @@ -1989,30 +1972,30 @@ void FakeVimPluginPrivate::changeSelection(const QList<QTextEdit::ExtraSelection void FakeVimPluginPrivate::highlightMatches(const QString &needle) { - IEditor *editor = EditorManager::currentEditor(); - QWidget *w = editor->widget(); - Find::IFindSupport *find = Aggregation::query<Find::IFindSupport>(w); - if (find != 0) - find->highlightAll(needle, Find::FindRegularExpression | Find::FindCaseSensitively); + foreach (IEditor *editor, EditorManager::visibleEditors()) { + QWidget *w = editor->widget(); + Find::IFindSupport *find = Aggregation::query<Find::IFindSupport>(w); + if (find != 0) + find->highlightAll(needle, Find::FindRegularExpression | Find::FindCaseSensitively); + } } int FakeVimPluginPrivate::currentFile() const { - OpenEditorsModel *model = EditorManager::instance()->openedEditorsModel(); IEditor *editor = EditorManager::currentEditor(); - return model->indexOf(editor).row(); + if (!editor) + return -1; + return EditorManager::documentModel()->indexOfDocument(editor->document()); } void FakeVimPluginPrivate::switchToFile(int n) { - EditorManager *editorManager = ICore::editorManager(); - OpenEditorsModel *model = editorManager->openedEditorsModel(); - int size = model->rowCount(); + int size = EditorManager::documentModel()->documentCount(); QTC_ASSERT(size, return); n = n % size; if (n < 0) n += size; - editorManager->activateEditorForIndex(model->index(n, 0)); + EditorManager::activateEditorForEntry(EditorManager::documentModel()->documents().at(n)); } ExCommandMap &FakeVimExCommandsPage::exCommandMap() |