1 /*
2 SPDX-FileCopyrightText: 2003 Russell Steffen <rsteffen@bayarea.net>
3 SPDX-FileCopyrightText: 2003 Stephan Zehetner <s.zehetner@nevox.org>
4 SPDX-FileCopyrightText: 2006 Dmitry Suzdalev <dimsuz@gmail.com>
5 SPDX-FileCopyrightText: 2006 Inge Wallin <inge@lysator.liu.se>
6 SPDX-FileCopyrightText: 2006 Pierre Ducroquet <pinaraf@gmail.com>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
11 #include "sector.h"
12 #include "planet.h"
13 #include "map/map.h"
14
15 //---------------------------------------------------------------------------
16 // class Sector
17 //---------------------------------------------------------------------------
18
Sector()19 Sector::Sector()
20 : m_map(nullptr ),
21 m_coord( 0,0 ),
22 m_planet( nullptr )
23 {}
24
Sector(Map * map,Coordinate coord)25 Sector::Sector( Map *map, Coordinate coord )
26 : m_map( map ),
27 m_coord( coord ),
28 m_planet(nullptr)
29 {
30 }
31
Sector(const Sector & other)32 Sector::Sector( const Sector & other )
33 : QObject( nullptr ),
34 m_map(other.m_map),
35 m_coord(other.m_coord),
36 m_planet(other.m_planet)
37 {
38 }
39
40
setPlanet(Planet * planet)41 void Sector::setPlanet( Planet *planet )
42 {
43 m_planet = planet;
44
45 connect(m_planet, &Planet::update, this, &Sector::childPlanetUpdate);
46
47 Q_EMIT update();
48 }
49
removePlanet()50 void Sector::removePlanet()
51 {
52 m_planet = nullptr;
53
54 Q_EMIT update();
55 }
56
57
childPlanetUpdate()58 void Sector::childPlanetUpdate()
59 {
60 Q_EMIT update();
61 }
62
63 Sector &
operator =(const Sector & other)64 Sector::operator=( const Sector &other )
65 {
66 m_coord = other.m_coord;
67 m_planet = other.m_planet;
68 m_map = other.m_map;
69
70 return *this;
71 }
72