Utils: Make AspectContainer a QObject

... and add a 'void applied()' signal.

I actually wanted to avoid that, but it seems to be a recurring
pattern of usage to do something on top of plain apply for all
children, like triggering IVersionControl::configurationChanged
in the VCS plugins.

Change-Id: Ib64c3147c6ba30b178237e51a3a377a291c550f2
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2021-03-31 12:37:34 +02:00
parent c24291648b
commit 6b82af5990
4 changed files with 13 additions and 6 deletions

View File

@@ -2089,8 +2089,8 @@ public:
} // Internal
AspectContainer::AspectContainer()
: d(new Internal::AspectContainerPrivate)
AspectContainer::AspectContainer(QObject *parent)
: QObject(parent), d(new Internal::AspectContainerPrivate)
{}
/*!
@@ -2192,6 +2192,8 @@ void AspectContainer::apply()
{
for (BaseAspect *aspect : qAsConst(d->m_items))
aspect->apply();
emit applied();
}
void AspectContainer::cancel()

View File

@@ -483,10 +483,12 @@ private:
std::unique_ptr<Internal::TextDisplayPrivate> d;
};
class QTCREATOR_UTILS_EXPORT AspectContainer
class QTCREATOR_UTILS_EXPORT AspectContainer : public QObject
{
Q_OBJECT
public:
AspectContainer();
AspectContainer(QObject *parent = nullptr);
~AspectContainer();
AspectContainer(const AspectContainer &) = delete;
@@ -547,6 +549,9 @@ public:
const_iterator begin() const;
const_iterator end() const;
signals:
void applied();
private:
std::unique_ptr<Internal::AspectContainerPrivate> d;
};

View File

@@ -33,7 +33,7 @@
namespace Docker {
namespace Internal {
class DockerSettings : public QObject, public Utils::AspectContainer
class DockerSettings : public Utils::AspectContainer
{
public:
DockerSettings();

View File

@@ -32,7 +32,7 @@
namespace QmakeProjectManager {
namespace Internal {
class QmakeSettings : public QObject, public Utils::AspectContainer
class QmakeSettings : public Utils::AspectContainer
{
Q_OBJECT