X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fsyncableobject.cpp;h=825b97db32d62a2a787fe1a6e7b533f8581c5969;hb=02a188baf63969b6e6f14c49d305c79b61a2cb06;hp=9fd7704f0122d29154ebb3c0f38b07c8b7382e91;hpb=c1cf157116de7fc3da96203aa6f03c38c7ebb650;p=quassel.git diff --git a/src/common/syncableobject.cpp b/src/common/syncableobject.cpp index 9fd7704f..825b97db 100644 --- a/src/common/syncableobject.cpp +++ b/src/common/syncableobject.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2018 by the Quassel Project * + * Copyright (C) 2005-2020 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -27,20 +27,22 @@ #include "util.h" SyncableObject::SyncableObject(QObject* parent) - : QObject(parent) + : SyncableObject(QString{}, parent) {} SyncableObject::SyncableObject(const QString& objectName, QObject* parent) : QObject(parent) { + _objectName = objectName; setObjectName(objectName); -} -SyncableObject::SyncableObject(const SyncableObject& other, QObject* parent) - : QObject(parent) - , _initialized(other._initialized) - , _allowClientUpdates(other._allowClientUpdates) -{} + connect(this, &QObject::objectNameChanged, this, [this](auto&& newName) { + for (auto&& proxy : _signalProxies) { + proxy->renameObject(this, newName, _objectName); + } + _objectName = newName; + }); +} SyncableObject::~SyncableObject() { @@ -52,16 +54,6 @@ SyncableObject::~SyncableObject() } } -SyncableObject& SyncableObject::operator=(const SyncableObject& other) -{ - if (this == &other) - return *this; - - _initialized = other._initialized; - _allowClientUpdates = other._allowClientUpdates; - return *this; -} - bool SyncableObject::isInitialized() const { return _initialized; @@ -156,17 +148,6 @@ bool SyncableObject::setInitValue(const QString& property, const QVariant& value return QMetaObject::invokeMethod(this, handlername.toLatin1(), param); } -void SyncableObject::renameObject(const QString& newName) -{ - const QString oldName = objectName(); - if (oldName != newName) { - setObjectName(newName); - foreach (SignalProxy* proxy, _signalProxies) { - proxy->renameObject(this, newName, oldName); - } - } -} - void SyncableObject::update(const QVariantMap& properties) { fromVariantMap(properties);