mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4031 Ensemble : Fix operator<
This commit is contained in:
parent
89d55d8354
commit
d275b2bf60
@ -142,26 +142,43 @@ QString RiaSummaryCurveDefinition::curveDefinitionText(const QString& caseName,
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RiaSummaryCurveDefinition::operator<(const RiaSummaryCurveDefinition& other) const
|
bool RiaSummaryCurveDefinition::operator<(const RiaSummaryCurveDefinition& other) const
|
||||||
{
|
{
|
||||||
if (m_summaryCase != other.summaryCase())
|
|
||||||
{
|
{
|
||||||
// Try comparing the dereferenced objects first. They have a predictable sorting operator.
|
QString ensembleName;
|
||||||
if (m_summaryCase && other.summaryCase())
|
QString otherEnsembleName;
|
||||||
|
|
||||||
|
if (m_ensemble)
|
||||||
{
|
{
|
||||||
return *m_summaryCase < *other.summaryCase();
|
ensembleName = m_ensemble->name();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (other.ensemble())
|
||||||
|
{
|
||||||
|
otherEnsembleName = other.ensemble()->name();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ensembleName != otherEnsembleName)
|
||||||
|
{
|
||||||
|
return ensembleName < otherEnsembleName;
|
||||||
}
|
}
|
||||||
// Sorting by pointer address, which may appear random to the user.
|
|
||||||
return m_summaryCase < other.summaryCase();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_ensemble != other.ensemble())
|
|
||||||
{
|
{
|
||||||
// Try comparing the dereferenced objects first. They have a predictable sorting operator.
|
QString summaryCaseName;
|
||||||
if (m_ensemble && other.ensemble())
|
QString otherSummaryCaseName;
|
||||||
|
|
||||||
|
if (m_summaryCase)
|
||||||
{
|
{
|
||||||
return *m_ensemble < *other.ensemble();
|
summaryCaseName = m_summaryCase->caseName();
|
||||||
|
}
|
||||||
|
if (other.summaryCase())
|
||||||
|
{
|
||||||
|
otherSummaryCaseName = other.summaryCase()->caseName();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (summaryCaseName != otherSummaryCaseName)
|
||||||
|
{
|
||||||
|
return summaryCaseName < otherSummaryCaseName;
|
||||||
}
|
}
|
||||||
// Sorting by pointer address, which may appear random to the user.
|
|
||||||
return (m_ensemble < other.ensemble());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (m_summaryAddress < other.summaryAddress());
|
return (m_summaryAddress < other.summaryAddress());
|
||||||
|
Loading…
Reference in New Issue
Block a user