1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
/***************************************************************************
locationdialog.h - K Desktop Planetarium
-------------------
begin : Sun Feb 11 2001
copyright : (C) 2001 by Jason Harris
email : jharris@30doradus.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef LOCATIONDIALOG_H
#define LOCATIONDIALOG_H
/**@class LocationDialog
*Dialog for changing the geographic location of the observer. The
*dialog is divided into two sections.
*
*The top section allows the location to be selected from a database
*of 2000 cities. It tqcontains a MapCanvas (showing map of the globe
*with cities overlaid, with a handler for mouse clicks), a QListBox
*containing the names of cities in the database, and three KLineEdit
*widgets, which allow the user to filter the List by the name of the
*City, Province, and Country. In addition, the List
*can be filtered by location, by clicking anywhere in the MapCanvas.
*Doing so will display cities within 2 degrees of the clicked position.
*
*The bottom section allows the location to be specified manually.
*The Longitude, Latitude, City name, Province/State name, and Country name
*are entered into KLineEdits. There is also a TQPushButton for adding the
*location to the custom Cities database. If the user selects "Add" without
*filling in all of the manual entry fields, an error message is displayed.
*@short Geographic Location dialog
*@author Jason Harris
*@version 1.0
*/
#include <kdialogbase.h>
#include "geolocation.h"
class TQVBoxLayout;
class TQHBoxLayout;
class TQGridLayout;
class TQGroupBox;
class TQLabel;
class TQListBox;
class TQListBoxItem;
class TQPushButton;
class TQComboBox;
class KLineEdit;
class MapCanvas;
class dmsBox;
class LocationDialog : public KDialogBase {
Q_OBJECT
public:
/**
*Constructor. Create all widgets, and pack them into QLayouts.
*Connect Signals to Slots. Run initCityList().
*/
LocationDialog( TQWidget* parent = 0 );
/**
*Destructor (empty)
*/
~LocationDialog();
/**
*Initialize list of cities. Note that the database is not read in here,
*that is done in the KStars constructor. This simply loads the local QListBox
*with the names of the cities from the kstarsData object.
*/
void initCityList( void );
/**@return pointer to the highlighted city in the List.
*/
GeoLocation* selectedCity() const { return SelectedCity; }
/**@return pointer to the List of filtered city pointers.
*/
TQPtrList<GeoLocation>* filteredList() { return &filteredCityList; }
/**@short Show only cities within 3 degrees of point specified by arguments
*@param longitude the longitude of the search point (int)
*@param latitude the latitude of the search point (int)
*/
void findCitiesNear( int longitude, int latitude );
/**@return the city name of the selected location.
*/
TQString selectedCityName( void ) const { return SelectedCity->translatedName(); }
/**@return the province name of the selected location.
*/
TQString selectedProvinceName( void ) const { return SelectedCity->translatedProvince(); }
/**@return the country name of the selected location.
*/
TQString selectedCountryName( void ) const { return SelectedCity->translatedCountry(); }
/**@return true if the AddCityBUtton is enabled
*/
bool addCityEnabled();
public slots:
/**
*When text is entered in the City/Province/Country Filter KLineEdits,
*the List of cities is trimmed to show only cities beginning with the entered text.
*Also, the TQMemArray of ID numbers is kept in sync with the filtered list.
*/
void filterCity( void );
/**
*When the selected city in the TQListBox changes, tqrepaint the MapCanvas
*so that the crosshairs icon appears on the newly selected city.
*/
void changeCity( void );
/**
*When the "Add new city" TQPushButton is clicked, add the manually-entered
*city information to the user's custom city database.
*/
void addCity( void );
void clearFields( void );
void showTZRules( void );
void nameChanged( void );
void dataChanged( void );
// void prepareToAccept( void );
void slotOk();
private:
/**
*Make sure Longitude and Latitude values are valid.
*/
bool checkLongLat( void );
bool dataModified, nameModified, bCityAdded;
TQGridLayout *glay, *glay2;
TQHBoxLayout *hlay, *hlayCoord, *hlayTZ, *hlayButtons, *hlay3;
TQVBoxLayout *RootLay, *CityLay, *CoordLay, *vlay;
TQGroupBox *CityBox, *CoordBox;
TQLabel *CityFiltLabel, *ProvinceFiltLabel, *CountryFiltLabel;
TQLabel *NewCityLabel, *NewProvinceLabel, *NewCountryLabel;
TQLabel *LongLabel, *LatLabel, *CountLabel;
TQLabel *TZLabel, *TZRuleLabel;
KLineEdit *NewCityName, *NewProvinceName, *NewCountryName;
KLineEdit *CityFilter, *ProvinceFilter, *CountryFilter;
dmsBox *NewLong, *NewLat;
TQComboBox *TZBox, *TZRuleBox;
TQPushButton *AddCityButton, *ClearFields, *ShowTZRules;
MapCanvas *MapView;
TQListBox *GeoBox;
GeoLocation *SelectedCity;
TQPtrList<GeoLocation> filteredCityList;
};
#endif
|