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
This commit is contained in:
Klaus Basan
2014-09-27 15:51:00 +02:00
parent 7304d8bd3e
commit e545288630
5 changed files with 19 additions and 6 deletions

View File

@@ -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

View File

@@ -19,6 +19,7 @@ namespace BlackGui
QFrame(parent), ui(new Ui::CLogComponent)
{
ui->setupUi(this);
this->ui->tvp_StatusMessages->setAutoResizeFrequency(3);
}
CLogComponent::~CLogComponent()

View File

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

View File

@@ -14,6 +14,7 @@
#include "runtimebasedcomponent.h"
#include "blackmisc/icon.h"
#include "blackgui/components/dockwidgetinfoareacomponent.h"
#include <QTabWidget>
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

View File

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