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

@@ -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);
};