Kstars

notifyupdatesui.cpp
1/*
2 SPDX-FileCopyrightText: 2012 Samikshan Bairagya <samikshan@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "skyobjects/supernova.h"
8#include "supernovaecomponent.h"
9#include "notifyupdatesui.h"
10#include "ui_notifyupdatesui.h"
11#include "kstars.h"
12#include "kstarsdata.h"
13#include "skymap.h"
14#include "QTreeWidget"
15
16#include <QApplication>
17
18NotifyUpdatesUI::NotifyUpdatesUI(QWidget *parent) : QDialog(parent), ui(new Ui::NotifyUpdatesUI)
19{
20 ui->setupUi(this);
21 setWindowTitle(i18nc("@title:window", "New Supernova(e) Discovered"));
22 connect(ui->centrePushButton, SIGNAL(clicked()), SLOT(slotCenter()));
23}
24
25NotifyUpdatesUI::~NotifyUpdatesUI()
26{
27 delete ui;
28}
29
30void NotifyUpdatesUI::addItems(QList<SkyObject *> updatesList)
31{
32 //int len = updatesList.size();
33 foreach (SkyObject *so, updatesList)
34 {
35 Supernova *sup = (Supernova *)so;
36
37 QString name = sup->name();
38 QString hostGalaxy = i18n("Host Galaxy :: %1", sup->getHostGalaxy());
39 QString magnitude = i18n("Magnitude :: %1", QString::number(sup->getMagnitude()));
40 QString type = i18n("Type :: %1", sup->getType());
41 QString position =
42 i18n("Position :: RA : %1 Dec : %2", sup->getRA().toHMSString(), sup->getDec().toDMSString());
43 QString date = i18n("Date :: %1", sup->getDate());
44
45 QTreeWidgetItem *info = new QTreeWidgetItem(ui->infoTreeWidget);
46 QTreeWidgetItem *hGalaxy = new QTreeWidgetItem(info);
47 QTreeWidgetItem *t = new QTreeWidgetItem(info);
48 QTreeWidgetItem *mag = new QTreeWidgetItem(info);
50 QTreeWidgetItem *dt = new QTreeWidgetItem(info);
51
52 info->setText(0, name);
53 hGalaxy->setText(0, hostGalaxy);
54 pos->setText(0, position);
55 mag->setText(0, magnitude);
56 t->setText(0, type);
57 dt->setText(0, date);
58 ui->infoTreeWidget->addTopLevelItem(info);
59 }
60}
61
62void NotifyUpdatesUI::slotCenter()
63{
64 KStars *kstars = KStars::Instance();
65 SkyObject *o = 0;
66 // get selected item
67 if (ui->infoTreeWidget->currentItem() != 0)
68 {
69 if (ui->infoTreeWidget->currentItem()->childCount() > 0) //Serial No. is selected
70 o = kstars->data()->objectNamed(ui->infoTreeWidget->currentItem()->text(0));
71 else
72 o = kstars->data()->objectNamed(ui->infoTreeWidget->currentItem()->parent()->text(0));
73 }
74 if (o != 0)
75 {
76 kstars->map()->setFocusPoint(o);
77 kstars->map()->setFocusObject(o);
78 kstars->map()->setDestination(*kstars->map()->focusPoint());
79 }
80}
SkyObject * objectNamed(const QString &name)
Find object by name.
This is the main window for KStars.
Definition kstars.h:89
SkyMap * map() const
Definition kstars.h:139
static KStars * Instance()
Definition kstars.h:121
KStarsData * data() const
Definition kstars.h:133
SkyPoint * focusPoint()
retrieve the FocusPoint position.
Definition skymap.h:149
void setDestination(const SkyPoint &f)
sets the destination point of the sky map.
Definition skymap.cpp:993
void setFocusObject(SkyObject *o)
Set the FocusObject pointer to the argument.
Definition skymap.cpp:371
void setFocusPoint(SkyPoint *f)
set the FocusPoint; the position that is to be the next Destination.
Definition skymap.h:204
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
virtual QString name(void) const
Definition skyobject.h:146
Represents the supernova object.
Definition supernova.h:34
QString getType() const
Definition supernova.h:48
QString getDate() const
Definition supernova.h:54
QString getHostGalaxy() const
Definition supernova.h:51
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
Type type(const QSqlDatabase &db)
QString name(StandardAction id)
QString number(double n, char format, int precision)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void setText(int column, const QString &text)
void setupUi(QWidget *widget)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.