AngleSpinBox.cpp   AngleSpinBox.cpp 
skipping to change at line 48 skipping to change at line 48
} }
const QString AngleSpinBox::positivePrefix(PrefixType prefix) const QString AngleSpinBox::positivePrefix(PrefixType prefix)
{ {
switch(prefix) switch(prefix)
{ {
case NormalPlus: case NormalPlus:
return("+"); return("+");
break; break;
case Longitude: case Longitude:
return(q_("E ")); return(q_("E")+" ");
break; break;
case Latitude: case Latitude:
return(q_("N ")); return(q_("N")+" ");
break; break;
case Normal: case Normal:
default: default:
return(""); return("");
break; break;
} }
} }
const QString AngleSpinBox::negativePrefix(PrefixType prefix) const QString AngleSpinBox::negativePrefix(PrefixType prefix)
{ {
switch(prefix) switch(prefix)
{ {
case NormalPlus: case NormalPlus:
return(QLocale().negativeSign()); return(QLocale().negativeSign());
break; break;
case Longitude: case Longitude:
return(q_("W ")); return(q_("W")+" ");
break; break;
case Latitude: case Latitude:
return(q_("S ")); return(q_("S")+" ");
break; break;
case Normal: case Normal:
default: default:
return(QLocale().negativeSign()); return(QLocale().negativeSign());
break; break;
} }
} }
AngleSpinBox::~AngleSpinBox() AngleSpinBox::~AngleSpinBox()
{ {
} }
AngleSpinBox::AngleSpinboxSection AngleSpinBox::getCurrentSection() const AngleSpinBox::AngleSpinboxSection AngleSpinBox::getCurrentSection() const
{ {
int cusorPos = lineEdit()->cursorPosition(); int cursorPos = lineEdit()->cursorPosition();
const QString str = lineEdit()->text(); const QString str = lineEdit()->text();
int cPosMin = str.indexOf(QRegExp("[+-"+q_("N")+q_("S")+q_("E")+q_(" // Regexp must not have "+-" immediately behind "[" !
W")+"]"), 0); int cPosMin = str.indexOf(QRegExp("^["+q_("N")+q_("S")+q_("E")+q_("W
")+"+-]"), 0);
// without prefix (e.g. right ascension): avoid unwanted negating!
if ((cPosMin==-1) && (cursorPos==0)) {
return SectionDegreesHours;
}
int cPosMax = cPosMin+1; int cPosMax = cPosMin+1;
if (cusorPos>=cPosMin && cusorPos<cPosMax) { if (cursorPos>=cPosMin && cursorPos<cPosMax) {
return SectionPrefix; return SectionPrefix;
} }
cPosMin = cPosMax; cPosMin = cPosMax;
cPosMax = str.indexOf(QRegExp(QString("[h%1]").arg(QChar(176))), 0)+ cPosMax = str.indexOf(QRegExp(QString("[dh%1]").arg(QChar(176))), 0)
1; +1;
if (cusorPos > cPosMin && cusorPos <= cPosMax) { if (cursorPos >= cPosMin && cursorPos <= cPosMax) {
return SectionDegreesHours; return SectionDegreesHours;
} }
cPosMin = cPosMax; cPosMin = cPosMax;
cPosMax = str.indexOf(QRegExp("[m']"), 0)+1; cPosMax = str.indexOf(QRegExp("[m']"), 0)+1;
if (cusorPos > cPosMin && cusorPos <= cPosMax) { if (cursorPos > cPosMin && cursorPos <= cPosMax) {
return SectionMinutes; return SectionMinutes;
} }
cPosMin = cPosMax; cPosMin = cPosMax;
cPosMax = str.indexOf(QRegExp("[s\"]"), 0)+1; cPosMax = str.indexOf(QRegExp("[s\"]"), 0)+1;
if (cusorPos > cPosMin && cusorPos <= cPosMax) { if (cursorPos > cPosMin && cursorPos <= cPosMax) {
return SectionSeconds; return SectionSeconds;
} }
return SectionNone; return SectionNone;
} }
void AngleSpinBox::stepBy (int steps) void AngleSpinBox::stepBy (int steps)
{ {
const int cusorPos = lineEdit()->cursorPosition(); const int cusorPos = lineEdit()->cursorPosition();
const AngleSpinBox::AngleSpinboxSection sec = getCurrentSection(); const AngleSpinBox::AngleSpinboxSection sec = getCurrentSection();
switch (sec) switch (sec)
{ {
case SectionPrefix: case SectionPrefix:
{ {
radAngle = -radAngle; radAngle = -radAngle;
break; break;
} }
case SectionDegreesHours: case SectionDegreesHours:
{ {
if (angleSpinBoxFormat==DMSLetters || angleSpinBoxFo if (angleSpinBoxFormat==DMSLetters || angleSpinBoxFo
rmat==DMSSymbols || angleSpinBoxFormat==DecimalDeg) rmat==DMSSymbols || angleSpinBoxFormat==DecimalDeg
|| angleSpinBoxFormat==DMSLettersUnsigned ||
angleSpinBoxFormat==DMSSymbolsUnsigned )
radAngle += M_PI/180.*steps; radAngle += M_PI/180.*steps;
else else
radAngle += M_PI/12.*steps; radAngle += M_PI/12.*steps;
break; break;
} }
case SectionMinutes: case SectionMinutes:
{ {
if (angleSpinBoxFormat==DMSLetters || angleSpinBoxFo if (angleSpinBoxFormat==DMSLetters || angleSpinBoxFo
rmat==DMSSymbols || angleSpinBoxFormat==DecimalDeg) rmat==DMSSymbols || angleSpinBoxFormat==DecimalDeg
|| angleSpinBoxFormat==DMSLettersUnsigned ||
angleSpinBoxFormat==DMSSymbolsUnsigned )
radAngle += M_PI/180.*steps/60.; radAngle += M_PI/180.*steps/60.;
else else
radAngle += M_PI/12.*steps/60.; radAngle += M_PI/12.*steps/60.;
break; break;
} }
case SectionSeconds: case SectionSeconds:
case SectionNone: case SectionNone:
{ {
if (angleSpinBoxFormat==DMSLetters || angleSpinBoxFo if (angleSpinBoxFormat==DMSLetters || angleSpinBoxFo
rmat==DMSSymbols || angleSpinBoxFormat==DecimalDeg) rmat==DMSSymbols || angleSpinBoxFormat==DecimalDeg
|| angleSpinBoxFormat==DMSLettersUnsigned ||
angleSpinBoxFormat==DMSSymbolsUnsigned )
radAngle += M_PI/180.*steps/3600.; radAngle += M_PI/180.*steps/3600.;
else else
radAngle += M_PI/12.*steps/3600.; radAngle += M_PI/12.*steps/3600.;
break; break;
} }
default: default:
{ {
return; return;
} }
} }
skipping to change at line 341 skipping to change at line 349
radAngle = degrees * M_PI/180.; radAngle = degrees * M_PI/180.;
formatText(); formatText();
} }
void AngleSpinBox::formatText(void) void AngleSpinBox::formatText(void)
{ {
switch (angleSpinBoxFormat) switch (angleSpinBoxFormat)
{ {
case DMSLetters: case DMSLetters:
case DMSSymbols: case DMSSymbols:
case DMSLettersUnsigned:
case DMSSymbolsUnsigned:
{ {
double angle = radAngle; double angle = radAngle;
int d, m; int d, m;
double s; double s;
bool sign=true; bool sign=true;
if (angle<0) if (angle<0)
{ {
angle *= -1; angle *= -1;
sign = false; sign = false;
} }
angle = fmod(angle,2.0*M_PI); angle = fmod(angle,2.0*M_PI);
angle *= 180./M_PI; angle *= 180./M_PI;
if ( (!sign) && ( (angleSpinBoxFormat==DMSLettersUns
igned) || (angleSpinBoxFormat==DMSSymbolsUnsigned))) {
angle = 360.0-angle;
sign=true;
}
d = (int)angle; d = (int)angle;
m = (int)((angle - d)*60); m = (int)((angle - d)*60);
s = (angle-d)*3600-60*m; s = (angle-d)*3600-60*m;
// we may have seconds as 60 and one less minute... // we may have seconds as 60 and one less minute...
if (s > 60.0 - ::pow(10.0, -1 * (decimalPlaces+1))) if (s > 60.0 - ::pow(10.0, -1 * (decimalPlaces+1)))
{ {
m+=1; m+=1;
s-=60.0; s-=60.0;
} }
skipping to change at line 382 skipping to change at line 397
// fix when we have tiny tiny tiny values. // fix when we have tiny tiny tiny values.
if (s < ::pow(10.0, -1 * (decimalPlaces+1))) if (s < ::pow(10.0, -1 * (decimalPlaces+1)))
s= 0.0; s= 0.0;
else if (s < 0.0 && 0.0 - ::pow(10.0, -1 * (decimalP laces+1))) else if (s < 0.0 && 0.0 - ::pow(10.0, -1 * (decimalP laces+1)))
s= 0.0; s= 0.0;
QString signInd = positivePrefix(currentPrefixType); QString signInd = positivePrefix(currentPrefixType);
if (!sign) if (!sign)
signInd = negativePrefix(currentPrefixType); signInd = negativePrefix(currentPrefixType);
if (angleSpinBoxFormat == DMSLetters) if ((angleSpinBoxFormat == DMSLetters) || (angleSpin BoxFormat == DMSLettersUnsigned))
lineEdit()->setText(QString("%1%2d %3m %4s") lineEdit()->setText(QString("%1%2d %3m %4s")
.arg(signInd).arg(d).arg(m).arg(s, 0, ' f', decimalPlaces, ' ')); .arg(signInd).arg(d).arg(m).arg(s, 0, ' f', decimalPlaces, ' '));
else else
lineEdit()->setText(QString("%1%2%3 %4' %5\" ") lineEdit()->setText(QString("%1%2%3 %4' %5\" ")
.arg(signInd).arg(d).arg(QChar(176)).ar g(m) .arg(signInd).arg(d).arg(QChar(176)).ar g(m)
.arg(s, 0, 'f', decimalPlaces, ' ')); .arg(s, 0, 'f', decimalPlaces, ' '));
break; break;
} }
case HMSLetters: case HMSLetters:
case HMSSymbols: case HMSSymbols:
 End of changes. 16 change blocks. 
20 lines changed or deleted 39 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/