// SPDX-FileCopyrightText: 2023 Joshua Goins // SPDX-License-Identifier: GPL-3.0-or-later #pragma once #include #include #include "gearview.h" enum class TreeType { Root, Category, Item }; struct TreeInformation { TreeType type; std::optional slotType; TreeInformation* parent = nullptr; std::optional gear; int row = 0; std::vector children; }; class GearListModel : public QAbstractItemModel { Q_OBJECT public: explicit GearListModel(GameData* data); int rowCount(const QModelIndex& parent = QModelIndex()) const override; int columnCount(const QModelIndex& parent = QModelIndex()) const override; QModelIndex index(int row, int column = 0, const QModelIndex& parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex& child) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; std::optional getGearFromIndex(const QModelIndex& index); private: void exdFinished(int index); void finished(); QFutureWatcher* exdFuture; std::vector gears; QStringList slotNames; GameData* gameData = nullptr; TreeInformation* rootItem = nullptr; };