Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
80b60b99
Commit
80b60b99
authored
Mar 15, 2010
by
mae
Browse files
Make code fodling persistent between session
Task-number: QTCREATORBUG-214
parent
62580fc0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/texteditor/basetexteditor.cpp
View file @
80b60b99
...
...
@@ -1539,13 +1539,29 @@ QByteArray BaseTextEditor::saveState() const
{
QByteArray
state
;
QDataStream
stream
(
&
state
,
QIODevice
::
WriteOnly
);
stream
<<
0
;
// version number
stream
<<
1
;
// version number
stream
<<
verticalScrollBar
()
->
value
();
stream
<<
horizontalScrollBar
()
->
value
();
int
line
,
column
;
convertPosition
(
textCursor
().
position
(),
&
line
,
&
column
);
stream
<<
line
;
stream
<<
column
;
// store code folding state
QList
<
int
>
collapsedBlocks
;
QTextBlock
block
=
document
()
->
firstBlock
();
while
(
block
.
isValid
())
{
if
(
block
.
userData
()
&&
static_cast
<
TextBlockUserData
*>
(
block
.
userData
())
->
collapsed
())
{
int
number
=
block
.
blockNumber
();
if
(
static_cast
<
TextBlockUserData
*>
(
block
.
userData
())
->
collapseMode
()
==
TextBlockUserData
::
CollapseThis
)
number
--
;
collapsedBlocks
+=
number
;
}
block
=
block
.
next
();
}
stream
<<
collapsedBlocks
;
return
state
;
}
...
...
@@ -1562,6 +1578,18 @@ bool BaseTextEditor::restoreState(const QByteArray &state)
stream
>>
hval
;
stream
>>
lval
;
stream
>>
cval
;
if
(
version
>=
1
)
{
QList
<
int
>
collapsedBlocks
;
stream
>>
collapsedBlocks
;
QTextDocument
*
doc
=
document
();
foreach
(
int
blockNumber
,
collapsedBlocks
)
{
QTextBlock
block
=
doc
->
findBlockByNumber
(
qMax
(
0
,
blockNumber
));
if
(
block
.
isValid
())
TextBlockUserData
::
doCollapse
(
block
,
false
);
}
}
d
->
m_lastCursorChangeWasInteresting
=
false
;
// avoid adding last position to history
gotoLine
(
lval
,
cval
);
verticalScrollBar
()
->
setValue
(
vval
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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