refs #368, updated components

* clear when connection status changed
* rowCount changed with filter parameter
This commit is contained in:
Klaus Basan
2015-01-18 23:27:18 +01:00
parent 5ae8f074b8
commit f0cc1ac003
9 changed files with 66 additions and 17 deletions

View File

@@ -13,9 +13,12 @@
#include "../guiutility.h"
#include "blackcore/context_network.h"
#include "blackcore/context_simulator.h"
#include "blackcore/network.h"
using namespace BlackGui;
using namespace BlackGui::Views;
using namespace BlackCore;
namespace BlackGui
{
@@ -31,8 +34,8 @@ namespace BlackGui
this->ui->tvp_AirportsInRange->setResizeMode(CAirportView::ResizingOnce);
m_updateTimer = new CUpdateTimer(SLOT(update()), this);
connect(this->ui->tvp_AircraftInRange, &CAircraftView::countChanged, this, &CAircraftComponent::ps_countChanged);
connect(this->ui->tvp_AirportsInRange, &CAircraftView::countChanged, this, &CAircraftComponent::ps_countChanged);
connect(this->ui->tvp_AircraftInRange, &CAircraftView::rowCountChanged, this, &CAircraftComponent::ps_onRowCountChanged);
connect(this->ui->tvp_AirportsInRange, &CAircraftView::rowCountChanged, this, &CAircraftComponent::ps_onRowCountChanged);
}
CAircraftComponent::~CAircraftComponent()
@@ -76,7 +79,9 @@ namespace BlackGui
void CAircraftComponent::runtimeHasBeenSet()
{
Q_ASSERT(this->getIContextNetwork());
connect(this->getParentInfoArea(), &CInfoArea::changedInfoAreaTabBarIndex, this, &CAircraftComponent::ps_infoAreaTabBarChanged);
connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAircraftComponent::ps_connectionStatusChanged);
}
void CAircraftComponent::ps_infoAreaTabBarChanged(int index)
@@ -91,9 +96,10 @@ namespace BlackGui
Q_UNUSED(index);
}
void CAircraftComponent::ps_countChanged(int count)
void CAircraftComponent::ps_onRowCountChanged(int count, bool withFilter)
{
Q_UNUSED(count);
Q_UNUSED(withFilter);
int ac = this->indexOf(this->ui->tb_AircraftInRange);
int ap = this->indexOf(this->ui->tb_AirportsInRange);
QString acs = this->tabBar()->tabText(ac);
@@ -104,5 +110,16 @@ namespace BlackGui
this->tabBar()->setTabText(ap, aps);
}
void CAircraftComponent::ps_connectionStatusChanged(uint from, uint to)
{
INetwork::ConnectionStatus fromStatus = static_cast<INetwork::ConnectionStatus>(from);
INetwork::ConnectionStatus toStatus = static_cast<INetwork::ConnectionStatus>(to);
Q_UNUSED(fromStatus);
if (INetwork::isDisconnectedStatus(toStatus))
{
this->ui->tvp_AircraftInRange->clear();
}
}
} // namespace
} // namespace

View File

@@ -71,7 +71,10 @@ namespace BlackGui
void ps_infoAreaTabBarChanged(int index);
//! Number of elements changed
void ps_countChanged(int count);
void ps_onRowCountChanged(int count, bool withFilter);
//! Connection status has been changed
void ps_connectionStatusChanged(uint from, uint to);
private:
QScopedPointer<Ui::CAircraftComponent> ui;

View File

@@ -57,12 +57,12 @@ namespace BlackGui
connect(this->ui->tvp_AtcStationsOnline, &QTableView::clicked, this, &CAtcStationComponent::ps_onlineAtcStationSelected);
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::testRequestDummyAtcOnlineStations, this, &CAtcStationComponent::ps_testCreateDummyOnlineAtcStations);
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::requestUpdate, this, &CAtcStationComponent::ps_requestOnlineStationsUpdate);
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::countChanged, this, &CAtcStationComponent::ps_countChanged);
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::countChanged, this, &CAtcStationComponent::ps_countChanged);
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::rowCountChanged, this, &CAtcStationComponent::ps_onCountChanged);
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::rowCountChanged, this, &CAtcStationComponent::ps_onCountChanged);
connect(this->ui->tvp_AtcStationsOnline, &CAtcStationView::requestComFrequency, this, &CAtcStationComponent::ps_setComFrequency);
connect(this->ui->tvp_AtcStationsBooked, &CAtcStationView::requestUpdate, this, &CAtcStationComponent::ps_reloadAtcStationsBooked);
connect(this->ui->tvp_AtcStationsBooked, &CAtcStationView::countChanged, this, &CAtcStationComponent::ps_countChanged);
connect(this->ui->tvp_AtcStationsBooked, &CAtcStationView::rowCountChanged, this, &CAtcStationComponent::ps_onCountChanged);
connect(this->ui->pb_AtcStationsAtisReload, &QPushButton::clicked, this, &CAtcStationComponent::ps_requestAtis);
}
@@ -231,9 +231,10 @@ namespace BlackGui
Q_UNUSED(index);
}
void CAtcStationComponent::ps_countChanged(int count)
void CAtcStationComponent::ps_onCountChanged(int count, bool withFilter)
{
Q_UNUSED(count);
Q_UNUSED(withFilter);
int io = this->indexOf(this->ui->tb_AtcStationsOnline);
int ib = this->indexOf(this->ui->tb_AtcStationsBooked);
QString o = this->tabBar()->tabText(io);

View File

@@ -107,7 +107,7 @@ namespace BlackGui
void ps_infoAreaTabBarChanged(int index);
//! Count has been changed
void ps_countChanged(int count);
void ps_onCountChanged(int count, bool withFilter);
//! Set COM frequency
void ps_setComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ComUnit unit);

