Skip to content
Snippets Groups Projects
Commit 1ec006bf authored by Matthias Puchner's avatar Matthias Puchner
Browse files

extend instrument tree model

parent 8c434f40
No related branches found
No related tags found
1 merge request!320Implement instrument library editor
...@@ -244,20 +244,17 @@ QVariant InstrumentsTreeModel::data(const QModelIndex& index, int role) const ...@@ -244,20 +244,17 @@ QVariant InstrumentsTreeModel::data(const QModelIndex& index, int role) const
if (role == Qt::TextAlignmentRole) if (role == Qt::TextAlignmentRole)
return QVariant(Qt::AlignLeft | Qt::AlignTop); return QVariant(Qt::AlignLeft | Qt::AlignTop);
if (role == Qt::DecorationRole) { if (role == Qt::DecorationRole)
if (item->is<GISASInstrumentItem>()) switch (instrumentType(item)) {
case Gisas:
return QIcon(":/images/gisas_instrument.svg"); return QIcon(":/images/gisas_instrument.svg");
case OffSpecular:
if (item->is<OffSpecularInstrumentItem>())
return QIcon(":/images/offspec_instrument.svg"); return QIcon(":/images/offspec_instrument.svg");
case Specular:
if (item->is<SpecularInstrumentItem>())
return QIcon(":/images/specular_instrument.svg"); return QIcon(":/images/specular_instrument.svg");
case DepthProbe:
if (item->is<DepthProbeInstrumentItem>())
return QIcon(":/images/depth_instrument.svg"); return QIcon(":/images/depth_instrument.svg");
} }
return QVariant(); return QVariant();
} }
...@@ -317,3 +314,21 @@ bool InstrumentsTreeModel::isHeadline(const QModelIndex& index) const ...@@ -317,3 +314,21 @@ bool InstrumentsTreeModel::isHeadline(const QModelIndex& index) const
return index.internalPointer() == nullptr; return index.internalPointer() == nullptr;
} }
InstrumentsTreeModel::InstrumentType InstrumentsTreeModel::instrumentType(InstrumentItem* item)
{
if (item->is<GISASInstrumentItem>())
return Gisas;
if (item->is<OffSpecularInstrumentItem>())
return OffSpecular;
if (item->is<SpecularInstrumentItem>())
return Specular;
if (item->is<DepthProbeInstrumentItem>())
return DepthProbe;
ASSERT(FALSE);
return None;
}
...@@ -59,6 +59,8 @@ public: ...@@ -59,6 +59,8 @@ public:
QModelIndex indexOfHeadline(InstrumentType type) const; QModelIndex indexOfHeadline(InstrumentType type) const;
bool isHeadline(const QModelIndex& index) const; bool isHeadline(const QModelIndex& index) const;
static InstrumentType instrumentType(InstrumentItem* item);
private: private:
void clear(); void clear();
QList<InstrumentType> visibleTypes() const; QList<InstrumentType> visibleTypes() const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment