mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-30 14:15:35 +08:00
refs #239, aircraft component
This commit is contained in:
29
src/blackgui/aircraftcomponent.cpp
Normal file
29
src/blackgui/aircraftcomponent.cpp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#include "aircraftcomponent.h"
|
||||||
|
#include "ui_aircraftcomponent.h"
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
|
||||||
|
CAircraftComponent::CAircraftComponent(QWidget *parent) :
|
||||||
|
QTabWidget(parent), CRuntimeBasedComponent(nullptr, false), ui(new Ui::CAircraftComponent), m_timerComponent(nullptr)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
m_timerComponent = new CTimerBasedComponent(SLOT(update()), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
CAircraftComponent::~CAircraftComponent()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAircraftComponent::update()
|
||||||
|
{
|
||||||
|
Q_ASSERT(this->ui->tvp_AircraftsInRange);
|
||||||
|
Q_ASSERT(this->getIContextNetwork());
|
||||||
|
|
||||||
|
if (this->getIContextNetwork()->isConnected())
|
||||||
|
{
|
||||||
|
this->ui->tvp_AircraftsInRange->update(this->getIContextNetwork()->getAircraftsInRange());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
47
src/blackgui/aircraftcomponent.h
Normal file
47
src/blackgui/aircraftcomponent.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#ifndef BLACKGUI_AIRCRAFTCOMPONENT_H
|
||||||
|
#define BLACKGUI_AIRCRAFTCOMPONENT_H
|
||||||
|
|
||||||
|
#include "blackgui/runtimebasedcomponent.h"
|
||||||
|
#include "blackgui/timerbasedcomponent.h"
|
||||||
|
#include "blackmisc/avaircraft.h"
|
||||||
|
|
||||||
|
#include <QTabWidget>
|
||||||
|
|
||||||
|
namespace Ui { class CAircraftComponent; }
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
//! Aircraft widget
|
||||||
|
class CAircraftComponent : public QTabWidget, public CRuntimeBasedComponent
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Constructor
|
||||||
|
explicit CAircraftComponent(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
//! Destructor
|
||||||
|
~CAircraftComponent();
|
||||||
|
|
||||||
|
//! Timer for updating
|
||||||
|
CTimerBasedComponent *getTimerComponent() { return this->m_timerComponent; }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
//! Update users
|
||||||
|
void update();
|
||||||
|
|
||||||
|
//! \copydoc CTimerBasedComponent::setUpdateIntervalSeconds
|
||||||
|
void setUpdateIntervalSeconds(int seconds) { Q_ASSERT(this->m_timerComponent); this->m_timerComponent->setUpdateIntervalSeconds(seconds); }
|
||||||
|
|
||||||
|
//! \copydoc CTimerBasedComponent::setUpdateInterval
|
||||||
|
void setUpdateInterval(int milliSeconds) { Q_ASSERT(this->m_timerComponent); this->m_timerComponent->setUpdateInterval(milliSeconds); }
|
||||||
|
|
||||||
|
//! \copydoc CTimerBasedComponent::stopTimer
|
||||||
|
void stopTimer() { Q_ASSERT(this->m_timerComponent); this->m_timerComponent->stopTimer(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::CAircraftComponent *ui;
|
||||||
|
CTimerBasedComponent *m_timerComponent;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
58
src/blackgui/aircraftcomponent.ui
Normal file
58
src/blackgui/aircraftcomponent.ui
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CAircraftComponent</class>
|
||||||
|
<widget class="QTabWidget" name="CAircraftComponent">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>TabWidget</string>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="tb_AircraftsInRange">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>In range</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="vl_AircraftsInRange">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</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::CAircraftView" name="tvp_AircraftsInRange">
|
||||||
|
<attribute name="verticalHeaderVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>BlackGui::CAircraftView</class>
|
||||||
|
<extends>QTableView</extends>
|
||||||
|
<header>blackgui/aircraftview.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Reference in New Issue
Block a user