From e5452886308203aca08e29770ce62805b72f9bf5 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 27 Sep 2014 15:51:00 +0200 Subject: [PATCH] refs#325, made simulator component CDockWidgetInfoAreaComponent compliant, finetuning with resizing in some components * updates can be skipped, when widget is invisible * current tab? only current tab updates * reduced resize frequency in some cases --- src/blackgui/components/aircraftcomponent.cpp | 8 +++++--- src/blackgui/components/logcomponent.cpp | 1 + src/blackgui/components/simulatorcomponent.cpp | 8 ++++++-- src/blackgui/components/simulatorcomponent.h | 6 +++++- src/swiftgui_standard/mainwindow.cpp | 2 ++ 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/blackgui/components/aircraftcomponent.cpp b/src/blackgui/components/aircraftcomponent.cpp index 87d3d1c2e..edfe4d03e 100644 --- a/src/blackgui/components/aircraftcomponent.cpp +++ b/src/blackgui/components/aircraftcomponent.cpp @@ -27,6 +27,7 @@ namespace BlackGui ui(new Ui::CAircraftComponent), m_timerComponent(nullptr) { ui->setupUi(this); + this->ui->tvp_AirportsInRange->setResizeMode(CAirportView::ResizingOnce); m_timerComponent = new CTimerBasedComponent(SLOT(update()), this); connect(this->ui->tvp_AircraftsInRange, &CAircraftView::countChanged, this, &CAircraftComponent::ps_countChanged); @@ -58,7 +59,8 @@ namespace BlackGui if (this->getIContextNetwork()->isConnected()) { - if (this->countAircrafts() < 1 || this->isVisibleWidget()) + bool visible = (this->isVisibleWidget() && this->currentWidget() == this->ui->tb_AircraftsInRange); + if (this->countAircrafts() < 1 || visible) { this->ui->tvp_AircraftsInRange->updateContainer(this->getIContextNetwork()->getAircraftsInRange()); } @@ -70,7 +72,8 @@ namespace BlackGui } if (this->getIContextSimulator()->isConnected()) { - if (this->countAirportsInRange() < 1 || this->isVisibleWidget()) + bool visible = (this->isVisibleWidget() && this->currentWidget() == this->ui->tb_AirportsInRange); + if (this->countAirportsInRange() < 1 || visible) { this->ui->tvp_AirportsInRange->updateContainer(this->getIContextSimulator()->getAirportsInRange()); } @@ -111,6 +114,5 @@ namespace BlackGui this->tabBar()->setTabText(ap, aps); } - } // namespace } // namespace diff --git a/src/blackgui/components/logcomponent.cpp b/src/blackgui/components/logcomponent.cpp index 297b19006..7e3faf91c 100644 --- a/src/blackgui/components/logcomponent.cpp +++ b/src/blackgui/components/logcomponent.cpp @@ -19,6 +19,7 @@ namespace BlackGui QFrame(parent), ui(new Ui::CLogComponent) { ui->setupUi(this); + this->ui->tvp_StatusMessages->setAutoResizeFrequency(3); } CLogComponent::~CLogComponent() diff --git a/src/blackgui/components/simulatorcomponent.cpp b/src/blackgui/components/simulatorcomponent.cpp index 8fb4649ae..7d46af5ae 100644 --- a/src/blackgui/components/simulatorcomponent.cpp +++ b/src/blackgui/components/simulatorcomponent.cpp @@ -16,10 +16,13 @@ namespace BlackGui namespace Components { CSimulatorComponent::CSimulatorComponent(QWidget *parent) : - QTabWidget(parent), ui(new Ui::CSimulatorComponent) + QTabWidget(parent), + CDockWidgetInfoAreaComponent(this), + ui(new Ui::CSimulatorComponent) { ui->setupUi(this); this->ui->tvp_LiveData->setIconMode(true); + this->ui->tvp_LiveData->setAutoResizeFrequency(10); // only resize every n-th time this->addOrUpdateByName("info", "no data yet", CIcons::StandardIconWarning16); } @@ -30,7 +33,8 @@ namespace BlackGui void CSimulatorComponent::addOrUpdateByName(const QString &name, const QString &value, const CIcon &icon) { - this->ui->tvp_LiveData->addOrUpdateByName(name, value, icon); + bool resize = this->currentWidget() == this->ui->tb_LiveData; // simulator live data selected? + this->ui->tvp_LiveData->addOrUpdateByName(name, value, icon, resize, false); } void CSimulatorComponent::addOrUpdateByName(const QString &name, const QString &value, CIcons::IconIndex iconIndex) diff --git a/src/blackgui/components/simulatorcomponent.h b/src/blackgui/components/simulatorcomponent.h index ffd0b90ac..8c57804d4 100644 --- a/src/blackgui/components/simulatorcomponent.h +++ b/src/blackgui/components/simulatorcomponent.h @@ -14,6 +14,7 @@ #include "runtimebasedcomponent.h" #include "blackmisc/icon.h" +#include "blackgui/components/dockwidgetinfoareacomponent.h" #include namespace Ui { class CSimulatorComponent; } @@ -23,7 +24,10 @@ namespace BlackGui { //! Simulator component - class CSimulatorComponent : public QTabWidget, public CRuntimeBasedComponent + class CSimulatorComponent : + public QTabWidget, + public CDockWidgetInfoAreaComponent, + public CRuntimeBasedComponent { Q_OBJECT diff --git a/src/swiftgui_standard/mainwindow.cpp b/src/swiftgui_standard/mainwindow.cpp index c494f8fcc..9b79fbb48 100644 --- a/src/swiftgui_standard/mainwindow.cpp +++ b/src/swiftgui_standard/mainwindow.cpp @@ -443,6 +443,8 @@ void MainWindow::updateSimulatorData() { CSimulatorComponent *simComp = this->ui->comp_MainInfoArea->getSimulatorComponent(); Q_ASSERT(simComp); + + if (!simComp->isVisibleWidget()) return; // no updates on invisible widgets if (!this->getIContextSimulator()->isConnected()) { simComp->clear();