00001 /* 00002 * The information in this file is 00003 * Copyright(c) 2007 Ball Aerospace & Technologies Corporation 00004 * and is subject to the terms and conditions of the 00005 * GNU Lesser General Public License Version 2.1 00006 * The license text is available from 00007 * http://www.gnu.org/licenses/lgpl.html 00008 */ 00009 00010 00011 00012 #ifndef LATLONLINEEDIT_H 00013 #define LATLONLINEEDIT_H 00014 00015 #include <QtGui/QLineEdit> 00016 00017 #include "GeoPoint.h" 00018 00019 /** 00020 * A line edit for a latitude or longitude value. 00021 * 00022 * The LatLonLineEdit provides a line edit where user can enter a latitude or longitude 00023 * value. The line edit effectively wraps a DmsPoint value, where after entering a value, 00024 * the format of the text changes to the format specified by the current DmsPoint::DmsType 00025 * value. 00026 * 00027 * @see DmsPoint 00028 */ 00029 class LatLonLineEdit : public QLineEdit 00030 { 00031 Q_OBJECT 00032 00033 public: 00034 /** 00035 * Creates a new line edit. 00036 * 00037 * The line edit is created with a default display type of DmsPoint::DmsType::DMS_DECIMAL. 00038 * 00039 * @param parent 00040 * The parent widget. 00041 */ 00042 LatLonLineEdit(QWidget* parent = 0); 00043 00044 /** 00045 * Creates a new line edit. 00046 * 00047 * The line edit is created and initialized with the given value. The initial display 00048 * format is set to the DmsPoint::DmsType value in the given DmsPoint value. 00049 * 00050 * @param dmsPoint 00051 * The initial latitude or longitude value. 00052 * @param parent 00053 * The parent widget. 00054 */ 00055 LatLonLineEdit(DmsPoint dmsPoint, QWidget* parent = 0); 00056 00057 /** 00058 * Destroys the line edit. 00059 */ 00060 ~LatLonLineEdit(); 00061 00062 /** 00063 * Sets the current latitude or longitude value. 00064 * 00065 * @param dmsPoint 00066 * The new current value. The display type is updated to the DmsPoint::DmsType 00067 * value in the given DmsPoint value. 00068 * 00069 * @see getMinimumValue(), getMaximumValue() 00070 */ 00071 void setValue(DmsPoint dmsPoint); 00072 00073 /** 00074 * Returns the current value represented by the text in the line edit. 00075 * 00076 * @return The current value, which is equivalent to DmsPoint::getValue(). A value of 00077 * 0.0 is returned if the current line edit text is empty. 00078 * 00079 * @see setValue(), DmsPoint 00080 */ 00081 double getValue() const; 00082 00083 /** 00084 * Sets the line edit to automatically update the text format. 00085 * 00086 * This method sets an internal flag to automatically update the text when the keyboard 00087 * focus leaves the line edit widget. The text is updated to the format specified by 00088 * DmsPoint::DmsType. 00089 * 00090 * @param bAutoUpdate 00091 * Set this value to true to automatically update the format of the text when 00092 * the keyboard focus leaves the widget. Set this value to false to not 00093 * automatically update the format of the text. 00094 * 00095 * @see hasAutoUpdate() 00096 */ 00097 void setAutoUpdate(bool bAutoUpdate); 00098 00099 /** 00100 * Queries whether the line edit automatically updates the text format. 00101 * 00102 * @return True if the line edit automatically updates the format of the text when the 00103 * keyboard focus leaves the widget, otherwise false. 00104 * 00105 * @see setAutoUpdate() 00106 */ 00107 bool hasAutoUpdate() const; 00108 00109 protected: 00110 /** 00111 * Updates the format of the current text. 00112 * 00113 * If the auto update flag is set to true, this method updates the text format to the 00114 * format specified by the current DmsPoint::DmsType value. 00115 * 00116 * @param pEvent 00117 * The focus event causing the update. 00118 * 00119 * @see hasAutoUpdate() 00120 */ 00121 void focusOutEvent(QFocusEvent* pEvent); 00122 00123 private: 00124 LatLonLineEdit(const LatLonLineEdit& rhs); 00125 LatLonLineEdit& operator=(const LatLonLineEdit& rhs); 00126 bool mAutoUpdate; 00127 DmsPoint::DmsType mDisplayType; 00128 }; 00129 00130 #endif