aboutsummaryrefslogtreecommitdiff
path: root/libs/installer_bsplugins/src/BSPluginInfo/PluginRecordModel.h
blob: b625e2d1cb48e9c6721a15cc00a5775c9fb7de29 (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
52
53
54
55
56
57
58
59
60
#ifndef BSPLUGININFO_PLUGINRECORDMODEL_H
#define BSPLUGININFO_PLUGINRECORDMODEL_H

#include "TESData/PluginList.h"

#include <imoinfo.h>

#include <QAbstractItemModel>

namespace BSPluginInfo
{

class PluginRecordModel final : public QAbstractItemModel
{
  Q_OBJECT

public:
  enum EColumn
  {
    COL_ID,
    COL_OWNER,
    COL_NAME,

    COL_COUNT
  };

  PluginRecordModel(MOBase::IOrganizer* organizer, TESData::PluginList* pluginList,
                    const QString& pluginName);

  [[nodiscard]] TESData::RecordPath getPath(const QModelIndex& index) const;

  QModelIndex index(int row, int column,
                    const QModelIndex& parent = QModelIndex()) const override;
  QModelIndex parent(const QModelIndex& index) const override;
  bool hasChildren(const QModelIndex& parent = QModelIndex()) const override;
  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
  int columnCount(const QModelIndex& parent = QModelIndex()) const override;

  bool canFetchMore(const QModelIndex& parent) const override;
  void fetchMore(const QModelIndex& parent) 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::FileEntry::TreeItem;

  static QString makeGroupName(TESFile::GroupData group);

  QString m_PluginName;
  MOBase::IOrganizer* m_Organizer   = nullptr;
  TESData::PluginList* m_PluginList = nullptr;
  TESData::FileEntry* m_FileEntry   = nullptr;
  Item* m_DataRoot                  = nullptr;
};

}  // namespace BSPluginInfo

#endif  // BSPLUGININFO_PLUGINRECORDMODEL_H