• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • geodata
  • data
GeoDataPlaylist.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2013 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
9 //
10 
11 #include "GeoDataPlaylist.h"
12 #include "GeoDataSoundCue.h"
13 #include "GeoDataAnimatedUpdate.h"
14 #include "GeoDataTourControl.h"
15 #include "GeoDataWait.h"
16 #include "GeoDataFlyTo.h"
17 
18 #include "GeoDataTypes.h"
19 
20 namespace Marble
21 {
22 
23 bool GeoDataPlaylist::operator==(const GeoDataPlaylist& other) const
24 {
25  if( this->m_primitives.size() != other.m_primitives.size() ){
26  return false;
27  }
28  else{
29  int index = 0;
30  foreach( GeoDataTourPrimitive* m_primitive, m_primitives ){
31  if( m_primitive->nodeType() != other.m_primitives.at( index )->nodeType() ){
32  return false;
33  }else{
34  const char* node = m_primitive->nodeType();
35  if ( node == GeoDataTypes::GeoDataAnimatedUpdateType ){
36  GeoDataAnimatedUpdate* update1 = static_cast<GeoDataAnimatedUpdate*>( m_primitive );
37  GeoDataAnimatedUpdate* update2 = static_cast<GeoDataAnimatedUpdate*>( other.m_primitives.at( index ) );
38  if( *update1 != *update2 ){
39  return false;
40  }
41  }
42  else if( node == GeoDataTypes::GeoDataSoundCueType ){
43  GeoDataSoundCue* cue1 = static_cast<GeoDataSoundCue*>( m_primitive );
44  GeoDataSoundCue* cue2 = static_cast<GeoDataSoundCue*>( other.m_primitives.at( index ) );
45  if ( *cue1 != *cue2 ){
46  return false;
47  }
48  }
49  else if( node == GeoDataTypes::GeoDataTourControlType ){
50  GeoDataTourControl* control1 = static_cast<GeoDataTourControl*>( m_primitive );
51  GeoDataTourControl* control2 = static_cast<GeoDataTourControl*>( other.m_primitives.at( index ) );
52  if( *control1 != *control2 ){
53  return false;
54  }
55  }
56  else if( node == GeoDataTypes::GeoDataWaitType ){
57  GeoDataWait* wait1 = static_cast<GeoDataWait*>( m_primitive );
58  GeoDataWait* wait2 = static_cast<GeoDataWait*>( other.m_primitives.at( index ) );
59  if( *wait1 != *wait2 ){
60  return false;
61  }
62  }
63  else if( node == GeoDataTypes::GeoDataFlyToType ){
64  GeoDataFlyTo* flyTo1 = static_cast<GeoDataFlyTo*>( m_primitive );
65  GeoDataFlyTo* flyTo2 = static_cast<GeoDataFlyTo*>( other.m_primitives.at( index ) );
66  if( *flyTo1 != *flyTo2 ){
67  return false;
68  }
69  }
70  index++;
71  }
72  }
73  return true;
74  }
75 }
76 
77 bool GeoDataPlaylist::operator!=(const GeoDataPlaylist& other) const
78 {
79  return !this->operator==(other);
80 }
81 
82 const char *GeoDataPlaylist::nodeType() const
83 {
84  return GeoDataTypes::GeoDataPlaylistType;
85 }
86 
87 GeoDataTourPrimitive* GeoDataPlaylist::primitive(int id)
88 {
89  if (size() <= id || id < 0) {
90  return 0;
91  }
92  return m_primitives.at(id);
93 }
94 
95 const GeoDataTourPrimitive* GeoDataPlaylist::primitive(int id) const
96 {
97  if (size() <= id || id < 0) {
98  return 0;
99  }
100  return m_primitives.at(id);
101 }
102 
103 void GeoDataPlaylist::addPrimitive( GeoDataTourPrimitive *primitive )
104 {
105  primitive->setParent( this );
106  m_primitives.push_back( primitive );
107 }
108 
109 void GeoDataPlaylist::insertPrimitive( int position, GeoDataTourPrimitive *primitive )
110 {
111  primitive->setParent( this );
112  int const index = qBound( 0, position, m_primitives.size() );
113  m_primitives.insert( index, primitive );
114 }
115 
116 void GeoDataPlaylist::removePrimitiveAt(int position)
117 {
118  m_primitives.removeAt( position );
119 }
120 
121 void GeoDataPlaylist::swapPrimitives( int positionA, int positionB )
122 {
123  if ( qMin( positionA, positionB ) >= 0 && qMax( positionA, positionB ) < m_primitives.size() ) {
124  m_primitives.swap( positionA, positionB );
125  }
126 }
127 
128 int GeoDataPlaylist::size() const
129 {
130  return m_primitives.size();
131 }
132 
133 } // namespace Marble
Marble::GeoDataPlaylist::addPrimitive
void addPrimitive(GeoDataTourPrimitive *primitive)
Definition: GeoDataPlaylist.cpp:103
Marble::GeoDataPlaylist::primitive
GeoDataTourPrimitive * primitive(int index)
Definition: GeoDataPlaylist.cpp:87
Marble::GeoDataPlaylist::operator==
bool operator==(const GeoDataPlaylist &other) const
Definition: GeoDataPlaylist.cpp:23
Marble::GeoDataTourPrimitive
Definition: GeoDataTourPrimitive.h:20
GeoDataWait.h
Marble::GeoDataPlaylist::operator!=
bool operator!=(const GeoDataPlaylist &other) const
Definition: GeoDataPlaylist.cpp:77
Marble::GeoDataObject::nodeType
virtual const char * nodeType() const =0
Provides type information for downcasting a GeoNode.
Marble::GeoDataObject::setParent
virtual void setParent(GeoDataObject *parent)
Sets the parent of the object.
Definition: GeoDataObject.cpp:70
Marble::GeoDataPlaylist::nodeType
const char * nodeType() const
Provides type information for downcasting a GeoNode.
Definition: GeoDataPlaylist.cpp:82
Marble::GeoDataSoundCue
Definition: GeoDataSoundCue.h:19
GeoDataSoundCue.h
Marble::GeoDataWait
Definition: GeoDataWait.h:19
Marble::GeoDataFlyTo
Definition: GeoDataFlyTo.h:23
Marble::GeoDataPlaylist::insertPrimitive
void insertPrimitive(int index, GeoDataTourPrimitive *primitive)
Definition: GeoDataPlaylist.cpp:109
Marble::GeoDataAnimatedUpdate
Definition: GeoDataAnimatedUpdate.h:23
GeoDataTourControl.h
Marble::GeoDataTypes::GeoDataFlyToType
const char * GeoDataFlyToType
Definition: GeoDataTypes.cpp:41
Marble::GeoDataPlaylist
Definition: GeoDataPlaylist.h:22
Marble::GeoDataTypes::GeoDataSoundCueType
const char * GeoDataSoundCueType
Definition: GeoDataTypes.cpp:79
Marble::GeoDataTypes::GeoDataTourControlType
const char * GeoDataTourControlType
Definition: GeoDataTypes.cpp:84
Marble::GeoDataPlaylist::swapPrimitives
void swapPrimitives(int indexA, int indexB)
Definition: GeoDataPlaylist.cpp:121
Marble::GeoDataTypes::GeoDataPlaylistType
const char * GeoDataPlaylistType
Definition: GeoDataTypes.cpp:67
GeoDataPlaylist.h
GeoDataAnimatedUpdate.h
Marble::GeoDataTypes::GeoDataWaitType
const char * GeoDataWaitType
Definition: GeoDataTypes.cpp:85
GeoDataFlyTo.h
Marble::GeoDataPlaylist::size
int size() const
Definition: GeoDataPlaylist.cpp:128
Marble::GeoDataTypes::GeoDataAnimatedUpdateType
const char * GeoDataAnimatedUpdateType
Definition: GeoDataTypes.cpp:29
GeoDataTypes.h
Marble::GeoDataPlaylist::removePrimitiveAt
void removePrimitiveAt(int index)
Definition: GeoDataPlaylist.cpp:116
Marble::GeoDataTourControl
Definition: GeoDataTourControl.h:19
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal