Ref T442, made ATC station component a QFrame

* details in group box
* count for tree view tab
* formatting of settings
This commit is contained in:
Klaus Basan
2018-12-09 03:17:15 +01:00
parent 8d3d5743d3
commit 6761a4c08a
4 changed files with 344 additions and 248 deletions

View File

@@ -34,6 +34,7 @@
#include <QStandardItemModel>
#include <QStringBuilder>
#include <QTabBar>
#include <QGroupBox>
#include <QTableView>
#include <QTextEdit>
#include <QTimer>
@@ -56,15 +57,15 @@ namespace BlackGui
namespace Components
{
CAtcStationComponent::CAtcStationComponent(QWidget *parent) :
COverlayMessagesTabWidget(parent),
COverlayMessagesFrame(parent),
CIdentifiable(this),
ui(new Ui::CAtcStationComponent)
{
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui");
ui->setupUi(this);
this->setCurrentIndex(0);
this->tabBar()->setExpanding(false);
this->tabBar()->setUsesScrollButtons(true);
ui->tw_Atc->setCurrentIndex(0);
ui->tw_Atc->tabBar()->setExpanding(false);
ui->tw_Atc->tabBar()->setUsesScrollButtons(true);
CUpperCaseValidator *ucv = new CUpperCaseValidator(ui->le_AtcStationsOnlineMetar);
ui->le_AtcStationsOnlineMetar->setValidator(ucv);
@@ -92,7 +93,7 @@ namespace BlackGui
connect(ui->tb_AtcStationsLoadMetar, &QPushButton::clicked, this, &CAtcStationComponent::getMetarAsEntered);
connect(ui->tb_Audio, &QPushButton::clicked, this, &CAtcStationComponent::requestAudioWidget);
connect(ui->tb_TextMessageOverlay, &QPushButton::clicked, this, &CAtcStationComponent::showOverlayInlineTextMessage);
connect(this, &QTabWidget::currentChanged, this, &CAtcStationComponent::atcStationsTabChanged); // "local" tab changed (booked, online)
connect(ui->tw_Atc, &QTabWidget::currentChanged, this, &CAtcStationComponent::atcStationsTabChanged); // "local" tab changed (booked, online)
connect(ui->tvp_AtcStationsOnline, &CAtcStationView::objectClicked, this, &CAtcStationComponent::onlineAtcStationSelected);
connect(ui->tvp_AtcStationsOnline, &CAtcStationView::objectSelected, this, &CAtcStationComponent::onlineAtcStationSelected);
connect(ui->tvp_AtcStationsOnline, &CAtcStationView::testRequestDummyAtcOnlineStations, this, &CAtcStationComponent::testCreateDummyOnlineAtcStations);
@@ -113,6 +114,9 @@ namespace BlackGui
connect(ui->tb_AtcStationsAtisReload, &QPushButton::clicked, this, &CAtcStationComponent::requestAtis);
connect(&m_updateTimer, &QTimer::timeout, this, &CAtcStationComponent::update);
// Group box
connect(ui->gb_Details, &QGroupBox::toggled, this, &CAtcStationComponent::onDetailsToggled);
// runtime based connects
connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnlineDigest, this, &CAtcStationComponent::changedAtcStationsOnline, Qt::QueuedConnection);
connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsBookedDigest, this, &CAtcStationComponent::changedAtcStationsBooked, Qt::QueuedConnection);
@@ -123,6 +127,10 @@ namespace BlackGui
ui->tvp_AtcStationsOnline->acceptClickSelection(true);
ui->tvp_AtcStationsOnline->acceptRowSelection(true);
QVBoxLayout *layout = this->vLayout();
m_stretch.push_back(layout->stretch(0));
m_stretch.push_back(layout->stretch(1));
// web readers
if (sGui->hasWebDataServices())
{
@@ -140,7 +148,7 @@ namespace BlackGui
void CAtcStationComponent::setTab(CAtcStationComponent::AtcTab tab)
{
const int t = static_cast<int>(tab);
this->setCurrentIndex(t);
ui->tw_Atc->setCurrentIndex(t);
}
int CAtcStationComponent::countBookedStations() const
@@ -326,7 +334,7 @@ namespace BlackGui
const QPointer<CAtcStationComponent> myself(this);
QTimer::singleShot(1000, this, [ = ]
{
if (!myself) { return; }
if (!sApp || sApp->isShuttingDown() || !myself) { return; }
this->update();
});
Q_UNUSED(index);
@@ -336,14 +344,18 @@ namespace BlackGui
{
Q_UNUSED(count);
Q_UNUSED(withFilter);
int io = this->indexOf(ui->tb_AtcStationsOnline);
int ib = this->indexOf(ui->tb_AtcStationsBooked);
QString o = this->tabBar()->tabText(io);
QString b = this->tabBar()->tabText(ib);
const int io = ui->tw_Atc->indexOf(ui->tb_AtcStationsOnline);
const int it = ui->tw_Atc->indexOf(ui->tb_AtcStationsOnlineTree);
const int ib = ui->tw_Atc->indexOf(ui->tb_AtcStationsBooked);
QString o = ui->tw_Atc->tabBar()->tabText(io);
QString t = ui->tw_Atc->tabBar()->tabText(it);
QString b = ui->tw_Atc->tabBar()->tabText(ib);
o = CGuiUtility::replaceTabCountValue(o, this->countOnlineStations());
t = CGuiUtility::replaceTabCountValue(t, this->countOnlineStations());
b = CGuiUtility::replaceTabCountValue(b, this->countBookedStations());
this->tabBar()->setTabText(io, o);
this->tabBar()->setTabText(ib, b);
ui->tw_Atc->tabBar()->setTabText(io, o);
ui->tw_Atc->tabBar()->setTabText(it, t);
ui->tw_Atc->tabBar()->setTabText(ib, b);
}
void CAtcStationComponent::setComFrequency(const PhysicalQuantities::CFrequency &frequency, CComSystem::ComUnit unit)
@@ -416,13 +428,15 @@ namespace BlackGui
void CAtcStationComponent::atcStationsTabChanged()
{
if (this->currentWidget() == ui->tb_AtcStationsBooked)
const bool booked = ui->tw_Atc->currentWidget() == ui->tb_AtcStationsBooked;
if (booked)
{
if (ui->tvp_AtcStationsBooked->isEmpty())
{
this->reloadAtcStationsBooked();
}
}
ui->gb_Details->setVisible(!booked);
}
void CAtcStationComponent::requestAtis()
@@ -445,7 +459,39 @@ namespace BlackGui
void CAtcStationComponent::showOverlayInlineTextMessage()
{
COverlayMessagesTabWidget::showOverlayInlineTextMessage(TextMessagesCom1);
COverlayMessagesFrame::showOverlayInlineTextMessage(TextMessagesCom1);
}
void CAtcStationComponent::onDetailsToggled(bool checked)
{
QVBoxLayout *layout = this->vLayout();
if (layout)
{
if (checked)
{
layout->setStretchFactor(ui->tw_Atc, m_stretch.at(0));
layout->setStretchFactor(ui->gb_Details, m_stretch.at(1));
}
else
{
layout->setStretchFactor(ui->tw_Atc, 0);
layout->setStretchFactor(ui->gb_Details, 0);
}
}
ui->te_AtcStationsOnlineInfo->setVisible(checked);
ui->comp_AtcStationsSettings->setVisible(checked);
ui->le_AtcStationsOnlineMetar->setVisible(checked);
ui->tb_AtcStationsAtisReload->setVisible(checked);
ui->tb_AtcStationsLoadMetar->setVisible(checked);
ui->tb_TextMessageOverlay->setVisible(checked);
ui->tb_Audio->setVisible(checked);
}
QVBoxLayout *CAtcStationComponent::vLayout() const
{
QVBoxLayout *layout = qobject_cast<QVBoxLayout *>(this->layout());
return layout;
}
} // namespace
} // namespace

