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:
Klaus Basan
2014-05-28 01:27:52 +02:00
parent 6353edd50a
commit 0a4c47c800
9 changed files with 105 additions and 74 deletions

View File

@@ -62,21 +62,21 @@ namespace BlackCore
//! \copydoc IContextNetwork::getAtcStationsOnline() //! \copydoc IContextNetwork::getAtcStationsOnline()
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const override 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; return m_atcStationsOnline;
} }
//! \copydoc IContextNetwork::getAtcStationsBooked() //! \copydoc IContextNetwork::getAtcStationsBooked()
virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override 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; return m_atcStationsBooked;
} }
//! \copydoc IContextNetwork::getAircraftsInRange() //! \copydoc IContextNetwork::getAircraftsInRange()
virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const override 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; return m_aircraftsInRange;
} }

View File

@@ -236,32 +236,6 @@
<item row="5" column="0" colspan="4"> <item row="5" column="0" colspan="4">
<widget class="QPlainTextEdit" name="pte_Route"/> <widget class="QPlainTextEdit" name="pte_Route"/>
</item> </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"> <item row="7" column="0">
<widget class="QLineEdit" name="le_DestinationAirport"> <widget class="QLineEdit" name="le_DestinationAirport">
<property name="inputMask"> <property name="inputMask">
@@ -396,6 +370,57 @@
</property> </property>
</widget> </widget>
</item> </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> </layout>
</item> </item>
</layout> </layout>

View File

@@ -117,7 +117,7 @@ namespace BlackGui
QModelIndex i1 = index.sibling(index.row(), 0); QModelIndex i1 = index.sibling(index.row(), 0);
QModelIndex i2 = index.sibling(index.row(), this->columnCount(index) - 1); 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
} }
/* /*

View File

@@ -49,17 +49,17 @@ namespace BlackGui
virtual ~CListModelBase() {} virtual ~CListModelBase() {}
//! \copydoc QAbstractListModel::columnCount() //! \copydoc QAbstractListModel::columnCount()
virtual int columnCount(const QModelIndex &modelIndex) const; virtual int columnCount(const QModelIndex &modelIndex) const override;
//! \copydoc QAbstractItemModel::headerData() //! \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 //! Column to property index
virtual int columnToPropertyIndex(int column) const; virtual int columnToPropertyIndex(int column) const;
//! Index to property index //! Index to property index
virtual int indexToPropertyIndex(const QModelIndex &index) const virtual int indexToPropertyIndex(const QModelIndex &index) const
{ {
return this->columnToPropertyIndex(index.column()); return this->columnToPropertyIndex(index.column());
} }
@@ -103,10 +103,10 @@ namespace BlackGui
} }
//! \copydoc QAbstractListModel::data() //! \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() //! \copydoc QAbstractListModel::rowCount()
virtual int rowCount(const QModelIndex &index = QModelIndex()) const; virtual int rowCount(const QModelIndex &index = QModelIndex()) const override;
//! \copydoc QAbstractTableModel::flags //! \copydoc QAbstractTableModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override; Qt::ItemFlags flags(const QModelIndex &index) const override;
@@ -142,6 +142,6 @@ namespace BlackGui
//! Clear the list //! Clear the list
virtual void clear(); virtual void clear();
}; };
} }
#endif // guard #endif // guard

View File

@@ -78,7 +78,7 @@ namespace BlackMisc
// frequency // frequency
s.append(' '); s.append(' ');
s.append(this->m_frequency.toQString(i18n)); s.append(this->m_frequency.valueRoundedWithUnit(3, i18n));
// ATIS // ATIS
if (this->hasAtis()) if (this->hasAtis())
@@ -103,6 +103,7 @@ namespace BlackMisc
// distance to plane // distance to plane
if (this->m_distanceToPlane.isPositiveWithEpsilonConsidered()) if (this->m_distanceToPlane.isPositiveWithEpsilonConsidered())
{ {
s.append(' ');
i18n ? s.append(QCoreApplication::translate("Aviation", "distance")) : s.append("distance"); i18n ? s.append(QCoreApplication::translate("Aviation", "distance")) : s.append("distance");
s.append(' '); s.append(' ');
s.append(this->m_distanceToPlane.toQString(i18n)); s.append(this->m_distanceToPlane.toQString(i18n));
@@ -232,6 +233,14 @@ namespace BlackMisc
return !((*this) == other); return !((*this) == other);
} }
/*
* Frequency
*/
void CAtcStation::setFrequency(const CFrequency &frequency) {
this->m_frequency = frequency;
this->m_frequency.setUnit(CFrequencyUnit::MHz());
}
/* /*
* SyncronizeControllerData * SyncronizeControllerData
*/ */

