2
#include <qstringlist.h>
5
#include "TeQtLatEdit.h"
7
TeQtLatEdit::TeQtLatEdit(QWidget* parent, const char *name)
8
:QLineEdit(parent, name)
12
TeQtLatEdit::decode(QString lado, short& dg, short& mn, float& sc, double& grauDec)
18
pi = 4.*atan((double)1.);
21
if(dg < 0 || dg > lim)
27
if(sc < 0. || sc > 60.)
30
if(lado == "s" || lado == "S")
32
if(dg > 0) dg = dg * -1;
33
else if(mn > 0) mn = mn * -1;
37
dd = (double)(abs(dg)) + ((double)abs(mn)/60.) + fabs(sc)/3600.;
38
if (dg < 0 || mn < 0 || (int)sc < 0)
47
void TeQtLatEdit::focusOutEvent( QFocusEvent *e )
52
QRegExp exp1("^[nNsS][ ]\\d\\d?\\d?[ ]?\\d?\\d?[ ]?\\d?\\d?\\.?[0-9]?" );
53
QRegExp exp2("^[nNsS][;]\\d\\d?\\d?[;]?\\d?\\d?[;]?\\d?\\d?\\.?[0-9]?" );
54
QRegExp exp3("^[nNsS][:]\\d\\d?\\d?[:]?\\d?\\d?[:]?\\d?\\d?\\.?[0-9]?" );
55
QRegExp exp4("^[+-]?\\d\\d?\\d?\\.?[0-9]?" );
60
if ( (mat=exp1.match( str )) != -1 )
62
myList = QStringList::split(" ",str);
64
else if ((mat=exp2.match( str )) != -1 )
66
myList = QStringList::split(";",str);
68
else if ((mat=exp3.match( str )) != -1 )
70
myList = QStringList::split(":",str);
72
else if ((mat=exp4.match( str )) != -1 )
74
grauDec = str.toDouble();
75
if ((grauDec >= -90.0 && grauDec <=90.0))
77
echo_.sprintf("%3.10f",grauDec);
79
emit coordValidator(grauDec);
84
setSelection( 0, text().length() );
85
emit coordValidator(TeLATINVALID);
91
setSelection( 0, text().length() );
92
emit coordValidator(TeLATINVALID);
96
int nelementos = myList.count();
97
short graus, minutos = 0;
100
graus = myList[1].toShort();
103
minutos = myList[2].toShort();
106
segundos = myList[3].toFloat();
108
bool dec = decode(myList[0],graus, minutos, segundos, grauDec);
111
echo_.sprintf("%s %d %d %2.2f",(const char*) myList[0], abs(graus), minutos, segundos);
113
emit coordValidator(grauDec);
118
setSelection( 0, text().length() );
119
emit coordValidator(TeLATINVALID);
124
void TeQtLatEdit::keyPressEvent( QKeyEvent *e )
126
QLineEdit::keyPressEvent( e );
127
if ( e->key() == Key_Enter || e->key() == Key_Return )
129
emit focusOutEvent(0);
b'\\ No newline at end of file'