Stellarium 0.11.3
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

core/StelLocationMgr.hpp

00001 /*
00002  * Copyright (C) 2008 Fabien Chereau
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
00017  */
00018 
00019 #ifndef _STELLOCATIONMGR_HPP_
00020 #define _STELLOCATIONMGR_HPP_
00021 
00022 #include "StelLocation.hpp"
00023 #include <QString>
00024 #include <QObject>
00025 #include <QMetaType>
00026 #include <QMap>
00027 
00028 class QStringListModel;
00029 
00032 class StelLocationMgr : public QObject
00033 {
00034     Q_OBJECT
00035 
00036 public:
00038     StelLocationMgr();
00040     ~StelLocationMgr();
00041 
00043     QStringListModel* getModelAll() {return modelAllLocation;}
00044 
00046     QList<StelLocation> getAll() const {return locations.values();}
00047 
00050     const StelLocation locationForString(const QString& s, bool* ok=NULL) const;
00051 
00053     const StelLocation locationForSmallString(const QString& s, bool* ok=NULL) const;
00054 
00056     const StelLocation& getLastResortLocation() const {return lastResortLocation;}
00057     
00060     bool canSaveUserLocation(const StelLocation& loc) const;
00061 
00064     bool saveUserLocation(const StelLocation& loc);
00065 
00069     bool canDeleteUserLocation(const QString& id) const;
00070 
00074     bool deleteUserLocation(const QString& id);
00075 
00076 private:
00077     void generateBinaryLocationFile(const QString& txtFile, bool isUserLocation, const QString& binFile) const;
00078 
00080     QMap<QString, StelLocation> loadCities(const QString& fileName, bool isUserLocation) const;
00081     QMap<QString, StelLocation> loadCitiesBin(const QString& fileName) const;
00082 
00084     QStringListModel* modelAllLocation;
00085 
00087     QMap<QString, StelLocation> locations;
00088     
00089     StelLocation lastResortLocation;
00090 };
00091 
00092 #endif // _STELLOCATIONMGR_HPP_
Generated on Thu May 31 10:37:18 2012 for Stellarium by  doxygen 1.6.3