mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
refs #219, load flight plan
* fixed issue with parsing, only default locale is used. Now user's local possible * allow to load FP for other callsigns as well (voice capabilities) * Improved handling of CTime, inclusive bug fixes and time formatting * Max. lengths for FP fields as const value (so we can change it if required) * Load FP from GUI component * Samples for PQ classes * Adjusted depending classes (e.g. client)
This commit is contained in:
@@ -4,12 +4,26 @@ namespace BlackMisc
|
||||
{
|
||||
namespace PhysicalQuantities
|
||||
{
|
||||
CTime::CTime(int hours, int minutes, int seconds) : CPhysicalQuantity(0, CTimeUnit::nullUnit())
|
||||
{
|
||||
double value = hours + minutes / 100.0 + seconds / 10000.0;
|
||||
if (minutes == 0 && seconds == 0)
|
||||
{
|
||||
(*this) = CTime(hours, CTimeUnit::h());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (seconds == 0)
|
||||
(*this) = CTime(value, CTimeUnit::hrmin());
|
||||
else
|
||||
(*this) = CTime(value, CTimeUnit::hms());
|
||||
}
|
||||
}
|
||||
|
||||
CTime::CTime(const QTime &time) : CPhysicalQuantity(0, CTimeUnit::nullUnit())
|
||||
{
|
||||
int seconds = QTime(0, 0, 0).secsTo(time);
|
||||
CTime converted(seconds, CTimeUnit::s());
|
||||
converted.switchUnit(CTimeUnit::hms());
|
||||
*this = converted;
|
||||
CTime converted(time.hour(), time.minute(), time.second());
|
||||
(*this) = converted;
|
||||
}
|
||||
|
||||
void CTime::parseFromString(const QString &time)
|
||||
@@ -22,12 +36,7 @@ namespace BlackMisc
|
||||
t = QTime::fromString(ts, "hh:mm");
|
||||
else if (ts.length() == 8)
|
||||
t = QTime::fromString(ts, "hh:mm:ss");
|
||||
CTime parsed(t);
|
||||
if (ts.length() == 5)
|
||||
parsed.switchUnit(CTimeUnit::hrmin());
|
||||
else if (ts.length() == 8)
|
||||
parsed.switchUnit(CTimeUnit::hms());
|
||||
*this = parsed;
|
||||
(*this) = CTime(t);
|
||||
}
|
||||
else
|
||||
CPhysicalQuantity::parseFromString(ts);
|
||||
@@ -37,9 +46,19 @@ namespace BlackMisc
|
||||
{
|
||||
CTime copy(*this);
|
||||
copy.setUnit(CTimeUnit::hms());
|
||||
QString s = copy.toQString(false);
|
||||
QTime t = QTime::fromString(s, "hh:mm:ss");
|
||||
QString s = copy.toQString(false).replace('h', ':').replace('m', ':').replace('s', "");
|
||||
QTime t = s.length() == 8 ?
|
||||
QTime::fromString(s, "hh:mm:ss") :
|
||||
QTime::fromString(s, "hh:mm");
|
||||
return t;
|
||||
}
|
||||
|
||||
QList<int> CTime::getHrsMinSecParts() const
|
||||
{
|
||||
QTime t = this->toQTime();
|
||||
QList<int> parts;
|
||||
parts << t.hour() << t.minute() << t.second();
|
||||
return parts;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user