Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Tobias Hunger
qt-creator
Commits
fc79c737
Commit
fc79c737
authored
Mar 19, 2009
by
con
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add last edit position to navigation history.
Task: 240811
parent
f84c6514
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
13 deletions
+35
-13
src/plugins/coreplugin/editormanager/editormanager.cpp
src/plugins/coreplugin/editormanager/editormanager.cpp
+11
-3
src/plugins/coreplugin/editormanager/editormanager.h
src/plugins/coreplugin/editormanager/editormanager.h
+1
-1
src/plugins/texteditor/basetexteditor.cpp
src/plugins/texteditor/basetexteditor.cpp
+19
-7
src/plugins/texteditor/basetexteditor.h
src/plugins/texteditor/basetexteditor.h
+3
-2
src/plugins/texteditor/basetexteditor_p.h
src/plugins/texteditor/basetexteditor_p.h
+1
-0
No files found.
src/plugins/coreplugin/editormanager/editormanager.cpp
View file @
fc79c737
...
...
@@ -719,8 +719,8 @@ bool EditorManager::closeEditors(const QList<IEditor*> editorsToClose, bool askA
}
}
emit
editorsClosed
(
acceptedEditors
);
foreach
(
IEditor
*
editor
,
acceptedEditors
)
{
delete
editor
;
}
...
...
@@ -1358,7 +1358,7 @@ QList<IEditor*> EditorManager::editorHistory() const
return
m_d
->
m_editorHistory
;
}
void
EditorManager
::
addCurrentPositionToNavigationHistory
(
bool
compress
)
void
EditorManager
::
addCurrentPositionToNavigationHistory
(
const
QByteArray
&
saveState
)
{
IEditor
*
editor
=
currentEditor
();
if
(
!
editor
)
...
...
@@ -1367,7 +1367,15 @@ void EditorManager::addCurrentPositionToNavigationHistory(bool compress)
return
;
QString
fileName
=
editor
->
file
()
->
fileName
();
QByteArray
state
=
editor
->
saveState
();
bool
compress
;
QByteArray
state
;
if
(
saveState
.
isNull
())
{
state
=
editor
->
saveState
();
compress
=
false
;
}
else
{
state
=
saveState
;
compress
=
true
;
}
// cut existing
int
firstIndexToRemove
;
if
(
compress
&&
m_d
->
currentNavigationHistoryPosition
>
0
)
{
...
...
src/plugins/coreplugin/editormanager/editormanager.h
View file @
fc79c737
...
...
@@ -132,7 +132,7 @@ public:
QList
<
IEditor
*>
editorsForFiles
(
QList
<
IFile
*>
files
)
const
;
//QList<EditorGroup *> editorGroups() const;
QList
<
IEditor
*>
editorHistory
()
const
;
void
addCurrentPositionToNavigationHistory
(
bool
compress
=
false
);
void
addCurrentPositionToNavigationHistory
(
const
QByteArray
&
saveState
=
QByteArray
()
);
bool
saveEditor
(
IEditor
*
editor
);
...
...
src/plugins/texteditor/basetexteditor.cpp
View file @
fc79c737
...
...
@@ -564,8 +564,6 @@ Core::IFile *BaseTextEditor::file()
void
BaseTextEditor
::
editorContentsChange
(
int
position
,
int
charsRemoved
,
int
charsAdded
)
{
d
->
m_contentsChanged
=
true
;
// add last edit position to history
Core
::
EditorManager
::
instance
()
->
addCurrentPositionToNavigationHistory
(
true
);
// Keep the line numbers and the block information for the text marks updated
if
(
charsRemoved
!=
0
)
{
...
...
@@ -750,7 +748,6 @@ void BaseTextEditor::cleanWhitespace()
void
BaseTextEditor
::
keyPressEvent
(
QKeyEvent
*
e
)
{
d
->
clearVisibleCollapsedBlock
();
QKeyEvent
*
original_e
=
e
;
...
...
@@ -764,8 +761,6 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
return
;
}
d
->
m_contentsChanged
=
false
;
bool
ro
=
isReadOnly
();
if
(
d
->
m_inBlockSelectionMode
)
{
...
...
@@ -964,7 +959,7 @@ void BaseTextEditor::setTextCursor(const QTextCursor &cursor)
slotSelectionChanged
();
}
void
BaseTextEditor
::
gotoLine
(
int
line
,
int
column
)
void
BaseTextEditor
::
gotoLine
(
int
line
,
int
column
,
bool
saveNewPosition
)
{
const
int
blockNumber
=
line
-
1
;
const
QTextBlock
&
block
=
document
()
->
findBlockByNumber
(
blockNumber
);
...
...
@@ -982,6 +977,8 @@ void BaseTextEditor::gotoLine(int line, int column)
setTextCursor
(
cursor
);
centerCursor
();
}
if
(
saveNewPosition
)
saveCurrentCursorPositionForNavigation
();
}
int
BaseTextEditor
::
position
(
ITextEditor
::
PositionOperation
posOp
,
int
at
)
const
...
...
@@ -1034,6 +1031,7 @@ QChar BaseTextEditor::characterAt(int pos) const
bool
BaseTextEditor
::
event
(
QEvent
*
e
)
{
d
->
m_contentsChanged
=
false
;
switch
(
e
->
type
())
{
case
QEvent
::
ShortcutOverride
:
e
->
ignore
();
// we are a really nice citizen
...
...
@@ -1117,7 +1115,7 @@ bool BaseTextEditor::restoreState(const QByteArray &state)
stream
>>
hval
;
stream
>>
lval
;
stream
>>
cval
;
gotoLine
(
lval
,
cval
);
gotoLine
(
lval
,
cval
,
false
);
verticalScrollBar
()
->
setValue
(
vval
);
horizontalScrollBar
()
->
setValue
(
hval
);
return
true
;
...
...
@@ -1251,6 +1249,7 @@ int BaseTextEditor::visibleWrapColumn() const
BaseTextEditorPrivate
::
BaseTextEditorPrivate
()
:
m_contentsChanged
(
false
),
m_lastCursorChangeWasInteresting
(
false
),
m_document
(
new
BaseTextDocument
()),
m_parenthesesMatchingEnabled
(
false
),
m_extraArea
(
0
),
...
...
@@ -1436,6 +1435,7 @@ QRectF TextEditDocumentLayout::blockBoundingRect(const QTextBlock &block) const
bool
BaseTextEditor
::
viewportEvent
(
QEvent
*
event
)
{
d
->
m_contentsChanged
=
false
;
if
(
event
->
type
()
==
QEvent
::
ContextMenu
)
{
const
QContextMenuEvent
*
ce
=
static_cast
<
QContextMenuEvent
*>
(
event
);
if
(
ce
->
reason
()
==
QContextMenuEvent
::
Mouse
&&
!
textCursor
().
hasSelection
())
...
...
@@ -2322,8 +2322,20 @@ void BaseTextEditor::slotUpdateRequest(const QRect &r, int dy)
slotUpdateExtraAreaWidth
();
}
void
BaseTextEditor
::
saveCurrentCursorPositionForNavigation
()
{
d
->
m_lastCursorChangeWasInteresting
=
true
;
d
->
m_tempState
=
saveState
();
}
void
BaseTextEditor
::
slotCursorPositionChanged
()
{
if
(
!
d
->
m_contentsChanged
&&
d
->
m_lastCursorChangeWasInteresting
)
{
Core
::
EditorManager
::
instance
()
->
addCurrentPositionToNavigationHistory
(
d
->
m_tempState
);
d
->
m_lastCursorChangeWasInteresting
=
false
;
}
else
if
(
d
->
m_contentsChanged
)
{
saveCurrentCursorPositionForNavigation
();
}
QList
<
QTextEdit
::
ExtraSelection
>
extraSelections
;
setExtraSelections
(
ParenthesesMatchingSelection
,
extraSelections
);
// clear
if
(
d
->
m_parenthesesMatchingEnabled
)
...
...
src/plugins/texteditor/basetexteditor.h
View file @
fc79c737
...
...
@@ -241,7 +241,7 @@ public:
// ITextEditor
void
gotoLine
(
int
line
,
int
column
=
0
);
void
gotoLine
(
int
line
,
int
column
=
0
,
bool
saveNewPosition
=
true
);
int
position
(
ITextEditor
::
PositionOperation
posOp
=
ITextEditor
::
Current
...
...
@@ -454,6 +454,7 @@ private:
void
handleHomeKey
(
bool
anchor
);
void
handleBackspaceKey
();
void
moveLineUpDown
(
bool
up
);
void
saveCurrentCursorPositionForNavigation
();
void
toggleBlockVisible
(
const
QTextBlock
&
block
);
QRect
collapseBox
(
const
QTextBlock
&
block
);
...
...
@@ -498,7 +499,7 @@ public:
int
currentLine
()
const
;
int
currentColumn
()
const
;
inline
void
gotoLine
(
int
line
,
int
column
=
0
)
{
e
->
gotoLine
(
line
,
column
);
}
void
gotoLine
(
int
line
,
int
column
=
0
)
{
e
->
gotoLine
(
line
,
column
);
}
inline
int
position
(
ITextEditor
::
PositionOperation
posOp
=
ITextEditor
::
Current
...
...
src/plugins/texteditor/basetexteditor_p.h
View file @
fc79c737
...
...
@@ -140,6 +140,7 @@ public:
BaseTextEditor
*
q
;
bool
m_contentsChanged
;
bool
m_lastCursorChangeWasInteresting
;
QList
<
QTextEdit
::
ExtraSelection
>
m_syntaxHighlighterSelections
;
QTextEdit
::
ExtraSelection
m_lineSelection
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment