Skip to content
GitLab
Menu
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
8d48c511
Commit
8d48c511
authored
Jul 13, 2010
by
Kai Koehne
Browse files
QmlJSEditor: Delay update of outline by 150 ms
parent
2bafdb71
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/plugins/qmljseditor/qmljseditor.cpp
View file @
8d48c511
...
...
@@ -80,7 +80,7 @@
enum
{
UPDATE_DOCUMENT_DEFAULT_INTERVAL
=
50
,
UPDATE_USES_DEFAULT_INTERVAL
=
150
,
UPDATE_
METHOD_BOX
_INTERVAL
=
150
UPDATE_
OUTLINE
_INTERVAL
=
150
// msecs after new semantic info has been arrived / cursor has moved
};
using
namespace
QmlJS
;
...
...
@@ -648,8 +648,13 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
connect
(
this
,
SIGNAL
(
textChanged
()),
this
,
SLOT
(
updateDocument
()));
connect
(
this
,
SIGNAL
(
textChanged
()),
this
,
SLOT
(
updateUses
()));
m_updateOutlineTimer
=
new
QTimer
(
this
);
m_updateOutlineTimer
->
setInterval
(
UPDATE_OUTLINE_INTERVAL
);
m_updateOutlineTimer
->
setSingleShot
(
true
);
connect
(
m_updateOutlineTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
updateOutlineNow
()));
m_updateMethodBoxTimer
=
new
QTimer
(
this
);
m_updateMethodBoxTimer
->
setInterval
(
UPDATE_
METHOD_BOX
_INTERVAL
);
m_updateMethodBoxTimer
->
setInterval
(
UPDATE_
OUTLINE
_INTERVAL
);
m_updateMethodBoxTimer
->
setSingleShot
(
true
);
connect
(
m_updateMethodBoxTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
updateMethodBoxIndex
()));
...
...
@@ -804,6 +809,8 @@ void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc)
const
SemanticHighlighter
::
Source
source
=
currentSource
(
/*force = */
true
);
m_semanticHighlighter
->
rehighlight
(
source
);
m_updateOutlineTimer
->
start
();
}
else
{
// show parsing errors
QList
<
QTextEdit
::
ExtraSelection
>
selections
;
...
...
@@ -830,12 +837,29 @@ void QmlJSTextEditor::jumpToMethod(int /*index*/)
setFocus
();
}
void
QmlJSTextEditor
::
updateOutlineNow
()
{
const
Snapshot
snapshot
=
m_modelManager
->
snapshot
();
Document
::
Ptr
document
=
snapshot
.
document
(
file
()
->
fileName
());
if
(
!
document
)
return
;
if
(
document
->
editorRevision
()
!=
editorRevision
())
{
m_updateOutlineTimer
->
start
();
return
;
}
m_outlineModel
->
update
(
document
);
updateMethodBoxIndex
();
}
void
QmlJSTextEditor
::
updateMethodBoxIndex
()
{
if
(
!
m_
semanticInfo
.
document
)
if
(
!
m_
outlineModel
->
document
()
)
return
;
if
(
m_
semanticInfo
.
document
->
editorRevision
()
!=
editorRevision
())
{
if
(
m_
outlineModel
->
document
()
->
editorRevision
()
!=
editorRevision
())
{
m_updateMethodBoxTimer
->
start
();
return
;
}
...
...
@@ -1375,9 +1399,6 @@ void QmlJSTextEditor::updateSemanticInfo(const SemanticInfo &semanticInfo)
FindDeclarations
findDeclarations
;
m_semanticInfo
.
declarations
=
findDeclarations
(
doc
->
ast
());
m_outlineModel
->
update
(
doc
);
updateMethodBoxIndex
();
QTreeView
*
treeView
=
static_cast
<
QTreeView
*>
(
m_methodCombo
->
view
());
treeView
->
expandAll
();
...
...
src/plugins/qmljseditor/qmljseditor.h
View file @
8d48c511
...
...
@@ -233,6 +233,7 @@ private slots:
void
updateDocument
();
void
updateDocumentNow
();
void
jumpToMethod
(
int
index
);
void
updateOutlineNow
();
void
updateMethodBoxIndex
();
void
updateMethodBoxToolTip
();
void
updateFileName
();
...
...
@@ -278,6 +279,7 @@ private:
QTimer
*
m_updateDocumentTimer
;
QTimer
*
m_updateUsesTimer
;
QTimer
*
m_semanticRehighlightTimer
;
QTimer
*
m_updateOutlineTimer
;
QTimer
*
m_updateMethodBoxTimer
;
QComboBox
*
m_methodCombo
;
QmlOutlineModel
*
m_outlineModel
;
...
...
src/plugins/qmljseditor/qmloutlinemodel.cpp
View file @
8d48c511
...
...
@@ -140,8 +140,15 @@ QmlOutlineModel::QmlOutlineModel(QObject *parent) :
{
}
QmlJS
::
Document
::
Ptr
QmlOutlineModel
::
document
()
const
{
return
m_document
;
}
void
QmlOutlineModel
::
update
(
QmlJS
::
Document
::
Ptr
doc
)
{
m_document
=
doc
;
m_treePos
.
clear
();
m_treePos
.
append
(
0
);
m_currentItem
=
invisibleRootItem
();
...
...
src/plugins/qmljseditor/qmloutlinemodel.h
View file @
8d48c511
...
...
@@ -19,6 +19,7 @@ public:
QmlOutlineModel
(
QObject
*
parent
=
0
);
QmlJS
::
Document
::
Ptr
document
()
const
;
void
update
(
QmlJS
::
Document
::
Ptr
doc
);
QModelIndex
enterElement
(
const
QString
&
typeName
,
const
QString
&
id
,
const
QmlJS
::
AST
::
SourceLocation
&
location
);
...
...
@@ -36,6 +37,7 @@ private:
QStandardItem
*
parentItem
();
QmlJS
::
Document
::
Ptr
m_document
;
QList
<
int
>
m_treePos
;
QStandardItem
*
m_currentItem
;
QmlJS
::
Icons
m_icons
;
...
...
Write
Preview
Supports
Markdown
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