View File

@@ -246,7 +246,7 @@ namespace BlackGui
bool CCockpitComComponent::updateOwnCockpitInContext(const CAircraft &ownAircraft)
{
return this->getIContextOwnAircraft()->updateOwnCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), ownAircraft.getTransponder(), CCockpitComComponent::cockpitOriginator());
return this->getIContextOwnAircraft()->updateCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), ownAircraft.getTransponder(), CCockpitComComponent::cockpitOriginator());
}
void CCockpitComComponent::updateFrequencyDisplaysFromComSystems(const CComSystem &com1, const CComSystem &com2)

View File

@@ -69,7 +69,7 @@ namespace BlackGui
this->setMode(mode);
CTransponder xpdr = ownAircraft.getTransponder();
xpdr.setTransponderMode(mode);
this->getIContextOwnAircraft()->updateOwnCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), xpdr, ledsOriginator());
this->getIContextOwnAircraft()->updateCockpit(ownAircraft.getCom1System(), ownAircraft.getCom2System(), xpdr, ledsOriginator());
}
void CCockpitTransponderModeLedsComponent::init(bool horizontal)

View File

@@ -63,9 +63,9 @@ namespace BlackGui
{
if (!this->isVisibleWidget()) return; // no updates on invisible widgets
if (!this->getIContextOwnAircraft()) return;
if (!this->getIContextSimulator()->isRunning())
if (!this->getIContextSimulator()->isSimulating())
{
if (this->rowCount() == 1) return;
if (this->rowCount() == 1) { return; }
this->clear();
this->addOrUpdateByName("info", "sim not running", CIcons::StandardIconWarning16);
return;

View File

@@ -12,9 +12,11 @@
#include "../guiutility.h"
#include "blackmisc/nwuserlist.h"
#include "blackcore/context_network.h"
#include "blackcore/network.h"
using namespace BlackGui;
using namespace BlackGui::Views;
using namespace BlackCore;
namespace BlackGui
{
@@ -30,8 +32,8 @@ namespace BlackGui
this->tabBar()->setExpanding(false);
this->m_updateTimer = new CUpdateTimer(SLOT(update()), this);
connect(this->ui->tvp_AllUsers, &CUserView::countChanged, this, &CUserComponent::ps_countChanged);
connect(this->ui->tvp_Clients, &CClientView::countChanged, this, &CUserComponent::ps_countChanged);
connect(this->ui->tvp_AllUsers, &CUserView::rowCountChanged, this, &CUserComponent::ps_onCountChanged);
connect(this->ui->tvp_Clients, &CClientView::rowCountChanged, this, &CUserComponent::ps_onCountChanged);
}
CUserComponent::~CUserComponent()
@@ -70,9 +72,16 @@ namespace BlackGui
}
}
void CUserComponent::ps_countChanged(int count)
void CUserComponent::runtimeHasBeenSet()
{
Q_ASSERT(this->getIContextNetwork());
this->connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CUserComponent::ps_connectionStatusChanged);
}
void CUserComponent::ps_onCountChanged(int count, bool withFilter)
{
Q_UNUSED(count);
Q_UNUSED(withFilter);
int iu = this->indexOf(this->ui->tb_AllUsers);
int ic = this->indexOf(this->ui->tb_Clients);
QString u = this->tabBar()->tabText(iu);
@@ -83,5 +92,17 @@ namespace BlackGui
this->tabBar()->setTabText(ic, c);
}
void CUserComponent::ps_connectionStatusChanged(uint from, uint to)
{
INetwork::ConnectionStatus fromStatus = static_cast<INetwork::ConnectionStatus>(from);
INetwork::ConnectionStatus toStatus = static_cast<INetwork::ConnectionStatus>(to);
Q_UNUSED(fromStatus);
if (INetwork::isDisconnectedStatus(toStatus))
{
this->ui->tvp_AllUsers->clear();
this->ui->tvp_Clients->clear();
}
}
} // namespace
} // namespace

View File

@@ -63,9 +63,16 @@ namespace BlackGui
//! \copydoc CTimerBasedComponent::stopTimer
void stopTimer() { Q_ASSERT(this->m_updateTimer); this->m_updateTimer->stopTimer(); }
protected:
//! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet
void runtimeHasBeenSet() override;
private slots:
//! Number of elements changed
void ps_countChanged(int count);
void ps_onCountChanged(int count, bool withFilter);
//! Connection status
void ps_connectionStatusChanged(uint from, uint to);
private:
QScopedPointer<Ui::CUserComponent> ui;