Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
9b656eb1
Commit
9b656eb1
authored
14 years ago
by
Erik Verbruggen
Browse files
Options
Downloads
Patches
Plain Diff
Changed the description to include the new file name.
parent
2ec04fb6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp
+16
-14
16 additions, 14 deletions
src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp
with
16 additions
and
14 deletions
src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp
+
16
−
14
View file @
9b656eb1
...
...
@@ -75,26 +75,27 @@ static QString getIdProperty(UiObjectDefinition *def)
class
Operation
:
public
QmlJSQuickFixOperation
{
UiObjectDefinition
*
_objDef
;
UiObjectDefinition
*
m_objDef
;
QString
m_componentName
;
public:
Operation
(
const
QmlJSQuickFixState
&
state
,
UiObjectDefinition
*
objDef
)
:
QmlJSQuickFixOperation
(
state
,
0
)
,
_objDef
(
objDef
)
,
m
_objDef
(
objDef
)
{
Q_ASSERT
(
m_objDef
!=
0
);
m_componentName
=
getIdProperty
(
m_objDef
);
m_componentName
[
0
]
=
m_componentName
.
at
(
0
).
toUpper
();
setDescription
(
QCoreApplication
::
translate
(
"QmlJSEditor::ComponentFromObjectDef"
,
"
Extract
Component
"
));
"
Move
Component
into '%1.qml'"
).
arg
(
m_componentName
));
}
virtual
void
createChanges
()
{
Q_ASSERT
(
_objDef
!=
0
);
QString
componentName
=
getIdProperty
(
_objDef
);
componentName
[
0
]
=
componentName
.
at
(
0
).
toUpper
();
const
QString
path
=
fileName
();
const
QString
newFileName
=
QFileInfo
(
path
).
path
()
+
QDir
::
separator
()
+
componentName
+
QLatin1String
(
".qml"
);
const
QString
newFileName
=
QFileInfo
(
fileName
()).
path
()
+
QDir
::
separator
()
+
m_componentName
+
QLatin1String
(
".qml"
);
QString
imports
;
UiProgram
*
prog
=
state
().
semanticInfo
().
document
->
qmlProgram
();
...
...
@@ -104,13 +105,13 @@ public:
imports
=
state
().
textOf
(
start
,
end
);
}
const
int
start
=
startPosition
(
_objDef
->
firstSourceLocation
());
const
int
end
=
startPosition
(
_objDef
->
lastSourceLocation
());
const
int
start
=
startPosition
(
m
_objDef
->
firstSourceLocation
());
const
int
end
=
startPosition
(
m
_objDef
->
lastSourceLocation
());
const
QString
txt
=
imports
+
state
().
textOf
(
start
,
end
)
+
QLatin1String
(
"}
\n
"
);
Utils
::
ChangeSet
changes
;
changes
.
replace
(
start
,
end
,
componentName
+
QLatin1String
(
" {
\n
"
));
changes
.
replace
(
start
,
end
,
m_
componentName
+
QLatin1String
(
" {
\n
"
));
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
refactoringChanges
()
->
reindent
(
fileName
(),
range
(
start
,
end
+
1
));
...
...
@@ -130,7 +131,8 @@ QList<QmlJSQuickFixOperation::Ptr> ComponentFromObjectDef::match(const QmlJSQuic
for
(
int
i
=
path
.
size
()
-
1
;
i
>=
0
;
--
i
)
{
Node
*
node
=
path
.
at
(
i
);
if
(
UiObjectDefinition
*
objDef
=
cast
<
UiObjectDefinition
*>
(
node
))
{
if
(
i
>
0
&&
!
cast
<
UiProgram
*>
(
path
.
at
(
i
-
1
)))
{
// node is not the root node
// check that the node is not the root node
if
(
i
>
0
&&
!
cast
<
UiProgram
*>
(
path
.
at
(
i
-
1
)))
{
if
(
!
getIdProperty
(
objDef
).
isEmpty
())
{
result
.
append
(
QmlJSQuickFixOperation
::
Ptr
(
new
Operation
(
state
,
objDef
)));
return
result
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment