53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#pragma once
|
|
#include <vector>
|
|
#include <memory>
|
|
#include "item.h"
|
|
#include "itemsource.h"
|
|
|
|
#include <QJsonObject>
|
|
|
|
class ItemStore: public QObject
|
|
{
|
|
Q_OBJECT
|
|
private:
|
|
std::vector<std::shared_ptr<Item> > items_;
|
|
|
|
public:
|
|
|
|
ItemStore(QObject *parent = nullptr);
|
|
virtual ~ItemStore() {}
|
|
|
|
inline std::vector< std::shared_ptr<Item> >* getItems()
|
|
{
|
|
return &items_;
|
|
}
|
|
|
|
std::shared_ptr<Item> getItem(uint32_t id);
|
|
|
|
void registerItemSource(ItemSource* source);
|
|
void store(QJsonObject &json);
|
|
|
|
void clear();
|
|
|
|
signals:
|
|
|
|
void itemDeleted(ItemData item);
|
|
void itemAdded(std::weak_ptr<Item> Item);
|
|
void itemUpdated(std::weak_ptr<Item> Item);
|
|
void sigRefresh();
|
|
|
|
public slots:
|
|
|
|
void removeItem(const ItemData& item);
|
|
void addItem(std::shared_ptr<Item> item, bool inform = true);
|
|
void addItems(const std::vector<std::shared_ptr<Item>>& itemsIn, bool inform = true);
|
|
void replaceItems(const std::vector<std::shared_ptr<Item>>& items);
|
|
void updateItems(std::vector<ItemData> items, bool inform = true);
|
|
void updateItem(const ItemData& item, bool inform = true);
|
|
void refresh();
|
|
|
|
private slots:
|
|
void itemUpdateSlot(ItemData data);
|
|
};
|
|
|
|
extern ItemStore globalItems;
|