12#include "CelestialSortFilterProxyModel.h"
17CelestialSortFilterProxyModel::CelestialSortFilterProxyModel()
24CelestialSortFilterProxyModel::~CelestialSortFilterProxyModel() =
default;
31 if (newOne ==
tr(
"Moon")) {
33 }
else if (m_moons.contains(newOne.
toLower())) {
35 }
else if (m_dwarfs.contains(newOne.
toLower())) {
44void CelestialSortFilterProxyModel::setupPriorities()
50 m_priority[QStringLiteral(
"sun")] = prefix;
51 m_priority[QStringLiteral(
"mercury")] = prefix--;
52 m_priority[QStringLiteral(
"venus")] = prefix--;
53 m_priority[QStringLiteral(
"earth")] = prefix--;
54 m_priority[QStringLiteral(
"moon")] = prefix--;
55 m_priority[QStringLiteral(
"mars")] = prefix--;
57 m_priority[QStringLiteral(
"jupiter")] = prefix--;
59 m_priority[QStringLiteral(
"io")] = prefix--;
60 m_priority[QStringLiteral(
"europa")] = prefix--;
61 m_priority[QStringLiteral(
"ganymede")] = prefix--;
62 m_priority[QStringLiteral(
"callisto")] = prefix--;
64 m_priority[QStringLiteral(
"saturn")] = prefix--;
66 m_priority[QStringLiteral(
"mimas")] = prefix--;
67 m_priority[QStringLiteral(
"enceladus")] = prefix--;
68 m_priority[QStringLiteral(
"thetys")] = prefix--;
69 m_priority[QStringLiteral(
"dione")] = prefix--;
70 m_priority[QStringLiteral(
"rhea")] = prefix--;
71 m_priority[QStringLiteral(
"titan")] = prefix--;
72 m_priority[QStringLiteral(
"iapetus")] = prefix--;
74 m_priority[QStringLiteral(
"uranus")] = prefix--;
75 m_priority[QStringLiteral(
"neptune")] = prefix--;
76 m_priority[QStringLiteral(
"pluto")] = prefix--;
77 m_priority[QStringLiteral(
"ceres")] = prefix--;
80void CelestialSortFilterProxyModel::setupMoonsList()
82 m_moons.
push_back(QStringLiteral(
"moon"));
83 m_moons.
push_back(QStringLiteral(
"europa"));
84 m_moons.
push_back(QStringLiteral(
"ganymede"));
85 m_moons.
push_back(QStringLiteral(
"callisto"));
86 m_moons.
push_back(QStringLiteral(
"mimas"));
87 m_moons.
push_back(QStringLiteral(
"enceladus"));
88 m_moons.
push_back(QStringLiteral(
"thetys"));
89 m_moons.
push_back(QStringLiteral(
"dione"));
90 m_moons.
push_back(QStringLiteral(
"rhea"));
91 m_moons.
push_back(QStringLiteral(
"titan"));
92 m_moons.
push_back(QStringLiteral(
"iapetus"));
95void CelestialSortFilterProxyModel::setupDwarfsList()
97 m_dwarfs.push_back(QStringLiteral(
"pluto"));
98 m_dwarfs.push_back(QStringLiteral(
"ceres"));
101bool CelestialSortFilterProxyModel::lessThan(
const QModelIndex &left,
const QModelIndex &right)
const
103 const QString nameLeft =
sourceModel()->index(
left.row(), 1).data().toString();
104 const QString nameRight =
sourceModel()->index(
right.row(), 1).data().toString();
105 const QString first = nameLeft.
toLower();
106 const QString second = nameRight.
toLower();
109 if (m_priority.contains(first) && m_priority.contains(second)) {
110 return m_priority[first] > m_priority[second];
114 if (m_priority.contains(first) && !m_priority.contains(second)) {
119 if (!m_priority.contains(first) && m_priority.contains(second)) {
128#include "moc_CelestialSortFilterProxyModel.cpp"
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
A small trick to change names for dwarfs and moons.
Binds a QML item to a specific geodetic location in screen coordinates.
void push_back(parameter_type value)
QString tr(const char *sourceText, const char *disambiguation, int n)
virtual QVariant data(const QModelIndex &index, int role) const const override
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
virtual bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const const
QString toLower() const const
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)
QString toString() const const