1
Fork 0
mirror of https://github.com/redstrate/Novus.git synced 2025-04-25 05:17:44 +00:00
novus/mdlviewer/include/gearlistmodel.h
Joshua Goins 47d612eb8f Add file cache and concurrent item loading to speed up mdlviewer
Instead of extracting item sheets one at a time, it's now done on
multiple threads. Loading gear is now faster since reused files are
cached, switching between races is still wasteful, but it's a good
enough improvement for now.
2023-07-09 10:54:27 -04:00

52 lines
No EOL
1.3 KiB
C++

#pragma once
#include <QAbstractItemModel>
#include <QFutureWatcher>
#include "gearview.h"
enum class TreeType {
Root,
Category,
Item
};
struct TreeInformation {
TreeType type;
std::optional<Slot> slotType;
TreeInformation* parent = nullptr;
std::optional<GearInfo> gear;
int row = 0;
std::vector<TreeInformation*> 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<GearInfo> getGearFromIndex(const QModelIndex& index);
private:
void exdFinished(int index);
void finished();
QFutureWatcher<physis_EXD>* exdFuture;
std::vector<GearInfo> gears;
QStringList slotNames;
GameData* gameData = nullptr;
TreeInformation* rootItem = nullptr;
};