Kstars

pwizobjectselection.cpp
1/*
2 SPDX-FileCopyrightText: 2011 Rafał Kułaga <rl.kulaga@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "pwizobjectselection.h"
8#include "printingwizard.h"
9#include "kstars.h"
10#include "skymap.h"
11#include "dialogs/finddialog.h"
12#include "dialogs/detaildialog.h"
13#include "starobject.h"
14#include "ksplanetbase.h"
15#include "catalogobject.h"
16#include <QPointer>
17#include <KLocalizedString>
18
20 : QFrame(parent), m_ParentWizard(wizard)
21{
22 setupUi(this);
23
24 detailsButton->setVisible(false);
25 selectedObjLabel->setVisible(false);
26 objInfoLabel->setVisible(false);
27
28 connect(fromListButton, SIGNAL(clicked()), this, SLOT(slotSelectFromList()));
29 connect(pointButton, SIGNAL(clicked()), this, SLOT(slotPointObject()));
30 connect(detailsButton, SIGNAL(clicked()), this, SLOT(slotShowDetails()));
31}
32
34{
35 m_ParentWizard->setSkyObject(obj);
36 m_ParentWizard->updateStepButtons();
37
38 QString infoStr = objectInfoString(obj);
39
40 objInfoLabel->setText(infoStr);
41
42 detailsButton->setVisible(true);
43 selectedObjLabel->setVisible(true);
44 objInfoLabel->setVisible(true);
45}
46
47void PWizObjectSelectionUI::slotSelectFromList()
48{
49 if (FindDialog::Instance()->exec() == QDialog::Accepted)
50 {
51 SkyObject *obj = FindDialog::Instance()->targetObject();
52 if (obj)
53 {
54 setSkyObject(obj);
55 m_ParentWizard->updateStepButtons();
56 }
57 }
58}
59
60void PWizObjectSelectionUI::slotPointObject()
61{
62 m_ParentWizard->beginPointing();
63}
64
65void PWizObjectSelectionUI::slotShowDetails()
66{
67 if (m_ParentWizard->getSkyObject())
68 {
70 m_ParentWizard->getSkyObject(), KStars::Instance()->data()->ut(), KStars::Instance()->data()->geo(), this));
71 detailDlg->exec();
72 delete detailDlg;
73 }
74}
75
77{
78 QString retVal;
79
80 switch (obj->type())
81 {
82 case SkyObject::STAR:
83 {
84 StarObject *s = (StarObject *)obj;
85
86 retVal = s->longname();
87
88 if (s->getHDIndex() != 0)
89 {
90 if (!s->longname().isEmpty())
91 {
92 retVal += QString(" ● HD%1").arg(QString::number(s->getHDIndex()));
93 }
94
95 else
96 {
97 retVal += QString(" ● HD%1").arg(QString::number(s->getHDIndex()));
98 }
99 }
100
101 retVal += " ● " + s->sptype() + ' ' + i18n("star");
102 retVal += " ● " + i18nc("number in magnitudes", "%1 mag", QLocale().toString(s->mag(), 1));
103
104 break;
105 }
106
107 case SkyObject::ASTEROID: //[fall through to planets]
108 case SkyObject::COMET: //[fall through to planets]
109 case SkyObject::MOON: //[fall through to planets]
110
111 case SkyObject::PLANET:
112 {
113 KSPlanetBase *ps = (KSPlanetBase *)obj;
114
115 retVal = ps->longname();
116
117 //Type is "G5 star" for Sun
118 QString type;
119 if (ps->name() == i18n("Sun"))
120 {
121 type = i18n("G5 star");
122 }
123
124 else if (ps->name() == i18n("Moon"))
125 {
126 type = ps->translatedName();
127 }
128
129 else if (ps->name() == i18nc("Asteroid name (optional)", "Pluto") || ps->name() == i18nc("Asteroid name (optional)", "Ceres") || ps->name() == i18nc("Asteroid name (optional)", "Eris"))
130 {
131 type = i18n("Dwarf planet");
132 }
133 else
134 {
135 type = ps->typeName();
136 }
137
138 retVal += " ● " + type;
139 retVal += " ● " + i18nc("number in magnitudes", "%1 mag", QLocale().toString(ps->mag(), 1));
140
141 break;
142 }
143
144 default: // deep-sky object
145 {
146 auto *dso = (CatalogObject *)obj;
147
148 QString oname, pname;
149 //Show all names recorded for the object
150 if (!dso->longname().isEmpty() && dso->longname() != dso->name())
151 {
152 pname = dso->translatedLongName();
153 oname = dso->translatedName();
154 }
155
156 else
157 {
158 pname = dso->translatedName();
159 }
160
161 if (!dso->translatedName2().isEmpty())
162 {
163 if (oname.isEmpty())
164 {
165 oname = dso->translatedName2();
166 }
167
168 else
169 {
170 oname += " ● " + dso->translatedName2();
171 }
172 }
173
174 oname += " ● " + dso->catalogIdentifier();
175
176 if (!oname.isEmpty())
177 pname += " ● " + oname;
178
179 retVal = pname;
180 retVal += " ● " + dso->typeName();
181
182 break;
183 }
184 }
185
186 return retVal;
187}
A simple container object to hold the minimum information for a Deep Sky Object to be drawn on the sk...
DetailDialog is a window showing detailed information for a selected object.
SkyObject * targetObject()
Definition finddialog.h:53
A subclass of TrailObject that provides additional information needed for most solar system objects.
const KStarsDateTime & ut() const
Definition kstarsdata.h:157
GeoLocation * geo()
Definition kstarsdata.h:230
static KStars * Instance()
Definition kstars.h:123
KStarsData * data() const
Definition kstars.h:135
PWizObjectSelectionUI(PrintingWizard *wizard, QWidget *parent=nullptr)
Constructor.
static QString objectInfoString(SkyObject *obj)
Static function: get QString with basic information about SkyObject.
void setSkyObject(SkyObject *obj)
Update UI elements for newly selected SkyObject.
Class representing Printing Wizard for KStars printed documents (currently only finder charts).
void setSkyObject(SkyObject *obj)
Set SkyObject for which FinderChart is created.
SkyObject * getSkyObject()
Get selected SkyObject, for which FinderChart is created.
void beginPointing()
Set SkyMap to pointing mode and hide Printing Wizard.
void updateStepButtons()
Update Next/Previous step buttons.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
QString translatedName() const
Definition skyobject.h:148
virtual QString name(void) const
Definition skyobject.h:145
virtual QString longname(void) const
Definition skyobject.h:164
static QString typeName(const int t)
int type(void) const
Definition skyobject.h:188
float mag() const
Definition skyobject.h:206
This is a subclass of SkyObject.
Definition starobject.h:33
QString longname(void) const override
If star is unnamed return "star" otherwise return the longname.
Definition starobject.h:133
int getHDIndex() const
Definition starobject.h:248
QString sptype(void) const
Returns entire spectral type string.
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QString arg(Args &&... args) const const
bool isEmpty() const const
QString number(double n, char format, int precision)
void setupUi(QWidget *widget)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 12 2024 12:00:41 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.