From ecce4d3d9ff6573ae84e4f080423bc2724ec6742 Mon Sep 17 00:00:00 2001 From: "Alexander V. Wolf" Date: Tue, 24 Sep 2024 16:07:49 +0700 Subject: [PATCH] Activity class of meteor showers added in GUI of Search Tool now --- plugins/MeteorShowers/src/MeteorShower.cpp | 21 +++++++++++-------- plugins/MeteorShowers/src/MeteorShower.hpp | 4 +++- plugins/MeteorShowers/src/MeteorShowers.cpp | 1 + plugins/MeteorShowers/src/MeteorShowers.hpp | 1 + .../MeteorShowers/src/gui/MSSearchDialog.cpp | 5 ++++- .../MeteorShowers/src/gui/MSSearchDialog.hpp | 3 ++- .../MeteorShowers/src/gui/MSSearchDialog.ui | 3 --- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/plugins/MeteorShowers/src/MeteorShower.cpp b/plugins/MeteorShowers/src/MeteorShower.cpp index 23a8cba2ed2dee..d9baac99594dd8 100644 --- a/plugins/MeteorShowers/src/MeteorShower.cpp +++ b/plugins/MeteorShowers/src/MeteorShower.cpp @@ -538,11 +538,6 @@ QString MeteorShower::getInfoString(const StelCore* core, const InfoStringGroup& { INACTIVE, q_("inactive")}}; QString mstdata = mstMap.value(m_status, ""); - const QMapclassMap={ - { 1, "I" }, { 2, "II" }, { 3, "III" }, { 4, "IV" } - }; - QString mClass = classMap.value(m_class, ""); - if (flags&Name) { oss << "

" << getNameI18n(); @@ -556,7 +551,7 @@ QString MeteorShower::getInfoString(const StelCore* core, const InfoStringGroup& if (m_class==0) oss << QString("%1: %2 (%3)").arg(q_("Type"), getObjectTypeI18n(), mstdata) << "
"; else - oss << QString("%1: %2 (%3; %4 %5)").arg(q_("Type"), getObjectTypeI18n(), mstdata, qc_("class","class of meteor shower"), mClass) << "
"; + oss << QString("%1: %2 (%3; %4 %5)").arg(q_("Type"), getObjectTypeI18n(), mstdata, qc_("class","activity class of meteor shower"), getActivityClass().second) << "
"; } // Ra/Dec etc. @@ -774,7 +769,7 @@ QString MeteorShower::getInfoString(const StelCore* core, const InfoStringGroup& } if (m_class>0) - oss << QString("%1: %2").arg(q_("Description of class"), getClassDescription(m_class)) << "
"; + oss << QString("%1: %2").arg(q_("Description of class"), getClassDescription()) << "
"; } oss << getSolarLunarInfoString(core, flags); @@ -782,10 +777,18 @@ QString MeteorShower::getInfoString(const StelCore* core, const InfoStringGroup& return str; } -QString MeteorShower::getClassDescription(int mclass) const +QPair MeteorShower::getActivityClass() const +{ + const QMapactivityClassMap={ + { 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; diff --git a/plugins/MeteorShowers/src/MeteorShower.hpp b/plugins/MeteorShowers/src/MeteorShower.hpp index 0f0b6b3534c756..4c2637023e608f 100644 --- a/plugins/MeteorShowers/src/MeteorShower.hpp +++ b/plugins/MeteorShowers/src/MeteorShower.hpp @@ -124,6 +124,8 @@ class MeteorShower : public StelObject float getSelectPriority(const StelCore*) const override { return -4.0; } Vec3f getInfoColor(void) const override; + QPair getActivityClass() const; + //! @return approximate Julian day calculated from solar longitude (J2000) static double JDfromSolarLongitude(double solarLong, int year); @@ -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 */ diff --git a/plugins/MeteorShowers/src/MeteorShowers.cpp b/plugins/MeteorShowers/src/MeteorShowers.cpp index 8d9c04838d995b..f3bf4830701d53 100644 --- a/plugins/MeteorShowers/src/MeteorShowers.cpp +++ b/plugins/MeteorShowers/src/MeteorShowers.cpp @@ -146,6 +146,7 @@ QList MeteorShowers::searchEvents(int year) const if (found) { r.code = ms->getID(); + r.activityClass = ms->getActivityClass(); if (r.code!="ANT") { r.name = ms->getNameI18n(); diff --git a/plugins/MeteorShowers/src/MeteorShowers.hpp b/plugins/MeteorShowers/src/MeteorShowers.hpp index 9e7e9eb27a761a..65216b6d60afe8 100644 --- a/plugins/MeteorShowers/src/MeteorShowers.hpp +++ b/plugins/MeteorShowers/src/MeteorShowers.hpp @@ -46,6 +46,7 @@ class MeteorShowers : public StelObjectModule int peakyear; int zhrMax; int zhrMin; + QPair activityClass; }; //! Constructor diff --git a/plugins/MeteorShowers/src/gui/MSSearchDialog.cpp b/plugins/MeteorShowers/src/gui/MSSearchDialog.cpp index bc3d509b625308..0e49ba878da4ad 100644 --- a/plugins/MeteorShowers/src/gui/MSSearchDialog.cpp +++ b/plugins/MeteorShowers/src/gui/MSSearchDialog.cpp @@ -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 <() @@ -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 @@ -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 diff --git a/plugins/MeteorShowers/src/gui/MSSearchDialog.hpp b/plugins/MeteorShowers/src/gui/MSSearchDialog.hpp index f15cf934d10ddf..2209b57162a31b 100644 --- a/plugins/MeteorShowers/src/gui/MSSearchDialog.hpp +++ b/plugins/MeteorShowers/src/gui/MSSearchDialog.hpp @@ -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 }; @@ -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(); diff --git a/plugins/MeteorShowers/src/gui/MSSearchDialog.ui b/plugins/MeteorShowers/src/gui/MSSearchDialog.ui index 4fd20f3790d27a..39ec547914755a 100644 --- a/plugins/MeteorShowers/src/gui/MSSearchDialog.ui +++ b/plugins/MeteorShowers/src/gui/MSSearchDialog.ui @@ -151,9 +151,6 @@ 100 - - Qt::ScrollBarAlwaysOff - QAbstractItemView::NoEditTriggers