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