This commit is contained in:
Klaus Basan
2018-07-07 19:52:43 +02:00
parent 53a7ef2df3
commit ead1a93597
16 changed files with 93 additions and 90 deletions

View File

@@ -678,7 +678,7 @@ namespace BlackCore
{
static const BlackMisc::CLogCategoryList cats
(
CThreadedReader::getLogCategories().join({ BlackMisc::CLogCategory::swiftDbWebservice(), BlackMisc::CLogCategory::webservice() })
CThreadedReader::getLogCategories().join({ CLogCategory::swiftDbWebservice(), CLogCategory::webservice() })
);
return cats;
}

View File

@@ -279,9 +279,9 @@ namespace BlackCore
qint64 m_statsLastUpdateAircraftRequestedMs = 0; //!< when was the last aircraft update requested
qint64 m_statsUpdateAircraftRequestedDeltaMs = 0; //!< delta time between 2 aircraft updates
BlackMisc::Simulation::CSimulatorInternals m_simulatorInternals; //!< setup object
BlackMisc::Simulation::CInterpolationLogger m_interpolationLogger; //!< log.interpolation
BlackMisc::Aviation::CTimestampPerCallsign m_clampedLogMsg; //!< when logged last for this callsign, can be used so there is no log message overflow
BlackMisc::Simulation::CSimulatorInternals m_simulatorInternals; //!< setup object
BlackMisc::Simulation::CInterpolationLogger m_interpolationLogger; //!< log.interpolation
BlackMisc::Aviation::CTimestampPerCallsign m_clampedLogMsg; //!< when logged last for this callsign, can be used so there is no log message overflow
BlackMisc::Aviation::CAircraftSituationPerCallsign m_lastSentSituations; //!< last situation sent to simulator
BlackMisc::Aviation::CAircraftPartsPerCallsign m_lastSentParts; //!< last parts sent to simulator

View File

