Stellarium 0.12.4
StelLocationMgr.hpp
1 /*
2  * Copyright (C) 2008 Fabien Chereau
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
17  */
18 
19 #ifndef _STELLOCATIONMGR_HPP_
20 #define _STELLOCATIONMGR_HPP_
21 
22 #include "StelLocation.hpp"
23 #include <QString>
24 #include <QObject>
25 #include <QMetaType>
26 #include <QMap>
27 
28 class QStringListModel;
29 
32 class StelLocationMgr : public QObject
33 {
34  Q_OBJECT
35 
36 public:
41 
43  QStringListModel* getModelAll() {return modelAllLocation;}
44 
46  QList<StelLocation> getAll() const {return locations.values();}
47 
50  const StelLocation locationForString(const QString& s, bool* ok=NULL) const;
51 
53  const StelLocation locationForSmallString(const QString& s, bool* ok=NULL) const;
54 
56  const StelLocation& getLastResortLocation() const {return lastResortLocation;}
57 
60  bool canSaveUserLocation(const StelLocation& loc) const;
61 
64  bool saveUserLocation(const StelLocation& loc);
65 
69  bool canDeleteUserLocation(const QString& id) const;
70 
74  bool deleteUserLocation(const QString& id);
75 
76 private:
77  void generateBinaryLocationFile(const QString& txtFile, bool isUserLocation, const QString& binFile) const;
78 
80  QMap<QString, StelLocation> loadCities(const QString& fileName, bool isUserLocation) const;
81  QMap<QString, StelLocation> loadCitiesBin(const QString& fileName) const;
82 
84  QStringListModel* modelAllLocation;
85 
87  QMap<QString, StelLocation> locations;
88 
89  StelLocation lastResortLocation;
90 };
91 
92 #endif // _STELLOCATIONMGR_HPP_