Skip to content

Commit f67b828

Browse files
committed
Enabled partial show on map and show information functionality for online network clients.
Added highlight functionality for online network clients/aircraft. Added separate tabs for online network centers and clients. All albar965#45
1 parent 4895514 commit f67b828

29 files changed

+279
-98
lines changed

src/common/mapflags.h

+2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ enum MapObjectType
7171
HELIPAD = 1 << 25, /* Helipads on airports */
7272
COMPASS_ROSE = 1 << 26, /* Compass rose */
7373
USERPOINT = 1 << 27, /* A user defined waypoint - not used to define if should be drawn or not */
74+
7475
AIRSPACE_ONLINE = 1 << 28, /* Online network center */
76+
AIRCRAFT_AI_ONLINE = 1 << 29, /* Online network client/aircraft */
7577

7678
AIRPORT_ALL = AIRPORT | AIRPORT_HARD | AIRPORT_SOFT | AIRPORT_EMPTY | AIRPORT_ADDON,
7779
NAV_ALL = VOR | NDB | WAYPOINT,

src/gui/mainwindow.cpp

+40-25
Original file line numberDiff line numberDiff line change
@@ -724,11 +724,11 @@ void MainWindow::connectAllSlots()
724724

725725
// Airport search ===================================================================================
726726
AirportSearch *airportSearch = searchController->getAirportSearch();
727-
connect(airportSearch, &AirportSearch::showRect, mapWidget, &MapWidget::showRect);
728-
connect(airportSearch, &AirportSearch::showPos, mapWidget, &MapWidget::showPos);
729-
connect(airportSearch, &AirportSearch::changeSearchMark, mapWidget, &MapWidget::changeSearchMark);
730-
connect(airportSearch, &AirportSearch::showInformation, infoController, &InfoController::showInformation);
731-
connect(airportSearch, &AirportSearch::showProcedures,
727+
connect(airportSearch, &SearchBaseTable::showRect, mapWidget, &MapWidget::showRect);
728+
connect(airportSearch, &SearchBaseTable::showPos, mapWidget, &MapWidget::showPos);
729+
connect(airportSearch, &SearchBaseTable::changeSearchMark, mapWidget, &MapWidget::changeSearchMark);
730+
connect(airportSearch, &SearchBaseTable::showInformation, infoController, &InfoController::showInformation);
731+
connect(airportSearch, &SearchBaseTable::showProcedures,
732732
searchController->getProcedureSearch(), &ProcedureSearch::showProcedures);
733733
connect(airportSearch, &SearchBaseTable::routeSetDeparture, routeController, &RouteController::routeSetDeparture);
734734
connect(airportSearch, &SearchBaseTable::routeSetDestination, routeController, &RouteController::routeSetDestination);
@@ -751,16 +751,6 @@ void MainWindow::connectAllSlots()
751751
connect(userSearch, &SearchBaseTable::selectionChanged, this, &MainWindow::searchSelectionChanged);
752752
connect(userSearch, &SearchBaseTable::routeAdd, routeController, &RouteController::routeAdd);
753753

754-
// Online center search ===================================================================================
755-
OnlineCenterSearch *onlineCenterSearch = searchController->getOnlineCenterSearch();
756-
connect(onlineCenterSearch, &OnlineCenterSearch::showRect, mapWidget, &MapWidget::showRect);
757-
connect(onlineCenterSearch, &OnlineCenterSearch::showPos, mapWidget, &MapWidget::showPos);
758-
connect(onlineCenterSearch, &OnlineCenterSearch::changeSearchMark, mapWidget, &MapWidget::changeSearchMark);
759-
connect(onlineCenterSearch, &OnlineCenterSearch::showInformation, infoController, &InfoController::showInformation);
760-
connect(onlineCenterSearch, &OnlineCenterSearch::selectionChanged, this, &MainWindow::searchSelectionChanged);
761-
762-
// Online network ===================================================================================
763-
764754
// User data ===================================================================================
765755
UserdataController *userdataController = NavApp::getUserdataController();
766756
connect(ui->actionUserdataClearDatabase, &QAction::triggered, userdataController, &UserdataController::clearDatabase);
@@ -796,6 +786,20 @@ void MainWindow::connectAllSlots()
796786
OnlineServerSearch *serverSearch = searchController->getOnlineServerSearch();
797787
OnlinedataController *onlinedataController = NavApp::getOnlinedataController();
798788

789+
// Online client search ===================================================================================
790+
connect(clientSearch, &SearchBaseTable::showRect, mapWidget, &MapWidget::showRect);
791+
connect(clientSearch, &SearchBaseTable::showPos, mapWidget, &MapWidget::showPos);
792+
connect(clientSearch, &SearchBaseTable::changeSearchMark, mapWidget, &MapWidget::changeSearchMark);
793+
connect(clientSearch, &SearchBaseTable::showInformation, infoController, &InfoController::showInformation);
794+
connect(clientSearch, &SearchBaseTable::selectionChanged, this, &MainWindow::searchSelectionChanged);
795+
796+
// Online center search ===================================================================================
797+
connect(centerSearch, &SearchBaseTable::showRect, mapWidget, &MapWidget::showRect);
798+
connect(centerSearch, &SearchBaseTable::showPos, mapWidget, &MapWidget::showPos);
799+
connect(centerSearch, &SearchBaseTable::changeSearchMark, mapWidget, &MapWidget::changeSearchMark);
800+
connect(centerSearch, &SearchBaseTable::showInformation, infoController, &InfoController::showInformation);
801+
connect(centerSearch, &SearchBaseTable::selectionChanged, this, &MainWindow::searchSelectionChanged);
802+
799803
// Remove/add buttons and tabs
800804
connect(onlinedataController, &OnlinedataController::onlineNetworkChanged,
801805
this, &MainWindow::updateOnlineActionStates);
@@ -2198,25 +2202,25 @@ void MainWindow::searchSelectionChanged(const SearchBaseTable *source, int selec
21982202
{
21992203
QString selectionLabelText = tr("%1 of %2 %3 selected, %4 visible.%5");
22002204
QString type;
2201-
if(source->getTabIndex() == SEARCH_AIRPORT)
2205+
if(source->getTabIndex() == si::SEARCH_AIRPORT)
22022206
{
22032207
type = tr("Airports");
22042208
ui->labelAirportSearchStatus->setText(selectionLabelText.
22052209
arg(selected).arg(total).arg(type).arg(visible).arg(QString()));
22062210
}
2207-
else if(source->getTabIndex() == SEARCH_NAV)
2211+
else if(source->getTabIndex() == si::SEARCH_NAV)
22082212
{
22092213
type = tr("Navaids");
22102214
ui->labelNavSearchStatus->setText(selectionLabelText.
22112215
arg(selected).arg(total).arg(type).arg(visible).arg(QString()));
22122216
}
2213-
else if(source->getTabIndex() == SEARCH_USER)
2217+
else if(source->getTabIndex() == si::SEARCH_USER)
22142218
{
22152219
type = tr("Userpoints");
22162220
ui->labelUserdata->setText(selectionLabelText.
22172221
arg(selected).arg(total).arg(type).arg(visible).arg(QString()));
22182222
}
2219-
else if(source->getTabIndex() == SEARCH_ONLINE_CLIENT)
2223+
else if(source->getTabIndex() == si::SEARCH_ONLINE_CLIENT)
22202224
{
22212225
type = tr("Clients");
22222226
QString lastUpdate = tr(" Last Update: %1").
@@ -2225,7 +2229,7 @@ void MainWindow::searchSelectionChanged(const SearchBaseTable *source, int selec
22252229
arg(selected).arg(total).arg(type).arg(visible).
22262230
arg(lastUpdate));
22272231
}
2228-
else if(source->getTabIndex() == SEARCH_ONLINE_CENTER)
2232+
else if(source->getTabIndex() == si::SEARCH_ONLINE_CENTER)
22292233
{
22302234
type = tr("Centers");
22312235
QString lastUpdate = tr(" Last Update: %1").
@@ -2514,7 +2518,7 @@ void MainWindow::updateOnlineActionStates()
25142518
// Show action in menu and toolbar
25152519
ui->actionShowAirspacesOnline->setVisible(true);
25162520

2517-
// Add tabs
2521+
// Add tabs in search widget
25182522
if(ui->tabWidgetSearch->indexOf(ui->tabOnlineClientSearch) == -1)
25192523
ui->tabWidgetSearch->addTab(ui->tabOnlineClientSearch, tr("Online Clients"));
25202524

@@ -2523,16 +2527,27 @@ void MainWindow::updateOnlineActionStates()
25232527

25242528
if(ui->tabWidgetSearch->indexOf(ui->tabOnlineServerSearch) == -1)
25252529
ui->tabWidgetSearch->addTab(ui->tabOnlineServerSearch, tr("Online Server"));
2530+
2531+
// Add tabs in information widget
2532+
if(ui->tabWidgetInformation->indexOf(ui->tabOnlineCenterInfo) == -1)
2533+
ui->tabWidgetInformation->addTab(ui->tabOnlineCenterInfo, tr("Online Centers"));
2534+
2535+
if(ui->tabWidgetInformation->indexOf(ui->tabOnlineClientInfo) == -1)
2536+
ui->tabWidgetInformation->addTab(ui->tabOnlineClientInfo, tr("Online Clients"));
25262537
}
25272538
else
25282539
{
25292540
// Hide action in menu and toolbar
25302541
ui->actionShowAirspacesOnline->setVisible(false);
25312542

2532-
// Remove the tabs. Order is important - the search objects remain
2533-
ui->tabWidgetSearch->removeTab(SEARCH_ONLINE_SERVER);
2534-
ui->tabWidgetSearch->removeTab(SEARCH_ONLINE_CENTER);
2535-
ui->tabWidgetSearch->removeTab(SEARCH_ONLINE_CLIENT);
2543+
// Remove the tabs in search. Order is important - the search objects remain
2544+
ui->tabWidgetSearch->removeTab(si::SEARCH_ONLINE_SERVER);
2545+
ui->tabWidgetSearch->removeTab(si::SEARCH_ONLINE_CENTER);
2546+
ui->tabWidgetSearch->removeTab(si::SEARCH_ONLINE_CLIENT);
2547+
2548+
// Remove tabs in information
2549+
ui->tabWidgetInformation->removeTab(ic::INFO_ONLINE_CLIENT);
2550+
ui->tabWidgetInformation->removeTab(ic::INFO_ONLINE_CENTER);
25362551
}
25372552
}
25382553

src/gui/mainwindow.ui

+70
Original file line numberDiff line numberDiff line change
@@ -3897,6 +3897,76 @@
38973897
</item>
38983898
</layout>
38993899
</widget>
3900+
<widget class="QWidget" name="tabOnlineCenterInfo">
3901+
<attribute name="title">
3902+
<string>Online Centers</string>
3903+
</attribute>
3904+
<attribute name="toolTip">
3905+
<string>Online network center information</string>
3906+
</attribute>
3907+
<layout class="QVBoxLayout" name="verticalLayout_26">
3908+
<property name="spacing">
3909+
<number>2</number>
3910+
</property>
3911+
<property name="leftMargin">
3912+
<number>2</number>
3913+
</property>
3914+
<property name="topMargin">
3915+
<number>2</number>
3916+
</property>
3917+
<property name="rightMargin">
3918+
<number>2</number>
3919+
</property>
3920+
<property name="bottomMargin">
3921+
<number>2</number>
3922+
</property>
3923+
<item>
3924+
<widget class="QTextBrowser" name="textBrowserCenterInfo">
3925+
<property name="placeholderText">
3926+
<string>No online network center selected.</string>
3927+
</property>
3928+
<property name="openLinks">
3929+
<bool>false</bool>
3930+
</property>
3931+
</widget>
3932+
</item>
3933+
</layout>
3934+
</widget>
3935+
<widget class="QWidget" name="tabOnlineClientInfo">
3936+
<attribute name="title">
3937+
<string>Online Clients</string>
3938+
</attribute>
3939+
<attribute name="toolTip">
3940+
<string>Online network client/aircraft information</string>
3941+
</attribute>
3942+
<layout class="QVBoxLayout" name="verticalLayout_27">
3943+
<property name="spacing">
3944+
<number>2</number>
3945+
</property>
3946+
<property name="leftMargin">
3947+
<number>2</number>
3948+
</property>
3949+
<property name="topMargin">
3950+
<number>2</number>
3951+
</property>
3952+
<property name="rightMargin">
3953+
<number>2</number>
3954+
</property>
3955+
<property name="bottomMargin">
3956+
<number>2</number>
3957+
</property>
3958+
<item>
3959+
<widget class="QTextBrowser" name="textBrowserClientInfo">
3960+
<property name="placeholderText">
3961+
<string>No online client/aircraft selected.</string>
3962+
</property>
3963+
<property name="openLinks">
3964+
<bool>false</bool>
3965+
</property>
3966+
</widget>
3967+
</item>
3968+
</layout>
3969+
</widget>
39003970
</widget>
39013971
</item>
39023972
</layout>

src/info/infocontroller.cpp

+47-8
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ InfoController::InfoController(MainWindow *parent)
7474
ui->textBrowserWeatherInfo->setSearchPaths(paths);
7575
ui->textBrowserNavaidInfo->setSearchPaths(paths);
7676
ui->textBrowserAirspaceInfo->setSearchPaths(paths);
77+
ui->textBrowserCenterInfo->setSearchPaths(paths);
78+
ui->textBrowserClientInfo->setSearchPaths(paths);
79+
7780
ui->textBrowserAircraftInfo->setSearchPaths(paths);
7881
ui->textBrowserAircraftProgressInfo->setSearchPaths(paths);
7982
ui->textBrowserAircraftAiInfo->setSearchPaths(paths);
@@ -87,9 +90,11 @@ InfoController::InfoController(MainWindow *parent)
8790
connect(ui->textBrowserNavaidInfo, &QTextBrowser::anchorClicked, this, &InfoController::anchorClicked);
8891
connect(ui->textBrowserAirspaceInfo, &QTextBrowser::anchorClicked, this, &InfoController::anchorClicked);
8992

93+
connect(ui->textBrowserCenterInfo, &QTextBrowser::anchorClicked, this, &InfoController::anchorClicked);
94+
connect(ui->textBrowserClientInfo, &QTextBrowser::anchorClicked, this, &InfoController::anchorClicked);
95+
9096
connect(ui->textBrowserAircraftInfo, &QTextBrowser::anchorClicked, this, &InfoController::anchorClicked);
9197
connect(ui->textBrowserAircraftProgressInfo, &QTextBrowser::anchorClicked, this, &InfoController::anchorClicked);
92-
9398
connect(ui->textBrowserAircraftAiInfo, &QTextBrowser::anchorClicked, this, &InfoController::anchorClicked);
9499

95100
connect(ui->tabWidgetAircraft, &QTabWidget::currentChanged, this, &InfoController::currentTabChanged);
@@ -365,6 +370,9 @@ void InfoController::clearInfoTextBrowsers()
365370
ui->textBrowserWeatherInfo->clear();
366371
ui->textBrowserNavaidInfo->clear();
367372
ui->textBrowserAirspaceInfo->clear();
373+
374+
ui->textBrowserClientInfo->clear();
375+
ui->textBrowserCenterInfo->clear();
368376
}
369377

370378
void InfoController::showInformation(map::MapSearchResult result)
@@ -380,7 +388,7 @@ void InfoController::updateAllInformation()
380388
void InfoController::onlineNetworkChanged()
381389
{
382390
// Clear display
383-
NavApp::getMainUi()->textBrowserAirspaceInfo->clear();
391+
NavApp::getMainUi()->textBrowserCenterInfo->clear();
384392

385393
// Remove all online network airspaces from current result
386394
QList<map::MapAirspace> airspaces;
@@ -404,7 +412,7 @@ void InfoController::showInformationInternal(map::MapSearchResult result, bool s
404412
qDebug() << Q_FUNC_INFO;
405413

406414
bool foundAirport = false, foundNavaid = false, foundUserAircraft = false, foundAiAircraft = false,
407-
foundAirspace = false;
415+
foundAirspace = false, foundOnlineCenter = false;
408416
HtmlBuilder html(true);
409417

410418
Ui::MainWindow *ui = NavApp::getMainUi();
@@ -464,26 +472,46 @@ void InfoController::showInformationInternal(map::MapSearchResult result, bool s
464472
// Airspaces ================================================================
465473
if(!result.airspaces.isEmpty())
466474
{
475+
atools::sql::SqlRecord onlineRec;
467476
currentSearchResult.airspaces.clear();
477+
468478
html.clear();
469479
for(const map::MapAirspace& airspace : result.airspaces)
470480
{
481+
if(airspace.online)
482+
continue;
483+
qDebug() << "Found airspace" << airspace.id;
484+
485+
currentSearchResult.airspaces.append(airspace);
486+
infoBuilder->airspaceText(airspace, onlineRec, html);
487+
html.br();
488+
foundAirspace = true;
489+
}
490+
491+
// Update and keep scroll position
492+
atools::gui::util::updateTextEdit(ui->textBrowserAirspaceInfo, html.getHtml());
493+
494+
// Online Center ==================================
495+
html.clear();
496+
for(const map::MapAirspace& airspace : result.airspaces)
497+
{
498+
if(!airspace.online)
499+
continue;
471500
qDebug() << "Found airspace" << airspace.id;
472501

473502
currentSearchResult.airspaces.append(airspace);
474503

475504
// Get extra information for online network ATC
476-
atools::sql::SqlRecord onlineRec;
477505
if(airspace.online)
478506
onlineRec = NavApp::getAirspaceQueryOnline()->getAirspaceRecordById(airspace.id);
479507

480508
infoBuilder->airspaceText(airspace, onlineRec, html);
481509
html.br();
510+
foundOnlineCenter = true;
482511
}
483-
foundAirspace = true;
484512

485513
// Update and keep scroll position
486-
atools::gui::util::updateTextEdit(ui->textBrowserAirspaceInfo, html.getHtml());
514+
atools::gui::util::updateTextEdit(ui->textBrowserCenterInfo, html.getHtml());
487515
}
488516

489517
// Navaids ================================================================
@@ -566,7 +594,7 @@ void InfoController::showInformationInternal(map::MapSearchResult result, bool s
566594
// Show dock windows if needed
567595
if(showWindows)
568596
{
569-
if(foundNavaid || foundAirport || foundAirspace)
597+
if(foundNavaid || foundAirport || foundAirspace || foundOnlineCenter)
570598
{
571599
NavApp::getMainUi()->dockWidgetInformation->show();
572600
NavApp::getMainUi()->dockWidgetInformation->raise();
@@ -581,23 +609,31 @@ void InfoController::showInformationInternal(map::MapSearchResult result, bool s
581609

582610
if(showWindows)
583611
{
612+
// Select message ==========================================================
584613
if(foundNavaid)
585614
mainWindow->setStatusMessage(tr("Showing information for navaid."));
586615
else if(foundAirport)
587616
mainWindow->setStatusMessage(tr("Showing information for airport."));
588617
else if(foundAirspace)
589618
mainWindow->setStatusMessage(tr("Showing information for airspace."));
619+
else if(foundOnlineCenter)
620+
mainWindow->setStatusMessage(tr("Showing information for online center."));
590621

622+
// Select tab to activate ==========================================================
591623
ic::TabIndex idx = static_cast<ic::TabIndex>(ui->tabWidgetInformation->currentIndex());
624+
// Is any airport related tab active?
592625
bool airportActive = idx == ic::INFO_AIRPORT || idx == ic::INFO_RUNWAYS || idx == ic::INFO_COM ||
593626
idx == ic::INFO_APPROACHES || idx == ic::INFO_WEATHER;
594627

628+
// Is the navaid tab active
595629
bool navaidActive = idx == ic::INFO_NAVAID;
596630

597631
ic::TabIndex newIdx = idx;
598632

599-
if(foundAirspace && !foundNavaid && !foundAirport)
633+
if(foundAirspace && !foundOnlineCenter && !foundNavaid && !foundAirport)
600634
newIdx = ic::INFO_AIRSPACE;
635+
else if(foundOnlineCenter && !foundNavaid && !foundAirport)
636+
newIdx = ic::INFO_ONLINE_CENTER;
601637
else if(foundAirport && !foundNavaid)
602638
{
603639
if(!airportActive)
@@ -841,6 +877,9 @@ void InfoController::updateTextEditFontSizes()
841877
setTextEditFontSize(ui->textBrowserNavaidInfo, infoFontPtSize, sizePercent);
842878
setTextEditFontSize(ui->textBrowserAirspaceInfo, infoFontPtSize, sizePercent);
843879

880+
setTextEditFontSize(ui->textBrowserCenterInfo, infoFontPtSize, sizePercent);
881+
setTextEditFontSize(ui->textBrowserClientInfo, infoFontPtSize, sizePercent);
882+
844883
sizePercent = OptionData::instance().getGuiInfoSimSize();
845884
setTextEditFontSize(ui->textBrowserAircraftInfo, simInfoFontPtSize, sizePercent);
846885
setTextEditFontSize(ui->textBrowserAircraftProgressInfo, simInfoFontPtSize, sizePercent);

0 commit comments

Comments
 (0)