adding name sorting to dso and star browsers

pull/110/head
Gavin Stark 2018-04-27 08:40:35 -05:00 committed by Hleb Valoshka
parent bd076c38ab
commit 29a215ad17
3 changed files with 18 additions and 13 deletions

View File

@ -64,7 +64,7 @@ public:
SpectralType
};
StarPredicate(Criterion _criterion, const UniversalCoord& _observerPos);
StarPredicate(Criterion _criterion, const UniversalCoord& _observerPos, const Universe* _universe);
bool operator()(const Star* star0, const Star* star1) const;
@ -72,6 +72,7 @@ private:
Criterion criterion;
Vector3f pos;
UniversalCoord ucPos;
const Universe* universe;
};
@ -246,9 +247,11 @@ int StarTableModel::columnCount(const QModelIndex&) const
StarPredicate::StarPredicate(Criterion _criterion,
const UniversalCoord& _observerPos) :
const UniversalCoord& _observerPos,
const Universe *_universe) :
criterion(_criterion),
ucPos(_observerPos)
ucPos(_observerPos),
universe(_universe)
{
pos = ucPos.toLy().cast<float>();
}
@ -285,7 +288,7 @@ bool StarPredicate::operator()(const Star* star0, const Star* star1) const
return strcmp(star0->getSpectralType(), star1->getSpectralType()) < 0;
case Alphabetical:
return false; // TODO
return strcmp(universe->getStarCatalog()->getStarName(*star0, true).c_str(), universe->getStarCatalog()->getStarName(*star1, true).c_str()) < 0;
default:
return false;
@ -368,7 +371,7 @@ void StarTableModel::sort(int column, Qt::SortOrder order)
break;
}
StarPredicate pred(criterion, observerPos);
StarPredicate pred(criterion, observerPos, universe);
std::sort(stars.begin(), stars.end(), pred);
@ -391,7 +394,7 @@ void StarTableModel::populate(const UniversalCoord& _observerPos,
now = _now;
typedef multiset<Star*, StarPredicate> StarSet;
StarPredicate pred(criterion, observerPos);
StarPredicate pred(criterion, observerPos, universe);
// Apply the filter
vector<Star*> filteredStars;

View File

@ -61,13 +61,14 @@ public:
ObjectType
};
DSOPredicate(Criterion _criterion, const Vector3d& _observerPos);
DSOPredicate(Criterion _criterion, const Vector3d& _observerPos, const Universe* _universe);
bool operator()(const DeepSkyObject* dso0, const DeepSkyObject* dso1) const;
private:
Criterion criterion;
Vector3d pos;
const Universe *universe;
};
@ -211,9 +212,11 @@ int DSOTableModel::columnCount(const QModelIndex&) const
DSOPredicate::DSOPredicate(Criterion _criterion,
const Vector3d& _observerPos) :
const Vector3d& _observerPos,
const Universe* _universe) :
criterion(_criterion),
pos(_observerPos)
pos(_observerPos),
universe(_universe)
{
}
@ -241,7 +244,7 @@ bool DSOPredicate::operator()(const DeepSkyObject* dso0, const DeepSkyObject* ds
return strcmp(dso0->getType(), dso1->getType()) < 0;
case Alphabetical:
return false; // TODO
return strcmp(universe->getDSOCatalog()->getDSOName(dso0, true).c_str(), universe->getDSOCatalog()->getDSOName(dso1, true).c_str()) > 0;
default:
return false;
@ -294,7 +297,7 @@ void DSOTableModel::sort(int column, Qt::SortOrder order)
break;
}
DSOPredicate pred(criterion, observerPos);
DSOPredicate pred(criterion, observerPos, universe);
std::sort(dsos.begin(), dsos.end(), pred);
@ -316,7 +319,7 @@ void DSOTableModel::populate(const UniversalCoord& _observerPos,
typedef multiset<DeepSkyObject*, DSOPredicate> DSOSet;
DSOPredicate pred(criterion, observerPos);
DSOPredicate pred(criterion, observerPos, universe);
// Apply the filter
vector<DeepSkyObject*> filteredDSOs;

View File

@ -643,7 +643,6 @@ int SolarSystemTreeModel::columnCount(const QModelIndex&) const
return 2;
}
void SolarSystemTreeModel::sort(int /* column */, Qt::SortOrder /* order */)
{
}