@@ -42,46 +42,46 @@ namespace BlackGui
bool CMenuAction::isCheckableQAction() const
{
if (!this->m_action) { return false; }
return this->m_action->isCheckable();
if (!m_action) { return false; }
return m_action->isCheckable();
}
void CMenuAction::setActionChecked(bool checked)
{
if (this->m_action) { m_action->setChecked(checked); }
if (m_action) { m_action->setChecked(checked); }
}
bool CMenuAction::isActionEnabled() const
{
if (!this->m_action) { return false; }
return this->m_action->isEnabled();
if (!m_action) { return false; }
return m_action->isEnabled();
}
void CMenuAction::setActionEnabled(bool enabled)
{
if (this->m_action) { m_action->setEnabled(enabled); }
if (m_action) { m_action->setEnabled(enabled); }
}
bool CMenuAction::hasNoPathWithSeparator() const
{
return this->m_separator && this->hasNoPath();
return m_separator && this->hasNoPath();
}
bool CMenuAction::hasNoPath() const
{
return this->m_path.isEmpty() || this->m_path == pathNone();
return m_path.isEmpty() || m_path == pathNone();
}
QPixmap CMenuAction::getPixmap() const
{
if (this->m_icon.isNull()) { return QPixmap(); }
return this->m_icon.pixmap(this->m_icon.actualSize(QSize(16, 16)));
if (m_icon.isNull()) { return QPixmap(); }
return m_icon.pixmap(m_icon.actualSize(QSize(16, 16)));
}
void CMenuAction::setEnabled(bool enabled)
{
Q_ASSERT_X(this->m_action, Q_FUNC_INFO, "No action");
this->m_action->setEnabled(enabled);
Q_ASSERT_X(m_action, Q_FUNC_INFO, "No action");
m_action->setEnabled(enabled);
}
const CMenuAction &CMenuAction::subMenuDatabase()
@@ -104,18 +104,18 @@ namespace BlackGui
QString CMenuAction::getLastPathPart() const
{
if (this->m_path.contains('/'))
if (m_path.contains('/'))
{
if (this->m_path.endsWith('/')) { return ""; }
const int i = this->m_path.lastIndexOf('/');
return this->m_path.mid(i + 1);
if (m_path.endsWith('/')) { return ""; }
const int i = m_path.lastIndexOf('/');
return m_path.mid(i + 1);
}
return "";
}
void CMenuActions::splitSubMenus(const QString &key, QList<CMenuAction> &actions, QList<CMenuAction> &menus) const
{
QList<CMenuAction> myActions(this->m_actions.values(key));
QList<CMenuAction> myActions(m_actions.values(key));
QList<CMenuAction> checkableActions;
std::reverse(myActions.begin(), myActions.end()); // the order is reverse because of the insert multi value
for (const CMenuAction &action : myActions)
@@ -163,8 +163,8 @@ namespace BlackGui
CMenuActions CMenuActions::getMenuActions(const QString &path) const
{
if (this->m_actions.contains(path)) { return QList<CMenuAction>(); };
const QList<CMenuAction> allActions(this->m_actions.values(path));
if (m_actions.contains(path)) { return QList<CMenuAction>(); };
const QList<CMenuAction> allActions(m_actions.values(path));
QList<CMenuAction> menuActions;
for (const CMenuAction &a : allActions)
{
@@ -178,7 +178,7 @@ namespace BlackGui
bool CMenuActions::containsMenu(const QString &path) const
{
if (!this->m_actions.contains(path)) { return false; }
if (!m_actions.contains(path)) { return false; }
return getMenuActions(path).size() > 0;
}
@@ -218,7 +218,7 @@ namespace BlackGui
CMenuAction CMenuActions::addAction(const CMenuAction &menuAction)
{
Q_ASSERT_X(!menuAction.getPath().isEmpty(), Q_FUNC_INFO, "Need path");
this->m_actions.insertMulti(menuAction.getPath(), menuAction);
m_actions.insertMulti(menuAction.getPath(), menuAction);
return menuAction;
}
@@ -323,8 +323,8 @@ namespace BlackGui
void CMenuActions::toQMenu(QMenu &menu, bool separateGroups) const
{
if (this->m_actions.isEmpty()) { return; }
const QStringList keys = this->m_actions.uniqueKeys(); // Sorted ascending
if (m_actions.isEmpty()) { return; }
const QStringList keys = m_actions.uniqueKeys(); // Sorted ascending
QMap<QString, QMenu *> subMenus; // all sub menus
for (const QString &key : keys)
@@ -399,7 +399,7 @@ namespace BlackGui
QList<CMenuAction> CMenuActions::toQList() const
{
return this->m_actions.values();
return m_actions.values();
}
CMenuActions::operator QList<QAction *>() const

View File

@@ -151,7 +151,7 @@ namespace BlackGui
//! Client COM related
static const QString &pathClientCom() { static const QString p("Client.ATC"); return p; }
//! Client COM related
//! Client simulation related
static const QString &pathClientSimulation() { static const QString p("Client.Simulation"); return p; }
// ---- standard view paths --------

View File

@@ -40,6 +40,7 @@ namespace BlackGui
m_columns.addColumn(CColumn::standardString("gnd.elv.", CAircraftSituation::IndexGroundElevationPlusInfo));
m_columns.addColumn(CColumn::standardString("gnd.elv.alt.", { CAircraftSituation::IndexGroundElevationPlane, CElevationPlane::IndexGeodeticHeightAsString }));
m_columns.addColumn(CColumn("elv.radius", { CAircraftSituation::IndexGroundElevationPlane, CElevationPlane::IndexRadius }, new CPhysiqalQuantiyFormatter<CLengthUnit, CLength>(CLengthUnit::m(), 1)));
m_columns.addColumn(CColumn::standardString("cs.", "callsign", { CAircraftSituation::IndexCallsign, CCallsign::IndexCallsignStringAsSet }));
// default sort order
this->setSortColumnByPropertyIndex(CAircraftSituation::IndexAdjustedMsWithOffset);

View File

@@ -58,48 +58,48 @@ namespace BlackGui
void CAtcStationListModel::setStationMode(CAtcStationListModel::AtcStationMode stationMode)
{
if (this->m_stationMode == stationMode) return;
this->m_stationMode = stationMode;
this->m_columns.clear();
if (m_stationMode == stationMode) return;
m_stationMode = stationMode;
m_columns.clear();
switch (stationMode)
{
case NotSet:
case StationsOnline:
{
this->m_columns.addColumn(CColumn::standardString("cs.", "callsign", { CAtcStation::IndexCallsign, CCallsign::IndexCallsignStringAsSet }));
m_columns.addColumn(CColumn::standardString("cs.", "callsign", { CAtcStation::IndexCallsign, CCallsign::IndexCallsignStringAsSet }));
CColumn col("type", CAtcStation::IndexIcon);
col.setSortPropertyIndex({ CAtcStation::IndexCallsign, CCallsign::IndexSuffix });
this->m_columns.addColumn(col);
this->m_columns.addColumn(CColumn("distance", CAtcStation::IndexRelativeDistance, new CAirspaceDistanceFormatter()));
this->m_columns.addColumn(CColumn("frequency", CAtcStation::IndexFrequency, new CComFrequencyFormatter()));
this->m_columns.addColumn(CColumn("r.", "in range", CAtcStation::IndexIsInRange, new CBoolIconFormatter("in range", "outside range")));
this->m_columns.addColumn(CColumn("range", CAtcStation::IndexRange, new CAirspaceDistanceFormatter()));
this->m_columns.addColumn(CColumn::standardString("controllername", { CAtcStation::IndexController, CUser::IndexRealName }));
this->m_columns.addColumn(CColumn("from", "booked from", CAtcStation::IndexBookedFrom, new CDateTimeFormatter(CDateTimeFormatter::formatHm())));
this->m_columns.addColumn(CColumn("until", "booked until", CAtcStation::IndexBookedUntil, new CDateTimeFormatter(CDateTimeFormatter::formatHm())));
this->m_columns.addColumn(CColumn::standardString("voiceroomurl", { CAtcStation::IndexVoiceRoom, CVoiceRoom::IndexUrl }));
m_columns.addColumn(col);
m_columns.addColumn(CColumn("distance", CAtcStation::IndexRelativeDistance, new CAirspaceDistanceFormatter()));
m_columns.addColumn(CColumn("frequency", CAtcStation::IndexFrequency, new CComFrequencyFormatter()));
m_columns.addColumn(CColumn("r.", "in range", CAtcStation::IndexIsInRange, new CBoolIconFormatter("in range", "outside range")));
m_columns.addColumn(CColumn("range", CAtcStation::IndexRange, new CAirspaceDistanceFormatter()));
m_columns.addColumn(CColumn::standardString("controllername", { CAtcStation::IndexController, CUser::IndexRealName }));
m_columns.addColumn(CColumn("from", "booked from", CAtcStation::IndexBookedFrom, new CDateTimeFormatter(CDateTimeFormatter::formatHm())));
m_columns.addColumn(CColumn("until", "booked until", CAtcStation::IndexBookedUntil, new CDateTimeFormatter(CDateTimeFormatter::formatHm())));
m_columns.addColumn(CColumn::standardString("voiceroomurl", { CAtcStation::IndexVoiceRoom, CVoiceRoom::IndexUrl }));
// default sort order
this->setSortColumnByPropertyIndex(CAtcStation::IndexRelativeDistance);
this->m_sortOrder = Qt::AscendingOrder;
m_sortOrder = Qt::AscendingOrder;
}
break;
case StationsBooked:
{
this->m_columns.addColumn(CColumn::standardString("cs.", "callsign", { CAtcStation::IndexCallsign, CCallsign::IndexCallsignStringAsSet }));
m_columns.addColumn(CColumn::standardString("cs.", "callsign", { CAtcStation::IndexCallsign, CCallsign::IndexCallsignStringAsSet }));
CColumn col = CColumn("type", CAtcStation::IndexIcon);
col.setSortPropertyIndex({ CAtcStation::IndexCallsign, CCallsign::IndexSuffix });
this->m_columns.addColumn(col);
this->m_columns.addColumn(CColumn("", "on/offline", CAtcStation::IndexIsOnline, new CBoolLedFormatter("online", "offline")));
this->m_columns.addColumn(CColumn::standardString("controllername", { CAtcStation::IndexController, CUser::IndexRealName }));
this->m_columns.addColumn(CColumn("from", "booked from", CAtcStation::IndexBookedFrom, new CDateTimeFormatter(CDateTimeFormatter::formatYmdhm())));
this->m_columns.addColumn(CColumn("until", "booked until", CAtcStation::IndexBookedUntil, new CDateTimeFormatter(CDateTimeFormatter::formatYmdhm())));
this->m_columns.addColumn(CColumn("frequency", CAtcStation::IndexFrequency, new CComFrequencyFormatter()));
m_columns.addColumn(col);
m_columns.addColumn(CColumn("", "on/offline", CAtcStation::IndexIsOnline, new CBoolLedFormatter("online", "offline")));
m_columns.addColumn(CColumn::standardString("controllername", { CAtcStation::IndexController, CUser::IndexRealName }));
m_columns.addColumn(CColumn("from", "booked from", CAtcStation::IndexBookedFrom, new CDateTimeFormatter(CDateTimeFormatter::formatYmdhm())));
m_columns.addColumn(CColumn("until", "booked until", CAtcStation::IndexBookedUntil, new CDateTimeFormatter(CDateTimeFormatter::formatYmdhm())));
m_columns.addColumn(CColumn("frequency", CAtcStation::IndexFrequency, new CComFrequencyFormatter()));
// default sort order
this->setSortColumnByPropertyIndex(CAtcStation::IndexBookedFrom);
this->m_sortOrder = Qt::AscendingOrder;
m_sortOrder = Qt::AscendingOrder;
}
break;
@@ -161,7 +161,7 @@ namespace BlackGui
if (station.getCallsign().isEmpty()) return;
if (added)
{
bool c = this->m_container.contains(&CAtcStation::getCallsign, station.getCallsign());
bool c = m_container.contains(&CAtcStation::getCallsign, station.getCallsign());
if (!c) { this->insert(station); }
}
else

View File

@@ -28,12 +28,12 @@ namespace BlackGui
//! Airports view
class BLACKGUI_EXPORT CAirportView : public CViewBase<Models::CAirportListModel, BlackMisc::Aviation::CAirportList, BlackMisc::Aviation::CAirport>
{
public:
//! Constructor
explicit CAirportView(QWidget *parent = nullptr);
};
}
}
} // ns
#endif // guard

View File

@@ -56,36 +56,36 @@ namespace BlackGui
if (BlackConfig::CBuildConfig::isDebugBuild())
{
if (this->m_debugActions.isEmpty()) { this->m_actions = QList<QAction *>({nullptr, nullptr}); }
this->m_actions[0] = menuActions.addAction(this->m_actions[0], CIcons::tableSheet16(), "Test: 1k ATC online stations", CMenuAction::pathClientCom(), { this, &CAtcStationView::ps_testRequest1kAtcOnlineDummies });
this->m_actions[1] = menuActions.addAction(this->m_actions[1], CIcons::tableSheet16(), "Test: 3k ATC online stations", CMenuAction::pathClientCom(), { this, &CAtcStationView::ps_testRequest1kAtcOnlineDummies });
this->m_actions[0] = menuActions.addAction(this->m_actions[0], CIcons::tableSheet16(), "Test: 1k ATC online stations", CMenuAction::pathClientCom(), { this, &CAtcStationView::emitTestRequest1kAtcOnlineDummies });
this->m_actions[1] = menuActions.addAction(this->m_actions[1], CIcons::tableSheet16(), "Test: 3k ATC online stations", CMenuAction::pathClientCom(), { this, &CAtcStationView::emitTestRequest3kAtcOnlineDummies });
}
if (this->hasSelection())
{
if (this->m_debugActions.isEmpty()) { this->m_debugActions = QList<QAction *>({nullptr, nullptr, nullptr}); }
this->m_debugActions[0] = menuActions.addAction(this->m_debugActions[0], CIcons::appCockpit16(), "Tune in COM1", CMenuAction::pathClientCom(), { this, &CAtcStationView::ps_tuneInAtcCom1 });
this->m_debugActions[1] = menuActions.addAction(this->m_debugActions[1], CIcons::appCockpit16(), "Tune in COM2", CMenuAction::pathClientCom(), { this, &CAtcStationView::ps_tuneInAtcCom2 });
this->m_debugActions[2] = menuActions.addAction(this->m_debugActions[2], CIcons::appTextMessages16(), "Show text messages", CMenuAction::pathClientCom(), { this, &CAtcStationView::ps_requestTextMessage });
this->m_debugActions[0] = menuActions.addAction(this->m_debugActions[0], CIcons::appCockpit16(), "Tune in COM1", CMenuAction::pathClientCom(), { this, &CAtcStationView::tuneInAtcCom1 });
this->m_debugActions[1] = menuActions.addAction(this->m_debugActions[1], CIcons::appCockpit16(), "Tune in COM2", CMenuAction::pathClientCom(), { this, &CAtcStationView::tuneInAtcCom2 });
this->m_debugActions[2] = menuActions.addAction(this->m_debugActions[2], CIcons::appTextMessages16(), "Show text messages", CMenuAction::pathClientCom(), { this, &CAtcStationView::requestTextMessage });
}
CViewBase::customMenu(menuActions);
}
void CAtcStationView::ps_tuneInAtcCom1()
void CAtcStationView::tuneInAtcCom1()
{
const CAtcStation s(this->selectedObject());
if (s.getCallsign().isEmpty()) { return; }
emit this->requestComFrequency(s.getFrequency(), CComSystem::Com1);
}
void CAtcStationView::ps_tuneInAtcCom2()
void CAtcStationView::tuneInAtcCom2()
{
const CAtcStation s(this->selectedObject());
if (s.getCallsign().isEmpty()) { return; }
emit this->requestComFrequency(s.getFrequency(), CComSystem::Com2);
}
void CAtcStationView::ps_requestTextMessage()
void CAtcStationView::requestTextMessage()
{
const CAtcStation s(this->selectedObject());
if (s.getCallsign().isEmpty()) { return; }

View File

@@ -44,6 +44,9 @@ namespace BlackGui
//! Set station mode
void setStationMode(BlackGui::Models::CAtcStationListModel::AtcStationMode stationMode);
//! \copydoc Models::CAtcStationListModel::changedAtcStationConnectionStatus
void changedAtcStationConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added);
signals:
//! Request some dummy ATC stations
void testRequestDummyAtcOnlineStations(int number);
@@ -54,25 +57,21 @@ namespace BlackGui
//! Request a text message to
void requestTextMessageWidget(const BlackMisc::Aviation::CCallsign &callsign);
public slots:
//! \copydoc Models::CAtcStationListModel::changedAtcStationConnectionStatus
void changedAtcStationConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added);
protected:
//! \copydoc CViewBase::customMenu
virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
private slots:
void ps_testRequest1kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(1000); }
void ps_testRequest3kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(3000); }
void ps_tuneInAtcCom1();
void ps_tuneInAtcCom2();
void ps_requestTextMessage();
private:
void emitTestRequest1kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(1000); }
void emitTestRequest3kAtcOnlineDummies() { emit this->testRequestDummyAtcOnlineStations(3000); }
void tuneInAtcCom1();
void tuneInAtcCom2();
void requestTextMessage();
QList<QAction *> m_actions;
QList<QAction *> m_debugActions;
};
}
}
} // ns
#endif // guard

