27 struct PerspectiveListModel::Impl
29 IPerspectiveRegistry& m_PerspReg;
30 QList<IPerspectiveDescriptor::Pointer> m_Perspectives;
31 const bool m_MarkDefault;
33 Impl(IPerspectiveRegistry& perspReg,
bool markDefault)
34 : m_PerspReg(perspReg)
36 , m_Perspectives(perspReg.GetPerspectives())
37 , m_MarkDefault(markDefault)
43 : QAbstractListModel(parent)
44 , d(new Impl(perspReg, markDefault))
54 return d->m_Perspectives.size();
59 if (index.row() < 0 || index.row() >= d->m_Perspectives.size() ||
65 if (role == Qt::DisplayRole)
68 QString label = desc->GetLabel();
71 QString def = d->m_PerspReg.GetDefaultPerspective();
72 if (desc->GetId() == def)
74 label +=
" (default)";
79 else if (role == Qt::DecorationRole)
82 return desc->GetImageDescriptor();
92 return desc->GetDescription();
99 if (role == Qt::DisplayRole)
103 return QString(
"Perspective");
111 if (!index.isValid())
return QString::null;
113 return d->m_Perspectives.at(index.row())->GetLabel();
118 return d->m_Perspectives.at(index.row());
124 for(
int i = 0; i < d->m_Perspectives.size(); ++i)
126 if (d->m_Perspectives.at(i)->GetId() == perspId)
135 return this->createIndex(index, 0);
137 return QModelIndex();
QModelIndex index(const QString &perspId) const
SmartPointer< IPerspectiveDescriptor > perspectiveDescriptor(const QModelIndex &index) const
QString perspectiveName(const QModelIndex &index) 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