aboutsummaryrefslogtreecommitdiff
path: root/libs/installer_bsplugins/src/BSPluginInfo/RecordStructureModel.h
blob: 9592b241d96af314180e144c7e5d9fae39a9ccd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef BSPLUGININFO_RECORDSTRUCTUREMODEL_H
#define BSPLUGININFO_RECORDSTRUCTUREMODEL_H

#include "TESData/DataItem.h"
#include "TESData/PluginList.h"
#include "TESData/RecordPath.h"

#include <QAbstractItemModel>
#include <QList>

namespace BSPluginInfo
{

class RecordStructureModel final : public QAbstractItemModel
{
  Q_OBJECT

public:
  RecordStructureModel(TESData::PluginList* pluginList, TESData::Record* record,
                       const TESData::RecordPath& path, MOBase::IOrganizer* organizer);

  void refresh();

  [[nodiscard]] const QString& file(int index) const { return m_Files[index]; }

  QModelIndex index(int row, int column,
                    const QModelIndex& parent = QModelIndex()) const override;
  QModelIndex parent(const QModelIndex& index) const override;
  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
  int columnCount(const QModelIndex& parent = QModelIndex()) 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;

private:
  using Item = TESData::DataItem;

  void readFile(const TESData::RecordPath& path, const QString& filePath,
                int index = 0);

  QList<QString> m_Files;
  MOBase::IOrganizer* m_Organizer   = nullptr;
  TESData::PluginList* m_PluginList = nullptr;
  TESData::Record* m_Record         = nullptr;
  TESData::RecordPath m_Path;
  std::shared_ptr<Item> m_Root;
};

}  // namespace BSPluginInfo

#endif  // BSPLUGININFO_RECORDSTRUCTUREMODEL_H