2 * This file is part of NixNote
\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 //**********************************************
\r
23 //**********************************************
\r
24 //* This is the dialog when the user clicks
\r
25 //* the geo tag for a note.
\r
26 //**********************************************
\r
27 //**********************************************
\r
29 import com.trolltech.qt.gui.QDialog;
\r
30 import com.trolltech.qt.gui.QDoubleValidator;
\r
31 import com.trolltech.qt.gui.QDoubleValidator.Notation;
\r
32 import com.trolltech.qt.gui.QGridLayout;
\r
33 import com.trolltech.qt.gui.QIcon;
\r
34 import com.trolltech.qt.gui.QLabel;
\r
35 import com.trolltech.qt.gui.QLineEdit;
\r
36 import com.trolltech.qt.gui.QPushButton;
\r
38 public class GeoDialog extends QDialog {
\r
40 private boolean okPressed;
\r
41 private final QLineEdit altitude;
\r
42 private final QLineEdit latitude;
\r
43 private final QLineEdit longitude;
\r
44 private final QPushButton ok;
\r
45 private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");
\r
49 public GeoDialog() {
\r
51 setWindowTitle(tr("Geo Location"));
\r
52 setWindowIcon(new QIcon(iconPath+"globe.png"));
\r
53 QGridLayout grid = new QGridLayout();
\r
55 QGridLayout passwordGrid = new QGridLayout();
\r
56 QGridLayout buttonGrid = new QGridLayout();
\r
59 longitude = new QLineEdit();
\r
60 QDoubleValidator longVal = new QDoubleValidator(-180.0,180.0,4,longitude);
\r
61 longVal.setNotation(Notation.StandardNotation);
\r
62 longitude.setValidator(longVal);
\r
64 latitude = new QLineEdit();
\r
65 QDoubleValidator latVal = new QDoubleValidator(-90.0,90.0,4,latitude);
\r
66 latVal.setNotation(Notation.StandardNotation);
\r
67 latitude.setValidator(latVal);
\r
69 altitude = new QLineEdit();
\r
70 QDoubleValidator altVal = new QDoubleValidator(-9999.0,9999.0,4,altitude);
\r
71 altVal.setNotation(Notation.StandardNotation);
\r
72 altitude.setValidator(altVal);
\r
75 passwordGrid.addWidget(new QLabel(tr("Longitude")), 1,1);
\r
76 passwordGrid.addWidget(longitude, 1, 2);
\r
77 passwordGrid.addWidget(new QLabel(tr("Latitude")), 2,1);
\r
78 passwordGrid.addWidget(latitude, 2, 2);
\r
79 passwordGrid.addWidget(new QLabel(tr("Altitude")), 3,1);
\r
80 passwordGrid.addWidget(altitude, 3, 2);
\r
81 passwordGrid.setContentsMargins(10, 10, -10, -10);
\r
82 grid.addLayout(passwordGrid,1,1);
\r
84 ok = new QPushButton(tr("OK"));
\r
85 ok.clicked.connect(this, "okButtonPressed()");
\r
86 QPushButton cancel = new QPushButton(tr("Cancel"));
\r
87 cancel.clicked.connect(this, "cancelButtonPressed()");
\r
88 buttonGrid.addWidget(ok, 1, 1);
\r
89 buttonGrid.addWidget(cancel, 1,2);
\r
90 grid.addLayout(buttonGrid,2,1);
\r
93 // The OK button was pressed
\r
94 @SuppressWarnings("unused")
\r
95 private void okButtonPressed() {
\r
100 // The CANCEL button was pressed
\r
101 @SuppressWarnings("unused")
\r
102 private void cancelButtonPressed() {
\r
107 // Get the longitude
\r
108 public double getLongitude() {
\r
110 return new Double(longitude.text());
\r
111 } catch (java.lang.NumberFormatException e) {
\r
116 // Get the latitude
\r
117 public double getLatitude() {
\r
119 return new Double(latitude.text());
\r
120 } catch (java.lang.NumberFormatException e) {
\r
125 // Get the altitude
\r
126 public double getAltitude() {
\r
128 return new Double(altitude.text());
\r
129 } catch (java.lang.NumberFormatException e) {
\r
135 public void setLongitude(double value) {
\r
136 longitude.setText(new Float(value).toString());
\r
139 public void setLatitude(double value) {
\r
140 latitude.setText(new Float(value).toString());
\r
143 public void setAltitude(double value) {
\r
144 altitude.setText(new Float(value).toString());
\r
148 // Check if the OK button was pressed
\r
149 public boolean okPressed() {
\r