View File

@@ -69,7 +69,7 @@ namespace BlackGui
protected:
//! \copydoc CViewBase::customMenu
virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
virtual void customMenu(Menus::CMenuActions &menuActions) override;
private:
//! Request text message for selected aircraft

View File

@@ -20,7 +20,6 @@
class QWidget;
namespace BlackMisc { namespace Network { class CTextMessage; } }
namespace BlackGui
{
namespace Views
@@ -28,7 +27,6 @@ namespace BlackGui
//! Airports view
class BLACKGUI_EXPORT CTextMessageView : public CViewBase<Models::CTextMessageListModel, BlackMisc::Network::CTextMessageList, BlackMisc::Network::CTextMessage>
{
public:
//! Constructor
explicit CTextMessageView(QWidget *parent = nullptr);

View File

@@ -19,7 +19,6 @@
class QWidget;
namespace BlackMisc { namespace Weather { class CWindLayer; } }
namespace BlackGui
{
namespace Views
@@ -29,7 +28,6 @@ namespace BlackGui
{
public:
//! Constructor
explicit CWindLayerView(QWidget *parent = nullptr);
};

View File

@@ -31,7 +31,7 @@ namespace BlackMisc
CAltitude CAltitude::withOffset(const CLength &offset) const
{
if (this->isNull()) { return CAltitude(offset, CAltitude::MeanSeaLevel); }
if (this->isNull()) { return CAltitude::null(); }
CAltitude copy(*this);
if (!offset.isNull() && !offset.isZeroEpsilonConsidered())
{

View File

@@ -83,7 +83,7 @@ namespace BlackMisc
//! Normal vector with double precision
virtual std::array<double, 3> normalVectorDouble() const = 0;
//! Is equal, epsilon considered?
//! Is equal? Epsilon considered.
bool equalNormalVectorDouble(const std::array<double, 3> &otherVector) const;
//! Is equal, epsilon considered?
@@ -120,7 +120,7 @@ namespace BlackMisc
//! \copydoc Mixin::Index::propertyByIndex
CVariant propertyByIndex(const CPropertyIndex &index) const;
//! Compare by index
//! \copydoc Mixin::Index::comparePropertyByIndex
int comparePropertyByIndex(const CPropertyIndex &index, const ICoordinateGeodetic &compareValue) const;
//! \copydoc Mixin::String::toQString
@@ -184,7 +184,7 @@ namespace BlackMisc
//! \copydoc Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
//! Compare by index
//! \copydoc Mixin::Index::comparePropertyByIndex
int comparePropertyByIndex(const CPropertyIndex &index, const ICoordinateWithRelativePosition &compareValue) const;
//! \copydoc Mixin::String::toQString

View File

@@ -286,6 +286,11 @@ namespace BlackMisc
int Index<Derived>::comparePropertyByIndex(const CPropertyIndex &index, const Derived &compareValue) const
{
if (this == &compareValue) { return 0; }
if (index.isMyself()) {
// slow, only last resort
return derived()->toQString().compare(compareValue.toQString());
}
const auto i = index.frontCasted<ColumnIndex>();
switch (i)
{
@@ -295,6 +300,8 @@ namespace BlackMisc
default:
break;
}
// slow, only last resort
return derived()->toQString().compare(compareValue.toQString());
}
} // Mixin

View File

@@ -246,10 +246,10 @@ namespace BlackMisc
// list from new to old
CAircraftSituationList updatedSituations; // copy of updated situations
{
const qint64 ts = QDateTime::currentMSecsSinceEpoch();
const qint64 now = QDateTime::currentMSecsSinceEpoch();
QWriteLocker lock(&m_lockSituations);
m_situationsAdded++;
m_situationsLastModified[cs] = ts;
m_situationsLastModified[cs] = now;
CAircraftSituationList &newSituationsList = m_situationsByCallsign[cs];
newSituationsList.setAdjustedSortHint(CAircraftSituationList::AdjustedTimestampLatestFirst);
const int situations = newSituationsList.size();
@@ -469,7 +469,7 @@ namespace BlackMisc
if (!this->isAircraftInRange(callsign)) { return 0; }
// update aircraft situation
const qint64 ts = QDateTime::currentMSecsSinceEpoch();
const qint64 now = QDateTime::currentMSecsSinceEpoch();
const CAircraftModel model = this->getAircraftInRangeModelForCallsign(callsign);
CAircraftSituationChange change;
int updated = 0;
@@ -479,11 +479,11 @@ namespace BlackMisc
if (situations.isEmpty()) { return 0; }
updated = situations.setGroundElevationCheckedAndGuessGround(elevation, info, model, &change);
if (updated < 1) { return 0; }
m_situationsLastModified[callsign] = ts;
const CAircraftSituation latest = situations.front();
if (info == CAircraftSituation::FromProvider && latest.isOnGround())
m_situationsLastModified[callsign] = now;
const CAircraftSituation latestSituation = situations.front();
if (info == CAircraftSituation::FromProvider && latestSituation.isOnGround())
{
m_latestOnGroundProviderElevation[callsign] = latest;
m_latestOnGroundProviderElevation[callsign] = latestSituation;
}
}