BornAgain
1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Base class for a GUI data collection. A collection is e.g. all real data (RealDataModel). Every model is implementing a Qt item model, therefore the "model" in the class name. Each model is populated by objects derived from SessionItem.
Purpose of a model is to
Definition at line 42 of file SessionModel.h.
Public Member Functions | |
SessionModel (QString model_tag, QObject *parent=nullptr) | |
~SessionModel () override | |
QVector< QString > | acceptableDefaultItemTypes (const QModelIndex &parent) const |
bool | canDropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override |
virtual void | clear () |
int | columnCount (const QModelIndex &parent) const override |
SessionItem * | copy (const SessionItem *item_to_copy, SessionItem *new_parent=nullptr, const QString &tag="") |
Copy given item to the new_parent at given row. Item intended for copying can belong to another model and it will remain intact. Returns pointer to the new child. More... | |
template<typename T > | |
T * | copyItem (const T *item_to_copy, SessionItem *new_parent=nullptr, const QString &tag="") |
void | createRootItem () |
QVariant | data (const QModelIndex &index, int role) const override |
bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override |
Qt::ItemFlags | flags (const QModelIndex &index) const override |
QString | getModelTag () const |
QVariant | headerData (int section, Qt::Orientation orientation, int role) const override |
QModelIndex | index (int row, int column, const QModelIndex &parent) const override |
QModelIndex | indexOfItem (SessionItem *item) const |
virtual void | initFrom (SessionModel *model, SessionItem *parent) |
template<typename T > | |
T * | insertItem (const QModelIndex &parent, int row=-1, QString tag="") |
template<typename T > | |
T * | insertItem (SessionItem *parent=nullptr, int row=-1, QString tag="") |
SessionItem * | insertNewItem (QString model_type, const QModelIndex &parent_item, int row=-1, QString tag="") |
SessionItem * | insertNewItem (QString model_type, SessionItem *parent_item=nullptr, int row=-1, QString tag="") |
SessionItem * | itemForIndex (const QModelIndex &index) const |
QMimeData * | mimeData (const QModelIndexList &indices) const override |
QStringList | mimeTypes () const override |
SessionItem * | moveItem (SessionItem *item, SessionItem *new_parent=nullptr, int row=-1, const QString &tag="") |
Move given parameterized item to the new_parent at given row. If new_parent is not defined, use root_item as a new parent. More... | |
virtual QVector< SessionItem * > | nonXMLItems () const |
QModelIndex | parent (const QModelIndex &child) const override |
virtual void | readFrom (QXmlStreamReader *reader, MessageService *messageService=nullptr) |
void | removeItem (SessionItem *item) |
bool | removeRows (int row, int count, const QModelIndex &parent) override |
SessionItem * | rootItem () const |
int | rowCount (const QModelIndex &parent) const override |
bool | setData (const QModelIndex &index, const QVariant &value, int role) override |
void | setDraggedItemType (const QString &type) |
Qt::DropActions | supportedDragActions () const override |
Qt::DropActions | supportedDropActions () const override |
template<typename T = SessionItem> | |
T * | topItem () const |
Returns first item in list of topItems. More... | |
template<typename T = SessionItem> | |
QVector< T * > | topItems () const |
template<typename T = SessionItem> | |
QVector< T * > | topItems (std::function< bool(const T &)> accept) const |
virtual void | writeTo (QXmlStreamWriter *writer) |
Protected Member Functions | |
void | setRootItem (SessionItem *root) |
Private Attributes | |
QString | m_dragged_item_type |
QString | m_model_tag |
SessionItem * | m_root_item |
Friends | |
class | SessionItem |
|
explicit |
Definition at line 49 of file SessionModel.cpp.
References createRootItem().
|
override |
QVector< QString > SessionModel::acceptableDefaultItemTypes | ( | const QModelIndex & | parent | ) | const |
Definition at line 310 of file SessionModel.cpp.
References itemForIndex(), and parent().
Referenced by canDropMimeData(), and flags().
|
override |
Definition at line 213 of file SessionModel.cpp.
References acceptableDefaultItemTypes(), data(), GUI::Session::XML::ItemMimeType, GUI::Session::XML::ItemTag(), GUI::Session::XML::ModelTypeAttribute(), and parent().
Referenced by dropMimeData().
|
virtual |
Reimplemented in JobModel, and MaskItems.
Definition at line 319 of file SessionModel.cpp.
References createRootItem(), and m_root_item.
Referenced by MaskItems::clear(), JobModel::clear(), ApplicationModels::readFrom(), and readFrom().
|
override |
Definition at line 134 of file SessionModel.cpp.
References SessionFlags::MAX_COLUMNS, and parent().
Referenced by data(), and index().
SessionItem * SessionModel::copy | ( | const SessionItem * | item_to_copy, |
SessionItem * | new_parent = nullptr , |
||
const QString & | tag = "" |
||
) |
Copy given item to the new_parent at given row. Item intended for copying can belong to another model and it will remain intact. Returns pointer to the new child.
Definition at line 395 of file SessionModel.cpp.
References SessionItem::defaultTag(), SessionItem::getItems(), m_root_item, GUI::Session::XML::readItems(), and GUI::Session::XML::writeItemAndChildItems().
Referenced by copyItem().
T * SessionModel::copyItem | ( | const T * | item_to_copy, |
SessionItem * | new_parent = nullptr , |
||
const QString & | tag = "" |
||
) |
Definition at line 149 of file SessionModel.h.
References copy().
Referenced by MaskItems::copy(), and JobItem::copyRealDataIntoJob().
void SessionModel::createRootItem | ( | ) |
Definition at line 56 of file SessionModel.cpp.
References m_root_item, SessionItem::registerTag(), SessionItem, and SessionItem::setModel().
Referenced by SessionModel(), and clear().
|
override |
Definition at line 88 of file SessionModel.cpp.
References columnCount(), index(), SessionFlags::ITEM_NAME, SessionFlags::ITEM_VALUE, itemForIndex(), SessionItem::itemName(), m_root_item, and SessionItem::value().
Referenced by canDropMimeData(), and dropMimeData().
|
override |
Definition at line 241 of file SessionModel.cpp.
References canDropMimeData(), data(), itemForIndex(), GUI::Session::XML::ItemMimeType, SessionItem::numberOfChildren(), and parent().
|
override |
Definition at line 71 of file SessionModel.cpp.
References acceptableDefaultItemTypes(), index(), SessionItem::isEditable(), SessionItem::isEnabled(), SessionFlags::ITEM_VALUE, itemForIndex(), m_dragged_item_type, and SessionItem::value().
|
inline |
Definition at line 202 of file SessionModel.h.
References m_model_tag.
Referenced by ApplicationModels::readFrom(), GUI::Session::XML::readItems(), and GUI::Session::XML::writeModel().
|
override |
Definition at line 112 of file SessionModel.cpp.
References SessionFlags::ITEM_NAME, and SessionFlags::ITEM_VALUE.
|
override |
Definition at line 141 of file SessionModel.cpp.
References SessionItem::childAt(), columnCount(), itemForIndex(), m_root_item, and parent().
Referenced by MaskResultsPresenter::createMaskPresentation(), data(), MaskGraphicsScene::deleteViews(), flags(), MaskItems::insertMask(), GUI::Model::Path::isValidItem(), itemForIndex(), ModelMapper::onBeginRemoveRows(), ModelMapper::onRowRemoved(), MaskGraphicsScene::onRowsAboutToBeRemoved(), ItemStackWidget::onRowsAboutToBeRemoved(), ModelMapper::onRowsInserted(), removeItem(), setData(), MaskGraphicsScene::setItemName(), MaskGraphicsScene::setZValues(), topItems(), and MaskGraphicsScene::updateViews().
QModelIndex SessionModel::indexOfItem | ( | SessionItem * | item | ) | const |
Definition at line 265 of file SessionModel.cpp.
References m_root_item, SessionItem::parentItem(), and SessionItem::rowOfChild().
Referenced by MaskGraphicsScene::cancelCurrentDrawing(), MaskEditorActions::changeMaskStackingOrder(), SessionItem::emitDataChanged(), SessionItem::index(), MaskGraphicsScene::onSceneSelectionChanged(), MaskGraphicsScene::onSessionSelectionChanged(), MaskGraphicsScene::processLineItem(), MaskGraphicsScene::processPolygonItem(), and removeItem().
|
virtual |
Definition at line 413 of file SessionModel.cpp.
References readFrom(), and writeTo().
T * SessionModel::insertItem | ( | const QModelIndex & | parent, |
int | row = -1 , |
||
QString | tag = "" |
||
) |
Definition at line 143 of file SessionModel.h.
References itemForIndex(), and parent().
T * SessionModel::insertItem | ( | SessionItem * | parent = nullptr , |
int | row = -1 , |
||
QString | tag = "" |
||
) |
Definition at line 137 of file SessionModel.h.
References insertNewItem(), SessionItem::modelType(), and parent().
Referenced by IntensityDataFFTPresenter::IntensityDataFFTPresenter(), FitParameterItem::addLink(), JobItem::createDataViewItem(), FitComparison1DViewController::createDiffViewItem(), FitParameterContainerItem::createFitParameter(), FitSuiteItem::createFitParametersContainer(), JobItem::createFitSuiteItem(), FitSuiteItem::createMinimizerContainer(), Data1DViewItem::createPropertyContainerItem(), JobItem::createRealDataItem(), IntensityDataItem::getOrCreateMaskContainerItem(), IntensityDataItem::getOrCreateProjectionContainerItem(), RealDataItem::initDataItem(), ProjectionsEditorCanvas::onEnteringColorMap(), MaskGraphicsScene::processHorizontalLineItem(), MaskGraphicsScene::processMaskAllItem(), MaskGraphicsScene::processPolygonItem(), MaskGraphicsScene::processVerticalLineItem(), and JobItem::setDataType().
SessionItem * SessionModel::insertNewItem | ( | QString | model_type, |
const QModelIndex & | parent_item, | ||
int | row = -1 , |
||
QString | tag = "" |
||
) |
Definition at line 297 of file SessionModel.cpp.
References insertNewItem(), and itemForIndex().
SessionItem * SessionModel::insertNewItem | ( | QString | model_type, |
SessionItem * | parent_item = nullptr , |
||
int | row = -1 , |
||
QString | tag = "" |
||
) |
Definition at line 274 of file SessionModel.cpp.
References GUI::Model::ItemFactory::CreateItem(), SessionItem::defaultTag(), SessionItem::insertChild(), SessionItemTags::isValid(), m_root_item, SessionItem::numberOfChildren(), and SessionItem::sessionItemTags().
Referenced by insertItem(), insertNewItem(), and MaskGraphicsScene::processRectangleShapeItem().
SessionItem * SessionModel::itemForIndex | ( | const QModelIndex & | index | ) | const |
Definition at line 327 of file SessionModel.cpp.
References index(), and m_root_item.
Referenced by acceptableDefaultItemTypes(), MaskEditorActions::changeMaskStackingOrder(), MaskResultsPresenter::createMaskPresentation(), data(), DataProperties::dataItem(), MaskGraphicsScene::deleteViews(), dropMimeData(), flags(), index(), insertItem(), insertNewItem(), MaskEditorActions::isSendToBackPossible(), GUI::Model::Path::isValidItem(), MaskEditorPropertyPanel::maskItemForIndex(), mimeData(), ModelMapper::onBeginRemoveRows(), ModelMapper::onDataChanged(), ModelMapper::onRowRemoved(), ItemStackWidget::onRowsAboutToBeRemoved(), ModelMapper::onRowsInserted(), FitParameterModel::onSourceDataChanged(), MaskEditorActions::onToggleMaskValueAction(), parent(), removeRows(), rowCount(), setData(), MaskGraphicsScene::setItemName(), MaskEditor::setMaskContext(), MaskGraphicsScene::setMaskContext(), MaskGraphicsScene::setZValues(), SessionDecorationModel::textColor(), topItems(), MaskGraphicsScene::updateScene(), and MaskGraphicsScene::updateViews().
|
override |
Definition at line 197 of file SessionModel.cpp.
References itemForIndex(), GUI::Session::XML::ItemMimeType, and GUI::Session::XML::writeItemAndChildItems().
|
override |
Definition at line 192 of file SessionModel.cpp.
References GUI::Session::XML::ItemMimeType.
SessionItem * SessionModel::moveItem | ( | SessionItem * | item, |
SessionItem * | new_parent = nullptr , |
||
int | row = -1 , |
||
const QString & | tag = "" |
||
) |
Move given parameterized item to the new_parent at given row. If new_parent is not defined, use root_item as a new parent.
Definition at line 360 of file SessionModel.cpp.
References SessionItem::defaultTag(), SessionItem::getItems(), SessionItem::insertChild(), SessionItemTags::isValid(), m_root_item, SessionItemTags::maximumReached(), SessionItem::modelType(), SessionItem::parentItem(), SessionItem::rowOfChild(), SessionItem::sessionItemTags(), SessionItem::takeItem(), and SessionItem::takeRow().
Referenced by MaskEditorActions::changeMaskStackingOrder().
|
virtual |
Reimplemented in RealDataModel, and JobModel.
Definition at line 436 of file SessionModel.cpp.
|
override |
Definition at line 155 of file SessionModel.cpp.
References itemForIndex(), m_root_item, and SessionItem::parentItem().
Referenced by acceptableDefaultItemTypes(), canDropMimeData(), columnCount(), dropMimeData(), index(), insertItem(), RealDataModel::onRowsChange(), removeRows(), and rowCount().
|
virtual |
Reimplemented in RealDataModel, and JobModel.
Definition at line 336 of file SessionModel.cpp.
References clear(), Error, m_model_tag, m_root_item, and GUI::Session::XML::readItems().
Referenced by initFrom(), JobModel::readFrom(), and RealDataModel::readFrom().
void SessionModel::removeItem | ( | SessionItem * | item | ) |
Definition at line 303 of file SessionModel.cpp.
References index(), indexOfItem(), and removeRows().
|
override |
Definition at line 183 of file SessionModel.cpp.
References itemForIndex(), m_root_item, parent(), and SessionItem::takeRow().
Referenced by MaskGraphicsScene::cancelCurrentDrawing(), MaskContainerItem::clear(), ProjectionsEditorActions::onDeleteAction(), MaskEditorActions::onDeleteMaskAction(), removeItem(), and JobModel::removeJob().
SessionItem * SessionModel::rootItem | ( | ) | const |
Definition at line 430 of file SessionModel.cpp.
References m_root_item.
Referenced by ModelMapper::nestlingDepth().
|
override |
Definition at line 126 of file SessionModel.cpp.
References itemForIndex(), SessionItem::numberOfChildren(), and parent().
Referenced by MaskResultsPresenter::createMaskPresentation(), MaskGraphicsScene::deleteViews(), GUI::Model::Path::isValidItem(), MaskGraphicsScene::setItemName(), MaskGraphicsScene::setZValues(), topItems(), and MaskGraphicsScene::updateViews().
|
override |
Definition at line 170 of file SessionModel.cpp.
References index(), itemForIndex(), and SessionItem::setRoleProperty().
|
inline |
Definition at line 207 of file SessionModel.h.
References m_dragged_item_type.
|
inlineprotected |
|
inlineoverride |
Definition at line 192 of file SessionModel.h.
|
inlineoverride |
Definition at line 197 of file SessionModel.h.
T * SessionModel::topItem |
Returns first item in list of topItems.
Definition at line 155 of file SessionModel.h.
References SessionItem::items().
QVector< T * > SessionModel::topItems |
Definition at line 162 of file SessionModel.h.
References index(), SessionItem::item(), itemForIndex(), and rowCount().
QVector< T * > SessionModel::topItems | ( | std::function< bool(const T &)> | accept | ) | const |
Definition at line 177 of file SessionModel.h.
References index(), SessionItem::item(), itemForIndex(), and rowCount().
|
virtual |
Definition at line 352 of file SessionModel.cpp.
References m_root_item, and GUI::Session::XML::writeModel().
Referenced by initFrom(), and ApplicationModels::writeTo().
|
friend |
Definition at line 44 of file SessionModel.h.
Referenced by createRootItem().
|
private |
Definition at line 132 of file SessionModel.h.
Referenced by flags(), and setDraggedItemType().
|
private |
Definition at line 133 of file SessionModel.h.
Referenced by getModelTag(), and readFrom().
|
private |
Definition at line 131 of file SessionModel.h.
Referenced by ~SessionModel(), clear(), copy(), createRootItem(), data(), index(), indexOfItem(), insertNewItem(), itemForIndex(), moveItem(), parent(), readFrom(), removeRows(), rootItem(), setRootItem(), and writeTo().