Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
flatpak-qt-creator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
b74fcb77
Commit
b74fcb77
authored
Mar 02, 2009
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache the UTF-8 encoded contents of the text editors, and some cleanup in updateEditorSelections().
parent
a8cfda0d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
14 deletions
+22
-14
src/plugins/cpptools/cppmodelmanager.cpp
src/plugins/cpptools/cppmodelmanager.cpp
+13
-7
src/plugins/cpptools/cppmodelmanager.h
src/plugins/cpptools/cppmodelmanager.h
+1
-1
src/plugins/cpptools/cpptoolseditorsupport.cpp
src/plugins/cpptools/cpptoolseditorsupport.cpp
+6
-4
src/plugins/cpptools/cpptoolseditorsupport.h
src/plugins/cpptools/cpptoolseditorsupport.h
+2
-2
No files found.
src/plugins/cpptools/cppmodelmanager.cpp
View file @
b74fcb77
...
...
@@ -662,7 +662,7 @@ QMap<QString, QByteArray> CppModelManager::buildWorkingCopyList()
TextEditor
::
ITextEditor
*
textEditor
=
it
.
key
();
CppEditorSupport
*
editorSupport
=
it
.
value
();
QString
fileName
=
textEditor
->
file
()
->
fileName
();
workingCopy
[
fileName
]
=
editorSupport
->
contents
()
.
toUtf8
()
;
workingCopy
[
fileName
]
=
editorSupport
->
contents
();
}
// add the project configuration file
...
...
@@ -846,12 +846,12 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
QList
<
Editor
>
todo
;
foreach
(
const
Editor
&
e
,
todo
)
{
if
(
e
.
widget
!=
ed
)
if
(
e
.
textEditor
!=
textEditor
)
todo
.
append
(
e
);
}
Editor
e
;
e
.
widget
=
ed
;
e
.
textEditor
=
textEditor
;
e
.
selections
=
selections
;
e
.
ifdefedOutBlocks
=
blockRanges
;
todo
.
append
(
e
);
...
...
@@ -870,16 +870,22 @@ void CppModelManager::postEditorUpdate()
void
CppModelManager
::
updateEditorSelections
()
{
foreach
(
const
Editor
&
ed
,
m_todo
)
{
if
(
!
ed
.
widget
)
if
(
!
ed
.
textEditor
)
continue
;
ed
.
widget
->
setExtraSelections
(
TextEditor
::
BaseTextEditor
::
CodeWarningsSelection
,
ed
.
selections
);
TextEditor
::
ITextEditor
*
textEditor
=
ed
.
textEditor
;
TextEditor
::
BaseTextEditor
*
editor
=
qobject_cast
<
TextEditor
::
BaseTextEditor
*>
(
textEditor
->
widget
());
if
(
!
editor
)
continue
;
editor
->
setExtraSelections
(
TextEditor
::
BaseTextEditor
::
CodeWarningsSelection
,
ed
.
selections
);
ed
.
widget
->
setIfdefedOutBlocks
(
ed
.
ifdefedOutBlocks
);
ed
itor
->
setIfdefedOutBlocks
(
ed
.
ifdefedOutBlocks
);
}
m_todo
.
clear
();
}
void
CppModelManager
::
onProjectAdded
(
ProjectExplorer
::
Project
*
)
...
...
src/plugins/cpptools/cppmodelmanager.h
View file @
b74fcb77
...
...
@@ -167,7 +167,7 @@ private:
mutable
QMutex
mutex
;
struct
Editor
{
QPointer
<
TextEditor
::
BaseTextEditor
>
widget
;
QPointer
<
TextEditor
::
ITextEditor
>
textEditor
;
QList
<
QTextEdit
::
ExtraSelection
>
selections
;
QList
<
TextEditor
::
BaseTextEditor
::
BlockRange
>
ifdefedOutBlocks
;
};
...
...
src/plugins/cpptools/cpptoolseditorsupport.cpp
View file @
b74fcb77
...
...
@@ -66,12 +66,12 @@ void CppEditorSupport::setTextEditor(TextEditor::ITextEditor *textEditor)
updateDocument
();
}
Q
String
CppEditorSupport
::
contents
()
Q
ByteArray
CppEditorSupport
::
contents
()
{
if
(
!
_textEditor
)
return
Q
String
();
return
Q
ByteArray
();
else
if
(
!
_cachedContents
.
isEmpty
())
_cachedContents
=
_textEditor
->
contents
();
_cachedContents
=
_textEditor
->
contents
()
.
toUtf8
()
;
return
_cachedContents
;
}
...
...
@@ -96,13 +96,15 @@ void CppEditorSupport::updateDocument()
void
CppEditorSupport
::
updateDocumentNow
()
{
qDebug
()
<<
"*** update document now"
;
if
(
_documentParser
.
isRunning
())
{
_updateDocumentTimer
->
start
(
_updateDocumentInterval
);
}
else
{
_updateDocumentTimer
->
stop
();
QStringList
sourceFiles
(
_textEditor
->
file
()
->
fileName
());
_cachedContents
=
_textEditor
->
contents
();
_cachedContents
=
_textEditor
->
contents
()
.
toUtf8
()
;
_documentParser
=
_modelManager
->
refreshSourceFiles
(
sourceFiles
);
}
}
...
...
src/plugins/cpptools/cpptoolseditorsupport.h
View file @
b74fcb77
...
...
@@ -61,7 +61,7 @@ public:
int
updateDocumentInterval
()
const
;
void
setUpdateDocumentInterval
(
int
updateDocumentInterval
);
Q
String
contents
();
Q
ByteArray
contents
();
// UTF-8 encoded
Q_SIGNALS:
void
contentsChanged
();
...
...
@@ -78,7 +78,7 @@ private:
QTimer
*
_updateDocumentTimer
;
int
_updateDocumentInterval
;
QFuture
<
void
>
_documentParser
;
Q
String
_cachedContents
;
Q
ByteArray
_cachedContents
;
};
}
// namespace Internal
...
...
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