Skip to content

Commit

Permalink
Activity class of meteor showers added in GUI of Search Tool now
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-w committed Sep 24, 2024
1 parent a442a92 commit ecce4d3
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 15 deletions.
21 changes: 12 additions & 9 deletions plugins/MeteorShowers/src/MeteorShower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,6 @@ QString MeteorShower::getInfoString(const StelCore* core, const InfoStringGroup&
{ INACTIVE, q_("inactive")}};
QString mstdata = mstMap.value(m_status, "");

const QMap<int, QString>classMap={
{ 1, "I" }, { 2, "II" }, { 3, "III" }, { 4, "IV" }
};
QString mClass = classMap.value(m_class, "");

if (flags&Name)
{
oss << "<h2>" << getNameI18n();
Expand All @@ -556,7 +551,7 @@ QString MeteorShower::getInfoString(const StelCore* core, const InfoStringGroup&
if (m_class==0)
oss << QString("%1: <b>%2</b> (%3)").arg(q_("Type"), getObjectTypeI18n(), mstdata) << "<br />";
else
oss << QString("%1: <b>%2</b> (%3; %4 %5)").arg(q_("Type"), getObjectTypeI18n(), mstdata, qc_("class","class of meteor shower"), mClass) << "<br />";
oss << QString("%1: <b>%2</b> (%3; %4 %5)").arg(q_("Type"), getObjectTypeI18n(), mstdata, qc_("class","activity class of meteor shower"), getActivityClass().second) << "<br />";
}

// Ra/Dec etc.
Expand Down Expand Up @@ -774,18 +769,26 @@ QString MeteorShower::getInfoString(const StelCore* core, const InfoStringGroup&
}

if (m_class>0)
oss << QString("%1: %2").arg(q_("Description of class"), getClassDescription(m_class)) << "<br />";
oss << QString("%1: %2").arg(q_("Description of class"), getClassDescription()) << "<br />";
}

oss << getSolarLunarInfoString(core, flags);
postProcessInfoString(str, flags);
return str;
}

QString MeteorShower::getClassDescription(int mclass) const
QPair<int, QString> MeteorShower::getActivityClass() const
{
const QMap<int, QString>activityClassMap={
{ 1, "I" }, { 2, "II" }, { 3, "III" }, { 4, "IV" }
};
return qMakePair(m_class, activityClassMap.value(m_class, ""));
}

QString MeteorShower::getClassDescription() const
{
QString mcdesc;
switch (mclass) {
switch (m_class) {
case 1:
mcdesc = qc_("the strongest annual showers with ZHR’s normally ten or better.", "description of meteor shower class");
break;
Expand Down
4 changes: 3 additions & 1 deletion plugins/MeteorShowers/src/MeteorShower.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class MeteorShower : public StelObject
float getSelectPriority(const StelCore*) const override { return -4.0; }
Vec3f getInfoColor(void) const override;

QPair<int, QString> getActivityClass() const;

//! @return approximate Julian day calculated from solar longitude (J2000)
static double JDfromSolarLongitude(double solarLong, int year);

Expand Down Expand Up @@ -165,7 +167,7 @@ class MeteorShower : public StelObject
//! Calculates the ZHR using two types of distribution function
int calculateZHR(StelCore* core);

QString getClassDescription(int mclass) const;
QString getClassDescription() const;
};

#endif /* METEORSHOWER_HPP */
1 change: 1 addition & 0 deletions plugins/MeteorShowers/src/MeteorShowers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ QList<MeteorShowers::SearchResult> MeteorShowers::searchEvents(int year) const
if (found)
{
r.code = ms->getID();
r.activityClass = ms->getActivityClass();
if (r.code!="ANT")
{
r.name = ms->getNameI18n();
Expand Down
1 change: 1 addition & 0 deletions plugins/MeteorShowers/src/MeteorShowers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class MeteorShowers : public StelObjectModule
int peakyear;
int zhrMax;
int zhrMin;
QPair<int, QString> activityClass;
};

//! Constructor
Expand Down
5 changes: 4 additions & 1 deletion plugins/MeteorShowers/src/gui/MSSearchDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ void MSSearchDialog::searchEvents()
treeItem->setText(ColumnZHR, QString("%1-%2").arg(r.zhrMin).arg(r.zhrMax));
else
treeItem->setText(ColumnZHR, QString::number(r.zhrMax));
treeItem->setText(ColumnClass, r.activityClass.first>0 ? r.activityClass.second : QChar(0x2014));

// let's store the stuff in the UserRole to allow easier sorting
// check MSTreeWidgetItem::operator <()
Expand All @@ -130,6 +131,7 @@ void MSSearchDialog::searchEvents()
treeItem->setData(ColumnDataType, Qt::UserRole, r.type);
treeItem->setData(ColumnPeak, Qt::UserRole, peakJD);
treeItem->setData(ColumnZHR, Qt::UserRole, r.zhrMax);
treeItem->setData(ColumnClass, Qt::UserRole, r.activityClass.first);
}

// adjust the column width
Expand Down Expand Up @@ -181,9 +183,10 @@ void MSSearchDialog::setHeaderNames()
QStringList headerStrings;
headerStrings << q_("Code");
headerStrings << q_("Name");
headerStrings << q_("ZHR");
headerStrings << qc_("ZHR","column name");
headerStrings << q_("Data Type");
headerStrings << q_("Peak");
headerStrings << q_("Class");
m_ui->listEvents->setHeaderLabels(headerStrings);

// adjust the column width
Expand Down
3 changes: 2 additions & 1 deletion plugins/MeteorShowers/src/gui/MSSearchDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class MSSearchDialog : public StelDialog
ColumnZHR, //! zhr column
ColumnDataType, //! data type column
ColumnPeak, //! peak date column
ColumnClass, //! activity class column
ColumnCount //! total number of columns
};

Expand Down Expand Up @@ -95,7 +96,7 @@ class MSTreeWidgetItem : public QTreeWidgetItem
{
const int column = treeWidget()->sortColumn();

if (column == MSSearchDialog::ColumnZHR)
if (column == MSSearchDialog::ColumnZHR || column == MSSearchDialog::ColumnClass)
return this->data(column, Qt::UserRole).toInt() < other.data(column, Qt::UserRole).toInt();
else if (column == MSSearchDialog::ColumnPeak)
return this->data(column, Qt::UserRole).toDouble() < other.data(column, Qt::UserRole).toDouble();
Expand Down
3 changes: 0 additions & 3 deletions plugins/MeteorShowers/src/gui/MSSearchDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@
<height>100</height>
</size>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
Expand Down

0 comments on commit ecce4d3

Please sign in to comment.