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 }
18 else{
19 int index = 0;
20 for( GeoDataTourPrimitive* m_primitive: m_primitives ){
21 if (*m_primitive != *other.m_primitives.at(index)) {
22 return false;
23 }
24
25 index++;
26 }
27 return true;
28 }
29}
30
31bool GeoDataPlaylist::operator!=(const GeoDataPlaylist& other) const
32{
33 return !this->operator==(other);
34}
35
36const char *GeoDataPlaylist::nodeType() const
37{
38 return GeoDataTypes::GeoDataPlaylistType;
39}
40
41GeoDataTourPrimitive* GeoDataPlaylist::primitive(int id)
42{
43 if (size() <= id || id < 0) {
44 return nullptr;
45 }
46 return m_primitives.at(id);
47}
48
49const GeoDataTourPrimitive* GeoDataPlaylist::primitive(int id) const
50{
51 if (size() <= id || id < 0) {
52 return nullptr;
53 }
54 return m_primitives.at(id);
55}
56
57void GeoDataPlaylist::addPrimitive( GeoDataTourPrimitive *primitive )
58{
59 primitive->setParent( this );
60 m_primitives.push_back( primitive );
61}
62
63void GeoDataPlaylist::insertPrimitive( int position, GeoDataTourPrimitive *primitive )
64{
65 primitive->setParent( this );
66 int const index = qBound( 0, position, m_primitives.size() );
67 m_primitives.insert( index, primitive );
68}
69
70void GeoDataPlaylist::removePrimitiveAt(int position)
71{
72 m_primitives.removeAt( position );
73}
74
75void GeoDataPlaylist::swapPrimitives( int positionA, int positionB )
76{
77 if ( qMin( positionA, positionB ) >= 0 && qMax( positionA, positionB ) < m_primitives.size() ) {
78
79#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
80 m_primitives.swapItemsAt( positionA, positionB );
81#else
82 m_primitives.swap( positionA, positionB );
83#endif
84 }
85}
86
87int GeoDataPlaylist::size() const
88{
89 return m_primitives.size();
90}
91
92} // 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 swap(QList< T > &other)
void swapItemsAt(qsizetype i, qsizetype j)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:49:23 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.