Display number of table rows in tab

* countChanged event
* applied in components
This commit is contained in:
Klaus Basan
2014-09-25 23:37:15 +02:00
parent 84b5cee7d8
commit ae0ef4283c
12 changed files with 119 additions and 23 deletions

View File

@@ -12,6 +12,9 @@
#include "dockwidgetinfoareacomponent.h"
#include "../guiutility.h"
using namespace BlackGui;
using namespace BlackGui::Views;
namespace BlackGui
{
namespace Components
@@ -25,6 +28,9 @@ namespace BlackGui
{
ui->setupUi(this);
m_timerComponent = new CTimerBasedComponent(SLOT(update()), this);
connect(this->ui->tvp_AircraftsInRange, &CAircraftView::countChanged, this, &CAircraftComponent::ps_countChanged);
connect(this->ui->tvp_AirportsInRange, &CAircraftView::countChanged, this, &CAircraftComponent::ps_countChanged);
}
CAircraftComponent::~CAircraftComponent()
@@ -92,5 +98,19 @@ namespace BlackGui
Q_UNUSED(index);
}
void CAircraftComponent::ps_countChanged(int count)
{
Q_UNUSED(count);
int ac = this->indexOf(this->ui->tb_AircraftsInRange);
int ap = this->indexOf(this->ui->tb_AirportsInRange);
QString acs = this->tabBar()->tabText(ac);
QString aps = this->tabBar()->tabText(ap);
acs = CGuiUtility::replaceTabCountValue(acs, this->countAircrafts());
aps = CGuiUtility::replaceTabCountValue(aps, this->countAirportsInRange());
this->tabBar()->setTabText(ac, acs);
this->tabBar()->setTabText(ap, aps);
}
} // namespace
} // namespace

View File

@@ -68,6 +68,9 @@ namespace BlackGui
//! Info area tab bar has changed
void ps_infoAreaTabBarChanged(int index);
//! Number of elements changed
void ps_countChanged(int count);
private:
Ui::CAircraftComponent *ui;
CTimerBasedComponent *m_timerComponent;

View File

@@ -11,10 +11,12 @@
#include "atcstationcomponent.h"
#include "../views/atcstationview.h"
#include "../guiutility.h"
#include "ui_atcstationcomponent.h"
#include "blackmisc/avinformationmessage.h"
#include "blackmisc/logmessage.h"
using namespace BlackGui;
using namespace BlackGui::Models;
using namespace BlackGui::Views;
using namespace BlackMisc::Aviation;
@@ -42,6 +44,7 @@ namespace BlackGui
// set station mode
this->ui->tvp_AtcStationsOnline->setStationMode(CAtcStationListModel::StationsOnline);
this->ui->tvp_AtcStationsBooked->setStationMode(CAtcStationListModel::StationsBooked);
this->ui->tvp_AtcStationsBooked->setResizeMode(CAtcStationView::ResizingOnce);
// Signal / Slots
bool connected = this->connect(this->ui->le_AtcStationsOnlineMetar, SIGNAL(returnPressed()), this, SLOT(getMetar()));
@@ -52,7 +55,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_AtcStationsBooked, &CAtcStationView::requestUpdate, this, &CAtcStationComponent::ps_reloadAtcStationsBooked);
connect(this->ui->tvp_AtcStationsBooked, &CAtcStationView::countChanged, this, &CAtcStationComponent::ps_countChanged);
connect(this->ui->pb_AtcStationsAtisReload, &QPushButton::clicked, this, &CAtcStationComponent::ps_requestAtis);
}
@@ -224,6 +232,19 @@ namespace BlackGui
Q_UNUSED(index);
}
void CAtcStationComponent::ps_countChanged(int count)
{
Q_UNUSED(count);
int io = this->indexOf(this->ui->tb_AtcStationsOnline);
int ib = this->indexOf(this->ui->tb_AtcStationsBooked);
QString o = this->tabBar()->tabText(io);
QString b = this->tabBar()->tabText(ib);
o = CGuiUtility::replaceTabCountValue(o, this->countOnlineStations());
b = CGuiUtility::replaceTabCountValue(b, this->countBookedStations());
this->tabBar()->setTabText(io, o);
this->tabBar()->setTabText(ib, b);
}
void CAtcStationComponent::ps_onlineAtcStationSelected(QModelIndex index)
{
this->ui->te_AtcStationsOnlineInfo->setText(""); // reset

View File

@@ -107,6 +107,9 @@ namespace BlackGui
//! Info area tab bar has changed
void ps_infoAreaTabBarChanged(int index);
//! Count has been changed
void ps_countChanged(int count);
private:
Ui::CAtcStationComponent *ui;
CTimerBasedComponent *m_timerComponent;

View File

@@ -9,8 +9,12 @@
#include "usercomponent.h"
#include "ui_usercomponent.h"
#include "../guiutility.h"
#include "blackmisc/nwuserlist.h"
using namespace BlackGui;
using namespace BlackGui::Views;
namespace BlackGui
{
namespace Components
@@ -23,6 +27,9 @@ namespace BlackGui
{
ui->setupUi(this);
this->m_timerComponent = new CTimerBasedComponent(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);
}
CUserComponent::~CUserComponent()
@@ -63,5 +70,19 @@ namespace BlackGui
this->ui->tvp_AllUsers->updateContainer(this->getIContextNetwork()->getUsers());
}
}
}
} // guard
void CUserComponent::ps_countChanged(int count)
{
Q_UNUSED(count);
int iu = this->indexOf(this->ui->tb_AllUsers);
int ic = this->indexOf(this->ui->tb_Clients);
QString u = this->tabBar()->tabText(iu);
QString c = this->tabBar()->tabText(ic);
u = CGuiUtility::replaceTabCountValue(u, this->countUsers());
c = CGuiUtility::replaceTabCountValue(c, this->countClients());
this->tabBar()->setTabText(iu, u);
this->tabBar()->setTabText(ic, c);
}
} // namespace
} // namespace

View File

@@ -62,6 +62,10 @@ namespace BlackGui
//! \copydoc CTimerBasedComponent::stopTimer
void stopTimer() { Q_ASSERT(this->m_timerComponent); this->m_timerComponent->stopTimer(); }
private slots:
//! Number of elements changed
void ps_countChanged(int count);
private:
Ui::CUserComponent *ui;
CTimerBasedComponent *m_timerComponent;