Stellarium 0.12.4
StelLocaleMgr.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2006 Fabien Chereau
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _STELLOCALEMGR_HPP_
21 #define _STELLOCALEMGR_HPP_
22 
23 #include "StelTranslator.hpp"
24 
29 {
30 public:
31  StelLocaleMgr();
32  ~StelLocaleMgr();
33 
38  void init();
39 
41  // MESSAGES TRANSLATIONS
47 
51  void setAppLanguage(const QString& newAppLangName);
52 
55 
59  QString getSkyLanguage() const;
60 
65  void setSkyLanguage(const QString& newSkyLangName);
66 
69 
71  // DATE & TIME LOCALIZATION
80  QString getTimeFormatStr(void) const {return sTimeFormatToString(timeFormat);}
83  void setTimeFormatStr(const QString& tf) {timeFormat=stringToSTimeFormat(tf);}
92  QString getDateFormatStr(void) const {return sDateFormatToString(dateFormat);}
93  void setDateFormatStr(const QString& df) {dateFormat=stringToSDateFormat(df);}
94 
98  void setCustomTimezone(QString tZ) { setCustomTzName(tZ); }
99 
102  enum STimeFormat {
106  };
107 
110  enum SDateFormat {
115  };
116 
118  QString getPrintableDateLocal(double JD) const;
119 
121  QString getPrintableTimeLocal(double JD) const;
122 
125  {
129  };
130 
132  void setGMTShift(int t)
133  {
134  GMTShift=t;
135  }
137  float getGMTShift(double JD = 0) const;
139  void setCustomTzName(const QString& tzname);
141  QString getCustomTzName(void) const
142  {
143  return customTzName;
144  }
146  STzFormat getTzFormat(void) const
147  {
148  return timeZoneMode;
149  }
150 
153  QString getISO8601TimeLocal(double JD) const;
154 
160  double getJdFromISO8601TimeLocal(const QString& str, bool* ok) const;
161 
163  static QString countryCodeToString(const QString& countryCode);
164 
166  static QStringList getAllCountryNames();
167 
168 private:
169  // The translator used for astronomical object naming
170  StelTranslator skyTranslator;
171 
172  // Date and time variables
173  STimeFormat timeFormat;
174  SDateFormat dateFormat;
175  STzFormat timeZoneMode; // Can be the system default or a user defined value
176 
177  QString customTzName; // Something like "Europe/Paris"
178  float GMTShift; // Time shift between GMT time and local time in hour. (positive for Est of GMT)
179 
180  // Convert the time format enum to its associated string and reverse
181  STimeFormat stringToSTimeFormat(const QString&) const;
182  QString sTimeFormatToString(STimeFormat) const;
183 
184  // Convert the date format enum to its associated string and reverse
185  SDateFormat stringToSDateFormat(const QString& df) const;
186  QString sDateFormatToString(SDateFormat df) const;
187 
188  static QMap<QString, QString> countryCodeToStringMap;
189 
190  static void generateCountryList();
191 };
192 
193 #endif // _STELLOCALEMGR_HPP_