6#include "PlaybackAnimatedUpdateItem.h"
8#include "GeoDataAnimatedUpdate.h"
9#include "GeoDataChange.h"
10#include "GeoDataCreate.h"
11#include "GeoDataDelete.h"
12#include "GeoDataDocument.h"
13#include "GeoDataFolder.h"
14#include "GeoDataGroundOverlay.h"
15#include "GeoDataPhotoOverlay.h"
16#include "GeoDataPlacemark.h"
17#include "GeoDataScreenOverlay.h"
18#include "GeoDataUpdate.h"
24PlaybackAnimatedUpdateItem::PlaybackAnimatedUpdateItem(GeoDataAnimatedUpdate *animatedUpdate)
26 m_animatedUpdate = animatedUpdate;
27 m_rootDocument = rootDocument(m_animatedUpdate);
31const GeoDataAnimatedUpdate *PlaybackAnimatedUpdateItem::animatedUpdate()
const
33 return m_animatedUpdate;
36double PlaybackAnimatedUpdateItem::duration()
const
38 return m_animatedUpdate->duration();
41void PlaybackAnimatedUpdateItem::play()
48 if (!m_rootDocument || !m_animatedUpdate->update()) {
53 if (m_animatedUpdate->update()->change()) {
55 for (
int i = 0; i < placemarkList.
size(); i++) {
56 GeoDataPlacemark *placemark = placemarkList.
at(i);
57 QString targetId = placemark->targetId();
61 if (placemark->isBalloonVisible()) {
62 GeoDataFeature *feature = findFeature(m_rootDocument, targetId);
64 Q_EMIT balloonShown(placemark);
73 if (m_animatedUpdate->update()->create()) {
74 for (
int index = 0; index < m_animatedUpdate->update()->
create()->size(); ++index) {
75 GeoDataFeature *child = m_animatedUpdate->update()->create()->
child(index);
77 auto addContainer =
static_cast<GeoDataContainer *
>(child);
78 QString targetId = addContainer->targetId();
79 GeoDataFeature *feature = findFeature(m_rootDocument, targetId);
81 auto container =
static_cast<GeoDataContainer *
>(feature);
82 for (
int i = 0; i < addContainer->size(); ++i) {
83 Q_EMIT added(container, addContainer->child(i), -1);
85 if (placemark->isBalloonVisible()) {
86 Q_EMIT balloonShown(placemark);
96 if (m_animatedUpdate->update()->getDelete()) {
97 for (
int index = 0; index < m_animatedUpdate->update()->getDelete()->size(); ++index) {
98 GeoDataFeature *child = m_animatedUpdate->update()->getDelete()->
child(index);
99 QString targetId = child->targetId();
103 GeoDataFeature *feature = findFeature(m_rootDocument, targetId);
104 if (feature && canDelete(*feature)) {
105 m_deletedObjects.append(feature);
108 if (placemark->isBalloonVisible()) {
117GeoDataFeature *PlaybackAnimatedUpdateItem::findFeature(GeoDataFeature *feature,
const QString &
id)
const
119 if (feature && feature->id() ==
id) {
123 auto container =
dynamic_cast<GeoDataContainer *
>(feature);
127 for (; iter !=
end; ++iter) {
128 GeoDataFeature *foundFeature = findFeature(*iter,
id);
137GeoDataDocument *PlaybackAnimatedUpdateItem::rootDocument(GeoDataObject *
object)
const
139 if (!
object || !object->parent()) {
140 auto document =
dynamic_cast<GeoDataDocument *
>(object);
143 return rootDocument(object->parent());
148void PlaybackAnimatedUpdateItem::pause()
153void PlaybackAnimatedUpdateItem::seek(
double position)
159void PlaybackAnimatedUpdateItem::stop()
166 if (m_animatedUpdate->update()->change()) {
168 for (
int i = 0; i < placemarkList.
size(); i++) {
169 GeoDataPlacemark *placemark = placemarkList.
at(i);
170 QString targetId = placemark->targetId();
174 GeoDataFeature *feature = findFeature(m_rootDocument, targetId);
175 if (placemark->isBalloonVisible()) {
180 Q_EMIT balloonShown(
static_cast<GeoDataPlacemark *
>(feature));
185 if (m_animatedUpdate->update()->create()) {
186 for (
int index = 0; index < m_animatedUpdate->update()->
create()->size(); ++index) {
187 GeoDataFeature *feature = m_animatedUpdate->update()->create()->
child(index);
189 auto container =
static_cast<GeoDataContainer *
>(feature);
190 for (
int i = 0; i < container->size(); ++i) {
191 Q_EMIT removed(container->child(i));
193 if (placemark->isBalloonVisible()) {
202 for (GeoDataFeature *feature : std::as_const(m_deletedObjects)) {
203 if (feature->targetId().isEmpty()) {
206 GeoDataFeature *target = findFeature(m_rootDocument, feature->targetId());
209 Q_ASSERT(
dynamic_cast<GeoDataContainer *
>(target));
210 Q_EMIT added(
static_cast<GeoDataContainer *
>(target), feature, -1);
212 if (placemark->isBalloonVisible()) {
213 Q_EMIT balloonShown(placemark);
218 m_deletedObjects.clear();
221bool PlaybackAnimatedUpdateItem::isApplied()
const
226bool PlaybackAnimatedUpdateItem::canDelete(
const GeoDataFeature &feature)
234#include "moc_PlaybackAnimatedUpdateItem.cpp"
GeoDataFeature * child(int)
returns the requested child item
QList< GeoDataPlacemark * > placemarkList() const
A convenience function that returns all placemarks in this container.
QAction * create(StandardAction id, const QObject *recvr, const char *slot, QObject *parent)
const QList< QKeySequence > & end()
Binds a QML item to a specific geodetic location in screen coordinates.
T * geodata_cast(GeoDataObject *node)
Returns the given node cast to type T if the node was instantiated as type T; otherwise returns 0.
const_reference at(qsizetype i) const const
qsizetype size() const const
bool isEmpty() const const