File indexing completed on 2025-01-12 09:34:23
0001 /* 0002 SPDX-FileCopyrightText: 2005 Thomas Kabelmann <thomas.kabelmann@gmx.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "skycomponent.h" 0008 0009 #include "Options.h" 0010 #include "skycomposite.h" 0011 #include "skyobjects/skyobject.h" 0012 0013 SkyComponent::SkyComponent(SkyComposite *parent) : m_parent(parent) 0014 { 0015 } 0016 0017 //Hand the message up to SkyMapComposite 0018 void SkyComponent::emitProgressText(const QString &message) 0019 { 0020 parent()->emitProgressText(message); 0021 } 0022 0023 SkyObject *SkyComponent::findByName(const QString &, bool) 0024 { 0025 return nullptr; 0026 } 0027 0028 SkyObject *SkyComponent::objectNearest(SkyPoint *, double &) 0029 { 0030 return nullptr; 0031 } 0032 0033 void SkyComponent::drawTrails(SkyPainter *) 0034 { 0035 } 0036 0037 void SkyComponent::objectsInArea(QList<SkyObject *> &, const SkyRegion &) 0038 { 0039 } 0040 0041 QHash<int, QStringList> &SkyComponent::getObjectNames() 0042 { 0043 if (!parent()) 0044 { 0045 // Use a fake list if there is no parent object 0046 static QHash<int, QStringList> temp; 0047 0048 return temp; 0049 } 0050 return parent()->objectNames(); 0051 } 0052 0053 QHash<int, QVector<QPair<QString, const SkyObject *>>> &SkyComponent::getObjectLists() 0054 { 0055 if (!parent()) 0056 { 0057 // Use a fake list if there is no parent object 0058 static QHash<int, QVector<QPair<QString, const SkyObject *>>> temp; 0059 0060 return temp; 0061 } 0062 return parent()->objectLists(); 0063 } 0064 0065 void SkyComponent::removeFromNames(const SkyObject *obj) 0066 { 0067 QStringList &names = getObjectNames()[obj->type()]; 0068 int i; 0069 i = names.indexOf(obj->name()); 0070 if (i >= 0) 0071 names.removeAt(i); 0072 0073 i = names.indexOf(obj->longname()); 0074 if (i >= 0) 0075 names.removeAt(i); 0076 } 0077 0078 void SkyComponent::removeFromLists(const SkyObject *obj) 0079 { 0080 QVector<QPair<QString, const SkyObject *>> &names = getObjectLists()[obj->type()]; 0081 int i; 0082 i = names.indexOf(QPair<QString, const SkyObject *>(obj->name(), obj)); 0083 if (i >= 0) 0084 names.removeAt(i); 0085 0086 i = names.indexOf(QPair<QString, const SkyObject *>(obj->longname(), obj)); 0087 if (i >= 0) 0088 names.removeAt(i); 0089 }