2023-08-06 08:48:11 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-07-08 09:13:02 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QAbstractItemModel>
|
2023-07-09 10:54:27 -04:00
|
|
|
#include <QFutureWatcher>
|
|
|
|
|
|
|
|
#include "gearview.h"
|
2023-07-08 09:13:02 -04:00
|
|
|
|
2023-10-12 23:44:48 -04:00
|
|
|
enum class TreeType { Root, Category, Item };
|
2023-07-08 09:13:02 -04:00
|
|
|
|
|
|
|
struct TreeInformation {
|
|
|
|
TreeType type;
|
|
|
|
std::optional<Slot> slotType;
|
2023-10-12 23:44:48 -04:00
|
|
|
TreeInformation *parent = nullptr;
|
2023-07-08 09:13:02 -04:00
|
|
|
std::optional<GearInfo> gear;
|
|
|
|
int row = 0;
|
|
|
|
|
2023-10-12 23:44:48 -04:00
|
|
|
std::vector<TreeInformation *> children;
|
2023-07-08 09:13:02 -04:00
|
|
|
};
|
|
|
|
|
2023-10-12 23:44:48 -04:00
|
|
|
class GearListModel : public QAbstractItemModel
|
|
|
|
{
|
2023-07-08 09:13:02 -04:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2023-10-12 23:44:48 -04:00
|
|
|
explicit GearListModel(GameData *data, QObject *parent = nullptr);
|
2023-07-08 09:13:02 -04:00
|
|
|
|
2023-10-12 23:44:48 -04:00
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
2023-07-08 09:13:02 -04:00
|
|
|
|
2023-10-12 23:44:48 -04:00
|
|
|
QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
QModelIndex parent(const QModelIndex &child) const override;
|
2023-07-08 09:13:02 -04:00
|
|
|
|
2023-10-12 23:44:48 -04:00
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
2023-07-08 09:13:02 -04:00
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
|
|
|
2023-10-12 23:44:48 -04:00
|
|
|
std::optional<GearInfo> getGearFromIndex(const QModelIndex &index);
|
2023-07-08 09:13:02 -04:00
|
|
|
|
|
|
|
private:
|
2023-07-09 10:54:27 -04:00
|
|
|
void exdFinished(int index);
|
|
|
|
void finished();
|
|
|
|
|
2023-10-12 23:44:48 -04:00
|
|
|
QFutureWatcher<physis_EXD> *exdFuture;
|
2023-07-09 10:54:27 -04:00
|
|
|
|
2023-07-08 09:13:02 -04:00
|
|
|
std::vector<GearInfo> gears;
|
|
|
|
QStringList slotNames;
|
|
|
|
|
2023-10-12 23:44:48 -04:00
|
|
|
GameData *gameData = nullptr;
|
|
|
|
TreeInformation *rootItem = nullptr;
|
2023-07-08 09:13:02 -04:00
|
|
|
};
|