Merge lp:~stellarium/stellarium/ip-query-location into lp:stellarium

Proposed by Alexander Wolf
Status: Superseded
Proposed branch: lp:~stellarium/stellarium/ip-query-location
Merge into: lp:stellarium
Diff against target: 866 lines (+435/-164)
9 files modified
data/default_config.ini.cmake (+1/-1)
src/core/StelCore.cpp (+11/-2)
src/core/StelLocation.cpp (+7/-0)
src/core/StelLocation.hpp (+3/-0)
src/core/StelLocationMgr.cpp (+115/-1)
src/core/StelLocationMgr.hpp (+25/-0)
src/gui/LocationDialog.cpp (+122/-31)
src/gui/LocationDialog.hpp (+11/-1)
src/gui/locationDialogGui.ui (+140/-128)
To merge this branch: bzr merge lp:~stellarium/stellarium/ip-query-location
Reviewer Review Type Date Requested Status
Marcos Cardinot Approve
Fabien Chéreau Needs Fixing
Alexander Wolf Approve
gzotti Needs Resubmitting
Review via email: mp+227418@code.launchpad.net

This proposal has been superseded by a proposal from 2014-08-06.

Commit message

1) Added IP-based location query for location panel and optionally at program start.
2) Improved location GUI:
   (a) clicking on the map reduces site list to sites in 3 degrees vicinity.
   (b) selecting a country in the combo box reduces site list to sites in that country.
   (c) selecting a planet other than earth reduces site list to sites on that planet.

Description of the change

1) Added IP-based location query for location panel and optionally at program start.
2) Improved location GUI:
   (a) clicking on the map reduces site list to sites in 3 degrees vicinity.
   (b) selecting a country in the combo box reduces site list to sites in that country.
   (c) selecting a planet other than earth reduces site list to sites on that planet.

To post a comment you must log in.
Revision history for this message
Alexander Wolf (alexwolf) wrote :

I checked this feature and it good work! But one moment: I think that label "IP Query" on button is not very informative and we should add tooltip and describe it.

review: Approve
Revision history for this message
Alexander Wolf (alexwolf) wrote :

The second feature is OK for me. Are you want merge it yourself?

Revision history for this message
Alexander Wolf (alexwolf) wrote :

Wait! What about non-Earth location?

review: Needs Fixing
Revision history for this message
Fabien Chéreau (xalioth) wrote :
Download full text (11.0 KiB)

Hi Please cleanup The code. Also use the regular event loop to make a non
blocking call to the service.
 Le 19 juil. 2014 15:58, "Alexander Wolf" <email address hidden> a écrit :