View File

@@ -30,7 +30,9 @@
#include <QString>
#include <QTabWidget>
#include <QtGlobal>
#include <QVBoxLayout>
#include <QTimer>
#include <QList>
namespace BlackMisc { namespace Aviation { class CCallsign; } }
namespace Ui { class CAtcStationComponent; }
@@ -41,7 +43,7 @@ namespace BlackGui
{
//! ATC stations component
class BLACKGUI_EXPORT CAtcStationComponent :
public COverlayMessagesTabWidget,
public COverlayMessagesFrame,
public CEnableForDockWidgetInfoArea,
public BlackMisc::CIdentifiable
{
@@ -155,13 +157,20 @@ namespace BlackGui
//! Inline message
void showOverlayInlineTextMessage();
//! Details toggled
void onDetailsToggled(bool checked);
//! Get the vertical layout
QVBoxLayout *vLayout() const;
QScopedPointer<Ui::CAtcStationComponent> ui;
QTimer m_updateTimer;
QList<int> m_stretch;
QDateTime m_timestampLastReadOnlineStations; //!< stations read
QDateTime m_timestampOnlineStationsChanged; //!< stations marked as changed
QDateTime m_timestampLastReadBookedStations; //!< stations read
QDateTime m_timestampBookedStationsChanged; //!< stations marked as changed
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settingsView { this, &CAtcStationComponent::settingsChanged };
BlackMisc::CSettingReadOnly<BlackGui::Settings::TViewUpdateSettings> m_settingsView { this, &CAtcStationComponent::settingsChanged };
};
} // namespace
} // namespace