View File

@@ -143,7 +143,7 @@ namespace BlackMisc
const BlackMisc::PhysicalQuantities::CFrequency &getFrequency() const { return m_frequency; } const BlackMisc::PhysicalQuantities::CFrequency &getFrequency() const { return m_frequency; }
//! Set 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. //! Get the position of the center of the controller's area of visibility.
const BlackMisc::Geo::CCoordinateGeodetic &getPosition() const { return m_position; } const BlackMisc::Geo::CCoordinateGeodetic &getPosition() const { return m_position; }

View File

@@ -46,6 +46,16 @@ namespace BlackMisc
return this->findBy(&CAtcStation::getCallsign, callsign); 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 * Stations within range
*/ */
@@ -178,35 +188,27 @@ namespace BlackMisc
/* /*
* Merge with VATSIM data file * 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; if (stationToBeUpdated.hasValidRealName() && stationToBeUpdated.hasValidId() && stationToBeUpdated.hasValidFrequency()) return 0;
int c = 0; CAtcStation dataFileStation = this->findFirstByCallsign(stationToBeUpdated.getCallsign());
for (auto i = this->begin(); i != this->end(); ++i) if (dataFileStation.getCallsign().isEmpty()) return false; // not found
if (!stationToBeUpdated.hasValidRealName() || !stationToBeUpdated.hasValidId())
{ {
CAtcStation currentDataFileStation = *i; CUser user = stationToBeUpdated.getController();
if (currentDataFileStation.getCallsign() != stationToBeUpdated.getCallsign()) continue; if (!stationToBeUpdated.hasValidRealName()) user.setRealName(dataFileStation.getControllerRealName());
if (!stationToBeUpdated.hasValidId()) user.setId(dataFileStation.getControllerId());
if (!stationToBeUpdated.hasValidRealName() || !stationToBeUpdated.hasValidId()) stationToBeUpdated.setController(user);
{
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++;
} }
// normally 1 expected, as I should find if (!stationToBeUpdated.hasValidFrequency())
// only one online station for this booking {
return c; stationToBeUpdated.setFrequency(dataFileStation.getFrequency());
}
return true;
} }
} // namespace } // namespace
} // namespace } // namespace

View File

@@ -43,6 +43,9 @@ namespace BlackMisc
//! Find 0..n stations by callsign //! Find 0..n stations by callsign
CAtcStationList findByCallsign(const CCallsign &callsign) const; 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 //! Find 0..n stations within range of given coordinate
CAtcStationList findWithinRange(const BlackMisc::Geo::ICoordinateGeodetic &coordinate, const BlackMisc::PhysicalQuantities::CLength &range) const; 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 //! 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 //! \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 } //namespace

View File

@@ -25,27 +25,19 @@ namespace BlackMisc
class CCallsignList : public CSequence<CCallsign> class CCallsignList : public CSequence<CCallsign>
{ {
public: public:
/*! //! Default constructor.
* \brief Default constructor.
*/
CCallsignList(); CCallsignList();
/*! //! Construct from a base class object.
* \brief Construct from a base class object.
*/
CCallsignList(const CSequence<CCallsign> &other); CCallsignList(const CSequence<CCallsign> &other);
/*! //! CValueObject::toQVariant()
* \copydoc CValueObject::toQVariant()
*/
virtual QVariant toQVariant() const virtual QVariant toQVariant() const
{ {
return QVariant::fromValue(*this); return QVariant::fromValue(*this);
} }
/*! //! Register metadata
* \brief Register metadata
*/
static void registerMetadata(); static void registerMetadata();
}; };