CppEditor: Quick fix "Insert (Pure) Virtual Methods"

This quick fix inserts (pure) virtual functions of base classes to the
current class. For selecting the functions which should be inserted and
for choosing the insertion mode (only declarations or with definitions
inside, outside or in the implementation file) a dialog is shown.

Task-number: QTCREATORBUG-2210
Task-number: QTCREATORBUG-2692
Task-number: QTCREATORBUG-3908
Task-number: QTCREATORBUG-5868
Task-number: QTCREATORBUG-7982
Change-Id: I8e94905afcae4778986f4c3925a494e0c6b3b8ee
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
Lorenz Haas
2013-04-29 23:15:50 +02:00
committed by Nikolai Kosjar
parent 7ef611047f
commit d288e3999b
8 changed files with 1307 additions and 30 deletions

View File

@@ -42,33 +42,6 @@ using namespace CppTools;
namespace {
static QString generate(InsertionPointLocator::AccessSpec xsSpec)
{
switch (xsSpec) {
default:
case InsertionPointLocator::Public:
return QLatin1String("public:\n");
case InsertionPointLocator::Protected:
return QLatin1String("protected:\n");
case InsertionPointLocator::Private:
return QLatin1String("private:\n");
case InsertionPointLocator::PublicSlot:
return QLatin1String("public slots:\n");
case InsertionPointLocator::ProtectedSlot:
return QLatin1String("protected slots:\n");
case InsertionPointLocator::PrivateSlot:
return QLatin1String("private slots:\n");
case InsertionPointLocator::Signals:
return QLatin1String("signals:\n");
}
}
static int ordering(InsertionPointLocator::AccessSpec xsSpec)
{
static QList<InsertionPointLocator::AccessSpec> order = QList<InsertionPointLocator::AccessSpec>()
@@ -161,7 +134,7 @@ protected:
if (needsLeadingEmptyLine)
prefix += QLatin1String("\n");
if (needsPrefix)
prefix += generate(_xsSpec);
prefix += InsertionPointLocator::accessSpecToString(_xsSpec);
QString suffix;
if (needsSuffix)
@@ -299,6 +272,33 @@ InsertionLocation::InsertionLocation(const QString &fileName,
, m_column(column)
{}
QString InsertionPointLocator::accessSpecToString(InsertionPointLocator::AccessSpec xsSpec)
{
switch (xsSpec) {
default:
case InsertionPointLocator::Public:
return QLatin1String("public:\n");
case InsertionPointLocator::Protected:
return QLatin1String("protected:\n");
case InsertionPointLocator::Private:
return QLatin1String("private:\n");
case InsertionPointLocator::PublicSlot:
return QLatin1String("public slots:\n");
case InsertionPointLocator::ProtectedSlot:
return QLatin1String("protected slots:\n");
case InsertionPointLocator::PrivateSlot:
return QLatin1String("private slots:\n");
case InsertionPointLocator::Signals:
return QLatin1String("signals:\n");
}
}
InsertionPointLocator::InsertionPointLocator(const CppRefactoringChanges &refactoringChanges)
: m_refactoringChanges(refactoringChanges)
{

View File

@@ -89,6 +89,7 @@ public:
ProtectedSlot = Protected | SlotBit,
PrivateSlot = Private | SlotBit
};
static QString accessSpecToString(InsertionPointLocator::AccessSpec xsSpec);
public:
InsertionPointLocator(const CppRefactoringChanges &refactoringChanges);