BornAgain
1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
|
List model for sample selection (used in the left pane of the layer oriented sample editor)
Definition at line 24 of file SampleListModel.h.
Public Member Functions | |
SampleListModel (QObject *parent, MultiLayerItems *model) | |
QModelIndex | createSample () |
Create a new sample (sample) and return the index of it. More... | |
QModelIndex | createSampleFromExamples (const QString &className, const QString &title, const QString &description) |
Create sample from list of built-in examples. More... | |
QModelIndex | createSampleFromPython () |
Create sample from an imported python code. More... | |
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
Qt::ItemFlags | flags (const QModelIndex &index) const override |
QModelIndex | indexForItem (MultiLayerItem *item) const |
MultiLayerItem * | itemForIndex (const QModelIndex &index) const |
void | removeSample (MultiLayerItem *item) |
Remove the given sample. nullptr is allowed. More... | |
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
bool | setData (const QModelIndex &index, const QVariant &value, int role) override |
Private Attributes | |
MultiLayerItems * | m_sampleItems = nullptr |
SampleListModel::SampleListModel | ( | QObject * | parent, |
MultiLayerItems * | model | ||
) |
Definition at line 28 of file SampleListModel.cpp.
QModelIndex SampleListModel::createSample | ( | ) |
Create a new sample (sample) and return the index of it.
Definition at line 124 of file SampleListModel.cpp.
References MultiLayerItems::addMultiLayer(), indexForItem(), m_sampleItems, MultiLayerItems::sampleItems(), MultiLayerItems::sampleNames(), MultiLayerItem::setSampleName(), and GUI::Util::String::suggestName().
Referenced by SampleListView::createNewSample().
QModelIndex SampleListModel::createSampleFromExamples | ( | const QString & | className, |
const QString & | title, | ||
const QString & | description | ||
) |
Create sample from list of built-in examples.
Returns invalid index if anything went wrong.
Definition at line 137 of file SampleListModel.cpp.
References MultiLayerItems::addMultiLayer(), indexForItem(), GUI::ExamplesFactory::itemizeSample(), m_sampleItems, GUI::Global::mainWindow, MultiLayerItems::sampleItems(), and MultiLayerItem::setSampleName().
Referenced by SampleListView::createSampleFromLibrary().
QModelIndex SampleListModel::createSampleFromPython | ( | ) |
Create sample from an imported python code.
Returns invalid index if anything went wrong.
Definition at line 164 of file SampleListModel.cpp.
References MultiLayerItems::addMultiLayer(), PyImportAssistant::importMultiLayer(), indexForItem(), PyImportAssistant::itemizeSample(), m_sampleItems, and MultiLayerItems::sampleItems().
Referenced by SampleListView::importSampleFromPython().
|
override |
Definition at line 42 of file SampleListModel.cpp.
References itemForIndex().
|
override |
Definition at line 69 of file SampleListModel.cpp.
QModelIndex SampleListModel::indexForItem | ( | MultiLayerItem * | item | ) | const |
Definition at line 105 of file SampleListModel.cpp.
References m_sampleItems, and MultiLayerItems::sampleItems().
Referenced by createSample(), createSampleFromExamples(), createSampleFromPython(), removeSample(), and SampleListView::setCurrentSample().
MultiLayerItem * SampleListModel::itemForIndex | ( | const QModelIndex & | index | ) | const |
Definition at line 97 of file SampleListModel.cpp.
References m_sampleItems, and MultiLayerItems::sampleItems().
Referenced by SampleListView::currentSample(), data(), SampleListView::getOverlayActions(), SampleListView::onCurrentChanged(), setData(), and SampleListView::showContextMenu().
void SampleListModel::removeSample | ( | MultiLayerItem * | item | ) |
Remove the given sample. nullptr is allowed.
Definition at line 113 of file SampleListModel.cpp.
References indexForItem(), m_sampleItems, and MultiLayerItems::removeMultiLayer().
Referenced by SampleListView::removeSample().
|
override |
Definition at line 34 of file SampleListModel.cpp.
References m_sampleItems, and MultiLayerItems::sampleItems().
|
override |
Definition at line 77 of file SampleListModel.cpp.
References itemForIndex(), MultiLayerItem::setDescription(), and MultiLayerItem::setSampleName().
|
private |
Definition at line 56 of file SampleListModel.h.
Referenced by createSample(), createSampleFromExamples(), createSampleFromPython(), indexForItem(), itemForIndex(), removeSample(), and rowCount().