mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
Ref T539, tree view can select objects and hence refresh ATIS display
* select signal for tree view * signal/slots and connects
This commit is contained in:
committed by
Mat Sutcliffe
parent
d68726080f
commit
cc6adc6c40
@@ -34,7 +34,8 @@ namespace BlackGui
|
||||
this->setModel(new CAtcStationTreeModel(this));
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this, &CAtcStationTreeView::customContextMenuRequested, this, &CAtcStationTreeView::customMenu);
|
||||
connect(this, &CAtcStationTreeView::expanded, this, &CAtcStationTreeView::onExpanded);
|
||||
connect(this, &CAtcStationTreeView::expanded, this, &CAtcStationTreeView::onExpanded, Qt::QueuedConnection);
|
||||
connect(this->selectionModel(), &QItemSelectionModel::selectionChanged, this, &CAtcStationTreeView::onSelected, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void CAtcStationTreeView::changedAtcStationConnectionStatus(const CAtcStation &station, bool added)
|
||||
@@ -94,6 +95,11 @@ namespace BlackGui
|
||||
CAtcStation CAtcStationTreeView::selectedObject() const
|
||||
{
|
||||
const QModelIndex index = this->currentIndex();
|
||||
return this->selectedObject(index);
|
||||
}
|
||||
|
||||
CAtcStation CAtcStationTreeView::selectedObject(const QModelIndex &index) const
|
||||
{
|
||||
const QVariant data = this->model()->data(index.siblingAtColumn(0)); // supposed to be the callsign
|
||||
const QString callsign = data.toString();
|
||||
const CAtcStationTreeModel *model = this->stationModel();
|
||||
@@ -113,6 +119,15 @@ namespace BlackGui
|
||||
this->fullResizeToContents();
|
||||
}
|
||||
|
||||
void CAtcStationTreeView::onSelected(const QItemSelection &selected, const QItemSelection &deselected)
|
||||
{
|
||||
Q_UNUSED(deselected);
|
||||
if (selected.isEmpty()) { return; }
|
||||
const CAtcStation atcStation = this->selectedObject(selected.indexes().front());
|
||||
if (!atcStation.hasCallsign()) { return; }
|
||||
emit this->objectSelected(atcStation);
|
||||
}
|
||||
|
||||
void CAtcStationTreeView::customMenu(const QPoint &point)
|
||||
{
|
||||
if (!this->stationModel()) { return; }
|
||||
|
||||
@@ -73,6 +73,9 @@ namespace BlackGui
|
||||
//! Request a text message to
|
||||
void requestTextMessageWidget(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! This object has been selected
|
||||
void objectSelected(const BlackMisc::Aviation::CAtcStation &station);
|
||||
|
||||
private:
|
||||
//! Used model
|
||||
const Models::CAtcStationTreeModel *stationModel() const;
|
||||
@@ -86,12 +89,18 @@ namespace BlackGui
|
||||
//! The selected object
|
||||
BlackMisc::Aviation::CAtcStation selectedObject() const;
|
||||
|
||||
//! The selected object
|
||||
BlackMisc::Aviation::CAtcStation selectedObject(const QModelIndex &index) const;
|
||||
|
||||
//! Suffix for index
|
||||
QString suffixForIndex(const QModelIndex &index);
|
||||
|
||||
//! Expanded
|
||||
void onExpanded(const QModelIndex &index);
|
||||
|
||||
//! Selected
|
||||
void onSelected(const QItemSelection &selected, const QItemSelection &deselected);
|
||||
|
||||
//! Custom menu
|
||||
void customMenu(const QPoint &point);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user