#include "CLayerModel.h" #include "Editor/UICommon.h" #include CLayerModel::CLayerModel(QObject *pParent) : QAbstractListModel(pParent) { } CLayerModel::~CLayerModel() = default; int CLayerModel::rowCount(const QModelIndex& /*parent*/) const { return mpArea ? static_cast(mpArea->NumScriptLayers()) : 0; } QVariant CLayerModel::data(const QModelIndex &index, int role) const { if (mpArea && (role == Qt::DisplayRole) && (index.row() < rowCount(QModelIndex()))) return TO_QSTRING(Layer(index)->Name()); return QVariant(); } void CLayerModel::SetArea(CGameArea *pArea) { mpArea = pArea; emit layoutChanged(); } CScriptLayer* CLayerModel::Layer(const QModelIndex& index) const { if (!mpArea) return nullptr; const size_t NumLayers = mpArea->NumScriptLayers(); if (index.row() < static_cast(NumLayers)) return mpArea->ScriptLayer(static_cast(index.row())); return nullptr; }