refs #538, Formatting, minor tweaks, comments

* new slot syntax in ATC station component
* formatting, comments
* tab order
* utility function for severity in status message
* null checks in threadutils
* invalidKey function in datastore
* changed data object keys (cached objets)
* added missing value object compare cases
* renamed timer in context network
* finder function for model list
* renamed getContainer to container (as it is just a reference)
This commit is contained in:
Klaus Basan
2015-12-05 16:39:54 +01:00
parent 66ff1803cf
commit 8f85c54989
24 changed files with 90 additions and 45 deletions

View File

@@ -53,21 +53,20 @@ namespace BlackGui
this->ui->tvp_AtcStationsOnlineTree->setHeaderHidden(true);
// Signal / Slots
bool connected = this->connect(this->ui->le_AtcStationsOnlineMetar, SIGNAL(returnPressed()), this, SLOT(getMetar()));
Q_ASSERT(connected);
connected = this->connect(this->ui->pb_AtcStationsLoadMetar, SIGNAL(clicked()), this, SLOT(getMetar()));
Q_ASSERT(connected);
Q_UNUSED(connected);
connect(this->ui->le_AtcStationsOnlineMetar, &QLineEdit::returnPressed, this, &CAtcStationComponent::ps_getMetarAsEntered);
connect(this->ui->pb_AtcStationsLoadMetar, &QPushButton::clicked, this, &CAtcStationComponent::ps_getMetarAsEntered);
connect(this, &QTabWidget::currentChanged, this, &CAtcStationComponent::ps_atcStationsTabChanged); // "local" tab changed (booked, online)
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::requestNewBackendData, this, &CAtcStationComponent::ps_requestOnlineStationsUpdate);
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_AtcStationsOnline, &CAtcStationView::requestTextMessageWidget, this, &CAtcStationComponent::requestTextMessageWidget);
connect(this->ui->tvp_AtcStationsBooked, &CAtcStationView::requestUpdate, this, &CAtcStationComponent::ps_reloadAtcStationsBooked);
connect(this->ui->tvp_AtcStationsBooked, &CAtcStationView::requestNewBackendData, this, &CAtcStationComponent::ps_reloadAtcStationsBooked);
connect(this->ui->tvp_AtcStationsBooked, &CAtcStationView::rowCountChanged, this, &CAtcStationComponent::ps_onCountChanged);
connect(this->ui->pb_AtcStationsAtisReload, &QPushButton::clicked, this, &CAtcStationComponent::ps_requestAtis);
@@ -133,7 +132,6 @@ namespace BlackGui
);
this->m_timestampLastReadOnlineStations = QDateTime::currentDateTimeUtc();
this->m_timestampOnlineStationsChanged = this->m_timestampLastReadOnlineStations;
this->updateTreeView();
}
}
@@ -151,7 +149,7 @@ namespace BlackGui
void CAtcStationComponent::getMetar(const QString &airportIcaoCode)
{
QString icao = airportIcaoCode.isEmpty() ? this->ui->le_AtcStationsOnlineMetar->text().trimmed().toUpper() : airportIcaoCode.trimmed().toUpper();
QString icao(airportIcaoCode.isEmpty() ? this->ui->le_AtcStationsOnlineMetar->text().trimmed().toUpper() : airportIcaoCode.trimmed().toUpper());
this->ui->le_AtcStationsOnlineMetar->setText(icao);
if (icao.length() != 4) { return; }
CMetar metar(this->getIContextNetwork()->getMetarForAirport(icao));
@@ -183,7 +181,7 @@ namespace BlackGui
}
else
{
this->ui->tvp_AtcStationsBooked->updateContainer(this->getIContextNetwork()->getAtcStationsBooked());
this->ui->tvp_AtcStationsBooked->updateContainerMaybeAsync(this->getIContextNetwork()->getAtcStationsBooked());
this->m_timestampLastReadBookedStations = QDateTime::currentDateTimeUtc();
}
}
@@ -235,7 +233,7 @@ namespace BlackGui
if (this->isParentDockWidgetFloating()) { return; }
// here I know I am the selected widget, update, but keep GUI responsive (-> timer)
QTimer::singleShot(1000, this, SLOT(update()));
QTimer::singleShot(1000, this, &CAtcStationComponent::update);
Q_UNUSED(index);
}
@@ -263,6 +261,7 @@ namespace BlackGui
void CAtcStationComponent::updateTreeView()
{
// EXPERIMENTAL CODE
//! \todo change model so we can directly use hierarchies
QAbstractItemModel *old = (this->ui->tvp_AtcStationsOnlineTree->model());
this->ui->tvp_AtcStationsOnlineTree->setModel(
this->ui->tvp_AtcStationsOnline->derivedModel()->toAtcGroupModel()

View File

@@ -66,7 +66,7 @@ namespace BlackGui
void stopTimer() { Q_ASSERT(this->m_updateTimer); this->m_updateTimer->stopTimer(); }
//! Get METAR for given ICAO airport code
void getMetar(const QString &airportIcaoCode = "");
void getMetar(const QString &airportIcaoCode);
//! \copydoc CAtcStationListModel::changedAtcStationConnectionStatus
void changedAtcStationOnlineConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added);
@@ -76,6 +76,9 @@ namespace BlackGui
void runtimeHasBeenSet() override;
private slots:
//! Get all METARs
void ps_getMetarAsEntered() { this->getMetar(""); }
//! Request new ATIS
void ps_requestAtis();

View File

@@ -2,6 +2,14 @@
<ui version="4.0">
<class>CDbLoginComponent</class>
<widget class="QFrame" name="CDbLoginComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>345</width>
<height>325</height>
</rect>
</property>
<property name="windowTitle">
<string>DB login</string>
</property>
@@ -73,7 +81,7 @@
<item>
<widget class="QLabel" name="lbl_SwiftDB">
<property name="text">
<string>DB</string>
<string>DB replaced by URL</string>
</property>
</widget>
</item>
@@ -126,7 +134,7 @@
<item row="0" column="0">
<widget class="QLabel" name="lbl_User">
<property name="text">
<string>User:</string>
<string>Name:</string>
</property>
</widget>
</item>

View File

@@ -71,6 +71,7 @@ namespace BlackGui
this->ui->lbl_AircraftIconDisplayed->setText("Icon displayed here");
// Updates
this->ui->tvp_AircraftModels->setDisplayAutomatically(false);
this->m_updateTimer->setUpdateInterval(10 * 1000);
}
@@ -92,7 +93,7 @@ namespace BlackGui
CAircraftModelList CMappingComponent::findModelsStartingWith(const QString modelName, Qt::CaseSensitivity cs)
{
Q_ASSERT(this->ui->tvp_AircraftModels);
return this->ui->tvp_AircraftModels->getContainer().findModelsStartingWith(modelName, cs);
return this->ui->tvp_AircraftModels->container().findModelsStartingWith(modelName, cs);
}
void CMappingComponent::runtimeHasBeenSet()
@@ -217,7 +218,7 @@ namespace BlackGui
}
const CCallsign callsign(cs);
bool hasCallsign = this->ui->tvp_SimulatedAircraft->getContainer().containsCallsign(callsign);
bool hasCallsign = this->ui->tvp_SimulatedAircraft->container().containsCallsign(callsign);
if (!hasCallsign)
{
CLogMessage(this).validationError("Unmapped callsign %1 for mapping") << callsign.asString();
@@ -231,7 +232,7 @@ namespace BlackGui
return;
}
bool hasModel = this->ui->tvp_AircraftModels->getContainer().containsModelString(modelString);
bool hasModel = this->ui->tvp_AircraftModels->container().containsModelString(modelString);
if (!hasModel)
{
CLogMessage(this).validationError("Invalid model for mapping");
@@ -297,7 +298,7 @@ namespace BlackGui
void CMappingComponent::ps_onModelsUpdateRequested()
{
Q_ASSERT(getIContextSimulator());
CAircraftModelList ml = getIContextSimulator()->getInstalledModels();
CAircraftModelList ml(getIContextSimulator()->getInstalledModels());
this->ui->tvp_AircraftModels->updateContainer(ml);
// model completer