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
Tobias Hunger
qt-creator
Commits
e871b7e3
Commit
e871b7e3
authored
Sep 27, 2010
by
Kai Koehne
Browse files
QmlOutline: Show functions in outline
Reviewed-by: Christiaan Janssen
parent
f1cb362d
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/libs/qmljs/images/func.png
0 → 100644
View file @
e871b7e3
583 Bytes
src/libs/qmljs/qmljs.qrc
View file @
e871b7e3
...
...
@@ -3,5 +3,6 @@
<file>images/element.png</file>
<file>images/property.png</file>
<file>images/publicmember.png</file>
<file>images/func.png</file>
</qresource>
</RCC>
src/libs/qmljs/qmljsicons.cpp
View file @
e871b7e3
...
...
@@ -50,6 +50,7 @@ public:
QIcon
elementIcon
;
QIcon
propertyIcon
;
QIcon
publicMemberIcon
;
QIcon
functionDeclarationIcon
;
QHash
<
QPair
<
QString
,
QString
>
,
QIcon
>
iconHash
;
QString
resourcePath
;
};
...
...
@@ -62,6 +63,7 @@ Icons::Icons()
m_d
->
elementIcon
=
QIcon
(
QLatin1String
(
":/qmljs/images/element.png"
));
m_d
->
propertyIcon
=
QIcon
(
QLatin1String
(
":/qmljs/images/property.png"
));
m_d
->
publicMemberIcon
=
QIcon
(
QLatin1String
(
":/qmljs/images/publicmember.png"
));
m_d
->
functionDeclarationIcon
=
QIcon
(
QLatin1String
(
":/qmljs/images/func.png"
));
}
Icons
::~
Icons
()
...
...
@@ -141,3 +143,8 @@ QIcon Icons::publicMemberIcon() const
{
return
m_d
->
publicMemberIcon
;
}
QIcon
Icons
::
functionDeclarationIcon
()
const
{
return
m_d
->
functionDeclarationIcon
;
}
src/libs/qmljs/qmljsicons.h
View file @
e871b7e3
...
...
@@ -53,6 +53,7 @@ public:
QIcon
objectDefinitionIcon
()
const
;
QIcon
scriptBindingIcon
()
const
;
QIcon
publicMemberIcon
()
const
;
QIcon
functionDeclarationIcon
()
const
;
private:
Icons
();
...
...
src/plugins/qmljseditor/qmloutlinemodel.cpp
View file @
e871b7e3
...
...
@@ -223,6 +223,19 @@ private:
m_model
->
leavePublicMember
();
}
bool
visit
(
AST
::
FunctionDeclaration
*
functionDeclaration
)
{
QModelIndex
index
=
m_model
->
enterFunctionDeclaration
(
functionDeclaration
);
m_nodeToIndex
.
insert
(
functionDeclaration
,
index
);
return
true
;
}
void
endVisit
(
AST
::
FunctionDeclaration
*
/*functionDeclaration*/
)
{
m_model
->
leaveFunctionDeclaration
();
}
QmlOutlineModel
*
m_model
;
QHash
<
AST
::
Node
*
,
QModelIndex
>
m_nodeToIndex
;
...
...
@@ -474,6 +487,23 @@ void QmlOutlineModel::leavePublicMember()
leaveNode
();
}
QModelIndex
QmlOutlineModel
::
enterFunctionDeclaration
(
AST
::
FunctionDeclaration
*
functionDeclaration
)
{
QMap
<
int
,
QVariant
>
objectData
;
objectData
.
insert
(
Qt
::
DisplayRole
,
functionDeclaration
->
name
->
asString
());
objectData
.
insert
(
ItemTypeRole
,
ElementBindingType
);
QmlOutlineItem
*
item
=
enterNode
(
objectData
,
functionDeclaration
,
0
,
m_icons
->
functionDeclarationIcon
());
return
item
->
index
();
}
void
QmlOutlineModel
::
leaveFunctionDeclaration
()
{
leaveNode
();
}
AST
::
Node
*
QmlOutlineModel
::
nodeForIndex
(
const
QModelIndex
&
index
)
const
{
QTC_ASSERT
(
index
.
isValid
()
&&
(
index
.
model
()
==
this
),
return
0
);
...
...
@@ -491,8 +521,11 @@ AST::SourceLocation QmlOutlineModel::sourceLocation(const QModelIndex &index) co
QTC_ASSERT
(
index
.
isValid
()
&&
(
index
.
model
()
==
this
),
return
location
);
AST
::
Node
*
node
=
nodeForIndex
(
index
);
if
(
node
)
{
if
(
AST
::
UiObjectMember
*
member
=
node
->
uiObjectMemberCast
())
if
(
AST
::
UiObjectMember
*
member
=
node
->
uiObjectMemberCast
())
{
location
=
getLocation
(
member
);
}
else
if
(
AST
::
ExpressionNode
*
expression
=
node
->
expressionCast
())
{
location
=
getLocation
(
expression
);
}
}
return
location
;
}
...
...
@@ -755,6 +788,15 @@ AST::SourceLocation QmlOutlineModel::getLocation(AST::UiObjectMember *objMember)
return
location
;
}
AST
::
SourceLocation
QmlOutlineModel
::
getLocation
(
AST
::
ExpressionNode
*
exprNode
)
{
AST
::
SourceLocation
location
;
location
.
offset
=
exprNode
->
firstSourceLocation
().
offset
;
location
.
length
=
exprNode
->
lastSourceLocation
().
offset
-
exprNode
->
firstSourceLocation
().
offset
+
exprNode
->
lastSourceLocation
().
length
;
return
location
;
}
QIcon
QmlOutlineModel
::
getIcon
(
AST
::
UiQualifiedId
*
qualifiedId
)
{
const
Interpreter
::
Value
*
value
=
m_context
->
evaluate
(
qualifiedId
);
...
...
src/plugins/qmljseditor/qmloutlinemodel.h
View file @
e871b7e3
...
...
@@ -89,6 +89,9 @@ private:
QModelIndex
enterPublicMember
(
QmlJS
::
AST
::
UiPublicMember
*
publicMember
);
void
leavePublicMember
();
QModelIndex
enterFunctionDeclaration
(
QmlJS
::
AST
::
FunctionDeclaration
*
functionDeclaration
);
void
leaveFunctionDeclaration
();
private:
QmlOutlineItem
*
enterNode
(
QMap
<
int
,
QVariant
>
data
,
QmlJS
::
AST
::
Node
*
node
,
QmlJS
::
AST
::
UiQualifiedId
*
idNode
,
const
QIcon
&
icon
);
void
leaveNode
();
...
...
@@ -102,6 +105,7 @@ private:
static
QString
asString
(
QmlJS
::
AST
::
UiQualifiedId
*
id
);
static
QmlJS
::
AST
::
SourceLocation
getLocation
(
QmlJS
::
AST
::
UiObjectMember
*
objMember
);
static
QmlJS
::
AST
::
SourceLocation
getLocation
(
QmlJS
::
AST
::
ExpressionNode
*
exprNode
);
QIcon
getIcon
(
QmlJS
::
AST
::
UiQualifiedId
*
objDef
);
QString
getAnnotation
(
QmlJS
::
AST
::
UiObjectInitializer
*
objInitializer
);
...
...
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