• 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
GeoDataTreeModel.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 2010 Thibaut Gridel <tgridel@free.fr>
9 // Copyright 2013 Levente Kurusa <levex@linux.com>
10 //
11 
12 
13 // Own
14 #include "GeoDataTreeModel.h"
15 
16 // Qt
17 #include <QBrush>
18 #include <QModelIndex>
19 #include <QFile>
20 #include <QList>
21 #include <QPixmap>
22 #include <QItemSelectionModel>
23 
24 // Marble
25 #include "GeoDataObject.h"
26 #include "GeoDataDocument.h"
27 #include "GeoDataContainer.h"
28 #include "GeoDataExtendedData.h"
29 #include "GeoDataFolder.h"
30 #include "GeoDataPlacemark.h"
31 #include "GeoDataPlaylist.h"
32 #include "GeoDataTour.h"
33 #include "GeoDataWait.h"
34 #include "GeoDataFlyTo.h"
35 #include "GeoDataCamera.h"
36 #include "GeoDataStyle.h"
37 #include "GeoDataTypes.h"
38 #include "FileManager.h"
39 #include "MarbleDebug.h"
40 #include "MarblePlacemarkModel.h"
41 
42 using namespace Marble;
43 
44 class GeoDataTreeModel::Private {
45  public:
46  Private( QAbstractItemModel* model );
47  ~Private();
48 
49  static void checkParenting( GeoDataObject *object );
50 
51  GeoDataDocument* m_rootDocument;
52  bool m_ownsRootDocument;
53  QItemSelectionModel m_selectionModel;
54 };
55 
56 GeoDataTreeModel::Private::Private( QAbstractItemModel *model ) :
57  m_rootDocument( new GeoDataDocument ),
58  m_ownsRootDocument( true ),
59  m_selectionModel( model )
60 {
61  // nothing to do
62 }
63 
64 GeoDataTreeModel::Private::~Private()
65 {
66  if ( m_ownsRootDocument ) {
67  delete m_rootDocument;
68  }
69 }
70 
71 void GeoDataTreeModel::Private::checkParenting( GeoDataObject *object )
72 {
73  if( object->nodeType() == GeoDataTypes::GeoDataDocumentType
74  || object->nodeType() == GeoDataTypes::GeoDataFolderType ) {
75  GeoDataContainer *container = static_cast<GeoDataContainer*>( object );
76  foreach( GeoDataFeature *child, container->featureList() ) {
77  if ( child->parent() != container ) {
78  qWarning() << "Parenting mismatch for " << child->name();
79  Q_ASSERT( 0 );
80  }
81  }
82  }
83 }
84 
85 GeoDataTreeModel::GeoDataTreeModel( QObject *parent )
86  : QAbstractItemModel( parent ),
87  d( new Private( this ) )
88 {
89 }
90 
91 GeoDataTreeModel::~GeoDataTreeModel()
92 {
93  delete d;
94 }
95 
96 bool GeoDataTreeModel::hasChildren( const QModelIndex &parent ) const
97 {
98  GeoDataObject *parentItem;
99  if ( parent.column() > 0 ) {
100  return false;
101  }
102 
103  if ( !parent.isValid() ) {
104  parentItem = d->m_rootDocument;
105  } else {
106  parentItem = static_cast<GeoDataObject*>( parent.internalPointer() );
107  }
108 
109  if ( !parentItem ) {
110  return false;
111  }
112 
113  if ( parentItem->nodeType() == GeoDataTypes::GeoDataPlacemarkType ) {
114  GeoDataPlacemark *placemark = static_cast<GeoDataPlacemark*>( parentItem );
115  return dynamic_cast<const GeoDataMultiGeometry*>( placemark->geometry() );
116  }
117 
118  if ( parentItem->nodeType() == GeoDataTypes::GeoDataFolderType
119  || parentItem->nodeType() == GeoDataTypes::GeoDataDocumentType ) {
120  GeoDataContainer *container = static_cast<GeoDataContainer*>( parentItem );
121  return container->size();
122  }
123 
124  if ( parentItem->nodeType() == GeoDataTypes::GeoDataMultiGeometryType ) {
125  GeoDataMultiGeometry *geometry = static_cast<GeoDataMultiGeometry*>( parentItem );
126  return geometry->size();
127  }
128 
129  if ( parentItem->nodeType() == GeoDataTypes::GeoDataTourType ) {
130  GeoDataTour *tour = static_cast<GeoDataTour*>( parentItem );
131  return tour->playlist();
132  }
133 
134  if ( parentItem->nodeType() == GeoDataTypes::GeoDataPlaylistType ) {
135  GeoDataPlaylist *playlist = static_cast<GeoDataPlaylist*>( parentItem );
136  return playlist->size();
137  }
138 
139  return false;
140 }
141 
142 int GeoDataTreeModel::rowCount( const QModelIndex &parent ) const
143 {
144 // mDebug() << "rowCount";
145  GeoDataObject *parentItem;
146  if ( parent.column() > 0 ) {
147 // mDebug() << "rowCount bad column";
148  return 0;
149  }
150 
151  if ( !parent.isValid() ) {
152 // mDebug() << "rowCount root parent";
153  parentItem = d->m_rootDocument;
154  } else {
155  parentItem = static_cast<GeoDataObject*>( parent.internalPointer() );
156  }
157 
158  if ( !parentItem ) {
159 // mDebug() << "rowCount bad parent";
160  return 0;
161  }
162 
163  if ( parentItem->nodeType() == GeoDataTypes::GeoDataFolderType
164  || parentItem->nodeType() == GeoDataTypes::GeoDataDocumentType ) {
165  GeoDataContainer *container = static_cast<GeoDataContainer*>( parentItem );
166 // mDebug() << "rowCount " << type << "(" << parentItem << ") =" << container->size();
167  return container->size();
168 // } else {
169 // mDebug() << "rowCount bad container " << container;
170  }
171 
172  if ( parentItem->nodeType() == GeoDataTypes::GeoDataPlacemarkType ) {
173  GeoDataPlacemark *placemark = static_cast<GeoDataPlacemark*>( parentItem );
174  if ( dynamic_cast<const GeoDataMultiGeometry*>( placemark->geometry() ) ) {
175 // mDebug() << "rowCount " << type << "(" << parentItem << ") = 1";
176  return 1;
177  }
178  }
179 
180  if ( parentItem->nodeType() == GeoDataTypes::GeoDataMultiGeometryType ) {
181  GeoDataMultiGeometry *geometry = static_cast<GeoDataMultiGeometry*>( parentItem );
182 // mDebug() << "rowCount " << parent << " " << type << " " << geometry->size();
183  return geometry->size();
184 // } else {
185 // mDebug() << "rowCount bad geometry " << geometry;
186  }
187 
188  if ( parentItem->nodeType() == GeoDataTypes::GeoDataTourType ) {
189  GeoDataTour *tour = static_cast<GeoDataTour*>( parentItem );
190  GeoDataPlaylist *playlist = tour->playlist();
191  if ( playlist ) {
192 // mDebug() << "rowCount " << parent << " Playlist " << 1;
193  return 1;
194  }
195  }
196 
197  if ( parentItem->nodeType() == GeoDataTypes::GeoDataPlaylistType ) {
198  GeoDataPlaylist *playlist = static_cast<GeoDataPlaylist*>( parentItem );
199 // mDebug() << "rowCount " << parent << " Playlist " << playlist->size();
200  return playlist->size();
201  }
202 
203 // mDebug() << "rowcount end";
204  return 0;//parentItem->childCount();
205 }
206 
207 QVariant GeoDataTreeModel::headerData(int section, Qt::Orientation orientation,
208  int role) const
209 {
210  if ( role == Qt::DisplayRole && orientation == Qt::Horizontal )
211  {
212  switch ( section ) {
213  case 0:
214  return tr("Name");
215  break;
216  case 1:
217  return tr("Type");
218  break;
219  case 2:
220  return tr("Popularity");
221  break;
222  case 3:
223  return tr("PopIndex", "Popularity index");
224  break;
225  }
226  }
227  return QVariant();
228 }
229 
230 QVariant GeoDataTreeModel::data( const QModelIndex &index, int role ) const
231 {
232 // mDebug() << "data";
233  if ( !index.isValid() )
234  return QVariant();
235 
236  GeoDataObject *object = static_cast<GeoDataObject*>( index.internalPointer() );
237  if ( role == Qt::DisplayRole ) {
238 
239  if ( object->nodeType() == GeoDataTypes::GeoDataPlacemarkType ) {
240  GeoDataPlacemark *placemark = static_cast<GeoDataPlacemark*>( object );
241  if ( index.column() == 0 ){
242  if ( placemark->countryCode().isEmpty() ) {
243  return QVariant( placemark->name() );
244  } else {
245  return QVariant( QString( "%1 (%2)" ).arg( placemark->name() ).arg( placemark->countryCode() ) );
246  }
247 
248  }
249  else if ( index.column() == 1 ){
250  return QVariant( placemark->nodeType() );
251  }
252  else if ( index.column() == 2 ){
253  return QVariant( placemark->popularity() );
254  }
255  else if ( index.column() == 3 ){
256  return QVariant( placemark->zoomLevel() );
257  }
258  }
259  if ( object->nodeType() == GeoDataTypes::GeoDataFolderType
260  || object->nodeType() == GeoDataTypes::GeoDataDocumentType
261  || object->nodeType() == GeoDataTypes::GeoDataTourType ) {
262  GeoDataFeature *feature = static_cast<GeoDataFeature*>( object );
263  if ( index.column() == 0 ){
264  return QVariant( feature->name() );
265  }
266  else if ( index.column() == 1 ){
267  return QVariant( feature->nodeType() );
268  }
269  }
270 
271  GeoDataGeometry *geometry = dynamic_cast<GeoDataGeometry*>( object );
272  if ( geometry && index.column() == 1 ){
273  return QVariant( geometry->nodeType() );
274  }
275 
276  GeoDataPlaylist *playlist = dynamic_cast<GeoDataPlaylist*>( object );
277  if ( playlist && index.column() == 0 ) {
278  return tr( "Playlist" );
279  }
280 
281  GeoDataObject *item = dynamic_cast<GeoDataObject*>( object );
282  if ( item && index.column() == 1 ){
283  return QVariant( item->nodeType() );
284  }
285 
286  }
287  else if ( role == Qt::CheckStateRole
288  && index.column() == 0 ) {
289  if ( object->nodeType() == GeoDataTypes::GeoDataPlacemarkType ) {
290  GeoDataPlacemark *feature = static_cast<GeoDataPlacemark*>( object );
291  const char* type = feature->geometry()->nodeType();
292  if ( feature->parent()->nodeType() == GeoDataTypes::GeoDataFolderType ) {
293  GeoDataFolder *folder = static_cast<GeoDataFolder *>( feature->parent() );
294  if ( folder->style()->listStyle().listItemType() == GeoDataListStyle::RadioFolder
295  || folder->style()->listStyle().listItemType() == GeoDataListStyle::CheckOffOnly) {
296  if ( feature->isVisible() ) {
297  return QVariant ( Qt::Checked );
298  } else {
299  return QVariant ( Qt::Unchecked );
300  }
301  }
302  }
303  if ( type == GeoDataTypes::GeoDataLineStringType
304  || type == GeoDataTypes::GeoDataPolygonType
305  || type == GeoDataTypes::GeoDataLinearRingType
306  || type == GeoDataTypes::GeoDataMultiGeometryType
307  || type == GeoDataTypes::GeoDataTrackType
308  ) {
309  if ( feature->isGloballyVisible() ) {
310  return QVariant( Qt::Checked );
311  } else if ( feature->isVisible() ) {
312  return QVariant( Qt::PartiallyChecked );
313  } else {
314  return QVariant( Qt::Unchecked );
315  }
316  }
317  } else if ( object->nodeType() == GeoDataTypes::GeoDataFolderType
318  || object->nodeType() == GeoDataTypes::GeoDataDocumentType ) {
319  GeoDataFeature *feature = static_cast<GeoDataFeature*>( object );
320  if ( object->nodeType() == GeoDataTypes::GeoDataFolderType ) {
321  GeoDataFolder *folder = static_cast<GeoDataFolder *>( object );
322  if ( folder->style()->listStyle().listItemType() == GeoDataListStyle::RadioFolder) {
323  bool anyVisible = false;
324  QVector<GeoDataFeature *>::Iterator i = folder->begin();
325  for (; i < folder->end(); ++i) {
326  if ((*i)->isVisible()) {
327  anyVisible = true;
328  break;
329  }
330  }
331  if (anyVisible) {
332  return QVariant( Qt::PartiallyChecked );
333  } else {
334  return QVariant( Qt::Unchecked );
335  }
336  } else if ( folder->style()->listStyle().listItemType() == GeoDataListStyle::CheckOffOnly) {
337  QVector<GeoDataFeature *>::Iterator i = folder->begin();
338  bool anyVisible = false;
339  bool allVisible = true;
340  for (; i < folder->end(); ++i) {
341  if ((*i)->isVisible()) {
342  anyVisible = true;
343  } else {
344  allVisible = false;
345  }
346  }
347  if (allVisible) {
348  return QVariant( Qt::Checked );
349  } else if (anyVisible) {
350  return QVariant( Qt::PartiallyChecked );
351  } else {
352  return QVariant( Qt::Unchecked );
353  }
354  }
355  }
356  if ( feature->isGloballyVisible() ) {
357  return QVariant( Qt::Checked );
358  } else if ( feature->isVisible() ) {
359  return QVariant( Qt::PartiallyChecked );
360  } else {
361  return QVariant( Qt::Unchecked );
362  }
363  }
364  }
365  else if ( role == Qt::DecorationRole
366  && index.column() == 0 ) {
367  if ( object->nodeType() == GeoDataTypes::GeoDataPlacemarkType
368  || object->nodeType() == GeoDataTypes::GeoDataFolderType
369  || object->nodeType() == GeoDataTypes::GeoDataDocumentType
370  || object->nodeType() == GeoDataTypes::GeoDataTourType ) {
371  GeoDataFeature *feature = static_cast<GeoDataFeature*>( object );
372  return QVariant(feature->style()->iconStyle().icon());
373  }
374  } else if ( role == Qt::ToolTipRole
375  && index.column() == 0 ) {
376  if ( object->nodeType() == GeoDataTypes::GeoDataPlacemarkType
377  || object->nodeType() == GeoDataTypes::GeoDataFolderType
378  || object->nodeType() == GeoDataTypes::GeoDataDocumentType
379  || object->nodeType() == GeoDataTypes::GeoDataTourType ) {
380  GeoDataFeature *feature = static_cast<GeoDataFeature*>( object );
381  return QVariant( feature->description() );
382  }
383  } else if ( role == MarblePlacemarkModel::ObjectPointerRole ) {
384  return qVariantFromValue( object );
385  } else if ( role == MarblePlacemarkModel::PopularityIndexRole ) {
386  if ( object->nodeType() == GeoDataTypes::GeoDataPlacemarkType ) {
387  GeoDataPlacemark *placemark = static_cast<GeoDataPlacemark*>( object );
388  return QVariant( placemark->zoomLevel() );
389  }
390  } else if ( role == MarblePlacemarkModel::PopularityRole ) {
391  if ( object->nodeType() == GeoDataTypes::GeoDataPlacemarkType ) {
392  GeoDataPlacemark *placemark = static_cast<GeoDataPlacemark*>( object );
393  return QVariant( placemark->popularity() );
394  }
395  } else if ( role == MarblePlacemarkModel::CoordinateRole ) {
396  if ( object->nodeType() == GeoDataTypes::GeoDataPlacemarkType ) {
397  GeoDataPlacemark *placemark = static_cast<GeoDataPlacemark*>( object );
398  return qVariantFromValue( placemark->coordinate() );
399  } else if ( object->nodeType() == GeoDataTypes::GeoDataFlyToType ) {
400  GeoDataFlyTo *flyTo = static_cast<GeoDataFlyTo*>( object );
401  if ( flyTo->view() && flyTo->view()->nodeType() == GeoDataTypes::GeoDataCameraType ) {
402  GeoDataCamera *camera = static_cast<GeoDataCamera*>( flyTo->view() );
403  return QVariant::fromValue<GeoDataCoordinates>( camera->coordinates() );
404  } else if ( flyTo->view() && flyTo->view()->nodeType() == GeoDataTypes::GeoDataLookAtType ) {
405  GeoDataLookAt *lookAt = static_cast<GeoDataLookAt*>( flyTo->view() );
406  return QVariant::fromValue<GeoDataCoordinates>( lookAt->coordinates() );
407  }
408  }
409  } else if ( role == Qt::BackgroundRole ) {
410  if ( object->nodeType() == GeoDataTypes::GeoDataPlacemarkType ) {
411  GeoDataPlacemark *placemark = static_cast<GeoDataPlacemark*>( object );
412  if ( placemark->parent() &&
413  ( placemark->parent()->nodeType() == GeoDataTypes::GeoDataFolderType ||
414  placemark->parent()->nodeType() == GeoDataTypes::GeoDataDocumentType ) ) {
415  GeoDataContainer *container = static_cast<GeoDataContainer *>( placemark->parent() );
416  return container->customStyle() ? QVariant( QBrush( container->customStyle()->listStyle().backgroundColor() )) : QVariant();
417  }
418  }
419  }
420 
421  return QVariant();
422 }
423 
424 QModelIndex GeoDataTreeModel::index( int row, int column, const QModelIndex &parent ) const
425 {
426 // mDebug() << "index";
427  if ( !hasIndex( row, column, parent ) ) {
428 // mDebug() << "index bad index";
429  return QModelIndex();
430  }
431 
432  GeoDataObject *parentItem;
433 
434  if ( !parent.isValid() )
435  parentItem = d->m_rootDocument;
436  else
437  parentItem = static_cast<GeoDataObject*>( parent.internalPointer() );
438 
439  if ( !parentItem ) {
440 // mDebug() << "index bad parent";
441  return QModelIndex();
442  }
443 
444  GeoDataObject *childItem = 0;
445 
446 
447  if ( parentItem->nodeType() == GeoDataTypes::GeoDataFolderType
448  || parentItem->nodeType() == GeoDataTypes::GeoDataDocumentType ) {
449  GeoDataContainer *container = static_cast<GeoDataContainer*>( parentItem );
450  childItem = container->child( row );
451  return createIndex( row, column, childItem );
452  }
453 
454  if ( parentItem->nodeType() == GeoDataTypes::GeoDataPlacemarkType ) {
455  GeoDataPlacemark *placemark = static_cast<GeoDataPlacemark*>( parentItem );
456  childItem = placemark->geometry();
457  if ( dynamic_cast<GeoDataMultiGeometry*>( childItem ) ) {
458  return createIndex( row, column, childItem );
459  }
460  }
461 
462  if ( parentItem->nodeType() == GeoDataTypes::GeoDataMultiGeometryType ) {
463  GeoDataMultiGeometry *geometry = static_cast<GeoDataMultiGeometry*>( parentItem );
464  childItem = geometry->child( row );
465  return createIndex( row, column, childItem );
466  }
467 
468  if ( parentItem->nodeType() == GeoDataTypes::GeoDataTourType ) {
469  GeoDataTour *tour = static_cast<GeoDataTour*>( parentItem );
470  childItem = tour->playlist();
471  return createIndex( row, column, childItem );
472  }
473 
474  if ( parentItem->nodeType() == GeoDataTypes::GeoDataPlaylistType ) {
475  GeoDataPlaylist *playlist = static_cast<GeoDataPlaylist*>( parentItem );
476  childItem = playlist->primitive( row );
477  return createIndex(row, column, childItem);
478  }
479 
480  return QModelIndex();
481 }
482 
483 QModelIndex GeoDataTreeModel::parent( const QModelIndex &index ) const
484 {
485 // mDebug() << "parent";
486  if ( !index.isValid() ) {
487 // mDebug() << "parent bad index";
488  return QModelIndex();
489  }
490 
491 
492  GeoDataObject *childObject = static_cast<GeoDataObject*>( index.internalPointer() );
493  if ( childObject ) {
494 
496  GeoDataObject *parentObject = childObject->parent();
497  if ( parentObject == d->m_rootDocument )
498  {
499  return QModelIndex();
500  }
501 
502  GeoDataObject *greatParentObject = parentObject->parent();
503 
504  // Avoid crashing when there is no grandparent
505  if ( greatParentObject == 0 )
506  {
507  return QModelIndex();
508  }
509 
510  // greatParent can be a container
511  if ( greatParentObject->nodeType() == GeoDataTypes::GeoDataFolderType
512  || greatParentObject->nodeType() == GeoDataTypes::GeoDataDocumentType ) {
513  GeoDataContainer *greatparentContainer = static_cast<GeoDataContainer*>( greatParentObject );
514  GeoDataFeature *parentFeature = static_cast<GeoDataFeature*>( parentObject );
515 // mDebug() << "parent " << childObject->nodeType() << "(" << childObject << ") = "
516 // << parentObject->nodeType() << "[" << greatparentContainer->childPosition( parentFeature ) << "](" << parentObject << ")";
517  return createIndex( greatparentContainer->childPosition( parentFeature ), 0, parentObject );
518  }
519 
520  // greatParent can be a placemark
521  if ( greatParentObject->nodeType() == GeoDataTypes::GeoDataPlacemarkType ) {
522 // GeoDataPlacemark *greatparentPlacemark = static_cast<GeoDataPlacemark*>( greatParentObject );
523 // mDebug() << "parent " << childObject->nodeType() << "(" << childObject << ") = "
524 // << parentObject->nodeType() << "[0](" << parentObject << ")";
525  return createIndex( 0, 0, parentObject );
526  }
527 
528  // greatParent can be a multigeometry
529  if ( greatParentObject->nodeType() == GeoDataTypes::GeoDataMultiGeometryType ) {
530  GeoDataMultiGeometry *greatparentMultiGeo = static_cast<GeoDataMultiGeometry*>( greatParentObject );
531  GeoDataGeometry *parentGeometry = static_cast<GeoDataGeometry*>( parentObject );
532 // mDebug() << "parent " << childObject->nodeType() << "(" << childObject << ") = "
533 // << parentObject->nodeType() << "[" << greatParentItem->childPosition( parentGeometry ) << "](" << parentObject << ")";
534  return createIndex( greatparentMultiGeo->childPosition( parentGeometry ), 0, parentObject );
535  }
536 
537  if ( greatParentObject->nodeType() == GeoDataTypes::GeoDataTourType ) {
538  GeoDataTour *tour = static_cast<GeoDataTour*>( greatParentObject );
539  return createIndex( 0, 0, tour->playlist() );
540  }
541 
542  }
543 
544 // mDebug() << "parent unknown index";
545  return QModelIndex();
546 }
547 
548 int GeoDataTreeModel::columnCount( const QModelIndex & ) const
549 {
550  return 4;
551 }
552 
553 bool GeoDataTreeModel::setData ( const QModelIndex & index, const QVariant & value, int role )
554 {
555  if ( !index.isValid() )
556  return false;
557 
558  GeoDataObject *object = static_cast<GeoDataObject*>( index.internalPointer() );
559  if ( role == Qt::CheckStateRole ) {
560  if ( object->nodeType() == GeoDataTypes::GeoDataPlacemarkType
561  || object->nodeType() == GeoDataTypes::GeoDataFolderType
562  || object->nodeType() == GeoDataTypes::GeoDataDocumentType ) {
563  GeoDataFeature *feature = static_cast<GeoDataFeature*>( object );
564  bool bValue = value.toBool();
565  if (feature->parent()->nodeType() == GeoDataTypes::GeoDataFolderType) {
566  GeoDataFolder *pfolder = static_cast<GeoDataFolder *>(feature->parent());
567  if ( pfolder->style()->listStyle().listItemType() == GeoDataListStyle::RadioFolder) {
568  if ( bValue ) {
569  QVector< GeoDataFeature * >::Iterator i = pfolder->begin();
570  for(; i < pfolder->end(); ++i) {
571  (*i)->setVisible( false );
572  }
573  }
574  }
575  }
576  if ( feature->nodeType() == GeoDataTypes::GeoDataFolderType) {
577  GeoDataFolder *folder = static_cast<GeoDataFolder *>( object );
578  if ( bValue ) {
579  } else {
580  if ( folder->style()->listStyle().listItemType() == GeoDataListStyle::RadioFolder
581  || folder->style()->listStyle().listItemType() == GeoDataListStyle::CheckOffOnly ) {
582  QVector< GeoDataFeature * >::Iterator i = folder->begin();
583  for(; i < folder->end(); ++i) {
584  (*i)->setVisible( false );
585  }
586  folder->setVisible( false );
587  }
588  }
589  }
590  feature->setVisible( bValue );
591  mDebug() << "setData " << feature->name();
592  updateFeature( feature );
593  return true;
594  }
595  } else if ( role == Qt::EditRole ) {
596  if ( object->nodeType() == GeoDataTypes::GeoDataPlacemarkType
597  || object->nodeType() == GeoDataTypes::GeoDataFolderType
598  || object->nodeType() == GeoDataTypes::GeoDataDocumentType
599  || object->nodeType() == GeoDataTypes::GeoDataTourType ) {
600  GeoDataFeature *feature = static_cast<GeoDataFeature*>( object );
601  feature->setName( value.toString() );
602  mDebug() << "setData " << feature->name() << " " << value.toString();
603  updateFeature( feature );
604  return true;
605  }
606  }
607 
608  return false;
609 }
610 
611 void GeoDataTreeModel::reset()
612 {
613  beginResetModel();
614  endResetModel();
615 }
616 
617 Qt::ItemFlags GeoDataTreeModel::flags ( const QModelIndex & index ) const
618 {
619  if ( !index.isValid() )
620  return Qt::NoItemFlags;
621 
622  GeoDataObject *object = static_cast<GeoDataObject*>( index.internalPointer() );
623  if ( object->nodeType() == GeoDataTypes::GeoDataDocumentType ) {
624  GeoDataDocument *document = static_cast<GeoDataDocument*>( object );
625  if( document->documentRole() == UserDocument ) {
626  return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEditable;
627  }
628  }
629  if ( object->nodeType() == GeoDataTypes::GeoDataPlacemarkType ) {
630  GeoDataFeature *feature = static_cast<GeoDataFeature*>( object );
631  GeoDataObject *parent = feature->parent();
632 
633  if ( parent->nodeType() == GeoDataTypes::GeoDataFolderType ) {
634  GeoDataFolder *parentfolder = static_cast<GeoDataFolder *>( parent );
635  if ( parentfolder->style()->listStyle().listItemType() == GeoDataListStyle::RadioFolder ) {
636  return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEditable;
637  } else if ( parentfolder->style()->listStyle().listItemType() == GeoDataListStyle::CheckHideChildren ) {
638  return 0;
639  }
640  }
641  }
642  if ( object->nodeType() == GeoDataTypes::GeoDataFolderType ) {
643  GeoDataFolder *folder = static_cast<GeoDataFolder *>( object );
644  if ( folder->style()->listStyle().listItemType() == GeoDataListStyle::RadioFolder) {
645  return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEditable;
646  } else if ( folder->style()->listStyle().listItemType() == GeoDataListStyle::CheckOffOnly ) {
647  QVector<GeoDataFeature *>::Iterator i = folder->begin();
648  bool allVisible = true;
649  for(; i < folder->end(); ++i) {
650  if( ! (*i)->isVisible() ) {
651  allVisible = false;
652  break;
653  }
654  }
655  if ( allVisible ) {
656  return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEditable;
657  } else {
658  return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
659  }
660  } else if ( folder->style()->listStyle().listItemType() == GeoDataListStyle::CheckHideChildren) {
661  return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEditable;
662  }
663  }
664  if ( object->nodeType() == GeoDataTypes::GeoDataPlacemarkType
665  || object->nodeType() == GeoDataTypes::GeoDataFolderType ) {
666  GeoDataFeature *feature = static_cast<GeoDataFeature*>( object );
667  GeoDataObject *parent = feature->parent();
668  while( parent->nodeType() != GeoDataTypes::GeoDataDocumentType ) {
669  parent = parent->parent();
670  }
671  GeoDataDocument *document = static_cast<GeoDataDocument*>( parent );
672  if( document->documentRole() == UserDocument ) {
673  return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEditable;;
674  }
675  }
676 
677  if ( object->nodeType() == GeoDataTypes::GeoDataPlacemarkType
678  || object->nodeType() == GeoDataTypes::GeoDataFolderType
679  || object->nodeType() == GeoDataTypes::GeoDataDocumentType ) {
680  return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
681  }
682 
683  if ( object->nodeType() == GeoDataTypes::GeoDataTourType ) {
684  return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
685  }
686 
687  if ( object->nodeType() == GeoDataTypes::GeoDataWaitType
688  || object->nodeType() == GeoDataTypes::GeoDataFlyToType
689  || object->nodeType() == GeoDataTypes::GeoDataPlaylistType ) {
690  return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
691  }
692  return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
693 }
694 
695 
696 QModelIndex GeoDataTreeModel::index( GeoDataObject *object )
697 {
698  //It first runs bottom-top, storing every ancestor of the object, and
699  //then goes top-down retrieving the QModelIndex of every ancestor until reaching the
700  //index of the requested object.
701  //The TreeModel contains: Documents, Folders, Placemarks, MultiGeometries
702  //and Geometries that are children of MultiGeometries
703  //You can not call this function with an element that does not belong to the tree
704 
705  Q_ASSERT( ( object->nodeType() == GeoDataTypes::GeoDataFolderType )
706  || ( object->nodeType() == GeoDataTypes::GeoDataDocumentType )
707  || ( object->nodeType() == GeoDataTypes::GeoDataPlacemarkType )
708  || ( object->nodeType() == GeoDataTypes::GeoDataTourType )
709  || ( ( object->nodeType() == GeoDataTypes::GeoDataPlaylistType )
710  && ( object->parent()->nodeType() == GeoDataTypes::GeoDataTourType ) )
711  || ( ( object->nodeType() == GeoDataTypes::GeoDataWaitType )
712  && ( object->parent()->nodeType() == GeoDataTypes::GeoDataPlaylistType ) )
713  || ( ( object->nodeType() == GeoDataTypes::GeoDataFlyToType )
714  && ( object->parent()->nodeType() == GeoDataTypes::GeoDataPlaylistType ) )
715  || ( ( object->nodeType() == GeoDataTypes::GeoDataLineStringType )
716  && ( object->parent()->nodeType() == GeoDataTypes::GeoDataMultiGeometryType ) )
717  || ( ( object->nodeType() == GeoDataTypes::GeoDataLinearRingType )
718  && ( object->parent()->nodeType() == GeoDataTypes::GeoDataMultiGeometryType ) )
719  || ( ( object->nodeType() == GeoDataTypes::GeoDataPointType )
720  && ( object->parent()->nodeType() == GeoDataTypes::GeoDataMultiGeometryType ) )
721  || ( ( object->nodeType() == GeoDataTypes::GeoDataPolygonType )
722  && ( object->parent()->nodeType() == GeoDataTypes::GeoDataMultiGeometryType ) )
723  || ( object->nodeType() == GeoDataTypes::GeoDataMultiGeometryType ) );
724 
725 
726  QList< GeoDataObject* > ancestors;
727 
728  GeoDataObject *itup = object; //Iterator to reach the top of the GeoDataDocument (bottom-up)
729 
730  while ( itup && ( itup != d->m_rootDocument ) ) {//We reach up to the rootDocument
731 
732  ancestors.append( itup );
733  itup = itup->parent() ;
734  }
735 
736  QModelIndex itdown;
737  if ( !ancestors.isEmpty() ) {
738 
739  itdown = index( d->m_rootDocument->childPosition( static_cast<GeoDataFeature*>( ancestors.last() ) ),0,QModelIndex());//Iterator to go top down
740 
741  while ( ( ancestors.size() > 1 ) ) {
742 
743  GeoDataObject *parent = static_cast<GeoDataObject*>( ancestors.last() );
744 
745  if ( ( parent->nodeType() == GeoDataTypes::GeoDataFolderType )
746  || ( parent->nodeType() == GeoDataTypes::GeoDataDocumentType ) ) {
747 
748  ancestors.removeLast();
749  itdown = index( static_cast<GeoDataContainer*>(parent)->childPosition( static_cast<GeoDataFeature*>( ancestors.last() ) ) , 0, itdown );
750  } else if ( ( parent->nodeType() == GeoDataTypes::GeoDataPlacemarkType ) ) {
751  //The only child of the model is a Geometry or MultiGeometry object
752  //If it is a geometry object, we should be on the bottom of the list
753  ancestors.removeLast();
754  if( ancestors.last()->nodeType() == GeoDataTypes::GeoDataMultiGeometryType )
755  itdown = index( 0 , 0, itdown );
756  else
757  itdown = QModelIndex();
758 
759  } else if ( ( parent->nodeType() == GeoDataTypes::GeoDataMultiGeometryType ) ) {
760  //The child is one of the geometry children of MultiGeometry
761  ancestors.removeLast();
762  itdown = index( static_cast<GeoDataMultiGeometry*>(parent)->childPosition( static_cast<GeoDataGeometry*>(ancestors.last()) ) , 0, itdown );
763  } else if ( ( parent->nodeType() == GeoDataTypes::GeoDataTourType ) ) {
764  ancestors.removeLast();
765  itdown = index( 0, 0, itdown );
766  } else if ( ( parent->nodeType() == GeoDataTypes::GeoDataPlaylistType ) ) {
767  GeoDataPlaylist *playlist = static_cast<GeoDataPlaylist*>( parent );
768  for ( int i=0; i< playlist->size(); i++ )
769  {
770  if ( playlist->primitive(i) == ancestors.last() )
771  {
772  ancestors.removeLast();
773  itdown = index( i, 0, itdown );
774  break;
775  }
776  }
777  }
778  else { //If the element is not found on the tree, it will be added under m_rootDocument
779  itdown = QModelIndex();
780  break;
781  }
782  }
783  }
784  return itdown;
785 }
786 
787 QItemSelectionModel *GeoDataTreeModel::selectionModel()
788 {
789  return &d->m_selectionModel;
790 }
791 
792 int GeoDataTreeModel::addFeature( GeoDataContainer *parent, GeoDataFeature *feature, int row )
793 {
794  if ( parent && feature ) {
795 
796  QModelIndex modelindex = index( parent );
797  //index(GeoDataObject*) returns QModelIndex() if parent == m_rootDocument
798  //or if parent is not found on the tree.
799  //We must check that we are in top of the tree (then QModelIndex() is
800  //the right parent to insert the child object) or that we have a valid QModelIndex
801 
802  if( ( parent == d->m_rootDocument ) || modelindex.isValid() )
803  {
804  if( row < 0 || row > parent->size()) {
805  row = parent->size();
806  }
807  beginInsertRows( modelindex , row , row );
808  parent->insert( feature, row );
809  d->checkParenting( parent );
810  endInsertRows();
811  emit added(feature);
812  }
813  else
814  qWarning() << "GeoDataTreeModel::addFeature (parent " << parent << " - feature" << feature << ") : parent not found on the TreeModel";
815  }
816  else
817  qWarning() << "Null pointer in call to GeoDataTreeModel::addFeature (parent " << parent << " - feature" << feature << ")";
818  return row; //-1 if it failed, the relative index otherwise.
819 }
820 
821 int GeoDataTreeModel::addDocument( GeoDataDocument *document )
822 {
823  return addFeature( d->m_rootDocument, document );
824 }
825 
826 bool GeoDataTreeModel::removeFeature( GeoDataContainer *parent, int row )
827 {
828  if ( row<parent->size() ) {
829  beginRemoveRows( index( parent ), row , row );
830  GeoDataFeature *feature = parent->child( row );
831  parent->remove( row );
832  emit removed(feature);
833  endRemoveRows();
834  return true;
835  }
836  return false; //Tried to remove a row that is not contained in the parent.
837 }
838 
839 int GeoDataTreeModel::removeFeature( const GeoDataFeature *feature )
840 {
841  if ( feature && ( feature!=d->m_rootDocument ) ) {
842 
843  //We check to see we are not removing the
844  //top level element m_rootDocument
845 
846  GeoDataObject *parent = static_cast< GeoDataObject* >( feature->parent() );
847 
848  if ( ( parent->nodeType() == GeoDataTypes::GeoDataFolderType )
849  || ( parent->nodeType() == GeoDataTypes::GeoDataDocumentType ) ) {
850 
851  int row = static_cast< GeoDataContainer* >( feature->parent() )->childPosition( feature );
852  if ( row != -1 ) {
853  bool removed = removeFeature( static_cast< GeoDataContainer* >( feature->parent() ) , row );
854  if( removed ) {
855  return row;
856  }
857  }
858  //The feature is not contained in the parent it points to
859  }
860  }
861  return -1; //We can not remove the rootDocument
862 }
863 
864 void GeoDataTreeModel::updateFeature( GeoDataFeature *feature )
865 {
866  GeoDataContainer *container = static_cast<GeoDataContainer*>( feature->parent() );
867  int index = removeFeature( feature );
868  Q_ASSERT( index != -1 );
869  addFeature( container, feature, index );
870 }
871 
872 void GeoDataTreeModel::removeDocument( int index )
873 {
874  removeFeature( d->m_rootDocument, index );
875 }
876 
877 void GeoDataTreeModel::removeDocument( GeoDataDocument *document )
878 {
879  removeFeature( document );
880 }
881 
882 void GeoDataTreeModel::update()
883 {
884 // mDebug() << "updating GeoDataTreeModel";
885  beginResetModel();
886  endResetModel();
887 }
888 
889 void GeoDataTreeModel::setRootDocument( GeoDataDocument* document )
890 {
891  beginResetModel();
892  if ( d->m_ownsRootDocument ) {
893  delete d->m_rootDocument;
894  }
895 
896  d->m_ownsRootDocument = ( document == 0 );
897  d->m_rootDocument = document ? document : new GeoDataDocument;
898  endResetModel();
899 }
900 
901 GeoDataDocument * GeoDataTreeModel::rootDocument()
902 {
903  return d->m_rootDocument;
904 }
905 
906 #include "GeoDataTreeModel.moc"
QAbstractItemModel::hasIndex
bool hasIndex(int row, int column, const QModelIndex &parent) const
GeoDataDocument.h
QModelIndex
Marble::GeoDataFeature::customStyle
const GeoDataStyle * customStyle() const
Return the style assigned to the placemark with setStyle (can be 0)
Definition: GeoDataFeature.cpp:730
Marble::GeoDataListStyle::RadioFolder
Definition: GeoDataListStyle.h:47
Marble::GeoDataGeometry::nodeType
virtual const char * nodeType() const
Provides type information for downcasting a GeoData.
Definition: GeoDataGeometry.cpp:77
Marble::GeoDataTypes::GeoDataMultiGeometryType
const char * GeoDataMultiGeometryType
Definition: GeoDataTypes.cpp:60
FileManager.h
Marble::GeoDataTreeModel::addFeature
int addFeature(GeoDataContainer *parent, GeoDataFeature *feature, int row=-1)
Definition: GeoDataTreeModel.cpp:792
Marble::GeoDataTypes::GeoDataLinearRingType
const char * GeoDataLinearRingType
Definition: GeoDataTypes.cpp:52
Marble::GeoDataDocument
A container for Features, Styles and in the future Schemas.
Definition: GeoDataDocument.h:65
Marble::GeoDataTypes::GeoDataPointType
const char * GeoDataPointType
Definition: GeoDataTypes.cpp:68
Marble::GeoDataContainer::child
GeoDataFeature * child(int)
returns the requested child item
Definition: GeoDataContainer.cpp:239
Marble::GeoDataTypes::GeoDataLookAtType
const char * GeoDataLookAtType
Definition: GeoDataTypes.cpp:58
Marble::GeoDataPlaylist::primitive
GeoDataTourPrimitive * primitive(int index)
Definition: GeoDataPlaylist.cpp:87
Marble::GeoDataTypes::GeoDataPolygonType
const char * GeoDataPolygonType
Definition: GeoDataTypes.cpp:69
Marble::GeoDataTreeModel::rootDocument
GeoDataDocument * rootDocument()
Definition: GeoDataTreeModel.cpp:901
GeoDataContainer.h
Marble::GeoDataTreeModel::setRootDocument
void setRootDocument(GeoDataDocument *document)
Sets the root document to use.
Definition: GeoDataTreeModel.cpp:889
Marble::GeoDataCamera::coordinates
GeoDataCoordinates coordinates() const
retrieve the lat/lon/alt triple as a GeoDataCoordinates object
Definition: GeoDataCamera.cpp:111
Marble::GeoDataMultiGeometry::child
GeoDataGeometry * child(int)
returns the requested child item
Definition: GeoDataMultiGeometry.cpp:159
Marble::GeoDataTreeModel::reset
void reset()
Definition: GeoDataTreeModel.cpp:611
Marble::GeoDataObject
A base class for all geodata objects.
Definition: GeoDataObject.h:48
Marble::GeoDataTreeModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition: GeoDataTreeModel.cpp:548
Marble::GeoDataGeometry
A base class for all geodata features.
Definition: GeoDataGeometry.h:47
Marble::GeoDataContainer::begin
QVector< GeoDataFeature * >::Iterator begin()
Definition: GeoDataContainer.cpp:331
Marble::GeoDataTypes::GeoDataPlacemarkType
const char * GeoDataPlacemarkType
Definition: GeoDataTypes.cpp:66
Marble::GeoDataTypes::GeoDataDocumentType
const char * GeoDataDocumentType
Definition: GeoDataTypes.cpp:38
Marble::GeoDataTreeModel::removeFeature
bool removeFeature(GeoDataContainer *parent, int index)
Definition: GeoDataTreeModel.cpp:826
Marble::GeoDataObject::parent
virtual GeoDataObject * parent() const
Provides the parent of the object in GeoDataContainers.
Definition: GeoDataObject.cpp:65
Marble::GeoDataStyle::iconStyle
GeoDataIconStyle & iconStyle()
Return the icon style of this style.
Definition: GeoDataStyle.cpp:133
GeoDataStyle.h
Marble::GeoDataFeature::isVisible
bool isVisible() const
Return whether this feature is visible or not.
Definition: GeoDataFeature.cpp:656
Marble::GeoDataContainer
A base class that can hold GeoDataFeatures.
Definition: GeoDataContainer.h:47
Marble::GeoDataFeature::description
QString description() const
Return the text description of the feature.
Definition: GeoDataFeature.cpp:588
Marble::GeoDataCamera
Definition: GeoDataCamera.h:22
Marble::GeoDataPlacemark::coordinate
GeoDataCoordinates coordinate(const QDateTime &dateTime=QDateTime(), bool *iconAtCoordinates=0) const
Return the coordinates of the placemark at time dateTime as a GeoDataCoordinates. ...
Definition: GeoDataPlacemark.cpp:172
Marble::GeoDataFeature::style
const GeoDataStyle * style() const
Return the style assigned to the placemark, or a default style if none has been set.
Definition: GeoDataFeature.cpp:709
GeoDataWait.h
QBrush
Marble::GeoDataTreeModel::~GeoDataTreeModel
~GeoDataTreeModel()
Destroys the GeoDataModel.
Definition: GeoDataTreeModel.cpp:91
Marble::GeoDataTreeModel::data
QVariant data(const QModelIndex &index, int role) const
Definition: GeoDataTreeModel.cpp:230
Marble::GeoDataFeature::zoomLevel
int zoomLevel() const
Return the popularity index of the placemark.
Definition: GeoDataFeature.cpp:797
Marble::GeoDataTour
Definition: GeoDataTour.h:25
GeoDataExtendedData.h
Marble::GeoDataTreeModel::added
void added(GeoDataObject *object)
Marble::MarblePlacemarkModel::ObjectPointerRole
The pointer to a specific object.
Definition: MarblePlacemarkModel.h:62
Marble::GeoDataTreeModel::GeoDataTreeModel
GeoDataTreeModel(QObject *parent=0)
Creates a new GeoDataTreeModel.
Definition: GeoDataTreeModel.cpp:85
MarbleDebug.h
Marble::GeoDataMultiGeometry::size
int size() const
Definition: GeoDataMultiGeometry.cpp:69
QObject::tr
QString tr(const char *sourceText, const char *disambiguation, int n)
Marble::GeoDataTreeModel::addDocument
int addDocument(GeoDataDocument *document)
Definition: GeoDataTreeModel.cpp:821
Marble::GeoDataObject::nodeType
virtual const char * nodeType() const =0
Provides type information for downcasting a GeoNode.
QList::size
int size() const
Marble::GeoDataPlacemark::geometry
GeoDataGeometry * geometry()
The geometry of the GeoDataPlacemark is to be rendered to the marble map along with the icon at the c...
Definition: GeoDataPlacemark.cpp:152
Marble::GeoDataFeature::popularity
qint64 popularity() const
Return the popularity of the feature.
Definition: GeoDataFeature.cpp:808
GeoDataCamera.h
QAbstractItemModel::beginResetModel
void beginResetModel()
QModelIndex::isValid
bool isValid() const
Marble::GeoDataTreeModel::setData
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Definition: GeoDataTreeModel.cpp:553
QList::append
void append(const T &value)
Marble::GeoDataTreeModel::hasChildren
virtual bool hasChildren(const QModelIndex &parent) const
Definition: GeoDataTreeModel.cpp:96
Marble::GeoDataFeature::setName
void setName(const QString &value)
Set a new name for this feature.
Definition: GeoDataFeature.cpp:549
QAbstractItemModel::endInsertRows
void endInsertRows()
Marble::GeoDataTreeModel::removeDocument
void removeDocument(int index)
Definition: GeoDataTreeModel.cpp:872
QObject
Marble::GeoDataFlyTo
Definition: GeoDataFlyTo.h:23
Marble::UserDocument
Definition: GeoDataDocument.h:42
QList::isEmpty
bool isEmpty() const
QString::isEmpty
bool isEmpty() const
Marble::GeoDataListStyle::backgroundColor
QColor backgroundColor() const
Definition: GeoDataListStyle.cpp:100
QAbstractItemModel::beginRemoveRows
void beginRemoveRows(const QModelIndex &parent, int first, int last)
GeoDataObject.h
Marble::GeoDataTypes::GeoDataFolderType
const char * GeoDataFolderType
Definition: GeoDataTypes.cpp:42
Marble::GeoDataTypes::GeoDataFlyToType
const char * GeoDataFlyToType
Definition: GeoDataTypes.cpp:41
Marble::GeoDataDocument::documentRole
DocumentRole documentRole() const
Definition: GeoDataDocument.cpp:81
Marble::GeoDataTreeModel::removed
void removed(GeoDataObject *object)
insert and remove row don't trigger any signal that proxies forward this signal will refresh geometry...
QModelIndex::internalPointer
void * internalPointer() const
Marble::GeoDataPlaylist
Definition: GeoDataPlaylist.h:22
Marble::GeoDataTreeModel::update
void update()
Definition: GeoDataTreeModel.cpp:882
Marble::GeoDataContainer::size
int size() const
size of the container
Definition: GeoDataContainer.cpp:286
Marble::GeoDataContainer::insert
void insert(GeoDataFeature *other, int index)
Definition: GeoDataContainer.cpp:265
Marble::GeoDataTypes::GeoDataLineStringType
const char * GeoDataLineStringType
Definition: GeoDataTypes.cpp:53
Marble::GeoDataListStyle::CheckOffOnly
Definition: GeoDataListStyle.h:48
QString
Marble::GeoDataTypes::GeoDataTourType
const char * GeoDataTourType
Definition: GeoDataTypes.cpp:83
QList
MarblePlacemarkModel.h
Marble::GeoDataTypes::GeoDataPlaylistType
const char * GeoDataPlaylistType
Definition: GeoDataTypes.cpp:67
Marble::MarblePlacemarkModel::PopularityRole
The popularity.
Definition: MarblePlacemarkModel.h:61
Marble::GeoDataTreeModel::updateFeature
void updateFeature(GeoDataFeature *feature)
Definition: GeoDataTreeModel.cpp:864
Marble::GeoDataFolder
Definition: GeoDataFolder.h:50
GeoDataPlacemark.h
GeoDataTreeModel.h
Marble::GeoDataContainer::childPosition
int childPosition(const GeoDataFeature *child) const
returns the position of an item in the list
Definition: GeoDataContainer.cpp:252
Marble::GeoDataFeature::isGloballyVisible
bool isGloballyVisible() const
Return whether this feature is visible or not in the context of its parenting.
Definition: GeoDataFeature.cpp:667
QAbstractItemModel::createIndex
QModelIndex createIndex(int row, int column, void *ptr) const
GeoDataPlaylist.h
Marble::GeoDataIconStyle::icon
QImage icon() const
Definition: GeoDataIconStyle.cpp:117
QAbstractItemModel::beginInsertRows
void beginInsertRows(const QModelIndex &parent, int first, int last)
Marble::MarblePlacemarkModel::PopularityIndexRole
The popularity index.
Definition: MarblePlacemarkModel.h:60
Marble::GeoDataLookAt
Definition: GeoDataLookAt.h:23
Marble::GeoDataFeature::setVisible
void setVisible(bool value)
Set a new value for visibility.
Definition: GeoDataFeature.cpp:661
Marble::MarblePlacemarkModel::CoordinateRole
The GeoDataCoordinates coordinate.
Definition: MarblePlacemarkModel.h:53
Marble::GeoDataTypes::GeoDataCameraType
const char * GeoDataCameraType
Definition: GeoDataTypes.cpp:31
GeoDataFolder.h
Marble::GeoDataTreeModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Definition: GeoDataTreeModel.cpp:207
Marble::GeoDataContainer::end
QVector< GeoDataFeature * >::Iterator end()
Definition: GeoDataContainer.cpp:336
Marble::GeoDataListStyle::CheckHideChildren
Definition: GeoDataListStyle.h:49
Marble::GeoDataPlacemark::countryCode
const QString countryCode() const
Return the country code of the placemark.
Definition: GeoDataPlacemark.cpp:271
QVector
Marble::GeoDataTypes::GeoDataWaitType
const char * GeoDataWaitType
Definition: GeoDataTypes.cpp:85
GeoDataFlyTo.h
Marble::GeoDataMultiGeometry::childPosition
int childPosition(const GeoDataGeometry *child) const
returns the position of an item in the list
Definition: GeoDataMultiGeometry.cpp:172
Marble::GeoDataFeature
A base class for all geodata features.
Definition: GeoDataFeature.h:57
Marble::GeoDataFeature::name
QString name() const
The name of the feature.
Definition: GeoDataFeature.cpp:544
Marble::GeoDataContainer::featureList
QVector< GeoDataFeature * > featureList() const
A convenience function that returns all features in this container.
Definition: GeoDataContainer.cpp:231
Marble::GeoDataListStyle::listItemType
ListItemType listItemType() const
Definition: GeoDataListStyle.cpp:90
QList::last
T & last()
Marble::GeoDataContainer::remove
void remove(int index)
Definition: GeoDataContainer.cpp:280
Marble::GeoDataPlaylist::size
int size() const
Definition: GeoDataPlaylist.cpp:128
QList::removeLast
void removeLast()
Marble::GeoDataMultiGeometry
Definition: GeoDataMultiGeometry.h:33
QModelIndex::column
int column() const
Marble::GeoDataTreeModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Definition: GeoDataTreeModel.cpp:424
QVariant::toBool
bool toBool() const
Marble::GeoDataTreeModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const
Definition: GeoDataTreeModel.cpp:617
QAbstractItemModel
Marble::GeoDataStyle::listStyle
GeoDataListStyle & listStyle()
Return the list style of this style.
Definition: GeoDataStyle.cpp:183
Marble::GeoDataTreeModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const
Return the number of Items in the Model.
Definition: GeoDataTreeModel.cpp:142
GeoDataTypes.h
QAbstractItemModel::endRemoveRows
void endRemoveRows()
Marble::GeoDataTypes::GeoDataTrackType
const char * GeoDataTrackType
Definition: GeoDataTypes.cpp:86
Marble::GeoDataLookAt::coordinates
GeoDataCoordinates coordinates() const
retrieve the lat/lon/alt triple as a GeoDataCoordinates object
Definition: GeoDataLookAt.cpp:109
QItemSelectionModel
QAbstractItemModel::endResetModel
void endResetModel()
QObject::parent
QObject * parent() const
Marble::GeoDataFeature::nodeType
virtual const char * nodeType() const
Provides type information for downcasting a GeoData.
Definition: GeoDataFeature.cpp:158
QVariant::toString
QString toString() const
Marble::GeoDataPlacemark
a class representing a point of interest on the map
Definition: GeoDataPlacemark.h:54
Marble::mDebug
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:36
Marble::GeoDataTour::playlist
GeoDataPlaylist * playlist()
Definition: GeoDataTour.cpp:64
GeoDataTour.h
Marble::GeoDataFlyTo::view
const GeoDataAbstractView * view() const
Definition: GeoDataFlyTo.cpp:110
Marble::GeoDataTreeModel::selectionModel
QItemSelectionModel * selectionModel()
Definition: GeoDataTreeModel.cpp:787
QVariant
Qt::ItemFlags
typedef ItemFlags
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