/***************************************************************************
- * Copyright (C) 2005-2018 by the Quassel Project *
+ * Copyright (C) 2005-2022 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#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()
{
}
}
-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;
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);