forked from qt-creator/qt-creator
update history position of the current editor when navigating
RevBy: eike
This commit is contained in:
@@ -478,7 +478,7 @@ void EditorManager::setCurrentEditor(IEditor *editor, bool ignoreNavigationHisto
|
|||||||
|
|
||||||
m_d->m_currentEditor = editor;
|
m_d->m_currentEditor = editor;
|
||||||
if (editor) {
|
if (editor) {
|
||||||
bool addToHistory = (!ignoreNavigationHistory && editor != currentEditor());
|
bool addToHistory = (!ignoreNavigationHistory);
|
||||||
if (addToHistory)
|
if (addToHistory)
|
||||||
addCurrentPositionToNavigationHistory(true);
|
addCurrentPositionToNavigationHistory(true);
|
||||||
|
|
||||||
@@ -678,8 +678,6 @@ bool EditorManager::closeEditors(const QList<IEditor*> editorsToClose, bool askA
|
|||||||
|
|
||||||
QList<EditorView*> currentViews;
|
QList<EditorView*> currentViews;
|
||||||
EditorView *currentView = 0;
|
EditorView *currentView = 0;
|
||||||
if (currentEditor())
|
|
||||||
addCurrentPositionToNavigationHistory(true);
|
|
||||||
|
|
||||||
// remove the editors
|
// remove the editors
|
||||||
foreach (IEditor *editor, acceptedEditors) {
|
foreach (IEditor *editor, acceptedEditors) {
|
||||||
@@ -812,11 +810,7 @@ void EditorManager::activateEditor(Core::Internal::EditorView *view, Core::IEdit
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasCurrent = (view->currentEditor() != 0);
|
|
||||||
|
|
||||||
editor = placeEditor(view, editor);
|
editor = placeEditor(view, editor);
|
||||||
if (!(flags & NoActivate) || !hasCurrent)
|
|
||||||
view->setCurrentEditor(editor);
|
|
||||||
|
|
||||||
if (!(flags & NoActivate)) {
|
if (!(flags & NoActivate)) {
|
||||||
setCurrentEditor(editor, (flags & IgnoreNavigationHistory));
|
setCurrentEditor(editor, (flags & IgnoreNavigationHistory));
|
||||||
@@ -1349,6 +1343,9 @@ void EditorManager::addCurrentPositionToNavigationHistory(bool compress)
|
|||||||
return;
|
return;
|
||||||
if (!editor->file())
|
if (!editor->file())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
qDebug() << "addCurrentPositionToNavigationHistory" << editor->file()->fileName();
|
||||||
|
|
||||||
QString fileName = editor->file()->fileName();
|
QString fileName = editor->file()->fileName();
|
||||||
QByteArray state = editor->saveState();
|
QByteArray state = editor->saveState();
|
||||||
// cut existing
|
// cut existing
|
||||||
@@ -1383,8 +1380,20 @@ void EditorManager::addCurrentPositionToNavigationHistory(bool compress)
|
|||||||
updateActions();
|
updateActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorManager::updateCurrentPositionInNavigationHistory()
|
||||||
|
{
|
||||||
|
if (!m_d->m_currentEditor)
|
||||||
|
return;
|
||||||
|
foreach (EditorManagerPrivate::EditLocation *location, m_d->m_navigationHistory)
|
||||||
|
if (location->editor == m_d->m_currentEditor) {
|
||||||
|
location->state = location->editor->saveState();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EditorManager::goBackInNavigationHistory()
|
void EditorManager::goBackInNavigationHistory()
|
||||||
{
|
{
|
||||||
|
updateCurrentPositionInNavigationHistory();
|
||||||
while (m_d->currentNavigationHistoryPosition > 0) {
|
while (m_d->currentNavigationHistoryPosition > 0) {
|
||||||
--m_d->currentNavigationHistoryPosition;
|
--m_d->currentNavigationHistoryPosition;
|
||||||
EditorManagerPrivate::EditLocation *location = m_d->m_navigationHistory.at(m_d->currentNavigationHistoryPosition);
|
EditorManagerPrivate::EditLocation *location = m_d->m_navigationHistory.at(m_d->currentNavigationHistoryPosition);
|
||||||
@@ -1408,6 +1417,7 @@ void EditorManager::goBackInNavigationHistory()
|
|||||||
|
|
||||||
void EditorManager::goForwardInNavigationHistory()
|
void EditorManager::goForwardInNavigationHistory()
|
||||||
{
|
{
|
||||||
|
updateCurrentPositionInNavigationHistory();
|
||||||
if (m_d->currentNavigationHistoryPosition >= m_d->m_navigationHistory.size()-1)
|
if (m_d->currentNavigationHistoryPosition >= m_d->m_navigationHistory.size()-1)
|
||||||
return;
|
return;
|
||||||
++m_d->currentNavigationHistoryPosition;
|
++m_d->currentNavigationHistoryPosition;
|
||||||
|
@@ -229,6 +229,8 @@ private:
|
|||||||
void emptyView(Core::Internal::EditorView *view);
|
void emptyView(Core::Internal::EditorView *view);
|
||||||
IEditor *pickUnusedEditor() const;
|
IEditor *pickUnusedEditor() const;
|
||||||
|
|
||||||
|
void updateCurrentPositionInNavigationHistory();
|
||||||
|
|
||||||
static EditorManager *m_instance;
|
static EditorManager *m_instance;
|
||||||
EditorManagerPrivate *m_d;
|
EditorManagerPrivate *m_d;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user