wip item refactor

This commit is contained in:
Carl Philipp Klemm 2026-03-30 16:59:32 +02:00
parent 5cd7c782ce
commit 18cf2b01bd
6 changed files with 60 additions and 18 deletions

View file

@ -79,7 +79,7 @@ bool ItemData::hasChanged(const ItemData& other)
return false;
}
bool ItemData::isHidden()
bool ItemData::isHidden() const
{
return hidden_;
}
@ -145,6 +145,30 @@ void Item::load(const QJsonObject &json, const bool preserve)
}
}
Item& Item::operator=(const ItemData& other)
{
name_ = other.getName();
value_ = other.getValue();
itemId_ = other.id();
hidden_ = other.isHidden();
return *this;
}
void Item::requestUpdate(ItemUpdateRequest update)
{
if(!hasChanged(update.data))
return;
if(update.type == ITEM_UPDATE_USER || (update.type == ITEM_UPDATE_ACTOR && !override_) || update.type == ITEM_UPDATE_REMOTE)
{
if(programMode == PROGRAM_MODE_PRIMARY || programMode == PROGRAM_MODE_HEADLESS_PRIMARY)
enactValue(update.data.getValue());
*this = update.data;
update.data = *this;
updated(update);
}
}
void Item::actorSetValue(uint8_t value)
{
if(!override_ && (programMode == PROGRAM_MODE_PRIMARY || programMode == PROGRAM_MODE_HEADLESS_PRIMARY))
@ -155,6 +179,7 @@ void Item::setValue(uint8_t value)
{
qDebug()<<__func__;
informValue(value);
updated(*this);
if(programMode == PROGRAM_MODE_PRIMARY || programMode == PROGRAM_MODE_HEADLESS_PRIMARY)
enactValue(value);
}
@ -165,7 +190,6 @@ void Item::informValue(uint8_t value)
{
value_ = value;
valueChanged(value_);
updated(*this);
}
}