SatellitesComponent::SatellitesComponent( SkyComposite *parent ) : SkyComponent( parent ) { KSFileReader fileReader; QString line; QStringList group_infos; if ( ! fileReader.open( "satellites.dat" ) ) return; emitProgressText( i18n("Loading satellites" ) ); while ( fileReader.hasMoreLines() ) { line = fileReader.readLine(); if ( line.trimmed().isEmpty() || line.at( 0 ) == '#' ) continue; group_infos = line.split( ';' ); m_groups.append( new SatelliteGroup( group_infos.at( 0 ), group_infos.at( 1 ), QUrl( group_infos.at( 2 ) ) ) ); } objectNames(SkyObject::SATELLITE).clear(); foreach( SatelliteGroup *group, m_groups ) { for ( int i=0; i<group->size(); i++ ) { Satellite *sat = group->at( i ); if ( sat->selected() && nameHash.contains(sat->name().toLower()) == false) { objectNames(SkyObject::SATELLITE).append(sat->name()); nameHash[sat->name().toLower()] = sat; } } } }
QString SkyObjItem::getDesc() const { if (m_Type == Planet) { KSFileReader fileReader; if (!fileReader.open("PlanetFacts.dat")) return i18n("No Description found for selected sky-object"); while (fileReader.hasMoreLines()) { QString line = fileReader.readLine(); if(line.length() != 0 && line[0] != '#') { QString soname = line.split("::")[0]; QString desc = line.split("::")[1]; if (soname == m_Name) { return desc; } } } } else if (m_Type == Star) { return i18n("Bright Star"); } else if (m_Type == Constellation) { return i18n("Constellation"); } return getTypeName(); }
ConstellationNamesComponent::ConstellationNamesComponent(SkyComposite *parent, CultureList* cultures ) : ListComponent(parent ) { uint i = 0; bool culture = false; KSFileReader fileReader; QString cultureName; if ( ! fileReader.open( "cnames.dat" ) ) return; emitProgressText( i18n("Loading constellation names" ) ); localCNames = Options::useLocalConstellNames(); while ( fileReader.hasMoreLines() ) { QString line, name, abbrev; int rah, ram, ras, dd, dm, ds; QChar sgn, mode; line = fileReader.readLine(); mode = line.at( 0 ); if ( mode == 'C') { cultureName = line.mid( 2 ).trimmed(); culture = cultureName == cultures->current(); i++; continue; } if ( culture ) { rah = line.mid( 0, 2 ).toInt(); ram = line.mid( 2, 2 ).toInt(); ras = line.mid( 4, 2 ).toInt(); sgn = line.at( 6 ); dd = line.mid( 7, 2 ).toInt(); dm = line.mid( 9, 2 ).toInt(); ds = line.mid( 11, 2 ).toInt(); abbrev = line.mid( 13, 3 ); name = line.mid( 17 ).trimmed(); if( Options::useLocalConstellNames() ) name = i18nc( "Constellation name (optional)", name.toLocal8Bit().data() ); dms r; r.setH( rah, ram, ras ); dms d( dd, dm, ds ); if ( sgn == '-' ) d.setD( -1.0*d.Degrees() ); SkyObject *o = new SkyObject( SkyObject::CONSTELLATION, r, d, 0.0, name, abbrev ); m_ObjectList.append( o ); //Add name to the list of object names objectNames(SkyObject::CONSTELLATION).append( name ); } } }
CultureList::CultureList() { KSFileReader fileReader; if ( ! fileReader.open( "cnames.dat" ) ) return; while ( fileReader.hasMoreLines() ) { QString line = fileReader.readLine(); if ( line.size() < 1 ) continue; QChar mode = line.at( 0 ); if ( mode == 'C' ) m_CultureList << line.mid( 2 ).trimmed(); } m_CultureList.sort(); m_CurrentCulture = m_CultureList.at( Options::skyCulture() ); }
SatellitesComponent::SatellitesComponent( SkyComposite *parent ) : SkyComponent( parent ) { KSFileReader fileReader; QString line; QStringList group_infos; if ( ! fileReader.open( "satellites.dat" ) ) return; emitProgressText( i18n("Loading satellites" ) ); while ( fileReader.hasMoreLines() ) { line = fileReader.readLine(); if ( line.trimmed().isEmpty() || line.at( 0 ) == '#' ) continue; group_infos = line.split( ";" ); m_groups.append( new SatelliteGroup( group_infos.at( 0 ), group_infos.at( 1 ), KUrl( group_infos.at( 2 ) ) ) ); } }
void SupernovaeComponent::loadData() { QString line; QString serialNo, hostGalaxy, date, type, offset, SNPosition, discoverers ; QStringList fields; dms ra, dec; float magnitude; KSFileReader fileReader; bool ok; kDebug()<<"Loading Supernovae data"<<endl; if( !fileReader.open("supernovae.dat")) return; //m_ObjectList.clear(); latest.clear(); objectNames(SkyObject::SUPERNOVA).clear(); while (fileReader.hasMoreLines()) { line=fileReader.readLine(); Supernova *sup=0; //kDebug()<<line[0]<<" "<<line.size()<<endl; if(line[0]=='#' || line.size()<10) continue; fields=line.split(","); serialNo=fields.at(0); hostGalaxy=fields.at(1); date=fields.at(2); ra=dms(fields.at(3),false); dec=dms(fields.at(4)); offset=fields.at(5); if(fields.at(6).isEmpty()) magnitude=99; else magnitude=fields.at(6).toFloat(&ok); SNPosition=fields.at(8); type=fields.at(10); discoverers=fields.at(12); sup=new Supernova(ra, dec, date, magnitude, serialNo, type, hostGalaxy, offset, discoverers); if (!m_ObjectList.empty()) { if ( findByName(sup->name() ) == 0 ) { //kDebug()<<"List of supernovae not empty. Found new supernova"; m_ObjectList.append(sup); latest.append(sup); }/* else m_ObjectList.append(sup);*/ } else //if the list is empty { m_ObjectList.append(sup); latest.append(sup); //notifyNewSupernovae(); } objectNames(SkyObject::SUPERNOVA).append(sup->name()); } //notifyNewSupernovae(); }