#ifndef RELAYSCROLLBOX_H #define RELAYSCROLLBOX_H #include #include #include #include #include #include #include "itemwidget.h" #include "../items/item.h" #include "../items/itemstore.h" namespace Ui { class RelayScrollBox; } class ItemScrollBox : public QWidget { Q_OBJECT private: struct Tab { QScrollArea* scroller; QWidget* content; QSpacerItem* spacer; }; QMap tabs_; QMap> widgets_; Ui::RelayScrollBox *ui; QString pendingSelectedGroup_; signals: void deleteRequest(const ItemData& item); public: explicit ItemScrollBox(QWidget *parent = nullptr); ~ItemScrollBox(); void setItemStore(ItemStore* itemStore); void store(QJsonObject& json) const; void load(const QJsonObject& json); public slots: void addItem(std::weak_ptr item); void removeItem(const ItemData& item); void onItemUpdate(const ItemUpdateRequest& update); private: void ensureTabExists(const QString& groupName); void cleanupEmptyTabs(); private: void addItemToTabs(std::weak_ptr item); void removeItemFromTabs(const ItemData& item); }; #endif // RELAYSCROLLBOX_H