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 {
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);
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{
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}
This is the main window for KStars.
Definition kstars.h:91
static KStars * Instance()
Definition kstars.h:123
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
Represents the supernova object.
Definition supernova.h:34
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 Fri May 17 2024 11:48:27 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.