Skip to content
Snippets Groups Projects
Commit bb875a5a authored by Wuttke, Joachim's avatar Wuttke, Joachim Committed by Wuttke, Joachim
Browse files

merge fct

parent 60013462
No related branches found
No related tags found
1 merge request!2052simplify SampleValidator (class -> namespace)
...@@ -21,18 +21,6 @@ ...@@ -21,18 +21,6 @@
#include "GUI/Model/Sample/ParticleLayoutItem.h" #include "GUI/Model/Sample/ParticleLayoutItem.h"
#include "GUI/Model/Sample/SampleItem.h" #include "GUI/Model/Sample/SampleItem.h"
void SampleValidator::validateItem(const ItemWithParticles* item)
{
if (const auto* p = dynamic_cast<const CoreAndShellItem*>(item)) {
if (!p->coreItem())
addMessage("Sim/shell particle doesn't have core defined.");
if (!p->shellItem())
addMessage("Sim/shell particle doesn't have shell defined.");
} else if (const auto* p = dynamic_cast<const CompoundItem*>(item))
if (p->itemsWithParticles().isEmpty())
addMessage("Particle composition doesn't have any particles.");
}
void SampleValidator::addMessage(const QString& m) void SampleValidator::addMessage(const QString& m)
{ {
m_messages += QString("* ") + m + "\n"; m_messages += QString("* ") + m + "\n";
...@@ -55,7 +43,14 @@ bool SampleValidator::isValidSample(const SampleItem* sample) ...@@ -55,7 +43,14 @@ bool SampleValidator::isValidSample(const SampleItem* sample)
if (layout->itemsWithParticles().isEmpty()) if (layout->itemsWithParticles().isEmpty())
addMessage("Particle layout doesn't contain any particles."); addMessage("Particle layout doesn't contain any particles.");
for (const auto* particle : layout->containedItemsWithParticles()) { for (const auto* particle : layout->containedItemsWithParticles()) {
validateItem(particle); if (const auto* p = dynamic_cast<const CoreAndShellItem*>(particle)) {
if (!p->coreItem())
addMessage("Sim/shell particle doesn't have core defined.");
if (!p->shellItem())
addMessage("Sim/shell particle doesn't have shell defined.");
} else if (const auto* p = dynamic_cast<const CompoundItem*>(particle))
if (p->itemsWithParticles().isEmpty())
addMessage("Particle composition doesn't have any particles.");
} }
} }
} }
......
...@@ -29,8 +29,6 @@ public: ...@@ -29,8 +29,6 @@ public:
QString getValidationMessage() const { return m_messages; } QString getValidationMessage() const { return m_messages; }
private: private:
void validateItem(const ItemWithParticles* item);
//! Adds this message to the report. //! Adds this message to the report.
void addMessage(const QString& m); void addMessage(const QString& m);
......
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