BornAgain
1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Public Member Functions | |
TestModel2 () | |
~TestModel2 () | |
void | clear (std::function< void(SessionItem *)> callback={}) |
Removes all items from the model. More... | |
SessionItem * | copyItem (const SessionItem *item, SessionItem *parent, const TagRow &tagrow={}) |
Copy item and insert it in parent's tag and row. Item could belong to any model/parent. More... | |
Variant | data (SessionItem *item, int role) const |
Returns the data for given item and role. More... | |
const ItemFactoryInterface * | factory () const |
Returns item factory which can generate all items supported by this model. More... | |
SessionItem * | findItem (const identifier_type &id) |
Returns SessionItem for given identifier. More... | |
template<typename T > | |
T * | insertItem (SessionItem *parent=nullptr, const TagRow &tagrow={}) |
Inserts item into given parent under given tagrow. More... | |
SessionItem * | insertNewItem (const model_type &modelType, SessionItem *parent=nullptr, const TagRow &tagrow={}) |
Insert new item using item's modelType. More... | |
ModelMapper * | mapper () |
Returns model mapper. Can be used to subscribe to various model's signal. More... | |
std::string | modelType () const |
Returns model type. More... | |
void | moveItem (SessionItem *item, SessionItem *new_parent, const TagRow &tagrow) |
Move item from it's current parent to a new parent under given tag and row. More... | |
template<typename T > | |
void | registerItem (const std::string &label={}) |
Register used defined item to use with the model. More... | |
void | removeItem (SessionItem *parent, const TagRow &tagrow) |
Removes given row from parent. More... | |
SessionItem * | rootItem () const |
Returns root item of the model. More... | |
bool | setData (SessionItem *item, const Variant &value, int role) |
Sets the data for given item. More... | |
void | setItemCatalogue (std::unique_ptr< ItemCatalogue > catalogue) |
Sets brand new catalog of user-defined items. More... | |
void | setUndoRedoEnabled (bool value) |
Sets undo/redo either enabled or disabled. By default undo/redo is disabled. More... | |
template<typename T = SessionItem> | |
T * | topItem () const |
Returns top item of the given type. More... | |
template<typename T = SessionItem> | |
std::vector< T * > | topItems () const |
Returns top items of the given type. More... | |
UndoStackInterface * | undoStack () const |
Returns command stack to perform undo/redo. More... | |
Private Member Functions | |
SessionItem * | intern_insert (const item_factory_func_t &func, SessionItem *parent, const TagRow &tagrow) |
Insert new item into given parent using factory function provided. More... | |
void | intern_register (const model_type &modelType, const item_factory_func_t &func, const std::string &label) |
void | registerInPool (SessionItem *item) |
Registers item in pool. This will allow to find item pointer using its unique identifier. More... | |
void | unregisterFromPool (SessionItem *item) |
Unregister item from pool. More... | |
Private Attributes | |
std::unique_ptr< SessionModelImpl > | p_impl |
Definition at line 41 of file jsondocument.test.cpp.
|
inline |
Definition at line 43 of file jsondocument.test.cpp.
|
default |
|
inherited |
Removes all items from the model.
If callback is provided, use it to rebuild content of root item (used while restoring the model from serialized content).
Definition at line 194 of file sessionmodel.cpp.
References ModelView::ModelMapper::callOnModelAboutToBeReset(), ModelView::ModelMapper::callOnModelReset(), ModelView::UndoStackInterface::clear(), ModelView::SessionModel::mapper(), ModelView::SessionModel::p_impl, ModelView::SessionModel::rootItem(), and ModelView::SessionModel::undoStack().
Referenced by gui2::SLDElementController::clearScene(), ModelView::JsonModelConverter::from_json(), and TEST_F().
|
inherited |
Copy item and insert it in parent's tag and row. Item could belong to any model/parent.
Definition at line 111 of file sessionmodel.cpp.
References ModelView::SessionModel::p_impl.
Referenced by gui2::MaterialModel::cloneMaterial(), and TEST_F().
|
inherited |
Returns the data for given item and role.
Definition at line 119 of file sessionmodel.cpp.
References ModelView::SessionItem::data().
Referenced by gui2::ExperimentalDataModel::addGraph(), and TEST_F().
|
inherited |
Returns item factory which can generate all items supported by this model.
Definition at line 161 of file sessionmodel.cpp.
References ModelView::SessionModel::p_impl.
Referenced by InsertNewItemCommandTest::create_command(), ModelView::CreateItemBackupStrategy(), ModelView::CreateItemCopyStrategy(), ModelView::JsonModelConverter::from_json(), ModelView::SessionModel::insertNewItem(), TEST_F(), and ModelView::JsonModelConverter::to_json().
|
inherited |
Returns SessionItem for given identifier.
Definition at line 168 of file sessionmodel.cpp.
References ModelView::SessionModel::p_impl.
Referenced by gui2::DataViewModel::dropMimeData(), ModelView::LinkedItem::get(), gui2::ExperimentalScanItem::graphItem(), TEST_F(), gui2::SLDElementController::updateRoughnessFromView(), gui2::SLDElementController::updateSLDFromView(), gui2::SLDElementController::updateThicknessFromView(), and gui2::SLDElementController::updateToView().
|
inherited |
Inserts item into given parent under given tagrow.
Definition at line 104 of file sessionmodel.h.
References ModelView::SessionModel::intern_insert().
Referenced by ModelView::Data1DItem::setAxis(), TEST(), and TEST_F().
|
inherited |
Insert new item using item's modelType.
Definition at line 86 of file sessionmodel.cpp.
References ModelView::ItemFactoryInterface::createItem(), ModelView::SessionModel::factory(), ModelView::SessionModel::intern_insert(), and ModelView::SessionModel::modelType().
Referenced by TEST_F().
|
privateinherited |
Insert new item into given parent using factory function provided.
Definition at line 222 of file sessionmodel.cpp.
References ModelView::SessionModel::p_impl.
Referenced by ModelView::SessionModel::insertItem(), and ModelView::SessionModel::insertNewItem().
|
privateinherited |
Definition at line 228 of file sessionmodel.cpp.
References ModelView::SessionModel::modelType(), and ModelView::SessionModel::p_impl.
Referenced by ModelView::SessionModel::registerItem().
|
inherited |
Returns model mapper. Can be used to subscribe to various model's signal.
Definition at line 147 of file sessionmodel.cpp.
References ModelView::SessionModel::p_impl.
Referenced by MockWidgetForModel::~MockWidgetForModel(), ModelView::SessionModel::clear(), gui2::SLDElementController::connectLayerModel(), gui2::SLDElementController::connectMaterialModel(), gui2::SLDElementController::connectSLDElementModel(), gui2::SLDElementController::disconnectLayerModel(), gui2::SLDElementController::disconnectMaterialModel(), gui2::SLDElementController::disconnectSLDElementModel(), MockWidgetForModel::setModel(), ModelView::ModelListenerBase::setOnAboutToRemoveItem(), ModelView::ModelListenerBase::setOnDataChange(), ModelView::ModelListenerBase::setOnItemInserted(), ModelView::ModelListenerBase::setOnItemRemoved(), ModelView::ModelListenerBase::setOnModelAboutToBeReset(), ModelView::ModelListenerBase::setOnModelDestroyed(), ModelView::ModelListenerBase::setOnModelReset(), and ModelView::ModelListenerBase::unsubscribe().
|
inherited |
Returns model type.
Definition at line 133 of file sessionmodel.cpp.
References ModelView::SessionModel::p_impl.
Referenced by ModelView::JsonModelConverter::from_json(), ModelView::SessionModel::insertNewItem(), ModelView::SessionModel::intern_register(), ModelView::SessionModel::registerItem(), ModelView::ProjectUtils::SuggestFileName(), and ModelView::JsonModelConverter::to_json().
|
inherited |
Move item from it's current parent to a new parent under given tag and row.
Old and new parents should belong to this model.
Definition at line 104 of file sessionmodel.cpp.
References ModelView::SessionModel::p_impl.
Referenced by gui2::DataViewModel::dropMimeData(), gui2::ExperimentalDataModel::mergeCanvases(), ModelView::Utils::MoveDown(), ModelView::Utils::MoveUp(), and TEST_F().
|
privateinherited |
Registers item in pool. This will allow to find item pointer using its unique identifier.
Definition at line 207 of file sessionmodel.cpp.
References ModelView::SessionItem::activate(), and ModelView::SessionModel::p_impl.
|
inherited |
Register used defined item to use with the model.
It will become possible to undo/redo operations with this item, as well as serialize it to/from JSON.
Definition at line 135 of file sessionmodel.h.
References ModelView::SessionModel::intern_register(), and ModelView::SessionModel::modelType().
Referenced by TEST_F().
|
inherited |
Removes given row from parent.
Definition at line 96 of file sessionmodel.cpp.
References ModelView::SessionModel::p_impl.
Referenced by ModelView::Utils::DeleteItemFromModel(), gui2::ExperimentalDataModel::mergeCanvases(), gui2::ExperimentalDataModel::removeCanvas(), gui2::ExperimentalDataModel::removeGraph(), TEST(), and TEST_F().
|
inherited |
Returns root item of the model.
Definition at line 140 of file sessionmodel.cpp.
References ModelView::SessionModel::p_impl.
Referenced by gui2::SLDElementController::buildSLD(), ModelView::SessionModel::clear(), ViewModelControllerTest::create_controller(), ModelView::Utils::FindItems(), ModelView::JsonModelConverter::from_json(), gui2::ExperimentalDataModel::init_model(), ModelView::CommandService::insertNewItem(), ModelView::Utils::ItemFromPath(), gui2::MaterialModel::material_data(), ModelView::ItemMapper::ItemMapperImpl::nestlingDepth(), TEST(), TEST_F(), ModelView::JsonModelConverter::to_json(), ModelView::SessionModel::topItems(), and ModelView::Utils::TopItems().
|
inherited |
Sets the data for given item.
Definition at line 126 of file sessionmodel.cpp.
References ModelView::SessionModel::p_impl.
Referenced by ModelView::SessionItem::set_data_internal(), TEST(), and TEST_F().
|
inherited |
Sets brand new catalog of user-defined items.
They become available for undo/redo and serialization. Internally user catalog will be merged with the catalog of standard items.
Definition at line 176 of file sessionmodel.cpp.
References ModelView::CreateStandardItemCatalogue(), and ModelView::SessionModel::p_impl.
Referenced by ToyItems::SampleModel::SampleModel(), gui2::SampleModel::SampleModel(), gui2::SLDElementModel::SLDElementModel(), gui2::ExperimentalDataModel::init_model(), and gui2::MaterialModel::init_model().
|
inherited |
Sets undo/redo either enabled or disabled. By default undo/redo is disabled.
Definition at line 186 of file sessionmodel.cpp.
References ModelView::SessionModel::p_impl.
Referenced by gui2::ExperimentalDataModel::init_model(), and TEST_F().
|
inherited |
Returns top item of the given type.
If more than one item exists, return the first one. The top item is an item that is a child of an invisible root item.
Definition at line 126 of file sessionmodel.h.
Referenced by gui2::SimPlotController::onInstrumentChange(), gui2::QuickSimController::process_multilayer(), gui2::LayerEditorWidget::setModels(), gui2::InstrumentPropertyEditor::setModels(), gui2::QuickSimController::submit_specular_simulation(), and TEST_F().
|
inherited |
Returns top items of the given type.
The top item is an item that is a child of an invisible root item.
Definition at line 112 of file sessionmodel.h.
References ModelView::SessionModel::rootItem().
Referenced by TEST_F().
|
inherited |
Returns command stack to perform undo/redo.
Definition at line 154 of file sessionmodel.cpp.
References ModelView::SessionModel::p_impl.
Referenced by ModelView::Utils::BeginMacros(), ModelView::SessionModel::clear(), ModelView::Utils::EndMacros(), gui2::ImportDataEditorActions::isUndoEnabled(), gui2::ImportDataEditorActions::onRedo(), gui2::ImportDataEditorActions::onUndo(), ModelView::Utils::Redo(), ModelView::SessionItem::set_data_internal(), TEST_F(), ModelView::Utils::Undo(), and gui2::ImportDataEditorActions::undoStack().
|
privateinherited |
Unregister item from pool.
Definition at line 215 of file sessionmodel.cpp.
References ModelView::SessionModel::p_impl.
|
privateinherited |
Definition at line 99 of file sessionmodel.h.
Referenced by ModelView::SessionModel::SessionModel(), ModelView::SessionModel::~SessionModel(), ModelView::SessionModel::clear(), ModelView::SessionModel::copyItem(), ModelView::SessionModel::factory(), ModelView::SessionModel::findItem(), ModelView::SessionModel::intern_insert(), ModelView::SessionModel::intern_register(), ModelView::SessionModel::mapper(), ModelView::SessionModel::modelType(), ModelView::SessionModel::moveItem(), ModelView::SessionModel::registerInPool(), ModelView::SessionModel::removeItem(), ModelView::SessionModel::rootItem(), ModelView::SessionModel::setData(), ModelView::SessionModel::setItemCatalogue(), ModelView::SessionModel::setUndoRedoEnabled(), ModelView::SessionModel::undoStack(), and ModelView::SessionModel::unregisterFromPool().