23 struct PerspectiveListModel::Impl
25 IPerspectiveRegistry& m_PerspReg;
26 QList<IPerspectiveDescriptor::Pointer> m_Perspectives;
27 const bool m_MarkDefault;
29 Impl(IPerspectiveRegistry& perspReg,
bool markDefault)
30 : m_PerspReg(perspReg)
32 , m_Perspectives(perspReg.GetPerspectives())
33 , m_MarkDefault(markDefault)
39 : QAbstractListModel(parent)
40 , d(new Impl(perspReg, markDefault))
50 return d->m_Perspectives.size();
55 if (index.row() < 0 || index.row() >= d->m_Perspectives.size() ||
61 if (role == Qt::DisplayRole)
64 QString label = desc->GetLabel();
67 QString def = d->m_PerspReg.GetDefaultPerspective();
68 if (desc->GetId() == def)
70 label +=
" (default)";
75 else if (role == Qt::DecorationRole)
78 return desc->GetImageDescriptor();
88 return desc->GetDescription();
95 if (role == Qt::DisplayRole)
99 return QString(
"Perspective");
107 if (!index.isValid())
return QString::null;
109 return d->m_Perspectives.at(index.row())->GetLabel();
114 return d->m_Perspectives.at(index.row());
120 for(
int i = 0; i < d->m_Perspectives.size(); ++i)
122 if (d->m_Perspectives.at(i)->GetId() == perspId)
131 return this->createIndex(index, 0);
133 return QModelIndex();
QString perspectiveName(const QModelIndex &index) const
~PerspectiveListModel() override
SmartPointer< IPerspectiveDescriptor > perspectiveDescriptor(const QModelIndex &index) const
QModelIndex index(const QString &perspId) const
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
PerspectiveListModel(IPerspectiveRegistry &perspReg, bool markDefault=true, QObject *parent=nullptr)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override