mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
refs #325, reduced loading in aircraft component
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "aircraftcomponent.h"
|
||||
#include "dockwidgetinfoareacomponent.h"
|
||||
#include "ui_aircraftcomponent.h"
|
||||
|
||||
namespace BlackGui
|
||||
@@ -30,6 +31,18 @@ namespace BlackGui
|
||||
delete ui;
|
||||
}
|
||||
|
||||
int CAircraftComponent::countAircrafts() const
|
||||
{
|
||||
Q_ASSERT(this->ui->tvp_AircraftsInRange);
|
||||
return this->ui->tvp_AircraftsInRange->rowCount();
|
||||
}
|
||||
|
||||
int CAircraftComponent::countAirportsInRange() const
|
||||
{
|
||||
Q_ASSERT(this->ui->tvp_AirportsInRange);
|
||||
return this->ui->tvp_AirportsInRange->rowCount();
|
||||
}
|
||||
|
||||
void CAircraftComponent::update()
|
||||
{
|
||||
Q_ASSERT(this->ui->tvp_AircraftsInRange);
|
||||
@@ -38,12 +51,45 @@ namespace BlackGui
|
||||
|
||||
if (this->getIContextNetwork()->isConnected())
|
||||
{
|
||||
this->ui->tvp_AircraftsInRange->updateContainer(this->getIContextNetwork()->getAircraftsInRange());
|
||||
if (this->countAircrafts() < 1 || this->isVisibleWidget())
|
||||
{
|
||||
this->ui->tvp_AircraftsInRange->updateContainer(this->getIContextNetwork()->getAircraftsInRange());
|
||||
}
|
||||
else
|
||||
{
|
||||
// KWB remove: qDebug() will be removed soo
|
||||
qDebug() << this->objectName() << "Skipping update (aircrafts)";
|
||||
}
|
||||
}
|
||||
if (this->getIContextSimulator()->isConnected())
|
||||
{
|
||||
this->ui->tvp_AirportsInRange->updateContainer(this->getIContextSimulator()->getAirportsInRange());
|
||||
if (this->countAirportsInRange() < 1 || this->isVisibleWidget())
|
||||
{
|
||||
this->ui->tvp_AirportsInRange->updateContainer(this->getIContextSimulator()->getAirportsInRange());
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << this->objectName() << "Skipping update (airports)";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftComponent::runtimeHasBeenSet()
|
||||
{
|
||||
connect(this->getParentInfoArea(), &CInfoArea::tabBarCurrentChanged, this, &CAircraftComponent::ps_infoAreaTabBarChanged);
|
||||
}
|
||||
|
||||
void CAircraftComponent::ps_infoAreaTabBarChanged(int index)
|
||||
{
|
||||
// ignore in those cases
|
||||
if (!this->isVisibleWidget()) return;
|
||||
if (this->isParentDockWidgetFloating()) return;
|
||||
if (!this->getIContextNetwork()->isConnected()) return;
|
||||
|
||||
// here I know I am the selected widget, update, but keep GUI responsive (hence
|
||||
QTimer::singleShot(1000, this, SLOT(update()));
|
||||
Q_UNUSED(index);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user