mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 20:40:29 +08:00
Using the same optimizations as in category tree view (Ref T472)
* isEmpty * digest signal
This commit is contained in:
committed by
Mat Sutcliffe
parent
fe05c2287b
commit
c123c8bbca
@@ -47,11 +47,8 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CAtcStationTreeModel::updateContainer(const CAtcStationList &stations)
|
void CAtcStationTreeModel::updateContainer(const CAtcStationList &stations)
|
||||||
{
|
{
|
||||||
if (stations.isEmpty())
|
this->clear();
|
||||||
{
|
if (stations.isEmpty()) { return; }
|
||||||
CAtcStationTreeModel::clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_stations = stations.sortedByAtcSuffixSortOrderAndDistance();
|
m_stations = stations.sortedByAtcSuffixSortOrderAndDistance();
|
||||||
m_stationsBySuffix = m_stations.splitPerSuffix();
|
m_stationsBySuffix = m_stations.splitPerSuffix();
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ namespace BlackGui
|
|||||||
this->stationModel()->clear();
|
this->stationModel()->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CAtcStationTreeView::isEmpty() const
|
||||||
|
{
|
||||||
|
return this->stationModel()->rowCount() < 1;
|
||||||
|
}
|
||||||
|
|
||||||
void CAtcStationTreeView::setColumns(const CColumns &columns)
|
void CAtcStationTreeView::setColumns(const CColumns &columns)
|
||||||
{
|
{
|
||||||
if (this->stationModel()) { this->stationModel()->setColumns(columns); }
|
if (this->stationModel()) { this->stationModel()->setColumns(columns); }
|
||||||
@@ -64,6 +69,12 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CAtcStationTreeView::fullResizeToContents()
|
void CAtcStationTreeView::fullResizeToContents()
|
||||||
{
|
{
|
||||||
|
m_dsFullResize.inputSignal();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAtcStationTreeView::fullResizeToContentsImpl()
|
||||||
|
{
|
||||||
|
if (this->isEmpty()) { return; }
|
||||||
for (int c = 0; c < this->model()->columnCount(); c++)
|
for (int c = 0; c < this->model()->columnCount(); c++)
|
||||||
{
|
{
|
||||||
this->resizeColumnToContents(c);
|
this->resizeColumnToContents(c);
|
||||||
@@ -83,8 +94,7 @@ namespace BlackGui
|
|||||||
CAtcStation CAtcStationTreeView::selectedObject() const
|
CAtcStation CAtcStationTreeView::selectedObject() const
|
||||||
{
|
{
|
||||||
const QModelIndex index = this->currentIndex();
|
const QModelIndex index = this->currentIndex();
|
||||||
// Qt 5.11 or later const QVariant data = this->model()->data(index.siblingAtColumn(0)); // supposed to be the callsign
|
const QVariant data = this->model()->data(index.siblingAtColumn(0)); // supposed to be the callsign
|
||||||
const QVariant data = this->model()->data(index.sibling(index.row(), 0)); // supposed to be the callsign
|
|
||||||
const QString callsign = data.toString();
|
const QString callsign = data.toString();
|
||||||
const CAtcStationTreeModel *model = this->stationModel();
|
const CAtcStationTreeModel *model = this->stationModel();
|
||||||
if (!model) { return CAtcStation(); }
|
if (!model) { return CAtcStation(); }
|
||||||
@@ -118,7 +128,7 @@ namespace BlackGui
|
|||||||
connect(com1, &QAction::triggered, this, &CAtcStationTreeView::tuneInAtcCom1);
|
connect(com1, &QAction::triggered, this, &CAtcStationTreeView::tuneInAtcCom1);
|
||||||
connect(com2, &QAction::triggered, this, &CAtcStationTreeView::tuneInAtcCom2);
|
connect(com2, &QAction::triggered, this, &CAtcStationTreeView::tuneInAtcCom2);
|
||||||
connect(text, &QAction::triggered, this, &CAtcStationTreeView::requestTextMessage);
|
connect(text, &QAction::triggered, this, &CAtcStationTreeView::requestTextMessage);
|
||||||
connect(resize, &QAction::triggered, this, &CAtcStationTreeView::fullResizeToContents);
|
connect(resize, &QAction::triggered, this, &CAtcStationTreeView::fullResizeToContentsImpl);
|
||||||
|
|
||||||
menu->addAction(com1);
|
menu->addAction(com1);
|
||||||
menu->addAction(com2);
|
menu->addAction(com2);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "blackmisc/aviation/atcstationlist.h"
|
#include "blackmisc/aviation/atcstationlist.h"
|
||||||
#include "blackmisc/aviation/comsystem.h"
|
#include "blackmisc/aviation/comsystem.h"
|
||||||
#include "blackmisc/pq/frequency.h"
|
#include "blackmisc/pq/frequency.h"
|
||||||
|
#include "blackmisc/digestsignal.h"
|
||||||
|
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@@ -52,6 +53,9 @@ namespace BlackGui
|
|||||||
//! Clear
|
//! Clear
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
//! Empty
|
||||||
|
bool isEmpty() const;
|
||||||
|
|
||||||
//! Set columns
|
//! Set columns
|
||||||
void setColumns(const Models::CColumns &columns);
|
void setColumns(const Models::CColumns &columns);
|
||||||
|
|
||||||
@@ -75,6 +79,9 @@ namespace BlackGui
|
|||||||
//! Used model
|
//! Used model
|
||||||
Models::CAtcStationTreeModel *stationModel();
|
Models::CAtcStationTreeModel *stationModel();
|
||||||
|
|
||||||
|
//! Resize all columns
|
||||||
|
void fullResizeToContentsImpl();
|
||||||
|
|
||||||
//! The selected object
|
//! The selected object
|
||||||
BlackMisc::Aviation::CAtcStation selectedObject() const;
|
BlackMisc::Aviation::CAtcStation selectedObject() const;
|
||||||
|
|
||||||
@@ -99,6 +106,7 @@ namespace BlackGui
|
|||||||
void requestTextMessage();
|
void requestTextMessage();
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
|
BlackMisc::CDigestSignal m_dsFullResize { this, &CAtcStationTreeView::fullResizeToContentsImpl, 1000, 25 };
|
||||||
QMap<QString, bool> m_expanded; //!< suffix/expanded
|
QMap<QString, bool> m_expanded; //!< suffix/expanded
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
Reference in New Issue
Block a user