Minor UI and style fixes

* completer for airports in ATC component
* log messages
* style fixes
This commit is contained in:
Klaus Basan
2016-11-20 23:03:06 +01:00
parent 1f57f7ca61
commit 20b4044d29
5 changed files with 53 additions and 13 deletions

View File

@@ -9,10 +9,12 @@
#include "blackcore/context/contextnetwork.h"
#include "blackcore/context/contextownaircraft.h"
#include "blackcore/webdataservices.h"
#include "blackgui/components/atcstationcomponent.h"
#include "blackgui/guiapplication.h"
#include "blackgui/guiutility.h"
#include "blackgui/infoarea.h"
#include "blackgui/uppercasevalidator.h"
#include "blackgui/models/atcstationlistmodel.h"
#include "blackgui/views/atcstationview.h"
#include "blackgui/views/viewbase.h"
@@ -34,6 +36,7 @@
#include <QTextEdit>
#include <QTimer>
#include <QTreeView>
#include <QCompleter>
using namespace BlackGui;
using namespace BlackGui::Models;
@@ -58,6 +61,8 @@ namespace BlackGui
ui->setupUi(this);
this->tabBar()->setExpanding(false);
this->tabBar()->setUsesScrollButtons(true);
CUpperCaseValidator *ucv = new CUpperCaseValidator(ui->le_AtcStationsOnlineMetar);
ui->le_AtcStationsOnlineMetar->setValidator(ucv);
// some icons
ui->pb_AtcStationsAtisReload->setIcon(CIcons::atis());
@@ -93,10 +98,17 @@ namespace BlackGui
connect(&m_updateTimer, &QTimer::timeout, this, &CAtcStationComponent::update);
// runtime based connects
this->connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnlineDigest, this, &CAtcStationComponent::ps_changedAtcStationsOnline);
this->connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsBookedDigest, this, &CAtcStationComponent::ps_changedAtcStationsBooked);
this->connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationOnlineConnectionStatus, this, &CAtcStationComponent::changedAtcStationOnlineConnectionStatus);
this->connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAtcStationComponent::ps_connectionStatusChanged);
connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnlineDigest, this, &CAtcStationComponent::ps_changedAtcStationsOnline);
connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsBookedDigest, this, &CAtcStationComponent::ps_changedAtcStationsBooked);
connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationOnlineConnectionStatus, this, &CAtcStationComponent::changedAtcStationOnlineConnectionStatus);
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &CAtcStationComponent::ps_connectionStatusChanged);
// web readers
if (sGui->hasWebDataServices())
{
connect(sGui->getWebDataServices(), &CWebDataServices::swiftDbAirportsRead, this, &CAtcStationComponent::ps_airportsRead);
this->ps_airportsRead();
}
// settings have
this->ps_settingsChanged();
@@ -174,6 +186,11 @@ namespace BlackGui
ui->tvp_AtcStationsOnline->changedAtcStationConnectionStatus(station, added);
}
void CAtcStationComponent::ps_getMetarAsEntered()
{
this->getMetar("");
}
void CAtcStationComponent::getMetar(const QString &airportIcaoCode)
{
QString icao(airportIcaoCode.isEmpty() ? ui->le_AtcStationsOnlineMetar->text().trimmed().toUpper() : airportIcaoCode.trimmed().toUpper());
@@ -296,6 +313,11 @@ namespace BlackGui
this->m_updateTimer.setInterval(settings.getAtcUpdateTime().toMs());
}
void CAtcStationComponent::ps_airportsRead()
{
this->initCompleters();
}
void CAtcStationComponent::updateTreeView()
{
//! \fixme EXPERIMENTAL CODE: change model so we can directly use hierarchies
@@ -313,6 +335,18 @@ namespace BlackGui
}
}
void CAtcStationComponent::initCompleters()
{
if (!sGui || !sGui->getWebDataServices()) { return; }
const QStringList airports = sGui->getWebDataServices()->getAirports().allIcaoCodes(true);
if (!airports.isEmpty())
{
QCompleter *airportCompleter = new QCompleter(airports, this);
airportCompleter->popup()->setMinimumWidth(75);
ui->le_AtcStationsOnlineMetar->setCompleter(airportCompleter);
}
}
void CAtcStationComponent::ps_onlineAtcStationSelected(QModelIndex index)
{
ui->te_AtcStationsOnlineInfo->setText(""); // reset