Skip to content
Snippets Groups Projects
Commit ea290d34 authored by Matthias Puchner's avatar Matthias Puchner
Browse files

enhance UIntDescriptor

parent 66677268
Branches
Tags
1 merge request!570remove SessionModel/Item from SampleModel and all related items
...@@ -49,6 +49,14 @@ UIntDescriptor::UIntDescriptor(QString label, QString tooltip, const RealLimits& ...@@ -49,6 +49,14 @@ UIntDescriptor::UIntDescriptor(QString label, QString tooltip, const RealLimits&
{ {
} }
UIntDescriptor::UIntDescriptor(const QString& label, const uint* var,
const variant<QString, Unit>& unit)
: UIntDescriptor(
label, "", RealLimits::nonnegative(), [=](uint v) { *const_cast<uint*>(var) = v; },
[=] { return *var; }, unit)
{
}
UIntDescriptor::operator uint() const UIntDescriptor::operator uint() const
{ {
return get(); return get();
......
...@@ -35,6 +35,7 @@ using std::variant; ...@@ -35,6 +35,7 @@ using std::variant;
//! member, or any other construction to hold a uint value. //! member, or any other construction to hold a uint value.
class UIntDescriptor { class UIntDescriptor {
public: public:
UIntDescriptor() = default;
//! Operates on a session item. The settings (like limits) are taken from the session //! Operates on a session item. The settings (like limits) are taken from the session
//! item. //! item.
//! Only for easier migration. Should be removed after SessionItem refactoring. //! Only for easier migration. Should be removed after SessionItem refactoring.
...@@ -45,6 +46,8 @@ public: ...@@ -45,6 +46,8 @@ public:
//! Only for easier migration. Should be removed after SessionItem refactoring. //! Only for easier migration. Should be removed after SessionItem refactoring.
UIntDescriptor(const QString& label, SessionItem* item, const variant<QString, Unit>& unit); UIntDescriptor(const QString& label, SessionItem* item, const variant<QString, Unit>& unit);
UIntDescriptor(const QString& label, const uint* var, const variant<QString, Unit>& unit);
private: private:
//! Operates on any kind of storage (e.g. session items), by using setter/getter methods //! Operates on any kind of storage (e.g. session items), by using setter/getter methods
UIntDescriptor(QString label, QString tooltip, const RealLimits& limits, UIntDescriptor(QString label, QString tooltip, const RealLimits& limits,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment