Details
-
Sub-task
-
Resolution: Done
-
P2: Important
-
None
-
5b5ae971045adebe40209150cf9e1cac6cc62191 (qt-creator/qt-creator/master)
Description
It would be nice add feature for auto-implementation of defined class. For example we have a class:
Object class difinition
class Object : public QObject { Q_OBJECT public: explicit Object(QObject* parent = 0); ~Object(); void foo(); private: void bar() const; int m_variable; };
If we are clicked RMB on "class Object" we must see menu with options like:
- Class auto-implementation
- Create implementation for class methods in .cpp file
- Create implementation for class methods in header
- Create implementation for class methods in header separate from class difinition
There is result of "Create implementation for class methods in .cpp file"
*.cpp file
Object::Object(QObject* parent = 0) : QObject(parent) /*auto-created stub*/ { } Object::~Object() /*auto-created stub*/ { } void Object::foo() /*already created NOTHING DO*/ { } void Object::bar() const /*auto-created stub*/ { }
There is result of "Create implementation for class methods in header"
*.h file
class Object : public QObject { Q_OBJECT public: explicit Object(QObject* parent = 0) : QObject(parent) {} ~Object() {} void foo() {} private: void bar() const {} int m_variable; };
There is result of "Create implementation for class methods in header separate from class difinition"
*.h file
class Object : public QObject { Q_OBJECT public: explicit Object(QObject* parent = 0); ~Object(); void foo(); private: void bar() const; int m_variable; }; Object::Object(QObject* parent = 0) : QObject(parent) /*auto-created stub*/ { } Object::~Object() /*auto-created stub*/ { } void Object::foo() /*already created NOTHING DO*/ { } void Object::bar() const /*auto-created stub*/ { }
Also we would auto-create stubs for Q_PROPERTY macros. User click on class variable and select menu action like:
- Meta-Object system
- Create stubs for member: "m_variable"
And our class seeing like this:
*.h file
class Object : public QObject { Q_OBJECT Q_PROPERTY(int variable READ variable WRITE setVariable) /*auto-created stub*/ public: explicit Object(QObject* parent = 0); ~Object(); void foo(); int variable() const {return m_variable;} /*auto-created stub*/ void setVariable(int variable) {m_variable = variable;} /*auto-created stub*/ private: void bar() const; int m_variable; };
Attachments
For Gerrit Dashboard: QTCREATORBUG-1532 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
310832,43 | CppEditor: Introduce QuickFix settings and unify getter/setter generation | master | qt-creator/qt-creator | Status: MERGED | +2 | 0 |