2 * This file is part of NeverNote
\r
3 * Copyright 2009 Randy Baumgarte
\r
5 * This file may be licensed under the terms of of the
\r
6 * GNU General Public License Version 2 (the ``GPL'').
\r
8 * Software distributed under the License is distributed
\r
9 * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
\r
10 * express or implied. See the GPL for the specific language
\r
11 * governing rights and limitations.
\r
13 * You should have received a copy of the GPL along with this
\r
14 * program. If not, go to http://www.gnu.org/licenses/gpl.html
\r
15 * or write to the Free Software Foundation, Inc.,
\r
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
20 package cx.fbn.nevernote.dialog;
\r
22 import com.trolltech.qt.gui.QDialog;
\r
23 import com.trolltech.qt.gui.QDoubleValidator;
\r
24 import com.trolltech.qt.gui.QDoubleValidator.Notation;
\r
25 import com.trolltech.qt.gui.QGridLayout;
\r
26 import com.trolltech.qt.gui.QLabel;
\r
27 import com.trolltech.qt.gui.QLineEdit;
\r
28 import com.trolltech.qt.gui.QPushButton;
\r
30 public class GeoDialog extends QDialog {
\r
32 private boolean okPressed;
\r
33 private final QLineEdit altitude;
\r
34 private final QLineEdit latitude;
\r
35 private final QLineEdit longitude;
\r
36 private final QPushButton ok;
\r
40 public GeoDialog() {
\r
42 setWindowTitle(tr("NeverNote Login"));
\r
43 QGridLayout grid = new QGridLayout();
\r
45 QGridLayout passwordGrid = new QGridLayout();
\r
46 QGridLayout buttonGrid = new QGridLayout();
\r
49 longitude = new QLineEdit();
\r
50 QDoubleValidator longVal = new QDoubleValidator(-180.0,180.0,4,longitude);
\r
51 longVal.setNotation(Notation.StandardNotation);
\r
52 longitude.setValidator(longVal);
\r
54 latitude = new QLineEdit();
\r
55 QDoubleValidator latVal = new QDoubleValidator(-90.0,90.0,4,latitude);
\r
56 latVal.setNotation(Notation.StandardNotation);
\r
57 latitude.setValidator(latVal);
\r
59 altitude = new QLineEdit();
\r
60 QDoubleValidator altVal = new QDoubleValidator(-9999.0,9999.0,4,altitude);
\r
61 altVal.setNotation(Notation.StandardNotation);
\r
62 altitude.setValidator(altVal);
\r
65 passwordGrid.addWidget(new QLabel(tr("Longitude")), 1,1);
\r
66 passwordGrid.addWidget(longitude, 1, 2);
\r
67 passwordGrid.addWidget(new QLabel(tr("Latitude")), 2,1);
\r
68 passwordGrid.addWidget(latitude, 2, 2);
\r
69 passwordGrid.addWidget(new QLabel(tr("Altitude")), 3,1);
\r
70 passwordGrid.addWidget(altitude, 3, 2);
\r
71 passwordGrid.setContentsMargins(10, 10, -10, -10);
\r
72 grid.addLayout(passwordGrid,1,1);
\r
74 ok = new QPushButton(tr("OK"));
\r
75 ok.clicked.connect(this, "okButtonPressed()");
\r
76 QPushButton cancel = new QPushButton(tr("Cancel"));
\r
77 cancel.clicked.connect(this, "cancelButtonPressed()");
\r
78 buttonGrid.addWidget(ok, 1, 1);
\r
79 buttonGrid.addWidget(cancel, 1,2);
\r
80 grid.addLayout(buttonGrid,2,1);
\r
83 // The OK button was pressed
\r
84 @SuppressWarnings("unused")
\r
85 private void okButtonPressed() {
\r
90 // The CANCEL button was pressed
\r
91 @SuppressWarnings("unused")
\r
92 private void cancelButtonPressed() {
\r
97 // Get the longitude
\r
98 public double getLongitude() {
\r
100 return new Double(longitude.text());
\r
101 } catch (java.lang.NumberFormatException e) {
\r
106 // Get the latitude
\r
107 public double getLatitude() {
\r
109 return new Double(latitude.text());
\r
110 } catch (java.lang.NumberFormatException e) {
\r
115 // Get the altitude
\r
116 public double getAltitude() {
\r
118 return new Double(altitude.text());
\r
119 } catch (java.lang.NumberFormatException e) {
\r
125 public void setLongitude(double value) {
\r
126 longitude.setText(new Float(value).toString());
\r
129 public void setLatitude(double value) {
\r
130 latitude.setText(new Float(value).toString());
\r
133 public void setAltitude(double value) {
\r
134 altitude.setText(new Float(value).toString());
\r
138 // Check if the OK button was pressed
\r
139 public boolean okPressed() {
\r