AngleSpinBox.hpp   AngleSpinBox.hpp 
skipping to change at line 30 skipping to change at line 30
#ifndef _ANGLESPINBOX_HPP_ #ifndef _ANGLESPINBOX_HPP_
#define _ANGLESPINBOX_HPP_ #define _ANGLESPINBOX_HPP_
#include <QAbstractSpinBox> #include <QAbstractSpinBox>
#include <QString> #include <QString>
//! @class AngleSpinBox //! @class AngleSpinBox
//! A spin box for displaying/entering angular values. //! A spin box for displaying/entering angular values.
//! This class can accept angles in various formats commonly used in astron omy //! This class can accept angles in various formats commonly used in astron omy
//! including decimal degrees, DMS and HMS. //! including decimal degrees, DMS and HMS.
class AngleSpinBox : public QAbstractSpinBox class AngleSpinBox : public QAbstractSpinBox
{ {
Q_OBJECT Q_OBJECT
public: public:
//! @enum DisplayFormat used to decide how to display the angle. //! @enum DisplayFormat
//! Used to decide how to display the angle.
enum DisplayFormat enum DisplayFormat
{ {
DMSLetters, //!< Degrees, minutes and seconds, e.g. 180d 4m 8s DMSLetters, //!< Degrees, minutes and seconds, e.g. 180d 4m 8s
DMSSymbols, //!< Degrees, minutes and seconds, e.g. 180° 4' 8" DMSSymbols, //!< Degrees, minutes and seconds, e.g. 180° 4' 8"
HMSLetters, //!< Hours, minutes and seconds, e.g. 12h 4m 6s HMSLetters, //!< Hours, minutes and seconds, e.g. 12h 4m 6s
HMSSymbols, //!< Hours, minutes and seconds, e.g. 12h 4' 6s" HMSSymbols, //!< Hours, minutes and seconds, e.g. 12h 4' 6s"
DecimalDeg //!< Decimal degrees, e.g. 180.06888 DecimalDeg //!< Decimal degrees, e.g. 180.06888
}; };
//! @enum PrefixType deteremines how positive and negative values ar //! @enum PrefixType
e indicated. //! Determines how positive and negative values are indicated.
enum PrefixType enum PrefixType
{ {
Normal, //!< negative values have '-' prefix Normal, //!< negative values have '-' prefix
NormalPlus, //!< positive values have '+' prefix, negati ve values have '-' prefix. NormalPlus, //!< positive values have '+' prefix, negati ve values have '-' prefix.
Longitude, //!< positive values have 'E' prefix, negati ve values have 'W' prefix. Longitude, //!< positive values have 'E' prefix, negati ve values have 'W' prefix.
Latitude, //!< positive values have 'N' prefix, negati ve values have 'S' prefix. Latitude, //!< positive values have 'N' prefix, negati ve values have 'S' prefix.
Unknown Unknown
}; };
AngleSpinBox(QWidget* parent=0, DisplayFormat format=DMSSymbols, Pre fixType prefix=Normal); AngleSpinBox(QWidget* parent=0, DisplayFormat format=DMSSymbols, Pre fixType prefix=Normal);
skipping to change at line 79 skipping to change at line 80
//! Get the angle held in the AngleSpinBox //! Get the angle held in the AngleSpinBox
//! @return the angle as formatted according to the current format a nd flags //! @return the angle as formatted according to the current format a nd flags
QString text(); QString text();
//! Convert a string value to a angle in radians. //! Convert a string value to a angle in radians.
//! This function can be used to validate a string as expressing an angle. Accepted //! This function can be used to validate a string as expressing an angle. Accepted
//! are any formats which the AngleSpinBox understands. //! are any formats which the AngleSpinBox understands.
//! @param input the string value to be converted / validated. //! @param input the string value to be converted / validated.
//! @param state a pointer to a QValidator::State value which is set according to the validation. //! @param state a pointer to a QValidator::State value which is set according to the validation.
//! @param prefix the kind of prefix to use for conversion.
//! @return the value of the angle expressed in input in radians. //! @return the value of the angle expressed in input in radians.
double stringToDouble(QString input, QValidator::State* state, Prefi xType prefix=Unknown) const; double stringToDouble(QString input, QValidator::State* state, Prefi xType prefix=Unknown) const;
//! Set the number of decimal places to express float values to (e.g . seconds in DMSLetters format) //! Set the number of decimal places to express float values to (e.g . seconds in DMSLetters format)
//! @param places the number of decimal places to use. //! @param places the number of decimal places to use.
void setDecimals(int places) { decimalPlaces = places; } void setDecimals(int places) { decimalPlaces = places; }
//! Set the number of decimal places to express float values to (e.g . seconds in DMSLetters format) //! Set the number of decimal places to express float values to (e.g . seconds in DMSLetters format)
//! @param places the number of decimal places to use. //! @return the number of decimal places used.
int decimals() { return decimalPlaces; } int decimals() { return decimalPlaces; }
//! Set the display format //! Set the display format
//! @param format the new format to use //! @param format the new format to use
void setDisplayFormat(DisplayFormat format) { angleSpinBoxFormat=for mat; emit(formatText()); } void setDisplayFormat(DisplayFormat format) { angleSpinBoxFormat=for mat; formatText(); }
//! Get the current display format //! Get the current display format
//! @return the current DisplayFormat //! @return the current DisplayFormat
DisplayFormat displayFormat() { return angleSpinBoxFormat; } DisplayFormat displayFormat() { return angleSpinBoxFormat; }
//! Set the prefix type //! Set the prefix type
//! @param prefix the new prefix type to use //! @param prefix the new prefix type to use
void setPrefixType(PrefixType prefix) { currentPrefixType=prefix; em it(formatText()); } void setPrefixType(PrefixType prefix) { currentPrefixType=prefix; fo rmatText(); }
//! Get the current display format //! Get the current display format
//! @return the current DisplayFormat //! @return the current DisplayFormat
PrefixType prefixType() { return currentPrefixType; } PrefixType prefixType() { return currentPrefixType; }
public slots: public slots:
void clear(); void clear();
//! Set the value of the spin box in radians. //! Set the value of the spin box in radians.
//! @param radians the value to set, in radians //! @param radians the value to set, in radians
void setRadians(double radians); void setRadians(double radians);
//! Set the value of the spin box in radians.
//! @param radians the value to set, in radians
void setDegrees(double degrees);
//! Set the value of the spin box in decimal degrees. //! Set the value of the spin box in decimal degrees.
//! @param radians the value to set, in decimal degrees //! @param degrees the value to set, in decimal degrees
void setDegrees(double degrees);
signals: signals:
//! emitted when the value changes. //! emitted when the value changes.
void valueChanged(void); void valueChanged();
protected: protected:
StepEnabled stepEnabled () const; StepEnabled stepEnabled () const;
private slots: private slots:
//! reformats the input according to the current value of angleSpinB
oxFormat/
//! This is called whenever an editingFinished() signal is emitted,
//! e.g. when RETURN is pressed.
void formatText(void);
//! updates radAngle (internal representation of the angle) and call s formatText //! updates radAngle (internal representation of the angle) and call s formatText
void updateValue(void); void updateValue(void);
private: private:
//! @enum AngleSpinboxSection
enum AngleSpinboxSection
{
SectionPrefix, //! Section of the S/W or E/
W or +/-
SectionDegreesHours, //! Section of the degree or hours
SectionMinutes, //! Section of the minutes (
of degree or of hours)
SectionSeconds, //! Section of the seconds (
of degree or of hours)
SectionNone //! No matching sect
ion, e.g. between 2 sections
};
//! Get the current section in which the line edit cursor is.
AngleSpinboxSection getCurrentSection() const;
//! Reformats the input according to the current value of angleSpinB
oxFormat/
//! This is called whenever an editingFinished() signal is emitted,
//! e.g. when RETURN is pressed.
void formatText(void);
static const QString positivePrefix(PrefixType prefix); static const QString positivePrefix(PrefixType prefix);
static const QString negativePrefix(PrefixType prefix); static const QString negativePrefix(PrefixType prefix);
DisplayFormat angleSpinBoxFormat; DisplayFormat angleSpinBoxFormat;
PrefixType currentPrefixType; PrefixType currentPrefixType;
int decimalPlaces; int decimalPlaces;
double radAngle; double radAngle;
}; };
 End of changes. 12 change blocks. 
18 lines changed or deleted 35 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/