View File

@@ -1,262 +1,277 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CAtcStationComponent</class>
<widget class="QTabWidget" name="CAtcStationComponent">
<widget class="QFrame" name="CAtcStationComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>462</height>
<width>278</width>
<height>507</height>
</rect>
</property>
<property name="windowTitle">
<string>ATC stations</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tb_AtcStationsOnline">
<attribute name="title">
<string>Online</string>
</attribute>
<layout class="QVBoxLayout" name="vl_AtcStationsOnline" stretch="4,0,0,1">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="BlackGui::Views::CAtcStationView" name="tvp_AtcStationsOnline">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
<layout class="QVBoxLayout" name="vl_ATCStations" stretch="3,1">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<widget class="QTabWidget" name="tw_Atc">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tb_AtcStationsOnline">
<attribute name="title">
<string>ATC stations</string>
</attribute>
</widget>
</item>
<item alignment="Qt::AlignLeft">
<widget class="QFrame" name="fr_AtcStationsOnlineBottom">
<layout class="QGridLayout" name="gl_Buttons">
<layout class="QVBoxLayout" name="vl_AtcStationsOnline">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLineEdit" name="le_AtcStationsOnlineMetar">
<property name="toolTip">
<string extracomment="METAR: Airport ICAO code">METAR: Airport ICAO code</string>
<item>
<widget class="BlackGui::Views::CAtcStationView" name="tvp_AtcStationsOnline">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="maxLength">
<number>5</number>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="placeholderText">
<string>e.g. KLAX</string>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="tb_AtcStationsAtisReload">
<property name="toolTip">
<string>Reload ATIS</string>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="text">
<string>ATIS</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="tb_Audio">
<property name="toolTip">
<string>goto audio panel</string>
</property>
<property name="text">
<string>audio</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QToolButton" name="tb_TextMessageOverlay">
<property name="toolTip">
<string>text message</string>
</property>
<property name="text">
<string>tm</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="tb_AtcStationsLoadMetar">
<property name="toolTip">
<string>Load METAR</string>
</property>
<property name="text">
<string>METAR</string>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item alignment="Qt::AlignLeft">
<widget class="BlackGui::Components::CSettingsAtcStationsInlineComponent" name="comp_AtcStationsSettings">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="te_AtcStationsOnlineInfo">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_AtcStationsOnlineTree">
<attribute name="title">
<string>Online (tree)</string>
</attribute>
<layout class="QVBoxLayout" name="vl_AtcStationsOnlineTree">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="BlackGui::Views::CAtcStationTreeView" name="tvp_AtcStationsOnlineTree">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="animated">
<bool>true</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
<widget class="QWidget" name="tb_AtcStationsOnlineTree">
<attribute name="title">
<string>ATC tree</string>
</attribute>
<layout class="QVBoxLayout" name="vl_AtcTree">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="BlackGui::Views::CAtcStationTreeView" name="tvp_AtcStationsOnlineTree">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="animated">
<bool>true</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_AtcStationsBooked">
<attribute name="title">
<string>Booked</string>
</attribute>
<layout class="QVBoxLayout" name="vl_AtcStationsBooked">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="BlackGui::Views::CAtcStationView" name="tvp_AtcStationsBooked">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
<widget class="QWidget" name="tb_AtcStationsBooked">
<attribute name="title">
<string>ATC booked</string>
</attribute>
<layout class="QVBoxLayout" name="vl_AtcBooked">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="BlackGui::Views::CAtcStationView" name="tvp_AtcStationsBooked">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_Details">
<property name="title">
<string>Details (METAR, ATIS, range)</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gl_Details">
<item row="1" column="1">
<widget class="QToolButton" name="tb_AtcStationsLoadMetar">
<property name="toolTip">
<string>Load METAR</string>
</property>
<property name="text">
<string>METAR</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="tb_AtcStationsAtisReload">
<property name="toolTip">
<string>Reload ATIS</string>
</property>
<property name="text">
<string>ATIS</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QToolButton" name="tb_TextMessageOverlay">
<property name="toolTip">
<string>text message</string>
</property>
<property name="text">
<string>tm</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="5">
<widget class="QTextEdit" name="te_AtcStationsOnlineInfo">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="le_AtcStationsOnlineMetar">
<property name="toolTip">
<string extracomment="METAR: Airport ICAO code">METAR: Airport ICAO code</string>
</property>
<property name="maxLength">
<number>5</number>
</property>
<property name="placeholderText">
<string>e.g. KLAX</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QToolButton" name="tb_Audio">
<property name="toolTip">
<string>goto audio panel</string>
</property>
<property name="text">
<string>audio</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="5">
<widget class="BlackGui::Components::CSettingsAtcStationsInlineComponent" name="comp_AtcStationsSettings">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
@@ -277,13 +292,14 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tw_Atc</tabstop>
<tabstop>tvp_AtcStationsOnline</tabstop>
<tabstop>gb_Details</tabstop>
<tabstop>le_AtcStationsOnlineMetar</tabstop>
<tabstop>tb_AtcStationsLoadMetar</tabstop>
<tabstop>tb_AtcStationsAtisReload</tabstop>
<tabstop>tb_Audio</tabstop>
<tabstop>tb_TextMessageOverlay</tabstop>
<tabstop>comp_AtcStationsSettings</tabstop>
<tabstop>te_AtcStationsOnlineInfo</tabstop>
<tabstop>tvp_AtcStationsOnlineTree</tabstop>
<tabstop>tvp_AtcStationsBooked</tabstop>

View File

@@ -6,14 +6,26 @@
<rect>
<x>0</x>
<y>0</y>
<width>256</width>
<height>31</height>
<width>291</width>
<height>24</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<layout class="QHBoxLayout" name="hl_AtcStationsInlineComponent">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="QCheckBox" name="cb_Frequency">
<property name="toolTip">
@@ -34,6 +46,19 @@
</property>
</widget>
</item>
<item>
<spacer name="hs_Settings">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="rb_All">
<property name="text">