Finish lerge refactor of systems
This commit is contained in:
parent
6d742e60db
commit
913d7df56d
36 changed files with 614 additions and 634 deletions
38
src/items/itemloadersource.cpp
Normal file
38
src/items/itemloadersource.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#include "itemloadersource.h"
|
||||
|
||||
#include <QJsonArray>
|
||||
|
||||
ItemLoaderSource::ItemLoaderSource(const QJsonObject& json, QObject *parent):
|
||||
ItemSource{parent},
|
||||
json(json)
|
||||
{
|
||||
}
|
||||
|
||||
void ItemLoaderSource::refresh()
|
||||
{
|
||||
std::vector<std::shared_ptr<Item>> items;
|
||||
const QJsonArray itemsArray(json["Items"].toArray());
|
||||
for(int i = 0; i < itemsArray.size(); ++i)
|
||||
{
|
||||
if(!itemsArray[i].isObject())
|
||||
continue;
|
||||
|
||||
const QJsonObject itemObject = itemsArray[i].toObject();
|
||||
std::shared_ptr<Item> newItem = Item::loadItem(itemObject);
|
||||
if(newItem)
|
||||
{
|
||||
items.push_back(newItem);
|
||||
qDebug()<<"Loaded item"<<newItem->getName();
|
||||
}
|
||||
}
|
||||
gotItems(items);
|
||||
}
|
||||
|
||||
void ItemLoaderSource::updateJson(const QJsonObject& json)
|
||||
{
|
||||
this->json = json;
|
||||
}
|
||||
|
||||
ItemLoaderSource::~ItemLoaderSource()
|
||||
{}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue