File indexing completed on 2024-12-08 03:47:13

0001 /*
0002     SPDX-FileCopyrightText: 2003 Russell Steffen <rsteffen@bayarea.net>
0003     SPDX-FileCopyrightText: 2003 Stephan Zehetner <s.zehetner@nevox.org>
0004     SPDX-FileCopyrightText: 2006 Dmitry Suzdalev <dimsuz@gmail.com>
0005     SPDX-FileCopyrightText: 2006 Inge Wallin <inge@lysator.liu.se>
0006     SPDX-FileCopyrightText: 2006 Pierre Ducroquet <pinaraf@gmail.com>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #include "sector.h"
0012 #include "planet.h"
0013 #include "map/map.h"
0014 
0015 //---------------------------------------------------------------------------
0016 // class Sector
0017 //---------------------------------------------------------------------------
0018 
0019 Sector::Sector()
0020   : m_map(nullptr ),
0021     m_coord( 0,0 ),
0022     m_planet( nullptr )
0023 {}
0024 
0025 Sector::Sector( Map *map, Coordinate coord )
0026   : m_map( map ),
0027     m_coord( coord ),
0028     m_planet(nullptr)
0029 {
0030 }
0031 
0032 Sector::Sector( const Sector & other )
0033   : QObject( nullptr ),
0034     m_map(other.m_map), 
0035     m_coord(other.m_coord),
0036     m_planet(other.m_planet)
0037 {
0038 }
0039 
0040 
0041 void Sector::setPlanet( Planet *planet )
0042 {
0043     m_planet = planet;
0044 
0045     connect(m_planet, &Planet::update, this, &Sector::childPlanetUpdate);
0046 
0047     Q_EMIT update();
0048 }
0049 
0050 void Sector::removePlanet()
0051 {
0052     m_planet = nullptr;
0053 
0054     Q_EMIT update();
0055 }
0056 
0057 
0058 void Sector::childPlanetUpdate()
0059 {
0060     Q_EMIT update();
0061 }
0062 
0063 Sector &
0064 Sector::operator=( const Sector &other )
0065 {
0066     m_coord  = other.m_coord;
0067     m_planet = other.m_planet;
0068     m_map    = other.m_map;
0069 
0070     return *this;
0071 }
0072 
0073 #include "moc_sector.cpp"