Kstars

skycomponent.cpp
1 /*
2  SPDX-FileCopyrightText: 2005 Thomas Kabelmann <[email protected]>
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 
14 {
15 }
16 
17 //Hand the message up to SkyMapComposite
19 {
21 }
22 
24 {
25  return nullptr;
26 }
27 
29 {
30  return nullptr;
31 }
32 
34 {
35 }
36 
38 {
39 }
40 
41 QHash<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 
53 QHash<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 
65 void 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 
78 void 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 SkyObject * objectNearest(SkyPoint *p, double &maxrad)
Find the SkyObject nearest the given SkyPoint.
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
virtual QString name(void) const
Definition: skyobject.h:145
int indexOf(const T &value, int from) const const
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...
virtual void objectsInArea(QList< SkyObject * > &list, const SkyRegion &region)
Searches the region(s) and appends the SkyObjects found to the list of sky objects.
void removeAt(int i)
SkyComposite * parent()
Definition: skycomponent.h:137
int type(void) const
Definition: skyobject.h:188
virtual void emitProgressText(const QString &message)
Emit signal about progress.
Draws things on the sky, without regard to backend.
Definition: skypainter.h:37
int indexOf(QStringView str, int from) const const
SkyComponent(SkyComposite *parent=nullptr)
Constructor parent pointer to the parent SkyComposite.
virtual QString longname(void) const
Definition: skyobject.h:164
virtual void drawTrails(SkyPainter *skyp)
Draw trails for objects.
void removeAt(int i)
Information about an object in the sky.
Definition: skyobject.h:41
QObject * parent() const const
QString message
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Wed Aug 17 2022 04:14:19 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.