> Alexander Wolf has proposed merging
> lp:~georg-zotti/stellarium/ip-query-location into lp:stellarium.
>
> Requested reviews:
> Alexander Wolf (alexwolf)
>
> For more details, see:
>
> https://code.launchpad.net/~georg-zotti/stellarium/ip-query-location/+merge/227418
>
> This branch introduces new feature - automatic finding approximate
> location of Stellarium from IP address.
> --
>
> https://code.launchpad.net/~georg-zotti/stellarium/ip-query-location/+merge/227418
> You are subscribed to branch lp:stellarium.
>
> === modified file 'src/core/StelCore.cpp'
> --- src/core/StelCore.cpp 2014-04-14 17:55:46 +0000
> +++ src/core/StelCore.cpp 2014-07-19 07:57:49 +0000
> @@ -114,7 +114,14 @@
> defaultLocationID =
> conf->value("init_location/location","error").toString();
> bool ok;
> StelLocationMgr* locationMgr =
> &StelApp::getInstance().getLocationMgr();
> - StelLocation location =
> locationMgr->locationForString(defaultLocationID);
> + StelLocation location;
> + if (conf->value("init_location/use_ip_geolocation_if_available",
> "false").toBool()
> + && locationMgr->ipConnectionExists())
> + {
> + location=locationMgr->locationFromIP();
> + }
> +
> + else location = locationMgr->locationForString(defaultLocationID);
> if (!location.isValid())
> {
> qWarning() << "Warning: location" << defaultLocationID <<
> "is unknown.";
>
> === modified file 'src/core/StelLocationMgr.cpp'
> --- src/core/StelLocationMgr.cpp 2014-06-12 15:47:22 +0000
> +++ src/core/StelLocationMgr.cpp 2014-07-19 07:57:49 +0000
> @@ -25,6 +25,13 @@
> #include <QDebug>
> #include <QFile>
> #include <QDir>
> +#include <QtNetwork/QNetworkInterface>
> +#include <QtNetwork/QNetworkAccessManager>
> +#include <QEventLoop>
> +#include <QNetworkRequest>
> +#include <QNetworkReply>
> +#include <QUrl>
> +#include <QUrlQuery>
>
> StelLocationMgr::StelLocationMgr()
> {
> @@ -307,3 +314,99 @@
> sourcefile.close();
> return true;
> }
> +
> +
> +//! check if there is an IP connection.
> +// Along the lines of
> +//
> http://karanbalkar.com/2014/02/detect-internet-connection-using-qt-5-framework/
> +//#define DEBUG 1
> +bool StelLocationMgr::ipConnectionExists() const
> +{
> + QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
> + bool connectionExists = false;
> +
> + for (int i = 0; i < ifaces.count(); i++) {
> +
> + QNetworkInterface iface = ifaces.at(i);
> + if ( iface.flags().testFlag(QNetworkInterface::IsUp)
> + && !iface.flags().testFlag(QNetworkInterface::IsLoopBack)) {
> +
> +#ifdef DEBUG
> + // details of connection
> + qDebug() << "name:" << iface.name() << endl
> + << "mac:" << iface.hardwareAddress() << endl
> + << "ip addresses:" << endl;
> +#endif
> + for (int j=0; j<iface.addressEntries().count...

Revision history for this message
gzotti (georg-zotti) wrote :

Hm, I was surprised that the site list mixes all sites anyhow. I will try
to reduce selection to the currently set planet...

G.

On Sa, 19.07.2014, 14:26, Alexander Wolf wrote:
> Review: Needs Fixing
>
> Wait! What about non-Earth location?
> --
> https://code.launchpad.net/~georg-zotti/stellarium/ip-query-location/+merge/227418
> You are the owner of lp:~georg-zotti/stellarium/ip-query-location.
>

Revision history for this message
Alexander Wolf (alexwolf) wrote :

This list is "correct". I meant new features. If I change the planet and picked some point on the map (as example on Mars) then I get locations from Earth!

Revision history for this message
gzotti (georg-zotti) wrote :

Sure. This context info did not exist previously...

I filter also by current planet name now. And I want to add a filter for
country as next step towards better usability.

G.

On Sa, 19.07.2014, 18:42, Alexander Wolf wrote:
> This list is "correct". I meant new features. If I change the planet and
> picked some point on the map (as example on Mars) then I get locations
> from Earth!
> --
> https://code.launchpad.net/~georg-zotti/stellarium/ip-query-location/+merge/227418
> You are the owner of lp:~georg-zotti/stellarium/ip-query-location.
>

Revision history for this message
Alexander Wolf (alexwolf) wrote :

2014-07-20 1:33 GMT+07:00 gzotti <email address hidden>:

> Sure. This context info did not exist previously...
>
> I filter also by current planet name now. And I want to add a filter for
> country as next step towards better usability.
>

It's introduces important problem: search tool will search location in full
list or in filtered list?

--
With best regards, Alexander

Revision history for this message
gzotti (georg-zotti) wrote :

The list box gets filled with a preselected short list of nearby locations
on the current planet. If the user selects Earth, the complete list will
be shown at the moment (50 non-Earth entries in 15000 locations, should
not matter...)

The search tool is directly connected to the list, so it only searches in
the pre-filtered list.

There is a reset list button to recreate all entries.

I am not yet sure if I shouldn't clear out the country combobox if
planet!=Earth. This was always quite strange...

G.

On Sa, 19.07.2014, 20:45, Alexander Wolf wrote:
> 2014-07-20 1:33 GMT+07:00 gzotti <email address hidden>:
>
>> Sure. This context info did not exist previously...
>>
>> I filter also by current planet name now. And I want to add a filter for
>> country as next step towards better usability.
>>
>
> It's introduces important problem: search tool will search location in
> full
> list or in filtered list?
>
> --
> With best regards, Alexander
>
> https://code.launchpad.net/~georg-zotti/stellarium/ip-query-location/+merge/227418
> You are the owner of lp:~georg-zotti/stellarium/ip-query-location.
>

Revision history for this message
gzotti (georg-zotti) wrote :

I have added the requested improvements. I think it works all now.

review: Needs Resubmitting
Revision history for this message
Alexander Wolf (alexwolf) wrote :

OK. It work correct now and I think it ready to merge. Fabien?

review: Approve
Revision history for this message
Fabien Chéreau (xalioth) wrote :

Please see comments

review: Needs Fixing
6935. By gzotti

removed include no longer required

Revision history for this message
Marcos Cardinot (cardinot) wrote :

Hello Georg,
congrats for the excellent work!
I have just a couple of things to suggest (nitpicks)... see comments + I noticed that you are using spaces instead of tabs...

review: Needs Fixing
6936. By gzotti

Added braces for Marcos Cardinot.
Fixed indentation (space/tab; 3 files worked, one didn't?)

Revision history for this message
Marcos Cardinot (cardinot) :
review: Approve
Revision history for this message
gzotti (georg-zotti) wrote :
Download full text (19.3 KiB)

Dear Fabien,

I fixed these items on Monday. Do you approve a merge now?

Kind regards,
Georg

On Mo, 21.07.2014, 19:07, Fabien Chéreau wrote:
> Review: Needs Fixing
>
> Please see comments
>
> Diff comments:
>
>> === modified file 'src/core/StelCore.cpp'
>> --- src/core/StelCore.cpp 2014-04-14 17:55:46 +0000
>> +++ src/core/StelCore.cpp 2014-07-20 13:42:31 +0000
>> @@ -114,7 +114,13 @@
>> defaultLocationID =
>> conf->value("init_location/location","error").toString();
>> bool ok;
>> StelLocationMgr* locationMgr =
>> &StelApp::getInstance().getLocationMgr();
>> - StelLocation location =
>> locationMgr->locationForString(defaultLocationID);
>> + StelLocation location;
>> + if (conf->value("init_location/use_ip_geolocation_if_available",
>> "false").toBool())
>> + {
>> + locationMgr->locationFromIP();
>> + }
>> +
>> + else location = locationMgr->locationForString(defaultLocationID);
>> if (!location.isValid())
>> {
>> qWarning() << "Warning: location" << defaultLocationID << "is
>> unknown.";
>>
>> === modified file 'src/core/StelLocation.cpp'
>> --- src/core/StelLocation.cpp 2014-02-15 15:37:23 +0000
>> +++ src/core/StelLocation.cpp 2014-07-20 13:42:31 +0000
>> @@ -125,3 +125,10 @@
>> return loc;
>> }
>>
>> +// Compute great-circle distance between two locations
>> +float StelLocation::distanceDegrees(const float long1, const float
>> lat1, const float long2, const float lat2)
>> +{
>> + const float DEGREES=M_PI/180.0f;
>> + return std::acos( std::sin(lat1*DEGREES)*std::sin(lat2*DEGREES) +
>> +
>> std::cos(lat1*DEGREES)*std::cos(lat2*DEGREES)*std::cos((long1-long2)*DEGREES)
>> ) / DEGREES;
>> +}
>>
>> === modified file 'src/core/StelLocation.hpp'
>> --- src/core/StelLocation.hpp 2014-04-15 17:10:07 +0000
>> +++ src/core/StelLocation.hpp 2014-07-20 13:42:31 +0000
>> @@ -74,6 +74,9 @@
>> //! Parse a location from a line serialization
>> static StelLocation createFromLine(const QString& line);
>>
>> + //! Compute great-circle distance between two locations
>> + static float distanceDegrees(const float long1, const float lat1,
>> const float long2, const float lat2);
>> +
>> //! Used privately by the StelLocationMgr
>> bool isUserLocation;
>>
>>
>> === modified file 'src/core/StelLocationMgr.cpp'
>> --- src/core/StelLocationMgr.cpp 2014-06-12 15:47:22 +0000
>> +++ src/core/StelLocationMgr.cpp 2014-07-20 13:42:31 +0000
>> @@ -17,6 +17,7 @@
>> */
>>
>> #include "StelApp.hpp"
>> +#include "StelCore.hpp"
>> #include "StelFileMgr.hpp"
>> #include "StelLocationMgr.hpp"
>> #include "StelUtils.hpp"
>> @@ -25,6 +26,12 @@
>> #include <QDebug>
>> #include <QFile>
>> #include <QDir>
>> +#include <QtNetwork/QNetworkInterface>
>> +#include <QtNetwork/QNetworkAccessManager>
>> +#include <QNetworkRequest>
>> +#include <QNetworkReply>
>> +#include <QUrl>
>> +#include <QUrlQuery>
>>
>> StelLocationMgr::StelLocationMgr()
>> {
>> @@ -36,9 +43,12 @@
>>
>> modelAllLocation = new QStringListModel(this);
>> modelAllLocation->setStringList(locations.keys());
>> + modelPickedLocation = new QStringListModel(this); // keep empty for
>> now.
>>
>> // Init to Paris France because it's the center of the world.
>> lastResortLocation =...

Revision history for this message
Fabien Chéreau (xalioth) wrote :
Download full text (22.3 KiB)

Hi Georg,

now that I'm back from holidays, I could acutally try the code, and I have
some more general comments about your (very very good!) work:

 - we should rename "IP Query" to something less technical, like "Get
location from Network"

 - I think the IP location is such an improvement that it should be the
default for all new install, and also probably used by default for installs
where the location was never set (set to Paris). This would imply that we
transform at startup all older config.ini from location = Paris, France to
location = auto. And use this "auto" value to trigger IP Lookup instead of
adding a new "init_location/use_ip_geolocation_if_available" key.

- Also when the lookup is successful, we could save the last know location
into an "init_location/last_resort_location" for the next time we start
without network.

Sorry to give these feedbacks so late, I hope they make sense, what do you
think? In any case, I think the lack of auto location feature was the most
annoying problem of Stellarium for an average user living in US, so thanks
a lot again!

Fabien

On Sat, Jul 26, 2014 at 12:24 PM, gzotti <email address hidden> wrote:

> Dear Fabien,
>
> I fixed these items on Monday. Do you approve a merge now?
>
> Kind regards,
> Georg
>
> On Mo, 21.07.2014, 19:07, Fabien Chéreau wrote:
> > Review: Needs Fixing
> >
> > Please see comments
> >
> > Diff comments:
> >
> >> === modified file 'src/core/StelCore.cpp'
> >> --- src/core/StelCore.cpp 2014-04-14 17:55:46 +0000
> >> +++ src/core/StelCore.cpp 2014-07-20 13:42:31 +0000
> >> @@ -114,7 +114,13 @@
> >> defaultLocationID =
> >> conf->value("init_location/location","error").toString();
> >> bool ok;
> >> StelLocationMgr* locationMgr =
> >> &StelApp::getInstance().getLocationMgr();
> >> - StelLocation location =
> >> locationMgr->locationForString(defaultLocationID);
> >> + StelLocation location;
> >> + if (conf->value("init_location/use_ip_geolocation_if_available",
> >> "false").toBool())
> >> + {
> >> + locationMgr->locationFromIP();
> >> + }
> >> +
> >> + else location = locationMgr->locationForString(defaultLocationID);
> >> if (!location.isValid())
> >> {
> >> qWarning() << "Warning: location" << defaultLocationID <<
> "is
> >> unknown.";
> >>
> >> === modified file 'src/core/StelLocation.cpp'
> >> --- src/core/StelLocation.cpp 2014-02-15 15:37:23 +0000
> >> +++ src/core/StelLocation.cpp 2014-07-20 13:42:31 +0000
> >> @@ -125,3 +125,10 @@
> >> return loc;
> >> }
> >>
> >> +// Compute great-circle distance between two locations
> >> +float StelLocation::distanceDegrees(const float long1, const float
> >> lat1, const float long2, const float lat2)
> >> +{
> >> + const float DEGREES=M_PI/180.0f;
> >> + return std::acos( std::sin(lat1*DEGREES)*std::sin(lat2*DEGREES) +
> >> +
> >>
> std::cos(lat1*DEGREES)*std::cos(lat2*DEGREES)*std::cos((long1-long2)*DEGREES)
> >> ) / DEGREES;
> >> +}
> >>
> >> === modified file 'src/core/StelLocation.hpp'
> >> --- src/core/StelLocation.hpp 2014-04-15 17:10:07 +0000
> >> +++ src/core/StelLocation.hpp 2014-07-20 13:42:31 +0000
> >> ...

Revision history for this message
gzotti (georg-zotti) wrote :
Download full text (3.3 KiB)

Dear Fabien,

thanks for your friendly words.

I know "IP query" is very technical. But what to write on a 6-letter
button? Else, the button must stretch over the whole window, I did not
want to make it too intrusive. If there is space, it should be
"approximate location", my own query is about 50km off... But it's still
quite a good start.

A default IP lookup for new installs seems fine, as long as there remains
a fallback location in case someone travels to his offline PC with an USB
stick with the latest version. (When I traveled to Namibia for some
astrophotos with a Stellarium-guided telescope, my Atom netbook was also
definitely offline...)

Having the always-auto-lookup-at-start feature is OK. But It must be
possible to set and keep a home position as well, even if we are online at
startup. (And if somebody in Paris is happy with startup location, he will
be surprised to find his place renamed to IPxxxx :-)

The other changes are with finding a location near map-click point and
with the country/planet comboboxes. I think they are much more functional
now. What may still be done is to deactivate and empty the country box if
we are not on Earth.

My short slot of time is unfortunately over for this weekend. So, if you
like it, please merge and feel free to tweak these small details.

I just tried your brother's no-bit-field branch. It compiles on my Atom
450 netbook (MSVC2012/Angle; takes ages...), but the shader programs are
too long. I cannot find any info on how to programmatically check shader
support from the GPU: is Angle limited to pixelshader2, vertexshader2 and
fails on every system, or would it compile ps_3, vs_3 if the graphics card
supports this? Going for Angle was the hope to support simpler/older
hardware, so if there would be a way to support ps_2+vs_2 hardware like
Atom or older Radeon or Intel GMA by utilizing simpler shader programs
(e.g. no ring shadows, normal maps, etc.?) after some tests, there would
be less users having to use super-slow MESA. (But I'm happy at least MESA
is a stable fallback...)

What I still don't know is why my both NVidias on WinXP fail. Both should
support OpenGL3.3.

Kind regards,
Georg

On Sa, 26.07.2014, 18:24, Fabien Chéreau wrote:
> Hi Georg,
>
> now that I'm back from holidays, I could acutally try the code, and I have
> some more general comments about your (very very good!) work:
>
> - we should rename "IP Query" to something less technical, like "Get
> location from Network"
>
> - I think the IP location is such an improvement that it should be the
> default for all new install, and also probably used by default for
> installs
> where the location was never set (set to Paris). This would imply that we
> transform at startup all older config.ini from location = Paris, France to
> location = auto. And use this "auto" value to trigger IP Lookup instead of
> adding a new "init_location/use_ip_geolocation_if_available" key.
>
> - Also when the lookup is successful, we could save the last know location
> into an "init_location/last_resort_location" for the next time we start
> without network.
>
> Sorry to give these feedbacks so late, I hope they make sense, what do you
> think? In ...

Read more...

Revision history for this message
Alexander Wolf (alexwolf) wrote :

IMHO we can merge this branch and improve some features.

6937. By Alexander Wolf

Stellarium will be get location from network by default for fresh installation now. Location dialog was changed for new feature support.

Revision history for this message
Alexander Wolf (alexwolf) wrote :

OK. I updated code to usage of this feature by default.

6938. By Alexander Wolf

avoid Antautorina's bug

6939. By Alexander Wolf

avoid unknown location's bug (location not exists in stellarium database)

6940. By Alexander Wolf

renamed last_resort_location to last_location

6941. By Alexander Wolf

fixed issue of display coordinates of location

6942. By Alexander Wolf

avoid rounding issue and extend unit tests

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/default_config.ini.cmake'
--- data/default_config.ini.cmake 2014-07-31 19:02:38 +0000
+++ data/default_config.ini.cmake 2014-08-06 17:11:24 +0000
@@ -242,7 +242,7 @@
242nebula_magnitude_limit = 8.5242nebula_magnitude_limit = 8.5
243243
244[init_location]244[init_location]
245location = Paris, France245location = auto
246landscape_name = guereins246landscape_name = guereins
247247
248[files]248[files]
249249
=== modified file 'src/core/StelCore.cpp'
--- src/core/StelCore.cpp 2014-04-14 17:55:46 +0000
+++ src/core/StelCore.cpp 2014-08-06 17:11:24 +0000
@@ -111,10 +111,19 @@
111{111{
112 QSettings* conf = StelApp::getInstance().getSettings();112 QSettings* conf = StelApp::getInstance().getSettings();
113113
114 defaultLocationID = conf->value("init_location/location","error").toString();114 defaultLocationID = conf->value("init_location/location", "auto").toString();
115 bool ok;115 bool ok;
116 StelLocationMgr* locationMgr = &StelApp::getInstance().getLocationMgr();116 StelLocationMgr* locationMgr = &StelApp::getInstance().getLocationMgr();
117 StelLocation location = locationMgr->locationForString(defaultLocationID);117 StelLocation location;
118 if (defaultLocationID.contains("auto"))
119 {
120 locationMgr->locationFromIP();
121 }
122 else
123 {
124 location = locationMgr->locationForString(defaultLocationID);
125 }
126
118 if (!location.isValid())127 if (!location.isValid())
119 {128 {
120 qWarning() << "Warning: location" << defaultLocationID << "is unknown.";129 qWarning() << "Warning: location" << defaultLocationID << "is unknown.";
121130
=== modified file 'src/core/StelLocation.cpp'
--- src/core/StelLocation.cpp 2014-02-15 15:37:23 +0000
+++ src/core/StelLocation.cpp 2014-08-06 17:11:24 +0000
@@ -125,3 +125,10 @@
125 return loc;125 return loc;
126}126}
127127
128// Compute great-circle distance between two locations
129float StelLocation::distanceDegrees(const float long1, const float lat1, const float long2, const float lat2)
130{
131 const float DEGREES=M_PI/180.0f;
132 return std::acos( std::sin(lat1*DEGREES)*std::sin(lat2*DEGREES) +
133 std::cos(lat1*DEGREES)*std::cos(lat2*DEGREES)*std::cos((long1-long2)*DEGREES) ) / DEGREES;
134}
128135
=== modified file 'src/core/StelLocation.hpp'
--- src/core/StelLocation.hpp 2014-04-15 17:10:07 +0000
+++ src/core/StelLocation.hpp 2014-08-06 17:11:24 +0000
@@ -74,6 +74,9 @@
74 //! Parse a location from a line serialization74 //! Parse a location from a line serialization
75 static StelLocation createFromLine(const QString& line);75 static StelLocation createFromLine(const QString& line);
7676
77 //! Compute great-circle distance between two locations
78 static float distanceDegrees(const float long1, const float lat1, const float long2, const float lat2);
79
77 //! Used privately by the StelLocationMgr80 //! Used privately by the StelLocationMgr
78 bool isUserLocation;81 bool isUserLocation;
7982
8083
=== modified file 'src/core/StelLocationMgr.cpp'
--- src/core/StelLocationMgr.cpp 2014-06-12 15:47:22 +0000
+++ src/core/StelLocationMgr.cpp 2014-08-06 17:11:24 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19#include "StelApp.hpp"19#include "StelApp.hpp"
20#include "StelCore.hpp"
20#include "StelFileMgr.hpp"21#include "StelFileMgr.hpp"
21#include "StelLocationMgr.hpp"22#include "StelLocationMgr.hpp"
22#include "StelUtils.hpp"23#include "StelUtils.hpp"
@@ -25,9 +26,18 @@
25#include <QDebug>26#include <QDebug>
26#include <QFile>27#include <QFile>
27#include <QDir>28#include <QDir>
29#include <QtNetwork/QNetworkInterface>
30#include <QtNetwork/QNetworkAccessManager>
31#include <QNetworkRequest>
32#include <QNetworkReply>
33#include <QUrl>
34#include <QUrlQuery>
35#include <QSettings>
2836
29StelLocationMgr::StelLocationMgr()37StelLocationMgr::StelLocationMgr()
30{38{
39 QSettings* conf = StelApp::getInstance().getSettings();
40
31 // The line below allows to re-generate the location file, you still need to gunzip it manually afterward.41 // The line below allows to re-generate the location file, you still need to gunzip it manually afterward.
32 // generateBinaryLocationFile("data/base_locations.txt", false, "data/base_locations.bin");42 // generateBinaryLocationFile("data/base_locations.txt", false, "data/base_locations.bin");
3343
@@ -36,9 +46,10 @@
3646
37 modelAllLocation = new QStringListModel(this);47 modelAllLocation = new QStringListModel(this);
38 modelAllLocation->setStringList(locations.keys());48 modelAllLocation->setStringList(locations.keys());
49 modelPickedLocation = new QStringListModel(this); // keep empty for now.
39 50
40 // Init to Paris France because it's the center of the world.51 // Init to Paris France because it's the center of the world.
41 lastResortLocation = locationForString("Paris, France");52 lastResortLocation = locationForString(conf->value("init_location/last_resort_location", "Paris, France").toString());
42}53}
4354
44void StelLocationMgr::generateBinaryLocationFile(const QString& fileName, bool isUserLocation, const QString& binFilePath) const55void StelLocationMgr::generateBinaryLocationFile(const QString& fileName, bool isUserLocation, const QString& binFilePath) const
@@ -144,6 +155,10 @@
144155
145StelLocationMgr::~StelLocationMgr()156StelLocationMgr::~StelLocationMgr()
146{157{
158 delete modelPickedLocation;
159 modelPickedLocation=NULL;
160 delete modelAllLocation;
161 modelAllLocation=NULL;
147}162}
148163
149static float parseAngle(const QString& s, bool* ok)164static float parseAngle(const QString& s, bool* ok)
@@ -307,3 +322,102 @@
307 sourcefile.close();322 sourcefile.close();
308 return true;323 return true;
309}324}
325
326// lookup location from IP address.
327void StelLocationMgr::locationFromIP()
328{
329 QNetworkRequest req( QUrl( QString("http://freegeoip.net/csv/") ) );
330 networkReply=StelApp::getInstance().getNetworkAccessManager()->get(req);
331 connect(networkReply, SIGNAL(finished()), this, SLOT(changeLocationFromNetworkLookup()));
332}
333
334// slot that receives IP-based location data from the network.
335void StelLocationMgr::changeLocationFromNetworkLookup()
336{
337 StelLocation location;
338 StelCore *core=StelApp::getInstance().getCore();
339 if (networkReply->error() == QNetworkReply::NoError) {
340 //success
341 // Tested with and without working network connection.
342 QByteArray answer=networkReply->readAll();
343 // answer/splitline example: "222.222.222.222","AT","Austria","","","","","47.3333","13.3333","",""
344 // The parts from freegeoip are: ip,country_code,country_name,region_code,region_name,city,zipcode,latitude,longitude,metro_code,area_code
345 // longitude and latitude should always be filled.
346 // A few tests:
347 if ((answer.count('"') != 22 ) || (answer.count(',') != 10 ))
348 {
349 qDebug() << "StelLocationMgr: Malformatted answer in IP-based location lookup: \n\t" << answer;
350 qDebug() << "StelLocationMgr: Will not change location.";
351 networkReply->deleteLater();
352 return;
353 }
354 const QStringList& splitline = QString(answer).split(",");
355 if (splitline.count() != 11 )
356 {
357 qDebug() << "StelLocationMgr: Unexpected answer in IP-based location lookup: \n\t" << answer;
358 qDebug() << "StelLocationMgr: Will not change location.";
359 networkReply->deleteLater();
360 return;
361 }
362 if ((splitline.at(7)=="\"\"") || (splitline.at(8)=="\"\"")) // empty coordinates?
363 {
364 qDebug() << "StelLocationMgr: Invalid coordinates from IP-based lookup. Ignoring: \n\t" << answer;
365 networkReply->deleteLater();
366 return;
367 }
368 float latitude=splitline.at(7).mid(1, splitline.at(7).length()-2).toFloat();
369 float longitude=splitline.at(8).mid(1, splitline.at(8).length()-2).toFloat();
370 QString locLine= // we re-pack into a new line that will be parsed back by StelLocation...
371 QString("%1\t%2\t%3\t%4\t%5\t%6\t%7\t0")
372 .arg(splitline.at(5).length()>2 ? splitline.at(5).mid(1, splitline.at(5).length()-2) : QString("IP%1").arg(splitline.at(0).mid(1, splitline.at(0).length()-2)))
373 .arg(splitline.at(4).length()>2 ? splitline.at(4).mid(1, splitline.at(4).length()-2) : "IPregion")
374 .arg(splitline.at(2).length()>2 ? splitline.at(2).mid(1, splitline.at(2).length()-2) : "IPcountry") // country
375 .arg("X") // role: X=user-defined
376 .arg(0) // population: unknown
377 .arg(latitude<0 ? QString("%1S").arg(-latitude, 0, 'f', 6) : QString("%1N").arg(latitude, 0, 'f', 6))
378 .arg(longitude<0 ? QString("%1W").arg(-longitude, 0, 'f', 6) : QString("%1E").arg(longitude, 0, 'f', 6));
379 location=StelLocation::createFromLine(locLine); // in lack of a regular constructor ;-)
380 core->moveObserverTo(location, 0.0f, 0.0f);
381 QSettings* conf = StelApp::getInstance().getSettings();
382 conf->setValue("init_location/last_resort_location", QString("%1, %2").arg(location.name).arg(location.country));
383 }
384 else
385 {
386 qDebug() << "Failure getting IP-based location: \n\t" <<networkReply->errorString();
387 core->moveObserverTo(lastResortLocation, 0.0f, 0.0f);
388 }
389 networkReply->deleteLater();
390}
391
392void StelLocationMgr::pickLocationsNearby(const QString planetName, const float longitude, const float latitude, const float radiusDegrees)
393{
394 pickedLocations.clear();
395 QMapIterator<QString, StelLocation> iter(locations);
396 while (iter.hasNext())
397 {
398 iter.next();
399 const StelLocation *loc=&iter.value();
400 if ( (loc->planetName == planetName) &&
401 (StelLocation::distanceDegrees(longitude, latitude, loc->longitude, loc->latitude) <= radiusDegrees) )
402 {
403 pickedLocations.insert(iter.key(), iter.value());
404 }
405 }
406 modelPickedLocation->setStringList(pickedLocations.keys());
407}
408
409void StelLocationMgr::pickLocationsInCountry(const QString country)
410{
411 pickedLocations.clear();
412 QMapIterator<QString, StelLocation> iter(locations);
413 while (iter.hasNext())
414 {
415 iter.next();
416 const StelLocation *loc=&iter.value();
417 if (loc->country == country)
418 {
419 pickedLocations.insert(iter.key(), iter.value());
420 }
421 }
422 modelPickedLocation->setStringList(pickedLocations.keys());
423}
310424
=== modified file 'src/core/StelLocationMgr.hpp'
--- src/core/StelLocationMgr.hpp 2013-10-14 07:43:06 +0000
+++ src/core/StelLocationMgr.hpp 2014-08-06 17:11:24 +0000
@@ -26,6 +26,7 @@
26#include <QMap>26#include <QMap>
2727
28class QStringListModel;28class QStringListModel;
29class QNetworkReply;
2930
30//! @class StelLocationMgr31//! @class StelLocationMgr
31//! Manage the list of available location.32//! Manage the list of available location.
@@ -41,6 +42,8 @@
4142
42 //! Return the model containing all the city43 //! Return the model containing all the city
43 QStringListModel* getModelAll() {return modelAllLocation;}44 QStringListModel* getModelAll() {return modelAllLocation;}
45 //! Return the model containing picked (nearby) cities or cities from a single country, or other preselection.
46 QStringListModel* getModelPicked() {return modelPickedLocation;}
4447
45 //! Return the list of all loaded locations48 //! Return the list of all loaded locations
46 QList<StelLocation> getAll() const {return locations.values();}49 QList<StelLocation> getAll() const {return locations.values();}
@@ -70,6 +73,20 @@
70 //! @param id the location ID73 //! @param id the location ID
71 bool deleteUserLocation(const QString& id);74 bool deleteUserLocation(const QString& id);
7275
76 //! Find location via online lookup of IP address
77 void locationFromIP();
78
79 //! Preselect list of locations within @param radiusDegrees of selected (usually screen-clicked) coordinates.
80 //! The list can be retrieved by calling @name getModelPicked().
81 void pickLocationsNearby(const QString planetName, const float longitude, const float latitude, const float radiusDegrees);
82 //! Preselect list of locations in a particular country only.
83 //! The list can be retrieved by calling @name getModelPicked().
84 void pickLocationsInCountry(const QString country);
85
86public slots:
87 //! Process answer from online lookup of IP address
88 void changeLocationFromNetworkLookup();
89
73private:90private:
74 void generateBinaryLocationFile(const QString& txtFile, bool isUserLocation, const QString& binFile) const;91 void generateBinaryLocationFile(const QString& txtFile, bool isUserLocation, const QString& binFile) const;
7592
@@ -79,11 +96,19 @@
7996
80 //! Model containing all the city information97 //! Model containing all the city information
81 QStringListModel* modelAllLocation;98 QStringListModel* modelAllLocation;
99 //! Model containing selected city information
100 QStringListModel* modelPickedLocation;
82101
83 //! The list of all loaded locations102 //! The list of all loaded locations
84 QMap<QString, StelLocation> locations;103 QMap<QString, StelLocation> locations;
104 //! A list of locations generated on-the-fly by filtering from @name locations
105 QMap<QString, StelLocation> pickedLocations;
85 106
86 StelLocation lastResortLocation;107 StelLocation lastResortLocation;
108
109 //! For IP-based location lookup
110 QNetworkReply *networkReply;
111
87};112};
88113
89#endif // _STELLOCATIONMGR_HPP_114#endif // _STELLOCATIONMGR_HPP_
90115
=== modified file 'src/gui/LocationDialog.cpp'
--- src/gui/LocationDialog.cpp 2014-03-21 18:03:55 +0000
+++ src/gui/LocationDialog.cpp 2014-08-06 17:11:24 +0000
@@ -99,22 +99,30 @@
99 connect(ui->mapLabel, SIGNAL(positionChanged(double, double)), this, SLOT(setPositionFromMap(double, double)));99 connect(ui->mapLabel, SIGNAL(positionChanged(double, double)), this, SLOT(setPositionFromMap(double, double)));
100100
101 connect(ui->addLocationToListPushButton, SIGNAL(clicked()), this, SLOT(addCurrentLocationToList()));101 connect(ui->addLocationToListPushButton, SIGNAL(clicked()), this, SLOT(addCurrentLocationToList()));
102 connect(ui->deleteLocationFromListPushButton, SIGNAL(clicked()), this, SLOT(deleteCurrentLocationFromList()));102 connect(ui->deleteLocationFromListPushButton, SIGNAL(clicked()), this, SLOT(deleteCurrentLocationFromList()));
103 connect(ui->resetListPushButton, SIGNAL(clicked()), this, SLOT(resetCompleteList()));
104 connect(ui->countryNameComboBox, SIGNAL(activated(const QString &)), this, SLOT(filterSitesByCountry()));
103105
104 StelCore* core = StelApp::getInstance().getCore();106 StelCore* core = StelApp::getInstance().getCore();
105 const StelLocation& currentLocation = core->getCurrentLocation();107 const StelLocation& currentLocation = core->getCurrentLocation();
108 bool b = (currentLocation.getID() == core->getDefaultLocationID());
109 QSettings* conf = StelApp::getInstance().getSettings();
110 if (conf->value("init_location/location", "auto").toString().contains("auto"))
111 {
112 ui->useIpQueryCheckBox->setChecked(true);
113 b = false;
114 }
115
106 setFieldsFromLocation(currentLocation);116 setFieldsFromLocation(currentLocation);
107
108 const bool b = (currentLocation.getID() == core->getDefaultLocationID());
109 updateDefaultLocationControls(b);117 updateDefaultLocationControls(b);
110 connect(ui->useAsDefaultLocationCheckBox, SIGNAL(clicked()), this, SLOT(setDefaultLocation()));118
111 connect(ui->pushButtonReturnToDefault, SIGNAL(clicked()),119 connect(ui->useIpQueryCheckBox, SIGNAL(clicked(bool)), this, SLOT(ipQueryLocation(bool)));
112 core, SLOT(returnToDefaultLocation()));120 connect(ui->useAsDefaultLocationCheckBox, SIGNAL(clicked(bool)), this, SLOT(setDefaultLocation(bool)));
121 connect(ui->pushButtonReturnToDefault, SIGNAL(clicked()), core, SLOT(returnToDefaultLocation()));
113122
114 connectEditSignals();123 connectEditSignals();
115 124
116 connect(core, SIGNAL(locationChanged(StelLocation)),125 connect(core, SIGNAL(locationChanged(StelLocation)), this, SLOT(updateFromProgram(StelLocation)));
117 this, SLOT(updateFromProgram(StelLocation)));
118126
119 ui->citySearchLineEdit->setFocus();127 ui->citySearchLineEdit->setFocus();
120}128}
@@ -138,7 +146,12 @@
138 // Check that the use as default check box needs to be updated146 // Check that the use as default check box needs to be updated
139 // Move to setFieldsFromLocation()? --BM?147 // Move to setFieldsFromLocation()? --BM?
140 const bool b = currentLocation.getID() == stelCore->getDefaultLocationID();148 const bool b = currentLocation.getID() == stelCore->getDefaultLocationID();
141 updateDefaultLocationControls(b);149 QSettings* conf = StelApp::getInstance().getSettings();
150 if (!conf->value("init_location/location", "auto").toString().contains("auto"))
151 {
152 updateDefaultLocationControls(b);
153 ui->pushButtonReturnToDefault->setEnabled(!b);
154 }
142155
143 const QString& key1 = currentLocation.getID();156 const QString& key1 = currentLocation.getID();
144 const QString& key2 = locationFromFields().getID();157 const QString& key2 = locationFromFields().getID();
@@ -169,8 +182,7 @@
169 disconnect(ui->countryNameComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(reportEdit()));182 disconnect(ui->countryNameComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(reportEdit()));
170 // Why an edit should be reported even if the country is not changed? --BM183 // Why an edit should be reported even if the country is not changed? --BM
171 //disconnect(ui->countryNameComboBox, SIGNAL(activated(const QString&)), this, SLOT(comboBoxChanged(const QString&)));184 //disconnect(ui->countryNameComboBox, SIGNAL(activated(const QString&)), this, SLOT(comboBoxChanged(const QString&)));
172 disconnect(ui->cityNameLineEdit, SIGNAL(textEdited(const QString&)),185 disconnect(ui->cityNameLineEdit, SIGNAL(textEdited(const QString&)), this, SLOT(reportEdit()));
173 this, SLOT(reportEdit()));
174}186}
175187
176void LocationDialog::connectEditSignals()188void LocationDialog::connectEditSignals()
@@ -182,8 +194,7 @@
182 connect(ui->countryNameComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(reportEdit()));194 connect(ui->countryNameComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(reportEdit()));
183 // Why an edit should be reported even if the country is not changed? --BM195 // Why an edit should be reported even if the country is not changed? --BM
184 //connect(ui->countryNameComboBox, SIGNAL(activated(const QString&)), this, SLOT(comboBoxChanged(const QString&)));196 //connect(ui->countryNameComboBox, SIGNAL(activated(const QString&)), this, SLOT(comboBoxChanged(const QString&)));
185 connect(ui->cityNameLineEdit, SIGNAL(textEdited(const QString&)),197 connect(ui->cityNameLineEdit, SIGNAL(textEdited(const QString&)), this, SLOT(reportEdit()));
186 this, SLOT(reportEdit()));
187}198}
188199
189void LocationDialog::setFieldsFromLocation(const StelLocation& loc)200void LocationDialog::setFieldsFromLocation(const StelLocation& loc)
@@ -235,7 +246,7 @@
235// Update the map for the given location.246// Update the map for the given location.
236void LocationDialog::setMapForLocation(const StelLocation& loc)247void LocationDialog::setMapForLocation(const StelLocation& loc)
237{248{
238 // Avoids usless processing249 // Avoids useless processing
239 if (lastPlanet==loc.planetName)250 if (lastPlanet==loc.planetName)
240 return;251 return;
241252
@@ -358,6 +369,15 @@
358 loc.longitude = longitude;369 loc.longitude = longitude;
359 setFieldsFromLocation(loc);370 setFieldsFromLocation(loc);
360 StelApp::getInstance().getCore()->moveObserverTo(loc, 0.);371 StelApp::getInstance().getCore()->moveObserverTo(loc, 0.);
372 // GZ: Filter location list for nearby sites. I assume Earth locations are better known. With only few locations on other planets in the list, 30 degrees seem OK.
373 StelApp::getInstance().getLocationMgr().pickLocationsNearby(loc.planetName, longitude, latitude, loc.planetName=="Earth" ? 3.0f: 30.0f);
374 QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
375 proxyModel->setSourceModel((QAbstractItemModel*)StelApp::getInstance().getLocationMgr().getModelPicked());
376 proxyModel->sort(0, Qt::AscendingOrder);
377 proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
378 ui->citiesListView->setModel(proxyModel);
379 ui->citySearchLineEdit->clear();
380 connect(ui->citySearchLineEdit, SIGNAL(textChanged(const QString&)), proxyModel, SLOT(setFilterWildcard(const QString&)));
361}381}
362382
363// Called when the planet name is changed by hand383// Called when the planet name is changed by hand
@@ -380,6 +400,24 @@
380 ls->setCurrentLandscapeID(ls->getDefaultLandscapeID());400 ls->setCurrentLandscapeID(ls->getDefaultLandscapeID());
381 }401 }
382402
403 // GZ populate site list with sites only from that planet, or full list for Earth (faster than removing the ~50 non-Earth positions...).
404 StelLocationMgr &locMgr=StelApp::getInstance().getLocationMgr();
405 QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
406 if (loc.planetName == "Earth")
407 {
408 proxyModel->setSourceModel((QAbstractItemModel*)locMgr.getModelAll());
409 }
410 else
411 {
412 locMgr.pickLocationsNearby(loc.planetName, 0.0f, 0.0f, 180.0f);
413 proxyModel->setSourceModel((QAbstractItemModel*)locMgr.getModelPicked());
414 }
415 proxyModel->sort(0, Qt::AscendingOrder);
416 proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
417 ui->citiesListView->setModel(proxyModel);
418 ui->citySearchLineEdit->clear();
419 connect(ui->citySearchLineEdit, SIGNAL(textChanged(const QString&)), proxyModel, SLOT(setFilterWildcard(const QString&)));
420 ui->citySearchLineEdit->setFocus();
383 }421 }
384 // Planet transition time also set to null to prevent uglyness when422 // Planet transition time also set to null to prevent uglyness when
385 // "use landscape location" is enabled for that planet's landscape. --BM423 // "use landscape location" is enabled for that planet's landscape. --BM
@@ -429,7 +467,7 @@
429 ui->deleteLocationFromListPushButton->setEnabled(locationMgr.canDeleteUserLocation(loc.getID()));467 ui->deleteLocationFromListPushButton->setEnabled(locationMgr.canDeleteUserLocation(loc.getID()));
430}468}
431469
432// Called when the user clic on the save button470// Called when the user clicks on the save button
433void LocationDialog::addCurrentLocationToList()471void LocationDialog::addCurrentLocationToList()
434{472{
435 const StelLocation& loc = locationFromFields();473 const StelLocation& loc = locationFromFields();
@@ -456,22 +494,27 @@
456}494}
457495
458// Called when the user wants to use the current location as default496// Called when the user wants to use the current location as default
459void LocationDialog::setDefaultLocation()497void LocationDialog::setDefaultLocation(bool state)
460{498{
461 StelCore* core = StelApp::getInstance().getCore();499 if (state)
462 QString currentLocationId = core->getCurrentLocation().getID();500 {
463 core->setDefaultLocationID(currentLocationId);501 StelCore* core = StelApp::getInstance().getCore();
502 QString currentLocationId = core->getCurrentLocation().getID();
503 core->setDefaultLocationID(currentLocationId);
464504
465 // Why this code even exists? After the previous code, this should always505 // Why this code even exists? After the previous code, this should always
466 // be true, except if setting the default location somehow fails. --BM506 // be true, except if setting the default location somehow fails. --BM
467 bool isDefault = (currentLocationId == core->getDefaultLocationID());507 bool isDefault = (currentLocationId == core->getDefaultLocationID());
468 disconnectEditSignals();508 disconnectEditSignals();
469 updateDefaultLocationControls(isDefault);509 updateDefaultLocationControls(isDefault);
470 //The focus need to be switched to another control, otherwise510 ui->pushButtonReturnToDefault->setEnabled(!isDefault);
471 //ui->latitudeSpinBox receives it and emits a valueChanged() signal when511 ui->useIpQueryCheckBox->setChecked(!state);
472 //the window is closed.512 //The focus need to be switched to another control, otherwise
473 ui->citySearchLineEdit->setFocus();513 //ui->latitudeSpinBox receives it and emits a valueChanged() signal when
474 connectEditSignals();514 //the window is closed.
515 ui->citySearchLineEdit->setFocus();
516 connectEditSignals();
517 }
475}518}
476519
477// Called when the user clicks on the delete button520// Called when the user clicks on the delete button
@@ -484,6 +527,54 @@
484void LocationDialog::updateDefaultLocationControls(bool currentIsDefault)527void LocationDialog::updateDefaultLocationControls(bool currentIsDefault)
485{528{
486 ui->useAsDefaultLocationCheckBox->setChecked(currentIsDefault);529 ui->useAsDefaultLocationCheckBox->setChecked(currentIsDefault);
487 ui->useAsDefaultLocationCheckBox->setEnabled(!currentIsDefault);530 ui->useAsDefaultLocationCheckBox->setEnabled(!currentIsDefault);
488 ui->pushButtonReturnToDefault->setEnabled(!currentIsDefault);531}
532
533// called when the user clicks on the IP Query button
534void LocationDialog::ipQueryLocation(bool state)
535{
536 if (state)
537 {
538 QSettings* conf = StelApp::getInstance().getSettings();
539 conf->setValue("init_location/location", "auto");
540 disconnectEditSignals();
541 resetCompleteList(); // in case we are on Moon/Mars, we must get list back to show all (earth) locations...
542 StelLocationMgr &locMgr=StelApp::getInstance().getLocationMgr();
543 locMgr.locationFromIP(); // This just triggers asynchronous lookup.
544 ui->useAsDefaultLocationCheckBox->setChecked(!state);
545 ui->pushButtonReturnToDefault->setEnabled(!state);
546 connectEditSignals();
547 ui->citySearchLineEdit->setFocus();
548 }
549}
550
551// called when user clicks "reset list"
552void LocationDialog::resetCompleteList()
553{
554 QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
555 proxyModel->setSourceModel((QAbstractItemModel*)StelApp::getInstance().getLocationMgr().getModelAll());
556 proxyModel->sort(0, Qt::AscendingOrder);
557 proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
558 ui->citiesListView->setModel(proxyModel);
559 ui->citySearchLineEdit->clear();
560 connect(ui->citySearchLineEdit, SIGNAL(textChanged(const QString&)), proxyModel, SLOT(setFilterWildcard(const QString&)));
561 ui->citySearchLineEdit->setFocus();
562}
563
564// called when user clicks in the country combobox and selects a country. The locations in the list are updated to select only sites in that country.
565void LocationDialog::filterSitesByCountry()
566{
567 QString country=ui->countryNameComboBox->currentData().toString();
568 QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
569 StelLocationMgr &locMgr=StelApp::getInstance().getLocationMgr();
570
571 locMgr.pickLocationsInCountry(country);
572 proxyModel->setSourceModel((QAbstractItemModel*)locMgr.getModelPicked());
573
574 proxyModel->sort(0, Qt::AscendingOrder);
575 proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
576 ui->citiesListView->setModel(proxyModel);
577 ui->citySearchLineEdit->clear();
578 connect(ui->citySearchLineEdit, SIGNAL(textChanged(const QString&)), proxyModel, SLOT(setFilterWildcard(const QString&)));
579 ui->citySearchLineEdit->setFocus();
489}580}
490581
=== modified file 'src/gui/LocationDialog.hpp'
--- src/gui/LocationDialog.hpp 2013-10-14 09:27:54 +0000
+++ src/gui/LocationDialog.hpp 2014-08-06 17:11:24 +0000
@@ -82,6 +82,7 @@
82 void updateFromProgram(const StelLocation& location);82 void updateFromProgram(const StelLocation& location);
83 83
84 //! Called when the map is clicked.84 //! Called when the map is clicked.
85 //! GZ_New: create new list for places nearby and feed into location list box.
85 void setPositionFromMap(double longitude, double latitude);86 void setPositionFromMap(double longitude, double latitude);
86 87
87 //! Called when the user activates an item from the locations list.88 //! Called when the user activates an item from the locations list.
@@ -97,9 +98,18 @@
97 98
98 //! Called when the user clicks on the delete button99 //! Called when the user clicks on the delete button
99 void deleteCurrentLocationFromList();100 void deleteCurrentLocationFromList();
101
102 //! filter city list to show entries from single country only
103 void filterSitesByCountry();
104
105 //! reset city list to complete list (may have been reduced to picked list)
106 void resetCompleteList();
107
108 //! called when the user wants get location from network
109 void ipQueryLocation(bool state);
100 110
101 //! Called when the user wants to use the current location as default111 //! Called when the user wants to use the current location as default
102 void setDefaultLocation();112 void setDefaultLocation(bool state);
103 113
104private:114private:
105 QString lastPlanet;115 QString lastPlanet;
106116
=== modified file 'src/gui/locationDialogGui.ui'
--- src/gui/locationDialogGui.ui 2014-06-16 13:43:31 +0000
+++ src/gui/locationDialogGui.ui 2014-08-06 17:11:24 +0000
@@ -7,7 +7,7 @@
7 <x>0</x>7 <x>0</x>
8 <y>0</y>8 <y>0</y>
9 <width>700</width>9 <width>700</width>
10 <height>452</height>10 <height>460</height>
11 </rect>11 </rect>
12 </property>12 </property>
13 <property name="styleSheet">13 <property name="styleSheet">
@@ -359,6 +359,16 @@
359 </property>359 </property>
360 </widget>360 </widget>
361 </item>361 </item>
362 <item>
363 <widget class="QPushButton" name="resetListPushButton">
364 <property name="toolTip">
365 <string>Reset location list to show all known locations</string>
366 </property>
367 <property name="text">
368 <string>Reset Location List</string>
369 </property>
370 </widget>
371 </item>
362 </layout>372 </layout>
363 </widget>373 </widget>
364 </item>374 </item>
@@ -383,113 +393,20 @@
383 <property name="bottomMargin">393 <property name="bottomMargin">
384 <number>0</number>394 <number>0</number>
385 </property>395 </property>
386 <item row="2" column="0" colspan="3">396 <item row="1" column="2" colspan="2">
387 <widget class="QFrame" name="frame_3">397 <spacer name="verticalSpacer">
388 <property name="minimumSize">398 <property name="orientation">
399 <enum>Qt::Vertical</enum>
400 </property>
401 <property name="sizeHint" stdset="0">
389 <size>402 <size>
390 <width>0</width>403 <width>20</width>
391 <height>0</height>404 <height>40</height>
392 </size>405 </size>
393 </property>406 </property>
394 <property name="frameShape">407 </spacer>
395 <enum>QFrame::StyledPanel</enum>
396 </property>
397 <property name="frameShadow">
398 <enum>QFrame::Raised</enum>
399 </property>
400 <layout class="QHBoxLayout" name="horizontalLayout">
401 <property name="leftMargin">
402 <number>0</number>
403 </property>
404 <property name="topMargin">
405 <number>0</number>
406 </property>
407 <property name="rightMargin">
408 <number>0</number>
409 </property>
410 <property name="bottomMargin">
411 <number>0</number>
412 </property>
413 <item>
414 <widget class="QCheckBox" name="useAsDefaultLocationCheckBox">
415 <property name="font">
416 <font>
417 <stylestrategy>PreferDefault</stylestrategy>
418 </font>
419 </property>
420 <property name="focusPolicy">
421 <enum>Qt::NoFocus</enum>
422 </property>
423 <property name="text">
424 <string>Use as default</string>
425 </property>
426 </widget>
427 </item>
428 <item>
429 <widget class="QPushButton" name="pushButtonReturnToDefault">
430 <property name="focusPolicy">
431 <enum>Qt::NoFocus</enum>
432 </property>
433 <property name="text">
434 <string>Return to default</string>
435 </property>
436 </widget>
437 </item>
438 <item>
439 <spacer name="horizontalSpacer">
440 <property name="orientation">
441 <enum>Qt::Horizontal</enum>
442 </property>
443 <property name="sizeHint" stdset="0">
444 <size>
445 <width>40</width>
446 <height>20</height>
447 </size>
448 </property>
449 </spacer>
450 </item>
451 <item>
452 <widget class="QPushButton" name="deleteLocationFromListPushButton">
453 <property name="enabled">
454 <bool>false</bool>
455 </property>
456 <property name="minimumSize">
457 <size>
458 <width>60</width>
459 <height>0</height>
460 </size>
461 </property>
462 <property name="focusPolicy">
463 <enum>Qt::NoFocus</enum>
464 </property>
465 <property name="text">
466 <string>Delete</string>
467 </property>
468 </widget>
469 </item>
470 <item>
471 <widget class="QPushButton" name="addLocationToListPushButton">
472 <property name="enabled">
473 <bool>false</bool>
474 </property>
475 <property name="minimumSize">
476 <size>
477 <width>100</width>
478 <height>0</height>
479 </size>
480 </property>
481 <property name="focusPolicy">
482 <enum>Qt::NoFocus</enum>
483 </property>
484 <property name="text">
485 <string>Add to list</string>
486 </property>
487 </widget>
488 </item>
489 </layout>
490 </widget>
491 </item>408 </item>
492 <item row="0" column="0">409 <item row="0" column="1">
493 <widget class="QFrame" name="frame_4">410 <widget class="QFrame" name="frame_4">
494 <property name="minimumSize">411 <property name="minimumSize">
495 <size>412 <size>
@@ -603,7 +520,114 @@
603 </layout>520 </layout>
604 </widget>521 </widget>
605 </item>522 </item>
523 <item row="2" column="1" colspan="3">
524 <widget class="QFrame" name="frame_3">
525 <property name="minimumSize">
526 <size>
527 <width>0</width>
528 <height>0</height>
529 </size>
530 </property>
531 <property name="frameShape">
532 <enum>QFrame::StyledPanel</enum>
533 </property>
534 <property name="frameShadow">
535 <enum>QFrame::Raised</enum>
536 </property>
537 <layout class="QHBoxLayout" name="horizontalLayout">
538 <property name="leftMargin">
539 <number>0</number>
540 </property>
541 <property name="topMargin">
542 <number>0</number>
543 </property>
544 <property name="rightMargin">
545 <number>0</number>
546 </property>
547 <property name="bottomMargin">
548 <number>0</number>
549 </property>
550 <item>
551 <spacer name="horizontalSpacer">
552 <property name="orientation">
553 <enum>Qt::Horizontal</enum>
554 </property>
555 <property name="sizeHint" stdset="0">
556 <size>
557 <width>40</width>
558 <height>20</height>
559 </size>
560 </property>
561 </spacer>
562 </item>
563 <item>
564 <widget class="QPushButton" name="pushButtonReturnToDefault">
565 <property name="enabled">
566 <bool>false</bool>
567 </property>
568 <property name="focusPolicy">
569 <enum>Qt::NoFocus</enum>
570 </property>
571 <property name="text">
572 <string>Return to default location</string>
573 </property>
574 </widget>
575 </item>
576 <item>
577 <widget class="QPushButton" name="deleteLocationFromListPushButton">
578 <property name="enabled">
579 <bool>false</bool>
580 </property>
581 <property name="minimumSize">
582 <size>
583 <width>60</width>
584 <height>0</height>
585 </size>
586 </property>
587 <property name="focusPolicy">
588 <enum>Qt::NoFocus</enum>
589 </property>
590 <property name="text">
591 <string>Delete</string>
592 </property>
593 </widget>
594 </item>
595 <item>
596 <widget class="QPushButton" name="addLocationToListPushButton">
597 <property name="enabled">
598 <bool>false</bool>
599 </property>
600 <property name="minimumSize">
601 <size>
602 <width>100</width>
603 <height>0</height>
604 </size>
605 </property>
606 <property name="focusPolicy">
607 <enum>Qt::NoFocus</enum>
608 </property>
609 <property name="text">
610 <string>Add to list</string>
611 </property>
612 </widget>
613 </item>
614 </layout>
615 </widget>
616 </item>
606 <item row="0" column="2">617 <item row="0" column="2">
618 <spacer name="horizontalSpacer_2">
619 <property name="orientation">
620 <enum>Qt::Horizontal</enum>
621 </property>
622 <property name="sizeHint" stdset="0">
623 <size>
624 <width>40</width>
625 <height>20</height>
626 </size>
627 </property>
628 </spacer>
629 </item>
630 <item row="0" column="3">
607 <widget class="QFrame" name="frame_5">631 <widget class="QFrame" name="frame_5">
608 <property name="minimumSize">632 <property name="minimumSize">
609 <size>633 <size>
@@ -717,31 +741,19 @@
717 </layout>741 </layout>
718 </widget>742 </widget>
719 </item>743 </item>
720 <item row="1" column="1" colspan="2">744 <item row="3" column="1">
721 <spacer name="verticalSpacer">745 <widget class="QCheckBox" name="useAsDefaultLocationCheckBox">
722 <property name="orientation">746 <property name="text">
723 <enum>Qt::Vertical</enum>747 <string>Use current location as default</string>
724 </property>748 </property>
725 <property name="sizeHint" stdset="0">749 </widget>
726 <size>
727 <width>20</width>
728 <height>40</height>
729 </size>
730 </property>
731 </spacer>
732 </item>750 </item>
733 <item row="0" column="1">751 <item row="3" column="3">
734 <spacer name="horizontalSpacer_2">752 <widget class="QCheckBox" name="useIpQueryCheckBox">
735 <property name="orientation">753 <property name="text">
736 <enum>Qt::Horizontal</enum>754 <string>Get location from Network</string>
737 </property>755 </property>
738 <property name="sizeHint" stdset="0">756 </widget>
739 <size>
740 <width>40</width>
741 <height>20</height>
742 </size>
743 </property>
744 </spacer>
745 </item>757 </item>
746 </layout>758 </layout>
747 </widget>759 </widget>