BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SessionItemUtils.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Models/SessionItemUtils.h
6 //! @brief Defines namespace SessionItemUtils
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI_COREGUI_MODELS_SESSIONITEMUTILS_H
16 #define BORNAGAIN_GUI_COREGUI_MODELS_SESSIONITEMUTILS_H
17 
18 #include "Base/Vector/Vectors3D.h"
19 #include <QString>
20 #include <QVariant>
21 
22 class SessionItem;
23 class GroupInfo;
24 
25 namespace SessionItemUtils {
26 //! Returns the index of the given item within its parent. Returns -1 when no parent is set.
27 int ParentRow(const SessionItem& item);
28 
29 //! Returns the row of the given item within its parent not accounting for all hidden items
30 //! above. Returns -1 when no parent set or item is hidden.
31 int ParentVisibleRow(const SessionItem& item);
32 
33 //! Returns text color for given item.
34 QVariant ForegroundRole(const SessionItem& item);
35 
36 //! Returns tooltip for given item.
37 QVariant ToolTipRole(const SessionItem& item, int ncol = 0);
38 
39 //! Returns tooltip for given item.
40 QVariant DecorationRole(const SessionItem& item);
41 
42 //! Returns check state for given item.
43 QVariant CheckStateRole(const SessionItem& item);
44 
45 //! Returns true if there is registered group.
46 bool IsValidGroup(const QString& group_type);
47 
48 //! Returns GroupInfo for group property construction
49 GroupInfo GetGroupInfo(const QString& group_type);
50 
51 //! Returns type of variant (additionally checks for user type).
52 int VariantType(const QVariant& variant);
53 
54 //! Returns true if variants has compatible types.
55 bool CompatibleVariantTypes(const QVariant& oldValue, const QVariant& newValue);
56 
57 //! Returns true if given variants have same type and value.
58 //! For custom variants (ComboProperty, ExternalProperty) will always return false (see
59 //! explanations in cpp file).
60 
61 bool IsTheSame(const QVariant& var1, const QVariant& var2);
62 
63 //! Returns true if current item is related to the position on sample editor canvas.
64 bool IsPositionRelated(const SessionItem& item);
65 
66 bool HasOwnAbundance(const SessionItem* item);
67 
68 } // namespace SessionItemUtils
69 
70 #endif // BORNAGAIN_GUI_COREGUI_MODELS_SESSIONITEMUTILS_H
Defines basic vectors in Z^3, R^3, C^3.
Defines info for GroupProperty, i.e.
Definition: GroupInfo.h:25
QVariant DecorationRole(const SessionItem &item)
Returns tooltip for given item.
bool IsTheSame(const QVariant &var1, const QVariant &var2)
Returns true if given variants have same type and value.
int VariantType(const QVariant &variant)
Returns type of variant (additionally checks for user type).
QVariant CheckStateRole(const SessionItem &item)
Returns check state for given item.
QVariant ToolTipRole(const SessionItem &item, int ncol=0)
Returns tooltip for given item.
QVariant ForegroundRole(const SessionItem &item)
Returns text color for given item.
bool CompatibleVariantTypes(const QVariant &oldValue, const QVariant &newValue)
Returns true if variants has compatible types.
bool IsPositionRelated(const SessionItem &item)
Returns true if current item is related to the position on sample editor canvas.
bool IsValidGroup(const QString &group_type)
Returns true if there is registered group.
int ParentVisibleRow(const SessionItem &item)
Returns the row of the given item within its parent not accounting for all hidden items above.
int ParentRow(const SessionItem &item)
Returns the index of the given item within its parent. Returns -1 when no parent is set.
GroupInfo GetGroupInfo(const QString &group_type)
Returns GroupInfo for group property construction.
bool HasOwnAbundance(const SessionItem *item)