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
Marco Bubke
flatpak-qt-creator
Commits
eca8693e
Commit
eca8693e
authored
Jul 05, 2010
by
Roberto Raggi
Browse files
Use the correct scope name when inserting QCoreApplication::translate().
parent
793ef6a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppquickfix.cpp
View file @
eca8693e
...
...
@@ -929,27 +929,16 @@ public:
}
// We need to do a QCA::translate, so we need a context.
// Use fully qualified class name:
QList
<
ClassOrNamespace
*>
stack
;
if
(
b
)
{
stack
.
append
(
b
);
while
(
b
->
parent
())
{
b
=
b
->
parent
();
stack
.
prepend
(
b
);
}
}
foreach
(
ClassOrNamespace
*
current
,
stack
)
{
foreach
(
Symbol
*
s
,
current
->
symbols
())
{
if
(
!
s
||
!
s
->
name
()
||
!
s
->
name
()
->
identifier
()
||
!
s
->
name
()
->
identifier
()
->
chars
())
{
continue
;
}
m_context
+=
s
->
name
()
->
identifier
()
->
chars
();
m_context
.
append
(
"::"
);
}
Overview
oo
;
foreach
(
const
Name
*
n
,
LookupContext
::
fullyQualifiedName
(
function
))
{
if
(
!
m_context
.
isEmpty
())
m_context
.
append
(
QLatin1String
(
"::"
));
m_context
.
append
(
oo
.
prettyName
(
n
));
}
if
(
m_context
.
size
()
>=
2
)
m_context
.
chop
(
2
);
else
if
(
m_context
.
isEmpty
())
if
(
m_context
.
isEmpty
())
m_context
.
append
(
"GLOBAL"
);
}
}
...
...
@@ -964,15 +953,15 @@ public:
ChangeSet
changes
;
const
int
startPos
=
startOf
(
m_literal
);
Q
ByteArray
replacement
(
"tr("
);
Q
String
replacement
(
"tr("
);
if
(
m_option
==
useQCoreApplicationTranslate
)
{
replacement
=
(
"QCoreApplication::translate(
\"
"
);
replacement
=
QLatin1String
(
"QCoreApplication::translate(
\"
"
);
replacement
+=
m_context
;
replacement
+=
"
\"
, "
;
replacement
+=
QLatin1String
(
"
\"
, "
)
;
}
changes
.
insert
(
startPos
,
replacement
);
changes
.
insert
(
endOf
(
m_literal
),
")"
);
changes
.
insert
(
endOf
(
m_literal
),
QLatin1String
(
")"
)
)
;
refactoringChanges
()
->
changeFile
(
fileName
(),
changes
);
}
...
...
@@ -980,7 +969,7 @@ public:
private:
ExpressionAST
*
m_literal
;
TranslationOption
m_option
;
Q
ByteArray
m_context
;
Q
String
m_context
;
};
class
CStringToNSString
:
public
CppQuickFixOperation
...
...
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