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

rm path usage of SessionModel, use identifier instead

parent 3d260ee9
No related branches found
No related tags found
1 merge request!570remove SessionModel/Item from SampleModel and all related items
......@@ -95,7 +95,7 @@ DoubleDescriptor MaterialItem::delta()
DoubleDescriptor d(
"Delta", "Delta of refractive index (n = 1 - delta + i*beta)", 3, RealLimits::limitless(),
setter, [=] { return m_delta; }, Unit::unitless);
d.path = [=] { return GUI::Model::Path::getPathFromItem(this) + "/delta"; };
d.path = [=] { return uidForDescriptor("delta"); };
return d;
}
......@@ -112,7 +112,7 @@ DoubleDescriptor MaterialItem::beta()
DoubleDescriptor d(
"Beta", "Beta of refractive index (n = 1 - delta + i*beta)", 3, RealLimits::limitless(),
setter, [=] { return m_beta; }, Unit::unitless);
d.path = [=] { return GUI::Model::Path::getPathFromItem(this) + "/beta"; };
d.path = [=] { return uidForDescriptor("beta"); };
return d;
}
......@@ -129,7 +129,7 @@ DoubleDescriptor MaterialItem::sldRe()
DoubleDescriptor d(
"SLD, real", "Real part of SLD (SLD = real - i*imag), AA^{-2}", 3, RealLimits::limitless(),
setter, [=] { return m_real; }, Unit::unitless);
d.path = [=] { return GUI::Model::Path::getPathFromItem(this) + "/re"; };
d.path = [=] { return uidForDescriptor("re"); };
return d;
}
......@@ -146,7 +146,7 @@ DoubleDescriptor MaterialItem::sldIm()
DoubleDescriptor d(
"SLD, imaginary", "Imaginary part of SLD (SLD = real - i*imag), AA^{-2}", 3,
RealLimits::limitless(), setter, [=] { return m_imag; }, Unit::unitless);
d.path = [=] { return GUI::Model::Path::getPathFromItem(this) + "/im"; };
d.path = [=] { return uidForDescriptor("im"); };
return d;
}
......@@ -161,7 +161,7 @@ VectorDescriptor MaterialItem::magnetizationVector()
}
};
d.x.get = [=]() { return m_magnetization.x(); };
d.x.path = [=] { return GUI::Model::Path::getPathFromItem(this) + "/mx"; };
d.x.path = [=] { return uidForDescriptor("mx"); };
d.y.set = [=](double v) {
if (m_magnetization.y() != v) {
......@@ -170,7 +170,7 @@ VectorDescriptor MaterialItem::magnetizationVector()
}
};
d.y.get = [=]() { return m_magnetization.y(); };
d.y.path = [=] { return GUI::Model::Path::getPathFromItem(this) + "/my"; };
d.y.path = [=] { return uidForDescriptor("my"); };
d.z.set = [=](double v) {
if (m_magnetization.z() != v) {
......@@ -179,7 +179,7 @@ VectorDescriptor MaterialItem::magnetizationVector()
}
};
d.z.get = [=]() { return m_magnetization.z(); };
d.z.path = [=] { return GUI::Model::Path::getPathFromItem(this) + "/mz"; };
d.z.path = [=] { return uidForDescriptor("mz"); };
return d;
}
......@@ -308,6 +308,11 @@ void MaterialItem::updateFrom(const MaterialItem& other)
}
}
QString MaterialItem::uidForDescriptor(const QString& lastPart) const
{
return "material/" + identifier() + "/" + lastPart;
}
bool MaterialItem::operator!=(const MaterialItem& other) const
{
return !operator==(other);
......
......@@ -88,6 +88,12 @@ public:
//! emits dataChanged, if differences exist.
void updateFrom(const MaterialItem& other);
private:
//! Returns a unique identifier for descriptors.
//!
//! lastPart will be attached to identify the relevant descriptor.
QString uidForDescriptor(const QString& lastPart) const;
signals:
void dataChanged() const;
......
......@@ -84,8 +84,3 @@ QString GUI::Model::Path::getPathFromItem(SessionItem* item)
ASSERT(item->model()); // if assert, item is not completely initialized
return getPathFromIndex(item->model()->indexOfItem(item));
}
QString GUI::Model::Path::getPathFromItem(const MaterialItem* item)
{
return "material/" + item->identifier();
}
......@@ -30,8 +30,6 @@ QString getPathFromIndex(const QModelIndex& index);
QString getPathFromItem(SessionItem* item);
QString getPathFromItem(const MaterialItem* item);
QModelIndex getIndexFromPath(const SessionModel* model, const QString& path);
bool isValidItem(SessionModel* model, SessionItem* item, const QModelIndex& parent);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment