Kstars

skycomponent.cpp
1/*
2 SPDX-FileCopyrightText: 2005 Thomas Kabelmann <thomas.kabelmann@gmx.de>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "skycomponent.h"
8
9#include "Options.h"
10#include "skycomposite.h"
11#include "skyobjects/skyobject.h"
12
13SkyComponent::SkyComponent(SkyComposite *parent) : m_parent(parent)
14{
15}
16
17//Hand the message up to SkyMapComposite
19{
20 parent()->emitProgressText(message);
21}
22
24{
25 return nullptr;
26}
27
29{
30 return nullptr;
31}
32
36
40
41QHash<int, QStringList> &SkyComponent::getObjectNames()
42{
43 if (!parent())
44 {
45 // Use a fake list if there is no parent object
46 static QHash<int, QStringList> temp;
47
48 return temp;
49 }
50 return parent()->objectNames();
51}
52
53QHash<int, QVector<QPair<QString, const SkyObject *>>> &SkyComponent::getObjectLists()
54{
55 if (!parent())
56 {
57 // Use a fake list if there is no parent object
59
60 return temp;
61 }
62 return parent()->objectLists();
63}
64
65void SkyComponent::removeFromNames(const SkyObject *obj)
66{
67 QStringList &names = getObjectNames()[obj->type()];
68 int i;
69 i = names.indexOf(obj->name());
70 if (i >= 0)
71 names.removeAt(i);
72
73 i = names.indexOf(obj->longname());
74 if (i >= 0)
75 names.removeAt(i);
76}
77
78void SkyComponent::removeFromLists(const SkyObject *obj)
79{
80 QVector<QPair<QString, const SkyObject *>> &names = getObjectLists()[obj->type()];
81 int i;
82 i = names.indexOf(QPair<QString, const SkyObject *>(obj->name(), obj));
83 if (i >= 0)
84 names.removeAt(i);
85
86 i = names.indexOf(QPair<QString, const SkyObject *>(obj->longname(), obj));
87 if (i >= 0)
88 names.removeAt(i);
89}
virtual void objectsInArea(QList< SkyObject * > &list, const SkyRegion &region)
Searches the region(s) and appends the SkyObjects found to the list of sky objects.
SkyComposite * parent()
virtual void drawTrails(SkyPainter *skyp)
Draw trails for objects.
virtual SkyObject * objectNearest(SkyPoint *p, double &maxrad)
Find the SkyObject nearest the given SkyPoint.
virtual SkyObject * findByName(const QString &name, bool exact=true)
Search the children of this SkyComponent for a SkyObject whose name matches the argument name the nam...
SkyComponent(SkyComposite *parent=nullptr)
Constructor parent pointer to the parent SkyComposite.
virtual void emitProgressText(const QString &message)
Emit signal about progress.
SkyComposite is a kind of container class for SkyComponent objects.
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:145
virtual QString longname(void) const
Definition skyobject.h:164
int type(void) const
Definition skyobject.h:188
Draws things on the sky, without regard to backend.
Definition skypainter.h:40
The sky coordinates of a point in the sky.
Definition skypoint.h:45
void removeAt(qsizetype i)
qsizetype indexOf(const QRegularExpression &re, qsizetype from) const const
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.