mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-14 08:45:36 +08:00
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:
@@ -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()
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -181,6 +181,15 @@
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>le_Id</tabstop>
|
||||
<tabstop>le_ModelKey</tabstop>
|
||||
<tabstop>le_Name</tabstop>
|
||||
<tabstop>le_Description</tabstop>
|
||||
<tabstop>ph_Stash</tabstop>
|
||||
<tabstop>pb_Save</tabstop>
|
||||
<tabstop>le_LastUpdated</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace BlackGui
|
||||
{
|
||||
namespace Models
|
||||
{
|
||||
|
||||
class ActionItem;
|
||||
|
||||
/*!
|
||||
@@ -31,7 +30,6 @@ namespace BlackGui
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! User roles
|
||||
enum ItemRole
|
||||
{
|
||||
@@ -63,12 +61,12 @@ namespace BlackGui
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
private:
|
||||
//! Init model data
|
||||
void setupModelData();
|
||||
|
||||
QScopedPointer<ActionItem> m_rootItem;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -94,14 +94,14 @@ namespace BlackGui
|
||||
QStandardItemModel *model = new QStandardItemModel();
|
||||
if (this->isEmpty()) { return model; }
|
||||
model->setColumnCount(4);
|
||||
QMap<QString, int> types = this->getContainer().getSuffixes();
|
||||
QMap<QString, int> types = this->container().getSuffixes();
|
||||
for (const QString &type : types.keys())
|
||||
{
|
||||
// ownership of QStandardItem is taken by model
|
||||
QStandardItem *typeFolderFirstColumn = new QStandardItem(CCallsign::atcSuffixToIcon(type).toQIcon(), type);
|
||||
QList<QStandardItem *> typeFolderRow { typeFolderFirstColumn };
|
||||
model->invisibleRootItem()->appendRow(typeFolderRow);
|
||||
CAtcStationList stations = this->getContainer().findBySuffix(type);
|
||||
CAtcStationList stations = this->container().findBySuffix(type);
|
||||
for (const CAtcStation &station : stations)
|
||||
{
|
||||
QList<QStandardItem *> stationRow;
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace BlackGui
|
||||
|
||||
const CDefaultFormatter *CColumns::getFormatter(const QModelIndex &index) const
|
||||
{
|
||||
if (!isValidColumn(index)) return nullptr;
|
||||
if (!isValidColumn(index)) { return nullptr; }
|
||||
return this->m_columns.at(index.column()).getFormatter();
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace BlackGui
|
||||
// check / init
|
||||
if (!this->isValidIndex(index)) { return QVariant(); }
|
||||
const CDefaultFormatter *formatter = this->m_columns.getFormatter(index);
|
||||
Q_ASSERT(formatter);
|
||||
Q_ASSERT_X(formatter, Q_FUNC_INFO, "Missing formatter");
|
||||
if (!formatter) { return QVariant(); }
|
||||
|
||||
//! Formatted data
|
||||
@@ -372,7 +372,7 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
template <typename ObjectType, typename ContainerType, bool UseCompare>
|
||||
const ContainerType &CListModelBase<ObjectType, ContainerType, UseCompare>::getContainer() const
|
||||
const ContainerType &CListModelBase<ObjectType, ContainerType, UseCompare>::container() const
|
||||
{
|
||||
return this->m_container;
|
||||
}
|
||||
@@ -507,7 +507,7 @@ namespace BlackGui
|
||||
{
|
||||
this->sort(); // make sure container is sorted
|
||||
}
|
||||
ContainerType container(this->getContainer());
|
||||
ContainerType container(this->container());
|
||||
container.truncate(maxNumber);
|
||||
this->updateContainerMaybeAsync(container, false);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace BlackGui
|
||||
virtual bool isValidIndex(const QModelIndex &index) const;
|
||||
|
||||
//! Used container data
|
||||
virtual const ContainerType &getContainer() const;
|
||||
const ContainerType &container() const;
|
||||
|
||||
//! \copydoc QAbstractItemModel::data()
|
||||
virtual QVariant data(const QModelIndex &index, int role) const override;
|
||||
@@ -226,9 +226,7 @@ namespace BlackGui
|
||||
protected:
|
||||
std::unique_ptr<IModelFilter<ContainerType> > m_filter; //!< Used filter
|
||||
|
||||
//! Constructor
|
||||
//! \param translationContext I18N context
|
||||
//! \param parent
|
||||
//! \copydoc CListModelBaseNonTemplate::CListModelBaseNonTemplate
|
||||
CListModelBase(const QString &translationContext, QObject *parent = nullptr)
|
||||
: CListModelBaseNonTemplate(translationContext, parent)
|
||||
{ }
|
||||
@@ -268,7 +266,6 @@ namespace BlackGui
|
||||
BlackMisc::CVariant bQv = b.propertyByIndex(index);
|
||||
return (order == Qt::AscendingOrder) ? (aQv < bQv) : (bQv < aQv);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace BlackGui
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
explicit CAtcStationView(QWidget *parent = nullptr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user