23 QString defaultInstrumentName()
29 QString defaultInstrumentName<SpecularInstrumentItem>()
35 QString defaultInstrumentName<DepthProbeInstrumentItem>()
41 QString defaultInstrumentName<GISASInstrumentItem>()
47 QString defaultInstrumentName<OffspecInstrumentItem>()
56 : QAbstractListModel(parent)
59 m_gisasIcon.addPixmap(QPixmap(
":/images/gisas_instrument.svg"), QIcon::Selected);
60 m_gisasIcon.addPixmap(QPixmap(
":/images/gisas_instrument_shaded.svg"), QIcon::Normal);
61 m_offspecIcon.addPixmap(QPixmap(
":/images/offspec_instrument.svg"), QIcon::Selected);
62 m_offspecIcon.addPixmap(QPixmap(
":/images/offspec_instrument_shaded.svg"), QIcon::Normal);
63 m_specularIcon.addPixmap(QPixmap(
":/images/specular_instrument.svg"), QIcon::Selected);
64 m_specularIcon.addPixmap(QPixmap(
":/images/specular_instrument_shaded.svg"), QIcon::Normal);
65 m_depthProbeIcon.addPixmap(QPixmap(
":/images/depth_instrument.svg"), QIcon::Selected);
66 m_depthProbeIcon.addPixmap(QPixmap(
":/images/depth_instrument_shaded.svg"), QIcon::Normal);
80 if (!index.isValid() || index.row() >= instruments.size() || index.row() < 0)
84 if (role == Qt::DecorationRole) {
96 if (role == Qt::DisplayRole)
104 if (!index.isValid())
108 if (index.row() >= 0 && index.row() < instruments.size())
109 return instruments[index.row()];
115 return addNewInstrument<GISASInstrumentItem>();
120 return addNewInstrument<OffspecInstrumentItem>();
125 return addNewInstrument<SpecularInstrumentItem>();
130 return addNewInstrument<DepthProbeInstrumentItem>();
135 beginRemoveRows(QModelIndex(), index.row(), index.row());
151 const QString copyName =
155 beginInsertRows(QModelIndex(), row, row);
159 return createIndex(row, 0);
162 template <
class Instrument>
169 beginInsertRows(QModelIndex(), row, row);
174 return createIndex(row, 0);
180 if (
const auto row = instruments.indexOf(
const_cast<InstrumentItem*
>(instrument)); row != -1)
181 emit dataChanged(index(row, 0), index(row, 0));
Defines class InstrumentItem and all its children.
Defines class InstrumentListModel.
Defines class InstrumentsEditController.
QVector< InstrumentItem * > collectedItems() const
QString suggestInstrumentName(const QString &baseName) const
Abstract base class for instrument-specific item classes.
QString instrumentName() const
QModelIndex addNewInstrument()
QModelIndex copyInstrument(const QModelIndex &source)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
InstrumentListModel(QObject *parent, InstrumentsEditController *ec)
QModelIndex addNewSpecularInstrument()
int rowCount(const QModelIndex &parent=QModelIndex()) const override
InstrumentsEditController * m_ec
QModelIndex addNewOffspecInstrument()
void removeInstrument(const QModelIndex &index)
void onInstrumentNameChanged(const InstrumentItem *instrument)
QModelIndex addNewGISASInstrument()
InstrumentItem * instrumentForIndex(const QModelIndex &index) const
QModelIndex addNewDepthProbeInstrument()
Assembles beam, detector and their relative positions with respect to the sample.
Class to modify the instruments list or a single instrument and provide the necessary signaling withi...
InstrumentItem * addCopy(const InstrumentItem *instrument, const QString &name)
Copy an instrument, set its name and emit the respective signal.
void instrumentNameChanged(const InstrumentItem *instrument)
Signals name change of the given instrument.
void setInstrumentName(InstrumentItem *instrument, const QString &name)
Set an instrument's name and emit the respective signal.
void removeInstrument(InstrumentItem *instrument)
Add an instrument and emit the respective signal.
InstrumentCollection * collectedItems()
The list of existing instruments.
T * addInstrument()
Add an instrument and emit the respective signal.
QString const & name(EShape k)