mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Some refactoring for model base / view base
* update by int index (row) * updateContainer renaming
This commit is contained in:
@@ -35,11 +35,11 @@ namespace BlackGui
|
||||
|
||||
if (this->getIContextNetwork()->isConnected())
|
||||
{
|
||||
this->ui->tvp_AircraftsInRange->update(this->getIContextNetwork()->getAircraftsInRange());
|
||||
this->ui->tvp_AircraftsInRange->updateContainer(this->getIContextNetwork()->getAircraftsInRange());
|
||||
}
|
||||
if (this->getIContextSimulator()->isConnected())
|
||||
{
|
||||
this->ui->tvp_AirportsInRange->update(this->getIContextSimulator()->getAirportsInRange());
|
||||
this->ui->tvp_AirportsInRange->updateContainer(this->getIContextSimulator()->getAirportsInRange());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace BlackGui
|
||||
if (this->m_timestampOnlineStationsChanged.isNull() || this->m_timestampLastReadOnlineStations.isNull() ||
|
||||
(this->m_timestampOnlineStationsChanged > this->m_timestampLastReadOnlineStations))
|
||||
{
|
||||
this->ui->tvp_AtcStationsOnline->update(this->getIContextNetwork()->getAtcStationsOnline());
|
||||
this->ui->tvp_AtcStationsOnline->updateContainer(this->getIContextNetwork()->getAtcStationsOnline());
|
||||
this->m_timestampLastReadOnlineStations = QDateTime::currentDateTimeUtc();
|
||||
this->m_timestampOnlineStationsChanged = this->m_timestampLastReadOnlineStations;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ namespace BlackGui
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->tvp_AtcStationsBooked->update(this->getIContextNetwork()->getAtcStationsBooked());
|
||||
this->ui->tvp_AtcStationsBooked->updateContainer(this->getIContextNetwork()->getAtcStationsBooked());
|
||||
this->m_timestampLastReadBookedStations = QDateTime::currentDateTimeUtc();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ namespace BlackGui
|
||||
if (room1.isConnected())
|
||||
{
|
||||
this->ui->le_CockpitVoiceRoomCom1->setStyleSheet("background: green");
|
||||
if (this->getIContextAudio()) this->ui->tvp_CockpitVoiceRoom1->update(this->getIContextAudio()->getCom1RoomUsers());
|
||||
if (this->getIContextAudio()) this->ui->tvp_CockpitVoiceRoom1->updateContainer(this->getIContextAudio()->getCom1RoomUsers());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -379,12 +379,12 @@ namespace BlackGui
|
||||
{
|
||||
if (!this->getIContextAudio()) return;
|
||||
if (!this->ui->le_CockpitVoiceRoomCom1->text().trimmed().isEmpty())
|
||||
this->ui->tvp_CockpitVoiceRoom1->update(this->getIContextAudio()->getCom1RoomUsers());
|
||||
this->ui->tvp_CockpitVoiceRoom1->updateContainer(this->getIContextAudio()->getCom1RoomUsers());
|
||||
else
|
||||
this->ui->tvp_CockpitVoiceRoom1->clear();
|
||||
|
||||
if (!this->ui->le_CockpitVoiceRoomCom2->text().trimmed().isEmpty())
|
||||
this->ui->tvp_CockpitVoiceRoom2->update(this->getIContextAudio()->getCom2RoomUsers());
|
||||
this->ui->tvp_CockpitVoiceRoom2->updateContainer(this->getIContextAudio()->getCom2RoomUsers());
|
||||
else
|
||||
this->ui->tvp_CockpitVoiceRoom2->clear();
|
||||
}
|
||||
|
||||
@@ -106,10 +106,10 @@ namespace BlackGui
|
||||
|
||||
// update servers
|
||||
this->ui->tvp_SettingsTnServers->setSelectedServer(nws.getCurrentTrafficNetworkServer());
|
||||
this->ui->tvp_SettingsTnServers->update(nws.getTrafficNetworkServers());
|
||||
this->ui->tvp_SettingsTnServers->updateContainer(nws.getTrafficNetworkServers());
|
||||
|
||||
// update hot keys
|
||||
this->ui->tvp_SettingsMiscHotkeys->update(this->getIContextSettings()->getHotkeys());
|
||||
this->ui->tvp_SettingsMiscHotkeys->updateContainer(this->getIContextSettings()->getHotkeys());
|
||||
|
||||
// fake setting for sound notifications
|
||||
this->ui->cb_SettingsAudioPlayNotificationSounds->setChecked(true);
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace BlackGui
|
||||
|
||||
if (this->getIContextNetwork()->isConnected())
|
||||
{
|
||||
this->ui->tvp_Clients->update(this->getIContextNetwork()->getOtherClients());
|
||||
this->ui->tvp_AllUsers->update(this->getIContextNetwork()->getUsers());
|
||||
this->ui->tvp_Clients->updateContainer(this->getIContextNetwork()->getOtherClients());
|
||||
this->ui->tvp_AllUsers->updateContainer(this->getIContextNetwork()->getUsers());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +126,12 @@ namespace BlackGui
|
||||
//! Update single element
|
||||
virtual void update(const QModelIndex &index, const ObjectType &object);
|
||||
|
||||
//! Update single element
|
||||
virtual void update(int rowIndex, const ObjectType &object)
|
||||
{
|
||||
this->update(this->index(rowIndex), object);
|
||||
}
|
||||
|
||||
//! Object at row position
|
||||
virtual const ObjectType &at(const QModelIndex &index) const
|
||||
{
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace BlackGui
|
||||
//! Clear
|
||||
void clear() { Q_ASSERT(this->m_model); this->m_model->clear(); }
|
||||
|
||||
//! Update
|
||||
template<class ContainerType> int update(const ContainerType &container, bool resize = true)
|
||||
//! Update whole container
|
||||
template<class ContainerType> int updateContainer(const ContainerType &container, bool resize = true)
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
int c = this->m_model->update(container);
|
||||
@@ -82,6 +82,13 @@ namespace BlackGui
|
||||
return this->m_model->rowCount();
|
||||
}
|
||||
|
||||
//! Column count
|
||||
int columnCount() const
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
return this->m_model->columnCount();
|
||||
}
|
||||
|
||||
//! Any data?
|
||||
bool isEmpty() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user