Bug fixes
This commit is contained in:
@ -128,6 +128,12 @@ bool Item::removeActor(Actor* actor)
|
||||
return false;
|
||||
}
|
||||
|
||||
void Item::removeAllActors()
|
||||
{
|
||||
for(unsigned int i = 0; i < actors_.size(); i++) delete actors_[i];
|
||||
actors_.clear();
|
||||
}
|
||||
|
||||
std::vector< Actor* >& Item::getActors()
|
||||
{
|
||||
return actors_;
|
||||
|
@ -59,6 +59,7 @@ public:
|
||||
bool hasActors();
|
||||
void addActor(Actor* actor);
|
||||
bool removeActor(Actor* actor);
|
||||
void removeAllActors();
|
||||
bool actorsActive() const;
|
||||
void setActorsActive(bool in);
|
||||
void informValue(uint8_t value);
|
||||
|
@ -91,7 +91,6 @@ void ItemStore::load(const QJsonObject& json, Microcontroller * const micro)
|
||||
if(itemsArray[i].isObject())
|
||||
{
|
||||
const QJsonObject itemObject = itemsArray[i].toObject();
|
||||
if(!itemObject["Name"].isObject()) qDebug()<<"no name";
|
||||
std::shared_ptr<Relay> newItem;
|
||||
if(itemObject["Type"].toString("") == "Relay")
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ MainObject::MainObject(QIODevice* ioDevice, const QString& settingsPathIn, const
|
||||
items.addItem(rgbItem);
|
||||
items.addItem(auxItem);
|
||||
|
||||
connect(&broadCast, &BroadCast::gotJson, this, &MainObject::load);
|
||||
connect(&broadCast, &BroadCast::gotJson, this, &MainObject::recivedJson);
|
||||
connect(&broadCast, &BroadCast::jsonRequested, this, &MainObject::sendJson);
|
||||
|
||||
if(master) load(getJsonObjectFromDisk(settingsPath));
|
||||
@ -68,9 +68,11 @@ void MainObject::store(QJsonObject &json)
|
||||
json.insert("Power", powerObject);
|
||||
}
|
||||
|
||||
void MainObject::load(const QJsonObject json)
|
||||
void MainObject::load(const QJsonObject& json)
|
||||
{
|
||||
items.clear();
|
||||
rgbItem->removeAllActors();
|
||||
auxItem->removeAllActors();
|
||||
items.addItem(rgbItem);
|
||||
items.addItem(auxItem);
|
||||
items.load(json, µ);
|
||||
@ -78,13 +80,18 @@ void MainObject::load(const QJsonObject json)
|
||||
qDebug()<<"aray size: "<<json.isEmpty();
|
||||
if(json["Items"].toArray().size() >= 2)
|
||||
{
|
||||
|
||||
rgbItem->load(json["Items"].toArray()[0].toObject());
|
||||
auxItem->load(json["Items"].toArray()[1].toObject());
|
||||
}
|
||||
micro.requestState();
|
||||
}
|
||||
|
||||
void MainObject::recivedJson(const QJsonObject json)
|
||||
{
|
||||
if(master)storeJsonObjectToDisk(json, settingsPath);
|
||||
load(json);
|
||||
}
|
||||
|
||||
void MainObject::sendJson()
|
||||
{
|
||||
QJsonObject json;
|
||||
|
@ -73,13 +73,15 @@ public:
|
||||
~MainObject();
|
||||
|
||||
void store(QJsonObject& json);
|
||||
void load(const QJsonObject& json);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
void load(const QJsonObject json);
|
||||
|
||||
void sendJson();
|
||||
void recivedJson(const QJsonObject json);
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user