Stellarium  0.90.0
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
MultiLevelJsonBase Class Referenceabstract

Abstract base class for managing multi-level tree objects stored in JSON format. More...

#include <MultiLevelJsonBase.hpp>

Public Member Functions

 MultiLevelJsonBase (MultiLevelJsonBase *parent=Q_NULLPTR)
 Default constructor.
 
void initFromUrl (const QString &url)
 Init the element from a URL. More...
 
void initFromQVariantMap (const QVariantMap &map)
 Init the element from a QVariantMap. More...
 
 ~MultiLevelJsonBase ()
 Destructor.
 
QString getShortName () const
 Return the short name for this image to be used in the loading bar.
 
bool hasErrorOccured () const
 Return true if an error occured while loading the data.
 
int getLevel () const
 Get the depth level in the tree.
 
QVariantMap toQVariantMap () const
 Convert the image informations to a map following the JSON structure. More...
 
void scheduleChildsDeletion ()
 Schedule a deletion for all the childs. More...
 
- Public Member Functions inherited from StelSkyLayer
 StelSkyLayer (QObject *parent=Q_NULLPTR)
 
virtual void draw (StelCore *core, StelPainter &sPainter, float opacity=1.)=0
 Draws the content of the layer.
 
virtual QString getShortServerCredits () const
 Return the short server name to display in the loading bar.
 
virtual QString getKeyHint () const
 Return a hint on which key to use for referencing this layer. More...
 
virtual QString getLayerDescriptionHtml () const
 Return a human readable description of the layer with e.g. More...
 
void setFrameType (StelCore::FrameType ft)
 Set the reference frame type.
 
StelCore::FrameType getFrameType ()
 Get the reference frame type.
 

Protected Member Functions

virtual void loadFromQVariantMap (const QVariantMap &map)=0
 Load the element from a valid QVariantMap. More...
 
bool isDeletionScheduled () const
 Return true if a deletion is currently scheduled.
 
void updatePercent (int tot, int numToBeLoaded)
 
void deleteUnusedSubTiles ()
 Delete all the subtiles which were not displayed since more than lastDrawTrigger seconds.
 
void cancelDeletion ()
 If a deletion was scheduled, cancel it.
 

Static Protected Member Functions

static QVariantMap loadFromJSON (QIODevice &input, bool qZcompressed=false, bool gzCompressed=false)
 Load the element information from a JSON file.
 

Protected Attributes

QString shortName
 The very short name for this image set to be used in loading bar.
 
QString baseUrl
 Base URL to prefix to relative URL.
 
QString contructorUrl
 The relative URL passed to the constructor.
 
QList< MultiLevelJsonBase * > subTiles
 The list of all the created subtiles for this tile.
 
bool errorOccured
 Set to true if an error occured with this tile and it should not be displayed.
 
bool downloading
 true if the JSON descriptor file is currently downloading
 

Friends

class JsonLoadThread
 

Additional Inherited Members

- Signals inherited from StelSkyLayer
void loadingStateChanged (bool b)
 Emitted when loading of data started or stopped. More...
 
void percentLoadedChanged (int percentage)
 Emitted when the percentage of loading tiles/tiles to be displayed changed. More...
 

Detailed Description

The JSON files can be stored on disk or remotely and are loaded into threads.

Member Function Documentation

void MultiLevelJsonBase::initFromQVariantMap ( const QVariantMap &  map)

This method should be called by the constructors of the subclass.

void MultiLevelJsonBase::initFromUrl ( const QString &  url)

This method should be called by the constructors of the subclass.

virtual void MultiLevelJsonBase::loadFromQVariantMap ( const QVariantMap &  map)
protectedpure virtual

This method is called after the JSON files are downloaded and parsed into a QVariantMap.

Implemented in StelSkyImageTile, and StelSkyPolygon.

void MultiLevelJsonBase::scheduleChildsDeletion ( )

It will practically occur after the delay passed as argument to deleteUnusedTiles() has expired.

QVariantMap MultiLevelJsonBase::toQVariantMap ( ) const

It can be saved as JSON using the StelJsonParser methods.