BornAgain
1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Collection of various widget-related utils. More...
Classes | |
struct | is_unique_ptr |
struct | is_unique_ptr< std::unique_ptr< T, D > > |
Functions | |
template<typename It , typename UnaryFunction > | |
std::vector< double > | Apply (It begin, It end, UnaryFunction func) |
Returns vector containing results of elemntwise unary function application. More... | |
MVVM_MODEL_EXPORT bool | AreAlmostEqual (double a, double b, double tolerance_factor=1.0) |
Returns true if two doubles agree within epsilon*tolerance. More... | |
MVVM_MODEL_EXPORT std::string | base_name (const std::string &path) |
Provide the filename of a file path. More... | |
MVVM_MODEL_EXPORT void | BeginMacros (const SessionItem *item, const std::string ¯o_name) |
Begin undo/redo macros with given name. More... | |
template<typename T > | |
std::vector< T * > | CastedItems (const std::vector< SessionItem * > &items) |
Returns vector of items casted to given type. More... | |
MVVM_VIEWMODEL_EXPORT QVariant | CheckStateRole (const SessionItem &item) |
Returns check state role of given item. More... | |
MVVM_MODEL_EXPORT SessionItem * | ChildAt (const SessionItem *parent, int index) |
Returns child at given index of parent. More... | |
MVVM_VIEW_EXPORT QString | ClickableText (const QString &text, const QString &tag={}) |
Returns text wrapped into 'href' tag to provide clickable links in QLabel. More... | |
MVVM_MODEL_EXPORT bool | CompatibleVariantTypes (const Variant &oldValue, const Variant &newValue) |
Returns true if variants has compatible types. More... | |
template<typename A , typename B > | |
bool | Contains (const A &container, const B &element) |
Returns true if container contains a given element. More... | |
MVVM_MODEL_EXPORT int | CopyNumber (const SessionItem *item) |
Returns copy number of given item in it's parent hierarchy. More... | |
MVVM_MODEL_EXPORT bool | create_directory (const std::string &path) |
Create directory, parent directory must exist. More... | |
template<typename T = SessionModel> | |
std::unique_ptr< T > | CreateClone (const T &model) |
Creates exact clone of given model. All item's ID will be preserved. More... | |
template<typename T = SessionModel> | |
std::unique_ptr< T > | CreateCopy (const T &model) |
Creates full deep copy of given model. All item's ID will be generated. More... | |
MVVM_VIEWMODEL_EXPORT QVariant | DecorationRole (const SessionItem &item) |
Returns decoration role for given item. More... | |
MVVM_MODEL_EXPORT void | DeleteItemFromModel (SessionItem *item) |
Removes and deletes item from its model. More... | |
MVVM_VIEW_EXPORT QStringList | deserialize (const QByteArray &byteArray) |
Converts byte array to vector of strings. More... | |
MVVM_MODEL_EXPORT void | EndMacros (const SessionItem *item) |
Finishes undo/redo macros. More... | |
MVVM_MODEL_EXPORT bool | exists (const std::string &fileName) |
Returns true if file exists. More... | |
MVVM_MODEL_EXPORT std::vector< std::string > | FindFiles (const std::string &dirname, const std::string &ext) |
Returns list of files with given extention found in given directory. More... | |
template<typename T = SessionItem> | |
std::vector< T * > | FindItems (const SessionModel *model) |
Returns all items in a tree of given type. More... | |
MVVM_VIEW_EXPORT QMainWindow * | FindMainWindow () |
Finds main window. More... | |
MVVM_MODEL_EXPORT SessionItem * | FindNextItemToSelect (SessionItem *item) |
Finds next item to select Method is used in the context of next item selection after given item was deleted. More... | |
MVVM_MODEL_EXPORT SessionItem * | FindNextSibling (SessionItem *item) |
Returns next sibling with same tag. More... | |
MVVM_MODEL_EXPORT SessionItem * | FindPreviousSibling (SessionItem *item) |
Returns previous sibling with same tag. More... | |
MVVM_VIEW_EXPORT std::vector< std::string > | fromStringList (const QStringList &string_list) |
Converts vector of strings to QStringList. More... | |
MVVM_MODEL_EXPORT bool | HasTag (const SessionItem &item, const std::string &tag) |
Returns true if given item has registered tag. More... | |
MVVM_VIEW_EXPORT int | HeightOfLetterM () |
Returns height of the letter 'M' deduced from current font metrics. More... | |
template<typename C > | |
std::vector< double > | Imag (const C &container) |
Returns vector with imag part of complex numbers. More... | |
MVVM_MODEL_EXPORT int | IndexOfChild (const SessionItem *parent, const SessionItem *child) |
Returns index in children array corresponding to given child. More... | |
template<typename C , typename T > | |
int | IndexOfItem (const C &container, const T &item) |
Returns index corresponding to the first occurance of the item in the container. More... | |
template<typename It , typename T > | |
int | IndexOfItem (It begin, It end, const T &item) |
Returns index corresponding to the first occurance of the item in the container. More... | |
MVVM_MODEL_EXPORT bool | is_empty (const std::string &path) |
Returns true if the file indicated by 'path' refers to empty file or directory. More... | |
MVVM_MODEL_EXPORT bool | IsBoolVariant (const Variant &variant) |
Returns true in the case of double value based variant. More... | |
MVVM_MODEL_EXPORT bool | IsColorVariant (const Variant &variant) |
Returns true in the case of QColor based variant. More... | |
MVVM_MODEL_EXPORT bool | IsComboVariant (const Variant &variant) |
Returns true in the case of double value based variant. More... | |
MVVM_MODEL_EXPORT bool | IsDoubleVariant (const Variant &variant) |
Returns true in the case of double value based variant. More... | |
MVVM_MODEL_EXPORT bool | IsDoubleVectorVariant (const Variant &variant) |
Returns true in the case of variant based on std::vector<double>. More... | |
MVVM_MODEL_EXPORT bool | IsExtPropertyVariant (const Variant &variant) |
Returns true in the case of ExternalProperty based variant. More... | |
MVVM_MODEL_EXPORT bool | IsIntVariant (const Variant &variant) |
Returns true in the case of double value based variant. More... | |
MVVM_MODEL_EXPORT bool | IsItemAncestor (const SessionItem *item, const SessionItem *candidate) |
Returns true if 'candidate' is one of ancestor of given item. More... | |
MVVM_VIEW_EXPORT bool | IsLinuxHost () |
Returns true if it is Linux. More... | |
MVVM_VIEW_EXPORT bool | IsMacHost () |
Returns true if it is Mac. More... | |
MVVM_MODEL_EXPORT bool | IsRealLimitsVariant (const Variant &variant) |
Returns true in the case of RealLimits based variant. More... | |
MVVM_MODEL_EXPORT bool | IsSinglePropertyTag (const SessionItem &item, const std::string &tag) |
Returns true if given item has registered tag , and it belongs to single property. More... | |
MVVM_MODEL_EXPORT bool | IsStdStringVariant (const Variant &variant) |
Returns true in the case of double value based variant. More... | |
MVVM_MODEL_EXPORT bool | IsTheSame (const Variant &var1, const Variant &var2) |
Returns true if given variants have same type and value. More... | |
MVVM_VIEW_EXPORT bool | IsWindowsHost () |
Returns true if it is Windows. More... | |
MVVM_MODEL_EXPORT SessionItem * | ItemFromPath (const SessionModel &moodel, const Path &path) |
Returns item found in the model following given Path. More... | |
MVVM_VIEWMODEL_EXPORT QVector< int > | ItemRoleToQtRole (int role) |
Returns vector of Qt roles corresponding to given ItemDataRole. More... | |
MVVM_VIEWMODEL_EXPORT std::vector< SessionItem * > | ItemsFromIndex (const QModelIndexList &index_list) |
Returns vector of underlying SessionItem's for given index list. More... | |
MVVM_MODEL_EXPORT void | iterate (SessionItem *item, const std::function< void(SessionItem *)> &fun) |
Iterates through item and all its children. More... | |
MVVM_MODEL_EXPORT void | iterate_if (const SessionItem *item, const std::function< bool(const SessionItem *)> &fun) |
Iterates through all model indices and calls user function. More... | |
MVVM_VIEWMODEL_EXPORT void | iterate_model (const QAbstractItemModel *model, const QModelIndex &parent, const std::function< void(const QModelIndex &child)> &fun) |
Iterates through QAbstractItem model. More... | |
MVVM_MODEL_EXPORT std::string | join (const std::string &part1, const std::string &part2) |
Joins two path elements into the path. More... | |
MVVM_MODEL_EXPORT void | MoveDown (SessionItem *item) |
Moves item down (increments row of the item). Works on children belonging to single tag. More... | |
MVVM_MODEL_EXPORT void | MoveUp (SessionItem *item) |
Moves item up (decrements row of the item). Works on children belonging to single tag. More... | |
MVVM_MODEL_EXPORT std::string | parent_path (const std::string &path) |
Returns the path to the parent directory. More... | |
MVVM_VIEWMODEL_EXPORT std::vector< SessionItem * > | ParentItemsFromIndex (const QModelIndexList &index_list) |
Returns vector of parent items from given index list. More... | |
MVVM_MODEL_EXPORT Path | PathFromItem (const SessionItem *item) |
Constructs path to find given item. Item must belong to a model. More... | |
MVVM_MODEL_EXPORT void | PopulateEmptyModel (const JsonModelConverterInterface *converter, const SessionModel &source, SessionModel &target) |
Populate empty model with content of target model using provided converter. More... | |
MVVM_VIEW_EXPORT QString | ProjectWindowTitle (const QString &project_dir, bool is_modified) |
Returns a title composed from last part of project path, and is_modified flag. More... | |
MVVM_MODEL_EXPORT double | RandDouble (double low, double high) |
Produces random FLOAT values uniformly distributed on the interval [low, high). More... | |
MVVM_MODEL_EXPORT int | RandInt (int low, int high) |
Produces random integer values uniformly distributed on the closed interval [low, high]. More... | |
MVVM_VIEW_EXPORT QColor | RandomColor () |
Returns random color. More... | |
MVVM_VIEW_EXPORT std::string | RandomNamedColor () |
Returns the name of random color. More... | |
template<typename C > | |
std::vector< double > | Real (const C &container) |
Returns vector with real part of complex numbers. More... | |
MVVM_MODEL_EXPORT void | Redo (SessionModel &model) |
Redo model operation which was undone just before. If not undo/redo enabled, will do nothing. More... | |
MVVM_MODEL_EXPORT std::vector< std::string > | RegisteredTags (const SessionItem &item) |
Returns vector of strings containing all registered tags of the given item. More... | |
MVVM_MODEL_EXPORT std::vector< std::string > | RegisteredUniversalTags (const SessionItem &item) |
Returns vector of strings containing all registered universal tags of the given item. More... | |
MVVM_MODEL_EXPORT bool | remove (const std::string &path) |
Removes file or empty directory. More... | |
MVVM_MODEL_EXPORT void | remove_all (const std::string &path) |
Removes directory with all its content. More... | |
MVVM_VIEW_EXPORT void | ScaleLabelFont (QLabel *label, double scale) |
Set label's font size to system font size scaled by given factor. More... | |
MVVM_VIEW_EXPORT QByteArray | serialize (const QStringList &data) |
Converts vector of strings to byte array. More... | |
MVVM_VIEW_EXPORT void | SetLogarithmicScale (QCPAxis *axis, bool is_log_scale) |
Switch axis to logarithmic scale mode. More... | |
MVVM_VIEW_EXPORT void | SetLogarithmicScale (QCPColorScale *axis, bool is_log_scale) |
Switch axis to logarithmic scale mode. More... | |
MVVM_MODEL_EXPORT std::vector< SessionItem * > | SinglePropertyItems (const SessionItem &item) |
Returns vector of children representing property items. More... | |
MVVM_VIEW_EXPORT QSize | SizeOfLetterM () |
Returns size corresponding to actual size of letter M basing on current font metrics. More... | |
MVVM_VIEW_EXPORT int | SystemPointSize () |
Returns size in points of default system font. More... | |
MVVM_VIEWMODEL_EXPORT QVariant | TextColorRole (const SessionItem &item) |
Returns text color for given item. More... | |
MVVM_MODEL_EXPORT Variant | toCustomVariant (const Variant &standard) |
Converts Qt variant to custom variant on board of SessionItem. More... | |
MVVM_VIEWMODEL_EXPORT QVariant | ToolTipRole (const SessionItem &item) |
Returns tooltip role for given item. More... | |
template<typename T = SessionItem> | |
T * | TopItem (const SessionModel *model) |
Returns top level item of given type. More... | |
template<typename T = SessionItem> | |
std::vector< T * > | TopItems (const SessionModel *model) |
Returns all top level items of given type. More... | |
MVVM_MODEL_EXPORT std::vector< SessionItem * > | TopLevelItems (const SessionItem &item) |
Returns vector of children representing top level items. More... | |
MVVM_MODEL_EXPORT Variant | toQtVariant (const Variant &custom) |
Converts custom variant to standard variant which Qt views will understand. More... | |
MVVM_VIEW_EXPORT QStringList | toStringList (const std::vector< std::string > &vec) |
Converts vector of strings to QStringList. More... | |
MVVM_MODEL_EXPORT void | Undo (SessionModel &model) |
Undo last model operation. If not undo/redo enabled, will do nothing. More... | |
MVVM_MODEL_EXPORT std::vector< SessionItem * > | UniqueItems (const std::vector< SessionItem * > &items) |
Returns vector with duplicates and 'nullptr' filtered out. More... | |
MVVM_VIEWMODEL_EXPORT std::vector< SessionItem * > | UniqueItemsFromIndex (const QModelIndexList &index_list) |
Returns vector of underlying SessionItem's for given index list. Removes repetitions. More... | |
template<typename C > | |
C | UniqueWithOrder (const C &container) |
Returns copy of container with all duplicated elements filtered our. The order is preserved. More... | |
MVVM_MODEL_EXPORT std::string | VariantName (const Variant &variant) |
Returns name of variant. More... | |
MVVM_MODEL_EXPORT int | VariantType (const Variant &variant) |
Returns type of variant (additionally checks for user type). More... | |
MVVM_VIEW_EXPORT int | WidthOfLetterM () |
Returns width of the letter 'M' deduced from current font metrics. More... | |
MVVM_VIEW_EXPORT QString | WithTildeHomePath (const QString &path) |
Returns a string where Linux path to the file is striped using '~/'. More... | |
Collection of various widget-related utils.
std::vector<double> ModelView::Utils::Apply | ( | It | begin, |
It | end, | ||
UnaryFunction | func | ||
) |
Returns vector containing results of elemntwise unary function application.
Definition at line 63 of file containerutils.h.
bool ModelView::Utils::AreAlmostEqual | ( | double | a, |
double | b, | ||
double | tolerance_factor = 1.0 |
||
) |
Returns true if two doubles agree within epsilon*tolerance.
Definition at line 23 of file numericutils.cpp.
Referenced by ModelView::DoubleEditor::onEditingFinished(), ModelView::ScientificDoubleEditor::onEditingFinished(), ModelView::ScientificSpinBoxEditor::onEditingFinished(), and TEST_F().
std::string ModelView::Utils::base_name | ( | const std::string & | path | ) |
Provide the filename of a file path.
Definition at line 78 of file fileutils.cpp.
Referenced by IParametricComponent::registerVector(), IParametricComponent::removeVector(), IParametricComponent::setVectorValue(), TEST_F(), IParametricComponent::XComponentName(), IParametricComponent::YComponentName(), and IParametricComponent::ZComponentName().
void ModelView::Utils::BeginMacros | ( | const SessionItem * | item, |
const std::string & | macro_name | ||
) |
Begin undo/redo macros with given name.
Works only if item belongs to the model, and model has undo/redo enabled. Otherwise, do nothing.
Definition at line 91 of file modelutils.cpp.
References ModelView::SessionItem::model(), and ModelView::SessionModel::undoStack().
Referenced by ModelView::ViewportItem::setViewportToContent().
std::vector<T*> ModelView::Utils::CastedItems | ( | const std::vector< SessionItem * > & | items | ) |
Returns vector of items casted to given type.
Definition at line 90 of file itemutils.h.
QVariant ModelView::Utils::CheckStateRole | ( | const SessionItem & | item | ) |
Returns check state role of given item.
Definition at line 73 of file viewmodelutils.cpp.
References ModelView::SessionItem::data(), and IsBoolVariant().
Referenced by ModelView::ViewDataItem::data(), and TEST_F().
SessionItem * ModelView::Utils::ChildAt | ( | const SessionItem * | parent, |
int | index | ||
) |
Returns child at given index of parent.
No tags are involved, index is considered as global index in the combined array of all children.
Definition at line 70 of file itemutils.cpp.
References ModelView::SessionItem::children().
Referenced by ItemFromPath(), and TEST_F().
QString ModelView::Utils::ClickableText | ( | const QString & | text, |
const QString & | tag = {} |
||
) |
Returns text wrapped into 'href' tag to provide clickable links in QLabel.
Example: text, if 'tag' is empty, 'text' will be used instead.
Definition at line 136 of file widgetutils.cpp.
Referenced by gui2::OpenProjectWidget::createLinkedLabelLayout(), and TEST_F().
bool ModelView::Utils::CompatibleVariantTypes | ( | const Variant & | oldValue, |
const Variant & | newValue | ||
) |
Returns true if variants has compatible types.
Definition at line 39 of file customvariants.cpp.
References VariantType().
Referenced by ModelView::SessionItemData::assure_validity(), and TEST_F().
bool ModelView::Utils::Contains | ( | const A & | container, |
const B & | element | ||
) |
Returns true if container contains a given element.
Definition at line 103 of file containerutils.h.
Referenced by ModelView::TagInfo::isValidChild(), ModelView::ComboProperty::setStringOfValues(), ModelView::ComboProperty::setValue(), ModelView::ComboProperty::setValues(), TEST_F(), ModelView::SelectableComboBoxEditor::update_components(), and gui2::DataHandler::updateRawData().
int ModelView::Utils::CopyNumber | ( | const SessionItem * | item | ) |
Returns copy number of given item in it's parent hierarchy.
Takes into account only items with same modelType.
Definition at line 49 of file itemutils.cpp.
References ModelView::SessionItem::modelType(), and ModelView::SessionItem::parent().
Referenced by ModelView::CompoundItem::displayName(), and TEST_F().
bool ModelView::Utils::create_directory | ( | const std::string & | path | ) |
Create directory, parent directory must exist.
If path resolves to existing directory, no error reported.
Definition at line 47 of file fileutils.cpp.
Referenced by FileSystemUtils::createDirectory(), FolderBasedTest::createEmptyDir(), TestUtils::CreateTestDirectory(), and TEST_F().
std::unique_ptr<T> ModelView::Utils::CreateClone | ( | const T & | model | ) |
Creates exact clone of given model. All item's ID will be preserved.
Definition at line 90 of file modelutils.h.
References ModelView::CreateModelCloneConverter(), and PopulateEmptyModel().
Referenced by TEST_F().
std::unique_ptr<T> ModelView::Utils::CreateCopy | ( | const T & | model | ) |
Creates full deep copy of given model. All item's ID will be generated.
Definition at line 81 of file modelutils.h.
References ModelView::CreateModelCopyConverter(), and PopulateEmptyModel().
Referenced by TEST_F().
QVariant ModelView::Utils::DecorationRole | ( | const SessionItem & | item | ) |
Returns decoration role for given item.
Definition at line 81 of file viewmodelutils.cpp.
References ModelView::ExternalProperty::color(), ModelView::SessionItem::data(), IsColorVariant(), and IsExtPropertyVariant().
Referenced by ModelView::ViewDataItem::data(), and TEST_F().
void ModelView::Utils::DeleteItemFromModel | ( | SessionItem * | item | ) |
Removes and deletes item from its model.
Definition at line 54 of file modelutils.cpp.
References ModelView::SessionItem::model(), ModelView::SessionItem::parent(), ModelView::SessionModel::removeItem(), and ModelView::SessionItem::tagRow().
Referenced by gui2::LayerEditorActions::onRemove(), gui2::MaterialEditorActions::onRemoveMaterial(), gui2::JobItem::removeDifferenceGraph(), gui2::JobItem::removeReferenceGraph(), and TEST_F().
QStringList ModelView::Utils::deserialize | ( | const QByteArray & | byteArray | ) |
Converts byte array to vector of strings.
Definition at line 172 of file widgetutils.cpp.
Referenced by gui2::DataViewModel::dropMimeData(), and TEST_F().
void ModelView::Utils::EndMacros | ( | const SessionItem * | item | ) |
Finishes undo/redo macros.
Works only if item belongs to the model, and model has undo/redo enabled. Otherwise, do nothing.
Definition at line 100 of file modelutils.cpp.
References ModelView::SessionItem::model(), and ModelView::SessionModel::undoStack().
Referenced by ModelView::ViewportItem::setViewportToContent().
bool ModelView::Utils::exists | ( | const std::string & | fileName | ) |
Returns true if file exists.
Definition at line 27 of file fileutils.cpp.
References ProjectUtils::exists().
Referenced by ModelView::Project::ProjectImpl::process(), gui2::RecentProjectSettings::recentProjects(), and TEST_F().
std::vector< std::string > ModelView::Utils::FindFiles | ( | const std::string & | dirname, |
const std::string & | ext | ||
) |
Returns list of files with given extention found in given directory.
Definition at line 87 of file fileutils.cpp.
References RealSpace::Particles::name().
Referenced by ModelView::ProjectUtils::IsPossibleProjectDir(), and TEST_F().
std::vector<T*> ModelView::Utils::FindItems | ( | const SessionModel * | model | ) |
Returns all items in a tree of given type.
Definition at line 55 of file modelutils.h.
References iterate(), and ModelView::SessionModel::rootItem().
QMainWindow * ModelView::Utils::FindMainWindow | ( | ) |
Finds main window.
Definition at line 127 of file widgetutils.cpp.
Referenced by gui2::ProjectHandler::updateCurrentProjectName().
SessionItem * ModelView::Utils::FindNextItemToSelect | ( | SessionItem * | item | ) |
Finds next item to select Method is used in the context of next item selection after given item was deleted.
Definition at line 149 of file itemutils.cpp.
References FindNextSibling(), FindPreviousSibling(), and ModelView::SessionItem::parent().
Referenced by TEST_F().
SessionItem * ModelView::Utils::FindNextSibling | ( | SessionItem * | item | ) |
Returns next sibling with same tag.
Definition at line 131 of file itemutils.cpp.
References ModelView::SessionItem::parent(), and ModelView::SessionItem::tagRow().
Referenced by FindNextItemToSelect(), gui2::LayerEditorActions::onRemove(), and TEST_F().
SessionItem * ModelView::Utils::FindPreviousSibling | ( | SessionItem * | item | ) |
Returns previous sibling with same tag.
Definition at line 140 of file itemutils.cpp.
References ModelView::SessionItem::parent(), and ModelView::SessionItem::tagRowOfItem().
Referenced by FindNextItemToSelect(), gui2::LayerEditorActions::onRemove(), and TEST_F().
std::vector< std::string > ModelView::Utils::fromStringList | ( | const QStringList & | string_list | ) |
Converts vector of strings to QStringList.
Definition at line 156 of file widgetutils.cpp.
Referenced by gui2::DataLoaderDialog::onLoadFilesRequest(), and TEST_F().
bool ModelView::Utils::HasTag | ( | const SessionItem & | item, |
const std::string & | tag | ||
) |
Returns true if given item has registered tag.
Definition at line 86 of file itemutils.cpp.
References ModelView::SessionItemTags::isTag(), and ModelView::SessionItem::itemTags().
Referenced by gui2::MaterialBaseItem::external_property(), and TEST_F().
int ModelView::Utils::HeightOfLetterM | ( | ) |
Returns height of the letter 'M' deduced from current font metrics.
Definition at line 111 of file widgetutils.cpp.
References SizeOfLetterM().
Referenced by ModelView::CollapsibleBar::CollapsibleBar(), and gui2::FancyTab::FancyTab().
std::vector<double> ModelView::Utils::Imag | ( | const C & | container | ) |
Returns vector with imag part of complex numbers.
Definition at line 80 of file containerutils.h.
References Apply().
Referenced by TEST_F().
int ModelView::Utils::IndexOfChild | ( | const SessionItem * | parent, |
const SessionItem * | child | ||
) |
Returns index in children array corresponding to given child.
No tags are involved, index is considered as global index in the combined array of all children.
Definition at line 81 of file itemutils.cpp.
References ModelView::SessionItem::children(), and IndexOfItem().
Referenced by PathFromItem(), and TEST_F().
int ModelView::Utils::IndexOfItem | ( | const C & | container, |
const T & | item | ||
) |
Returns index corresponding to the first occurance of the item in the container.
If item doesn't exist, will return -1. Works with containers containing unique_ptr.
Definition at line 55 of file containerutils.h.
References IndexOfItem().
int ModelView::Utils::IndexOfItem | ( | It | begin, |
It | end, | ||
const T & | item | ||
) |
Returns index corresponding to the first occurance of the item in the container.
If item doesn't exist, will return -1. Works with containers containing unique_ptr.
Definition at line 41 of file containerutils.h.
Referenced by gui2::ImportDataEditor::canvasInfo(), ModelView::ViewItem::ViewItemImpl::index_of_child(), IndexOfChild(), IndexOfItem(), ModelView::SessionItemContainer::indexOfItem(), ModelView::ViewModelController::ViewModelControllerImpl::insert_view(), ModelView::GroupItem::setCurrentType(), ModelView::ComboProperty::setSelected(), ModelView::ComboProperty::setStringOfValues(), ModelView::ComboProperty::setValue(), ModelView::ComboProperty::setValues(), and TEST_F().
bool ModelView::Utils::is_empty | ( | const std::string & | path | ) |
Returns true if the file indicated by 'path' refers to empty file or directory.
Definition at line 121 of file fileutils.cpp.
Referenced by ModelView ::Compatibility::IsCompatibleUniversalTag(), gui2::UserInteractor::onCreateDirRequest(), and TEST_F().
bool ModelView::Utils::IsBoolVariant | ( | const Variant & | variant | ) |
Returns true in the case of double value based variant.
Definition at line 92 of file customvariants.cpp.
Referenced by ModelView::DefaultCellDecorator::cellText(), CheckStateRole(), and TEST_F().
bool ModelView::Utils::IsColorVariant | ( | const Variant & | variant | ) |
Returns true in the case of QColor based variant.
Definition at line 122 of file customvariants.cpp.
Referenced by ModelView::DefaultCellDecorator::cellText(), DecorationRole(), TEST_F(), and ModelView::ColorEditor::update_components().
bool ModelView::Utils::IsComboVariant | ( | const Variant & | variant | ) |
Returns true in the case of double value based variant.
Definition at line 107 of file customvariants.cpp.
Referenced by ModelView::DefaultCellDecorator::cellText(), and TEST_F().
bool ModelView::Utils::IsDoubleVariant | ( | const Variant & | variant | ) |
Returns true in the case of double value based variant.
Definition at line 102 of file customvariants.cpp.
Referenced by ModelView::DefaultCellDecorator::cellText(), and TEST_F().
bool ModelView::Utils::IsDoubleVectorVariant | ( | const Variant & | variant | ) |
Returns true in the case of variant based on std::vector<double>.
Definition at line 117 of file customvariants.cpp.
References ModelView::Constants::vector_double_type_name.
Referenced by TEST_F(), and toQtVariant().
bool ModelView::Utils::IsExtPropertyVariant | ( | const Variant & | variant | ) |
Returns true in the case of ExternalProperty based variant.
Definition at line 127 of file customvariants.cpp.
Referenced by ModelView::DefaultCellDecorator::cellText(), gui2::CustomLayerTreeEditorFactory::createEditor(), gui2::CustomBeamPropertyEditorFactory::createEditor(), DecorationRole(), TEST_F(), and ModelView::ExternalPropertyEditor::update_components().
bool ModelView::Utils::IsIntVariant | ( | const Variant & | variant | ) |
Returns true in the case of double value based variant.
Definition at line 97 of file customvariants.cpp.
Referenced by TEST_F().
bool ModelView::Utils::IsItemAncestor | ( | const SessionItem * | item, |
const SessionItem * | candidate | ||
) |
Returns true if 'candidate' is one of ancestor of given item.
Definition at line 156 of file itemutils.cpp.
References ModelView::SessionItem::parent().
Referenced by ModelView::ViewModelController::onAboutToRemoveItem(), and TEST_F().
bool ModelView::Utils::IsLinuxHost | ( | ) |
Returns true if it is Linux.
Definition at line 70 of file widgetutils.cpp.
bool ModelView::Utils::IsMacHost | ( | ) |
Returns true if it is Mac.
Definition at line 61 of file widgetutils.cpp.
bool ModelView::Utils::IsRealLimitsVariant | ( | const Variant & | variant | ) |
Returns true in the case of RealLimits based variant.
Definition at line 132 of file customvariants.cpp.
Referenced by TEST_F().
bool ModelView::Utils::IsSinglePropertyTag | ( | const SessionItem & | item, |
const std::string & | tag | ||
) |
Returns true if given item has registered tag
, and it belongs to single property.
Definition at line 91 of file itemutils.cpp.
References ModelView::SessionItemTags::isSinglePropertyTag(), and ModelView::SessionItem::itemTags().
Referenced by ModelView::MoveItemCommand::MoveItemCommand(), RegisteredUniversalTags(), SinglePropertyItems(), TEST_F(), and TopLevelItems().
bool ModelView::Utils::IsStdStringVariant | ( | const Variant & | variant | ) |
Returns true in the case of double value based variant.
Definition at line 112 of file customvariants.cpp.
Referenced by TEST_F().
Returns true if given variants have same type and value.
Definition at line 51 of file customvariants.cpp.
References SessionItemUtils::VariantType().
Referenced by ModelView::DataRole::operator==(), ModelView::SessionItemData::setData(), and TEST_F().
bool ModelView::Utils::IsWindowsHost | ( | ) |
Returns true if it is Windows.
Definition at line 52 of file widgetutils.cpp.
Referenced by TEST_F(), and WithTildeHomePath().
SessionItem * ModelView::Utils::ItemFromPath | ( | const SessionModel & | moodel, |
const Path & | path | ||
) |
Returns item found in the model following given Path.
Definition at line 36 of file modelutils.cpp.
References ChildAt(), and ModelView::SessionModel::rootItem().
Referenced by ModelView::ViewModelController::ViewModelController(), ModelView::AbstractItemCommand::itemFromPath(), and TEST_F().
QVector< int > ModelView::Utils::ItemRoleToQtRole | ( | int | role | ) |
Returns vector of Qt roles corresponding to given ItemDataRole.
Translates SessionItem's data role to vector of Qt roles.
Definition at line 50 of file viewmodelutils.cpp.
References ModelView::ItemDataRole::APPEARANCE, ModelView::ItemDataRole::DATA, ModelView::ItemDataRole::DISPLAY, SessionItemUtils::ForegroundRole(), TextColorRole(), ModelView::ItemDataRole::TOOLTIP, and SessionItemUtils::ToolTipRole().
Referenced by ModelView::ViewModelController::onDataChange(), and TEST_F().
std::vector< SessionItem * > ModelView::Utils::ItemsFromIndex | ( | const QModelIndexList & | index_list | ) |
Returns vector of underlying SessionItem's for given index list.
Definition at line 97 of file viewmodelutils.cpp.
Referenced by ParentItemsFromIndex(), gui2::DataSelectionModel::selectedItems(), TEST_F(), and UniqueItemsFromIndex().
void ModelView::Utils::iterate | ( | SessionItem * | item, |
const std::function< void(SessionItem *)> & | fun | ||
) |
Iterates through item and all its children.
Definition at line 24 of file itemutils.cpp.
References ModelView::SessionItem::children(), and ModelUtils::iterate().
Referenced by FindItems(), and TEST_F().
void ModelView::Utils::iterate_if | ( | const SessionItem * | item, |
const std::function< bool(const SessionItem *)> & | fun | ||
) |
Iterates through all model indices and calls user function.
If function returns false for given index, iteration will not go down to children.
Definition at line 35 of file itemutils.cpp.
References ModelView::SessionItem::children(), and ModelUtils::iterate_if().
Referenced by TEST_F().
void ModelView::Utils::iterate_model | ( | const QAbstractItemModel * | model, |
const QModelIndex & | parent, | ||
const std::function< void(const QModelIndex &child)> & | fun | ||
) |
Iterates through QAbstractItem model.
Definition at line 29 of file viewmodelutils.cpp.
Referenced by ModelView::ViewModelController::ViewModelControllerImpl::findViews(), and TEST_F().
std::string ModelView::Utils::join | ( | const std::string & | part1, |
const std::string & | part2 | ||
) |
Joins two path elements into the path.
Definition at line 37 of file fileutils.cpp.
Referenced by FolderBasedTest::createEmptyDir(), ModelView::Project::ProjectImpl::process(), and TEST_F().
void ModelView::Utils::MoveDown | ( | SessionItem * | item | ) |
Moves item down (increments row of the item). Works on children belonging to single tag.
Definition at line 71 of file modelutils.cpp.
References ModelView::SessionItem::itemCount(), ModelView::SessionItem::model(), ModelView::SessionModel::moveItem(), ModelView::SessionItem::parent(), and ModelView::SessionItem::tagRow().
Referenced by gui2::LayerEditorActions::onMoveDown(), gui2::MaterialEditorActions::onMoveDown(), and TEST_F().
void ModelView::Utils::MoveUp | ( | SessionItem * | item | ) |
Moves item up (decrements row of the item). Works on children belonging to single tag.
Definition at line 63 of file modelutils.cpp.
References ModelView::SessionItem::model(), ModelView::SessionModel::moveItem(), ModelView::SessionItem::parent(), and ModelView::SessionItem::tagRow().
Referenced by gui2::LayerEditorActions::onMoveUp(), gui2::MaterialEditorActions::onMoveUp(), and TEST_F().
std::string ModelView::Utils::parent_path | ( | const std::string & | path | ) |
Returns the path to the parent directory.
Definition at line 111 of file fileutils.cpp.
Referenced by TEST_F(), gui2::ImportFileWidget::updateCurrentWorkdir(), and gui2::RecentProjectSettings::updateWorkdirFromSelection().
std::vector< SessionItem * > ModelView::Utils::ParentItemsFromIndex | ( | const QModelIndexList & | index_list | ) |
Returns vector of parent items from given index list.
Finds all SessionItems corresponding to given index list and collect their parents. Function is usefull in the context of table-like views when we want to find compound items (i.e. Layers) from table cells containing LayerItem's properties (i.e. thickness).
Definition at line 116 of file viewmodelutils.cpp.
References ItemsFromIndex().
Referenced by gui2::MaterialSelectionModel::selectedMaterials(), and TEST_F().
Path ModelView::Utils::PathFromItem | ( | const SessionItem * | item | ) |
Constructs path to find given item. Item must belong to a model.
Definition at line 22 of file modelutils.cpp.
References IndexOfChild(), ModelView::SessionItem::model(), ModelView::SessionItem::parent(), and ModelView::Path::prepend().
Referenced by ModelView::AbstractItemCommand::pathFromItem(), ModelView::ViewModelController::ViewModelControllerImpl::setRootSessionItemIntern(), and TEST_F().
void ModelView::Utils::PopulateEmptyModel | ( | const JsonModelConverterInterface * | converter, |
const SessionModel & | source, | ||
SessionModel & | target | ||
) |
Populate empty model with content of target model using provided converter.
Serves as auxiliary function for model copying and cloning.
Definition at line 47 of file modelutils.cpp.
References ModelView::JsonModelConverterInterface::from_json(), and ModelView::JsonModelConverterInterface::to_json().
Referenced by CreateClone(), and CreateCopy().
QString ModelView::Utils::ProjectWindowTitle | ( | const QString & | project_dir, |
bool | is_modified | ||
) |
Returns a title composed from last part of project path, and is_modified
flag.
Project without projectDir will be "Untitled", modified project will be "*Untitled".
Project with projectDir in "/home/user/project1" will get title "project1".
Definition at line 98 of file widgetutils.cpp.
Referenced by gui2::ProjectPaneWidget::setCurrentProject(), TEST_F(), and gui2::ProjectHandler::updateCurrentProjectName().
double ModelView::Utils::RandDouble | ( | double | low, |
double | high | ||
) |
Produces random FLOAT values uniformly distributed on the interval [low, high).
Definition at line 38 of file numericutils.cpp.
int ModelView::Utils::RandInt | ( | int | low, |
int | high | ||
) |
Produces random integer values uniformly distributed on the closed interval [low, high].
Definition at line 30 of file numericutils.cpp.
Referenced by RandomColor().
QColor ModelView::Utils::RandomColor | ( | ) |
Returns random color.
Definition at line 41 of file widgetutils.cpp.
References RandInt().
Referenced by RandomNamedColor().
std::string ModelView::Utils::RandomNamedColor | ( | ) |
Returns the name of random color.
Definition at line 47 of file widgetutils.cpp.
References RandomColor().
std::vector<double> ModelView::Utils::Real | ( | const C & | container | ) |
Returns vector with real part of complex numbers.
Definition at line 72 of file containerutils.h.
References Apply().
Referenced by gui2::SpecularToySimulation::sld_profile(), and TEST_F().
void ModelView::Utils::Redo | ( | SessionModel & | model | ) |
Redo model operation which was undone just before. If not undo/redo enabled, will do nothing.
Definition at line 85 of file modelutils.cpp.
References ModelView::SessionModel::undoStack().
std::vector< std::string > ModelView::Utils::RegisteredTags | ( | const SessionItem & | item | ) |
Returns vector of strings containing all registered tags of the given item.
Definition at line 96 of file itemutils.cpp.
References ModelView::SessionItem::itemTags().
Referenced by RegisteredUniversalTags(), and TEST_F().
std::vector< std::string > ModelView::Utils::RegisteredUniversalTags | ( | const SessionItem & | item | ) |
Returns vector of strings containing all registered universal tags of the given item.
A universal tag is a tag that is usually empty after item construction and serves for later children's insertion.
Definition at line 104 of file itemutils.cpp.
References IsSinglePropertyTag(), and RegisteredTags().
Referenced by TEST_F().
bool ModelView::Utils::remove | ( | const std::string & | path | ) |
Removes file or empty directory.
Definition at line 57 of file fileutils.cpp.
Referenced by LayoutUtils::removeColumn(), ParameterPool::removeParameter(), LayoutUtils::removeRow(), and TEST_F().
void ModelView::Utils::remove_all | ( | const std::string & | path | ) |
Removes directory with all its content.
Definition at line 67 of file fileutils.cpp.
Referenced by FolderBasedTest::createEmptyDir(), and TEST_F().
void ModelView::Utils::ScaleLabelFont | ( | QLabel * | label, |
double | scale | ||
) |
Set label's font size to system font size scaled by given factor.
Definition at line 141 of file widgetutils.cpp.
References SystemPointSize().
Referenced by gui2::FancyTab::FancyTab(), gui2::RecentProjectWidget::createCurrentProjectLayout(), gui2::OpenProjectWidget::createLinkedLabelLayout(), gui2::OpenProjectWidget::createProjectTitleLayout(), and gui2::RecentProjectWidget::createRecentProjectLayout().
QByteArray ModelView::Utils::serialize | ( | const QStringList & | data | ) |
Converts vector of strings to byte array.
Definition at line 164 of file widgetutils.cpp.
Referenced by gui2::DataViewModel::mimeData(), and TEST_F().
void ModelView::Utils::SetLogarithmicScale | ( | QCPAxis * | axis, |
bool | is_log_scale | ||
) |
void ModelView::Utils::SetLogarithmicScale | ( | QCPColorScale * | axis, |
bool | is_log_scale | ||
) |
Switch axis to logarithmic scale mode.
Definition at line 18 of file customplotutils.cpp.
Referenced by ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::setAxisLogScaleFromItem().
std::vector< SessionItem * > ModelView::Utils::SinglePropertyItems | ( | const SessionItem & | item | ) |
Returns vector of children representing property items.
Definition at line 122 of file itemutils.cpp.
References ModelView::SessionItem::children(), IsSinglePropertyTag(), ModelView::TagRow::tag, and ModelView::SessionItem::tagRowOfItem().
Referenced by ModelView::PropertyItemsStrategy::children(), ModelView::PropertyItemsFlatStrategy::children(), ModelView::PropertiesRowStrategy::constructRow(), and TEST_F().
QSize ModelView::Utils::SizeOfLetterM | ( | ) |
Returns size corresponding to actual size of letter M
basing on current font metrics.
Definition at line 116 of file widgetutils.cpp.
Referenced by gui2::OpenProjectWidget::OpenProjectWidget(), gui2::RecentProjectWidget::createRecentProjectScrollArea(), HeightOfLetterM(), and WidthOfLetterM().
int ModelView::Utils::SystemPointSize | ( | ) |
Returns size in points of default system font.
Definition at line 122 of file widgetutils.cpp.
Referenced by gui2::ImportTextView::ImportTextView(), and ScaleLabelFont().
QVariant ModelView::Utils::TextColorRole | ( | const SessionItem & | item | ) |
Returns text color for given item.
Definition at line 68 of file viewmodelutils.cpp.
References ModelView::SessionItem::isEnabled().
Referenced by ModelView::PropertyFlatView::PropertyFlatViewImpl::connect_model(), ModelView::ViewItem::data(), ItemRoleToQtRole(), and TEST_F().
Converts Qt variant to custom variant on board of SessionItem.
Definition at line 79 of file customvariants.cpp.
Referenced by ModelView::ViewItem::setData(), and TEST_F().
QVariant ModelView::Utils::ToolTipRole | ( | const SessionItem & | item | ) |
Returns tooltip role for given item.
Definition at line 91 of file viewmodelutils.cpp.
References ModelView::SessionItem::hasData(), ModelView::ItemDataRole::TOOLTIP, and ModelView::SessionItem::toolTip().
Referenced by ModelView::ViewItem::data(), and TEST_F().
T* ModelView::Utils::TopItem | ( | const SessionModel * | model | ) |
Returns top level item of given type.
Definition at line 47 of file modelutils.h.
std::vector<T*> ModelView::Utils::TopItems | ( | const SessionModel * | model | ) |
Returns all top level items of given type.
Definition at line 34 of file modelutils.h.
References ModelView::SessionItem::children(), and ModelView::SessionModel::rootItem().
std::vector< SessionItem * > ModelView::Utils::TopLevelItems | ( | const SessionItem & | item | ) |
Returns vector of children representing top level items.
Definition at line 113 of file itemutils.cpp.
References ModelView::SessionItem::children(), IsSinglePropertyTag(), ModelView::TagRow::tag, and ModelView::SessionItem::tagRowOfItem().
Referenced by ModelView::TopItemsStrategy::children(), and TEST_F().
Converts custom variant to standard variant which Qt views will understand.
Definition at line 61 of file customvariants.cpp.
References IsDoubleVectorVariant(), and ModelView::Constants::string_type_name.
Referenced by ModelView::ViewItem::data(), and TEST_F().
QStringList ModelView::Utils::toStringList | ( | const std::vector< std::string > & | vec | ) |
Converts vector of strings to QStringList.
Definition at line 148 of file widgetutils.cpp.
Referenced by gui2::DataLoaderDialog::setTargetCanvas(), and TEST_F().
void ModelView::Utils::Undo | ( | SessionModel & | model | ) |
Undo last model operation. If not undo/redo enabled, will do nothing.
Definition at line 79 of file modelutils.cpp.
References ModelView::SessionModel::undoStack().
std::vector< SessionItem * > ModelView::Utils::UniqueItems | ( | const std::vector< SessionItem * > & | items | ) |
Returns vector with duplicates and 'nullptr' filtered out.
Definition at line 170 of file itemutils.cpp.
References UniqueWithOrder().
Referenced by gui2::DataSelectionModel::selectedItems(), TEST_F(), and UniqueItemsFromIndex().
std::vector< SessionItem * > ModelView::Utils::UniqueItemsFromIndex | ( | const QModelIndexList & | index_list | ) |
Returns vector of underlying SessionItem's for given index list. Removes repetitions.
Definition at line 111 of file viewmodelutils.cpp.
References ItemsFromIndex(), and UniqueItems().
Referenced by gui2::DataViewModel::mimeData(), and TEST_F().
C ModelView::Utils::UniqueWithOrder | ( | const C & | container | ) |
Returns copy of container with all duplicated elements filtered our. The order is preserved.
Definition at line 88 of file containerutils.h.
Referenced by TEST_F(), and UniqueItems().
std::string ModelView::Utils::VariantName | ( | const Variant & | variant | ) |
Returns name of variant.
Definition at line 26 of file customvariants.cpp.
References ModelView::Constants::invalid_type_name.
Referenced by ModelView::VariantDependentEditorFactory::createEditor(), ModelView::JsonVariantConverter::get_json(), and TEST_F().
int ModelView::Utils::VariantType | ( | const Variant & | variant | ) |
Returns type of variant (additionally checks for user type).
Definition at line 31 of file customvariants.cpp.
Referenced by CompatibleVariantTypes(), and TEST_F().
int ModelView::Utils::WidthOfLetterM | ( | ) |
Returns width of the letter 'M' deduced from current font metrics.
Definition at line 106 of file widgetutils.cpp.
References SizeOfLetterM().
Referenced by gui2::SettingsView::SettingsView(), gui2::ParserPropertyWidget::addCustomSeparatorRow(), gui2::OpenProjectWidget::createLinkedLabelLayout(), gui2::SettingsView::init_list_selector(), and ModelView::StatusLabel::paintEvent().
QString ModelView::Utils::WithTildeHomePath | ( | const QString & | path | ) |
Returns a string where Linux path to the file is striped using '~/'.
Definition at line 79 of file widgetutils.cpp.
References IsWindowsHost().
Referenced by gui2::ActionManager::aboutToShowFileMenu(), gui2::ProjectPaneWidget::setCurrentProject(), and TEST_F().