File indexing completed on 2024-04-14 14:11:26

0001 /*
0002     SPDX-FileCopyrightText: 2010 Akarsh Simha <akarsh.simha@kdemail.net>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "targetlistcomponent.h"
0008 
0009 #ifndef KSTARS_LITE
0010 #include "skymap.h"
0011 #endif
0012 #include "skypainter.h"
0013 #include "auxiliary/ksutils.h"
0014 
0015 TargetListComponent::TargetListComponent(SkyComposite *parent) : SkyComponent(parent)
0016 {
0017     drawSymbols = nullptr;
0018     drawLabels  = nullptr;
0019 }
0020 
0021 TargetListComponent::TargetListComponent(SkyComposite *parent, SkyObjectList *objectList, QPen _pen,
0022                                          bool (*optionDrawSymbols)(void), bool (*optionDrawLabels)(void))
0023     : SkyComponent(parent), list(objectList), pen(_pen)
0024 {
0025     drawSymbols = optionDrawSymbols;
0026     drawLabels  = optionDrawLabels;
0027 }
0028 
0029 TargetListComponent::~TargetListComponent()
0030 {
0031     if (list.get())
0032     {
0033         qDeleteAll(*list);
0034     }
0035 }
0036 
0037 void TargetListComponent::draw(SkyPainter *skyp)
0038 {
0039     if (drawSymbols && !(*drawSymbols)())
0040         return;
0041 
0042     skyp->setPen(pen);
0043     if (list && list->count() > 0)
0044     {
0045         skyp->drawObservingList(*list);
0046     }
0047     if (list2.count() > 0)
0048     {
0049         SkyObjectList newList = KSUtils::makeVanillaPointerList(list2);
0050 
0051         skyp->drawObservingList(newList);
0052     }
0053 }