forked from qt-creator/qt-creator
FakeVim: Update file path and global marks
Update file path and global marks if file in project is renamed. Update file path on "Save as...". Task-number: QTCREATORBUG-12810 Change-Id: Ia2361e8f65a7a494e339d96c8b4610af4ab38edb Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -320,6 +320,8 @@ public:
|
|||||||
|
|
||||||
const QString &fileName() const { return m_fileName; }
|
const QString &fileName() const { return m_fileName; }
|
||||||
|
|
||||||
|
void setFileName(const QString &fileName) { m_fileName = fileName; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CursorPosition m_position;
|
CursorPosition m_position;
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
@@ -8472,6 +8474,15 @@ void FakeVimHandler::disconnectFromEditor()
|
|||||||
d->m_plaintextedit = 0;
|
d->m_plaintextedit = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FakeVimHandler::updateGlobalMarksFilenames(const QString &oldFileName, const QString &newFileName)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Private::g.marks.size(); ++i) {
|
||||||
|
Mark &mark = Private::g.marks[i];
|
||||||
|
if (mark.fileName() == oldFileName)
|
||||||
|
mark.setFileName(newFileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool FakeVimHandler::eventFilter(QObject *ob, QEvent *ev)
|
bool FakeVimHandler::eventFilter(QObject *ob, QEvent *ev)
|
||||||
{
|
{
|
||||||
#ifndef FAKEVIM_STANDALONE
|
#ifndef FAKEVIM_STANDALONE
|
||||||
|
|||||||
@@ -98,6 +98,8 @@ public:
|
|||||||
// call before widget is deleted
|
// call before widget is deleted
|
||||||
void disconnectFromEditor();
|
void disconnectFromEditor();
|
||||||
|
|
||||||
|
static void updateGlobalMarksFilenames(const QString &oldFileName, const QString &newFileName);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setCurrentFileName(const QString &fileName);
|
void setCurrentFileName(const QString &fileName);
|
||||||
QString currentFileName() const;
|
QString currentFileName() const;
|
||||||
|
|||||||
@@ -1003,6 +1003,10 @@ private slots:
|
|||||||
void editorOpened(Core::IEditor *);
|
void editorOpened(Core::IEditor *);
|
||||||
void editorAboutToClose(Core::IEditor *);
|
void editorAboutToClose(Core::IEditor *);
|
||||||
|
|
||||||
|
void allDocumentsRenamed(const QString &oldName, const QString &newName);
|
||||||
|
void documentRenamed(Core::IDocument *document, const QString &oldName, const QString &newName);
|
||||||
|
void renameFileNameInEditors(const QString &oldName, const QString &newName);
|
||||||
|
|
||||||
void setUseFakeVim(const QVariant &value);
|
void setUseFakeVim(const QVariant &value);
|
||||||
void setUseFakeVimInternal(bool on);
|
void setUseFakeVimInternal(bool on);
|
||||||
void quitFakeVim();
|
void quitFakeVim();
|
||||||
@@ -1222,6 +1226,11 @@ bool FakeVimPluginPrivate::initialize()
|
|||||||
connect(EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)),
|
connect(EditorManager::instance(), SIGNAL(editorOpened(Core::IEditor*)),
|
||||||
this, SLOT(editorOpened(Core::IEditor*)));
|
this, SLOT(editorOpened(Core::IEditor*)));
|
||||||
|
|
||||||
|
connect(DocumentManager::instance(), SIGNAL(allDocumentsRenamed(QString,QString)),
|
||||||
|
this, SLOT(allDocumentsRenamed(QString,QString)));
|
||||||
|
connect(DocumentManager::instance(), SIGNAL(documentRenamed(Core::IDocument*,QString,QString)),
|
||||||
|
this, SLOT(documentRenamed(Core::IDocument*,QString,QString)));
|
||||||
|
|
||||||
connect(theFakeVimSetting(ConfigUseFakeVim), SIGNAL(valueChanged(QVariant)),
|
connect(theFakeVimSetting(ConfigUseFakeVim), SIGNAL(valueChanged(QVariant)),
|
||||||
this, SLOT(setUseFakeVim(QVariant)));
|
this, SLOT(setUseFakeVim(QVariant)));
|
||||||
connect(theFakeVimSetting(ConfigReadVimRc), SIGNAL(valueChanged(QVariant)),
|
connect(theFakeVimSetting(ConfigReadVimRc), SIGNAL(valueChanged(QVariant)),
|
||||||
@@ -1823,6 +1832,26 @@ void FakeVimPluginPrivate::editorAboutToClose(IEditor *editor)
|
|||||||
m_editorToHandler.remove(editor);
|
m_editorToHandler.remove(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FakeVimPluginPrivate::allDocumentsRenamed(const QString &oldName, const QString &newName)
|
||||||
|
{
|
||||||
|
renameFileNameInEditors(oldName, newName);
|
||||||
|
FakeVimHandler::updateGlobalMarksFilenames(oldName, newName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeVimPluginPrivate::documentRenamed(
|
||||||
|
IDocument *, const QString &oldName, const QString &newName)
|
||||||
|
{
|
||||||
|
renameFileNameInEditors(oldName, newName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakeVimPluginPrivate::renameFileNameInEditors(const QString &oldName, const QString &newName)
|
||||||
|
{
|
||||||
|
foreach (FakeVimHandler *handler, m_editorToHandler.values()) {
|
||||||
|
if (handler->currentFileName() == oldName)
|
||||||
|
handler->setCurrentFileName(newName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::setUseFakeVim(const QVariant &value)
|
void FakeVimPluginPrivate::setUseFakeVim(const QVariant &value)
|
||||||
{
|
{
|
||||||
//qDebug() << "SET USE FAKEVIM" << value;
|
//qDebug() << "SET USE FAKEVIM" << value;
|
||||||
|
|||||||
Reference in New Issue
Block a user