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
Tobias Hunger
qt-creator
Commits
2ba49e4e
Commit
2ba49e4e
authored
Jul 08, 2010
by
Kai Koehne
Browse files
CppEditor: Reuse OverviewModel from text editor also in the outline pane
There's no use synchronizing the same model twice.
parent
1430358d
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppeditor.cpp
View file @
2ba49e4e
...
...
@@ -1417,6 +1417,11 @@ SemanticInfo CPPEditor::semanticInfo() const
return
m_lastSemanticInfo
;
}
CPlusPlus
::
OverviewModel
*
CPPEditor
::
overviewModel
()
const
{
return
m_overviewModel
;
}
bool
CPPEditor
::
isElectricCharacter
(
QChar
ch
)
const
{
if
(
ch
==
QLatin1Char
(
'{'
)
||
...
...
src/plugins/cppeditor/cppeditor.h
View file @
2ba49e4e
...
...
@@ -165,6 +165,7 @@ public:
unsigned
editorRevision
()
const
;
bool
isOutdated
()
const
;
SemanticInfo
semanticInfo
()
const
;
CPlusPlus
::
OverviewModel
*
overviewModel
()
const
;
virtual
void
paste
();
// reimplemented from BaseTextEditor
virtual
void
cut
();
// reimplemented from BaseTextEditor
...
...
src/plugins/cppeditor/cppoutline.cpp
View file @
2ba49e4e
...
...
@@ -6,8 +6,9 @@
#include
<coreplugin/ifile.h>
#include
<cplusplus/OverviewModel.h>
#include
<QtGui/QVBoxLayout>
#include
<QtCore/QDebug>
#include
<QtGui/QVBoxLayout>
#include
<QtCore/QTimer>
using
namespace
CppEditor
::
Internal
;
...
...
@@ -49,7 +50,7 @@ CppOutlineWidget::CppOutlineWidget(CPPEditor *editor) :
TextEditor
::
IOutlineWidget
(),
m_editor
(
editor
),
m_treeView
(
new
CppOutlineTreeView
(
this
)),
m_model
(
new
CPlusPlus
::
O
verviewModel
(
this
)),
m_model
(
m_editor
->
o
verviewModel
()),
m_proxyModel
(
new
CppOutlineFilterModel
(
this
)),
m_enableCursorSync
(
true
),
m_blockCursorSync
(
false
)
...
...
@@ -63,14 +64,8 @@ CppOutlineWidget::CppOutlineWidget(CPPEditor *editor) :
m_proxyModel
->
setSourceModel
(
m_model
);
m_treeView
->
setModel
(
m_proxyModel
);
CppTools
::
CppModelManagerInterface
*
modelManager
=
CppTools
::
CppModelManagerInterface
::
instance
();
connect
(
modelManager
,
SIGNAL
(
documentUpdated
(
CPlusPlus
::
Document
::
Ptr
)),
this
,
SLOT
(
updateOutline
(
CPlusPlus
::
Document
::
Ptr
)));
if
(
modelManager
->
snapshot
().
contains
(
editor
->
file
()
->
fileName
()))
{
updateOutline
(
modelManager
->
snapshot
().
document
(
editor
->
file
()
->
fileName
()));
}
connect
(
m_model
,
SIGNAL
(
modelReset
()),
this
,
SLOT
(
modelUpdated
()));
modelUpdated
();
connect
(
m_editor
,
SIGNAL
(
cursorPositionChanged
()),
this
,
SLOT
(
updateSelectionInTree
()));
...
...
@@ -85,18 +80,10 @@ void CppOutlineWidget::setCursorSynchronization(bool syncWithCursor)
updateSelectionInTree
();
}
void
CppOutlineWidget
::
updateOutline
(
CPlusPlus
::
Document
::
Ptr
document
)
void
CppOutlineWidget
::
modelUpdated
(
)
{
m_document
=
document
;
if
(
document
&&
m_editor
&&
(
document
->
fileName
()
==
m_editor
->
file
()
->
fileName
())
&&
(
document
->
editorRevision
()
==
m_editor
->
editorRevision
()))
{
if
(
debug
)
qDebug
()
<<
"CppOutline - rebuilding model"
;
m_model
->
rebuild
(
document
);
m_treeView
->
expandAll
();
updateSelectionInTree
();
}
m_treeView
->
expandAll
();
updateSelectionInTree
();
}
void
CppOutlineWidget
::
updateSelectionInTree
()
...
...
@@ -130,7 +117,8 @@ void CppOutlineWidget::updateSelectionInText(const QItemSelection &selection)
if
(
symbol
)
{
m_blockCursorSync
=
true
;
unsigned
line
,
column
;
m_document
->
translationUnit
()
->
getPosition
(
symbol
->
startOffset
(),
&
line
,
&
column
);
m_model
->
document
()
->
translationUnit
()
->
getPosition
(
symbol
->
startOffset
(),
&
line
,
&
column
);
if
(
debug
)
qDebug
()
<<
"CppOutline - moving cursor to"
<<
line
<<
column
-
1
;
...
...
@@ -161,9 +149,9 @@ QModelIndex CppOutlineWidget::indexForPosition(const QModelIndex &rootIndex, int
bool
CppOutlineWidget
::
positionInsideSymbol
(
unsigned
cursorLine
,
unsigned
cursorColumn
,
CPlusPlus
::
Symbol
*
symbol
)
const
{
if
(
!
m_document
)
if
(
!
m_
model
->
document
()
)
return
false
;
CPlusPlus
::
TranslationUnit
*
translationUnit
=
m_document
->
translationUnit
();
CPlusPlus
::
TranslationUnit
*
translationUnit
=
m_
model
->
document
()
->
translationUnit
();
unsigned
symbolStartLine
=
-
1
;
unsigned
symbolStartColumn
=
-
1
;
...
...
src/plugins/cppeditor/cppoutline.h
View file @
2ba49e4e
...
...
@@ -38,7 +38,7 @@ public:
virtual
void
setCursorSynchronization
(
bool
syncWithCursor
);
private
slots
:
void
updateOutline
(
CPlusPlus
::
Document
::
Ptr
document
);
void
modelUpdated
(
);
void
updateSelectionInTree
();
void
updateSelectionInText
(
const
QItemSelection
&
selection
);
...
...
@@ -52,7 +52,6 @@ private:
CppOutlineTreeView
*
m_treeView
;
CPlusPlus
::
OverviewModel
*
m_model
;
CppOutlineFilterModel
*
m_proxyModel
;
CPlusPlus
::
Document
::
Ptr
m_document
;
bool
m_enableCursorSync
;
bool
m_blockCursorSync
;
...
...
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