CppTools: accessSpecToString returns the plain name of AccessSpec

Change-Id: I840160a8f5b1c86d621f3334556a74ccb7176ba8
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Lorenz Haas
2015-02-08 10:40:41 +01:00
parent cedd9bf5e6
commit 711dbdec29
3 changed files with 11 additions and 21 deletions

View File

@@ -735,7 +735,7 @@ public:
const QString accessSpecString =
InsertionPointLocator::accessSpecToString(funcItem->accessSpec);
if (accessSpecString != lastAccessSpecString) {
declaration = accessSpecString + declaration;
declaration = accessSpecString + QLatin1String(":\n") + declaration;
if (!lastAccessSpecString.isEmpty()) // separate if not direct after the comment
declaration = QLatin1String("\n") + declaration;
lastAccessSpecString = accessSpecString;

View File

@@ -2367,19 +2367,9 @@ public:
, m_xsSpec(xsSpec)
, m_decl(decl)
{
QString type;
switch (xsSpec) {
case InsertionPointLocator::Public: type = QLatin1String("public"); break;
case InsertionPointLocator::Protected: type = QLatin1String("protected"); break;
case InsertionPointLocator::Private: type = QLatin1String("private"); break;
case InsertionPointLocator::PublicSlot: type = QLatin1String("public slot"); break;
case InsertionPointLocator::ProtectedSlot: type = QLatin1String("protected slot"); break;
case InsertionPointLocator::PrivateSlot: type = QLatin1String("private slot"); break;
default: break;
}
setDescription(QCoreApplication::translate("CppEditor::InsertDeclOperation",
"Add %1 Declaration").arg(type));
"Add %1 Declaration")
.arg(InsertionPointLocator::accessSpecToString(xsSpec)));
}
void perform()

View File

@@ -135,7 +135,7 @@ protected:
if (needsLeadingEmptyLine)
prefix += QLatin1String("\n");
if (needsPrefix)
prefix += InsertionPointLocator::accessSpecToString(_xsSpec);
prefix += InsertionPointLocator::accessSpecToString(_xsSpec) + QLatin1String(":\n");
QString suffix;
if (needsSuffix)
@@ -278,25 +278,25 @@ QString InsertionPointLocator::accessSpecToString(InsertionPointLocator::AccessS
switch (xsSpec) {
default:
case InsertionPointLocator::Public:
return QLatin1String("public:\n");
return QLatin1String("public");
case InsertionPointLocator::Protected:
return QLatin1String("protected:\n");
return QLatin1String("protected");
case InsertionPointLocator::Private:
return QLatin1String("private:\n");
return QLatin1String("private");
case InsertionPointLocator::PublicSlot:
return QLatin1String("public slots:\n");
return QLatin1String("public slots");
case InsertionPointLocator::ProtectedSlot:
return QLatin1String("protected slots:\n");
return QLatin1String("protected slots");
case InsertionPointLocator::PrivateSlot:
return QLatin1String("private slots:\n");
return QLatin1String("private slots");
case InsertionPointLocator::Signals:
return QLatin1String("signals:\n");
return QLatin1String("signals");
}
}