Marble

GeoDataPlaylist.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2013 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
4//
5
6#include "GeoDataPlaylist.h"
7
8#include "GeoDataTypes.h"
9
10namespace Marble
11{
12
13bool GeoDataPlaylist::operator==(const GeoDataPlaylist &other) const
14{
15 if (this->m_primitives.size() != other.m_primitives.size()) {
16 return false;
17 } else {
18 int index = 0;
19 for (GeoDataTourPrimitive *m_primitive : m_primitives) {
20 if (*m_primitive != *other.m_primitives.at(index)) {
21 return false;
22 }
23
24 index++;
25 }
26 return true;
27 }
28}
29
30bool GeoDataPlaylist::operator!=(const GeoDataPlaylist &other) const
31{
32 return !this->operator==(other);
33}
34
35const char *GeoDataPlaylist::nodeType() const
36{
37 return GeoDataTypes::GeoDataPlaylistType;
38}
39
40GeoDataTourPrimitive *GeoDataPlaylist::primitive(int id)
41{
42 if (size() <= id || id < 0) {
43 return nullptr;
44 }
45 return m_primitives.at(id);
46}
47
48const GeoDataTourPrimitive *GeoDataPlaylist::primitive(int id) const
49{
50 if (size() <= id || id < 0) {
51 return nullptr;
52 }
53 return m_primitives.at(id);
54}
55
56void GeoDataPlaylist::addPrimitive(GeoDataTourPrimitive *primitive)
57{
58 primitive->setParent(this);
59 m_primitives.push_back(primitive);
60}
61
62void GeoDataPlaylist::insertPrimitive(int position, GeoDataTourPrimitive *primitive)
63{
64 primitive->setParent(this);
65 int const index = qBound(0, position, m_primitives.size());
66 m_primitives.insert(index, primitive);
67}
68
69void GeoDataPlaylist::removePrimitiveAt(int position)
70{
71 m_primitives.removeAt(position);
72}
73
74void GeoDataPlaylist::swapPrimitives(int positionA, int positionB)
75{
76 if (qMin(positionA, positionB) >= 0 && qMax(positionA, positionB) < m_primitives.size()) {
77 m_primitives.swapItemsAt(positionA, positionB);
78 }
79}
80
81int GeoDataPlaylist::size() const
82{
83 return m_primitives.size();
84}
85
86} // namespace Marble
Binds a QML item to a specific geodetic location in screen coordinates.
const_reference at(qsizetype i) const const
iterator insert(const_iterator before, parameter_type value)
void push_back(parameter_type value)
void removeAt(qsizetype i)
qsizetype size() const const
void swapItemsAt(qsizetype i, qsizetype j)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:08:52 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.