mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
refs #250, formatting, minor tweaks and fixes
* changed return type for updateFromVatsimDataFileStation * improved resolution for own aircraft * convenience method findFirstByCallsign * automatically convert frequency to MHz for ATC station * improved output in toQString * GUI, flight plan formatting * corrected logging for network context * override keyword in listmodelbase
This commit is contained in:
@@ -62,21 +62,21 @@ namespace BlackCore
|
||||
//! \copydoc IContextNetwork::getAtcStationsOnline()
|
||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const override
|
||||
{
|
||||
// this->log(Q_FUNC_INFO);
|
||||
if (this->getRuntime()->isSlotLogForNetworkEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
|
||||
return m_atcStationsOnline;
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getAtcStationsBooked()
|
||||
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override
|
||||
{
|
||||
// this->log(Q_FUNC_INFO);
|
||||
if (this->getRuntime()->isSlotLogForNetworkEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
|
||||
return m_atcStationsBooked;
|
||||
}
|
||||
|
||||
//! \copydoc IContextNetwork::getAircraftsInRange()
|
||||
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const override
|
||||
{
|
||||
// this->log(Q_FUNC_INFO);
|
||||
if (this->getRuntime()->isSlotLogForNetworkEnabled()) this->getRuntime()->logSlot(Q_FUNC_INFO);
|
||||
return m_aircraftsInRange;
|
||||
}
|
||||
|
||||
|
||||
@@ -236,32 +236,6 @@
|
||||
<item row="5" column="0" colspan="4">
|
||||
<widget class="QPlainTextEdit" name="pte_Route"/>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="4">
|
||||
<widget class="QGroupBox" name="gb_Type">
|
||||
<property name="title">
|
||||
<string>1. Type</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_TypeVfr">
|
||||
<property name="text">
|
||||
<string>VFR</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_TypeIfr">
|
||||
<property name="text">
|
||||
<string>IFR</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLineEdit" name="le_DestinationAirport">
|
||||
<property name="inputMask">
|
||||
@@ -396,6 +370,57 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" rowspan="3">
|
||||
<widget class="QGroupBox" name="gb_Type">
|
||||
<property name="title">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_Type">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_TypeVfr">
|
||||
<property name="text">
|
||||
<string>VFR</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_TypeIfr">
|
||||
<property name="text">
|
||||
<string>IFR</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_Type">
|
||||
<property name="text">
|
||||
<string>1. Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace BlackGui
|
||||
|
||||
QModelIndex i1 = index.sibling(index.row(), 0);
|
||||
QModelIndex i2 = index.sibling(index.row(), this->columnCount(index) - 1);
|
||||
emit this->dataChanged(i1, i2);
|
||||
emit this->dataChanged(i1, i2); // which range has been changed
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -49,17 +49,17 @@ namespace BlackGui
|
||||
virtual ~CListModelBase() {}
|
||||
|
||||
//! \copydoc QAbstractListModel::columnCount()
|
||||
virtual int columnCount(const QModelIndex &modelIndex) const;
|
||||
virtual int columnCount(const QModelIndex &modelIndex) const override;
|
||||
|
||||
//! \copydoc QAbstractItemModel::headerData()
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
|
||||
//! Column to property index
|
||||
virtual int columnToPropertyIndex(int column) const;
|
||||
|
||||
//! Index to property index
|
||||
virtual int indexToPropertyIndex(const QModelIndex &index) const
|
||||
{
|
||||
{
|
||||
return this->columnToPropertyIndex(index.column());
|
||||
}
|
||||
|
||||
@@ -103,10 +103,10 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
//! \copydoc QAbstractListModel::data()
|
||||
virtual QVariant data(const QModelIndex &index, int role) const;
|
||||
virtual QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
//! \copydoc QAbstractListModel::rowCount()
|
||||
virtual int rowCount(const QModelIndex &index = QModelIndex()) const;
|
||||
virtual int rowCount(const QModelIndex &index = QModelIndex()) const override;
|
||||
|
||||
//! \copydoc QAbstractTableModel::flags
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
@@ -142,6 +142,6 @@ namespace BlackGui
|
||||
|
||||
//! Clear the list
|
||||
virtual void clear();
|
||||
};
|
||||
};
|
||||
}
|
||||
#endif // guard
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace BlackMisc
|
||||
|
||||
// frequency
|
||||
s.append(' ');
|
||||
s.append(this->m_frequency.toQString(i18n));
|
||||
s.append(this->m_frequency.valueRoundedWithUnit(3, i18n));
|
||||
|
||||
// ATIS
|
||||
if (this->hasAtis())
|
||||
@@ -103,6 +103,7 @@ namespace BlackMisc
|
||||
// distance to plane
|
||||
if (this->m_distanceToPlane.isPositiveWithEpsilonConsidered())
|
||||
{
|
||||
s.append(' ');
|
||||
i18n ? s.append(QCoreApplication::translate("Aviation", "distance")) : s.append("distance");
|
||||
s.append(' ');
|
||||
s.append(this->m_distanceToPlane.toQString(i18n));
|
||||
@@ -232,6 +233,14 @@ namespace BlackMisc
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
/*
|
||||
* Frequency
|
||||
*/
|
||||
void CAtcStation::setFrequency(const CFrequency &frequency) {
|
||||
this->m_frequency = frequency;
|
||||
this->m_frequency.setUnit(CFrequencyUnit::MHz());
|
||||
}
|
||||
|
||||
/*
|
||||
* SyncronizeControllerData
|
||||
*/
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace BlackMisc
|
||||
const BlackMisc::PhysicalQuantities::CFrequency &getFrequency() const { return m_frequency; }
|
||||
|
||||
//! Set frequency
|
||||
void setFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency) { this->m_frequency = frequency; }
|
||||
void setFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency);
|
||||
|
||||
//! Get the position of the center of the controller's area of visibility.
|
||||
const BlackMisc::Geo::CCoordinateGeodetic &getPosition() const { return m_position; }
|
||||
|
||||
@@ -46,6 +46,16 @@ namespace BlackMisc
|
||||
return this->findBy(&CAtcStation::getCallsign, callsign);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find first by callsign
|
||||
*/
|
||||
CAtcStation CAtcStationList::findFirstByCallsign(const CCallsign &callsign, const CAtcStation &ifNotFound) const
|
||||
{
|
||||
CAtcStationList stations = findByCallsign(callsign);
|
||||
if (!stations.isEmpty()) return stations[0];
|
||||
return ifNotFound;
|
||||
}
|
||||
|
||||
/*
|
||||
* Stations within range
|
||||
*/
|
||||
@@ -178,35 +188,27 @@ namespace BlackMisc
|
||||
/*
|
||||
* Merge with VATSIM data file
|
||||
*/
|
||||
int CAtcStationList::updateFromVatsimDataFileStation(CAtcStation &stationToBeUpdated) const
|
||||
bool CAtcStationList::updateFromVatsimDataFileStation(CAtcStation &stationToBeUpdated) const
|
||||
{
|
||||
if (this->isEmpty()) return 0;
|
||||
if (this->isEmpty()) return false;
|
||||
if (stationToBeUpdated.hasValidRealName() && stationToBeUpdated.hasValidId() && stationToBeUpdated.hasValidFrequency()) return 0;
|
||||
|
||||
int c = 0;
|
||||
for (auto i = this->begin(); i != this->end(); ++i)
|
||||
CAtcStation dataFileStation = this->findFirstByCallsign(stationToBeUpdated.getCallsign());
|
||||
if (dataFileStation.getCallsign().isEmpty()) return false; // not found
|
||||
|
||||
if (!stationToBeUpdated.hasValidRealName() || !stationToBeUpdated.hasValidId())
|
||||
{
|
||||
CAtcStation currentDataFileStation = *i;
|
||||
if (currentDataFileStation.getCallsign() != stationToBeUpdated.getCallsign()) continue;
|
||||
|
||||
if (!stationToBeUpdated.hasValidRealName() || !stationToBeUpdated.hasValidId())
|
||||
{
|
||||
CUser user = stationToBeUpdated.getController();
|
||||
if (!stationToBeUpdated.hasValidRealName()) user.setRealName(currentDataFileStation.getControllerRealName());
|
||||
if (!stationToBeUpdated.hasValidId()) user.setId(currentDataFileStation.getControllerId());
|
||||
stationToBeUpdated.setController(user);
|
||||
}
|
||||
|
||||
if (!stationToBeUpdated.hasValidFrequency())
|
||||
{
|
||||
stationToBeUpdated.setFrequency(currentDataFileStation.getFrequency());
|
||||
}
|
||||
c++;
|
||||
CUser user = stationToBeUpdated.getController();
|
||||
if (!stationToBeUpdated.hasValidRealName()) user.setRealName(dataFileStation.getControllerRealName());
|
||||
if (!stationToBeUpdated.hasValidId()) user.setId(dataFileStation.getControllerId());
|
||||
stationToBeUpdated.setController(user);
|
||||
}
|
||||
|
||||
// normally 1 expected, as I should find
|
||||
// only one online station for this booking
|
||||
return c;
|
||||
if (!stationToBeUpdated.hasValidFrequency())
|
||||
{
|
||||
stationToBeUpdated.setFrequency(dataFileStation.getFrequency());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -43,6 +43,9 @@ namespace BlackMisc
|
||||
//! Find 0..n stations by callsign
|
||||
CAtcStationList findByCallsign(const CCallsign &callsign) const;
|
||||
|
||||
//! Find first station by callsign, if not return given value / default
|
||||
CAtcStation findFirstByCallsign(const CCallsign &callsign, const CAtcStation &ifNotFound = CAtcStation()) const;
|
||||
|
||||
//! Find 0..n stations within range of given coordinate
|
||||
CAtcStationList findWithinRange(const BlackMisc::Geo::ICoordinateGeodetic &coordinate, const BlackMisc::PhysicalQuantities::CLength &range) const;
|
||||
|
||||
@@ -64,7 +67,7 @@ namespace BlackMisc
|
||||
|
||||
//! Merge with the data from the VATSIM data file
|
||||
//! \remarks Can be used if the stored data in this list are VATSIM data file stations
|
||||
int updateFromVatsimDataFileStation(CAtcStation &stationToBeUpdated) const;
|
||||
bool updateFromVatsimDataFileStation(CAtcStation &stationToBeUpdated) const;
|
||||
};
|
||||
|
||||
} //namespace
|
||||
|
||||
@@ -25,27 +25,19 @@ namespace BlackMisc
|
||||
class CCallsignList : public CSequence<CCallsign>
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Default constructor.
|
||||
*/
|
||||
//! Default constructor.
|
||||
CCallsignList();
|
||||
|
||||
/*!
|
||||
* \brief Construct from a base class object.
|
||||
*/
|
||||
//! Construct from a base class object.
|
||||
CCallsignList(const CSequence<CCallsign> &other);
|
||||
|
||||
/*!
|
||||
* \copydoc CValueObject::toQVariant()
|
||||
*/
|
||||
//! CValueObject::toQVariant()
|
||||
virtual QVariant toQVariant() const
|
||||
{
|
||||
return QVariant::fromValue(*this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Register metadata
|
||||
*/
|
||||
//! Register metadata
|
||||
static void registerMetadata();
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user