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

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
satellitegroup.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  satellitegroup.cpp - K Desktop Planetarium
3  -------------------
4  begin : Tue 22 Mar 2011
5  copyright : (C) 2011 by Jerome SONRIER
6  email : jsid@emor3j.fr.eu.org
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include <QFile>
19 
20 #include <kstandarddirs.h>
21 
22 #include "satellitegroup.h"
23 #include "ksutils.h"
24 
25 
26 SatelliteGroup::SatelliteGroup( QString name, QString tle_filename, KUrl update_url )
27 {
28  m_name = name;
29  m_tle_file = tle_filename;
30  m_tle_url = update_url;
31 
32  // Read TLE file and create satellites
33  readTLE();
34 }
35 
36 SatelliteGroup::~SatelliteGroup()
37 {
38 }
39 
40 void SatelliteGroup::readTLE()
41 {
42  QFile file;
43  QString line1, line2;
44 
45  // Delete all satellites
46  clear();
47 
48  // Read TLE file
49  if ( KSUtils::openDataFile( file, m_tle_file ) ) {
50  QTextStream stream( &file );
51  while ( !stream.atEnd() ) {
52  // Read satellite name
53  QString sat_name = stream.readLine().trimmed();
54  line1 = stream.readLine();
55  line2 = stream.readLine();
56 
57  // Create a new satellite and add it to the list of satellites
58  append( new Satellite( sat_name, line1, line2 ) );
59  }
60  file.close();
61  }
62 }
63 
64 void SatelliteGroup::updateSatellitesPos()
65 {
66  for ( int i=0; i<size(); i++ ) {
67  Satellite *sat = at( i );
68  if ( sat->selected() )
69  sat->updatePos();
70  }
71 }
72 
73 KUrl SatelliteGroup::tleFilename()
74 {
75  // Return absolute path with "file:" before the path
76  return KUrl( "file:" + KStandardDirs::locateLocal("appdata", "") + m_tle_file );
77 }
78 
79 KUrl SatelliteGroup::tleUrl()
80 {
81  return m_tle_url;
82 }
83 
84 QString SatelliteGroup::name()
85 {
86  return m_name;
87 }
satellitegroup.h
SatelliteGroup::tleUrl
KUrl tleUrl()
Definition: satellitegroup.cpp:79
SatelliteGroup::SatelliteGroup
SatelliteGroup(QString name, QString tle_filename, KUrl update_url)
Constructor.
Definition: satellitegroup.cpp:26
SatelliteGroup::name
QString name()
Definition: satellitegroup.cpp:84
SatelliteGroup::~SatelliteGroup
~SatelliteGroup()
Destructor.
Definition: satellitegroup.cpp:36
KSUtils::openDataFile
bool openDataFile(QFile &file, const QString &filename)
Attempt to open the data file named filename, using the QFile object "file".
SatelliteGroup::updateSatellitesPos
void updateSatellitesPos()
Compute current position of the each satellites in the group.
Definition: satellitegroup.cpp:64
Satellite::selected
bool selected()
Definition: satellite.cpp:1201
QTextStream
SatelliteGroup::readTLE
void readTLE()
Read TLE file of the group and create all satellites found in the file.
Definition: satellitegroup.cpp:40
Satellite
Represents an artificial satellites.
Definition: satellite.h:35
Satellite::updatePos
void updatePos()
Update satellite position.
Definition: satellite.cpp:647
ksutils.h
SatelliteGroup::tleFilename
KUrl tleFilename()
Definition: satellitegroup.cpp:73
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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