wip item refactor
This commit is contained in:
parent
5cd7c782ce
commit
18cf2b01bd
6 changed files with 60 additions and 18 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue