mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 07:15:34 +08:00
refs #358, GUI for installed / matched models
* model / view / component classes
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "aircraftcomponent.h"
|
||||
#include "cockpitcomponent.h"
|
||||
#include "usercomponent.h"
|
||||
#include "mappingcomponent.h"
|
||||
#include "textmessagecomponent.h"
|
||||
#include "simulatorcomponent.h"
|
||||
#include "flightplancomponent.h"
|
||||
|
||||
@@ -467,7 +467,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="comp_Mappings">
|
||||
<widget class="BlackGui::Components::CMappingComponent" name="comp_Mappings">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
@@ -633,6 +633,12 @@
|
||||
<header>blackgui/components/textmessagecomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CMappingComponent</class>
|
||||
<extends>QTabWidget</extends>
|
||||
<header>blackgui/components/mappingcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../blackmisc/blackmisc.qrc"/>
|
||||
|
||||
97
src/blackgui/components/mappingcomponent.cpp
Normal file
97
src/blackgui/components/mappingcomponent.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackcore/context_simulator.h"
|
||||
#include "../views/aircraftmodelview.h"
|
||||
#include "../models/aircraftmodellistmodel.h"
|
||||
#include "../guiutility.h"
|
||||
#include "mappingcomponent.h"
|
||||
#include "ui_mappingcomponent.h"
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackGui;
|
||||
using namespace BlackGui::Views;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
CMappingComponent::CMappingComponent(QWidget *parent) :
|
||||
QTabWidget(parent), ui(new Ui::CMappingComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->ui->tvp_CurrentMappings->setAircraftModelMode(CAircraftModelListModel::MappedModel);
|
||||
this->ui->tvp_AircraftModels->setAircraftModelMode(CAircraftModelListModel::ModelOnly);
|
||||
this->ui->tvp_CurrentMappings->setResizeMode(CAircraftModelView::ResizingOnce);
|
||||
this->ui->tvp_AircraftModels->setResizeMode(CAircraftModelView::ResizingOff);
|
||||
|
||||
connect(this->ui->tvp_AircraftModels, &CAircraftModelView::requestUpdate, this, &CMappingComponent::ps_aircraftModelsLoaded);
|
||||
connect(this->ui->tvp_CurrentMappings, &CAircraftModelView::requestUpdate, this, &CMappingComponent::ps_onMappingsChanged);
|
||||
connect(this->ui->tvp_AircraftModels, &CAircraftModelView::countChanged, this, &CMappingComponent::ps_countChanged);
|
||||
connect(this->ui->tvp_CurrentMappings, &CAircraftModelView::countChanged, this, &CMappingComponent::ps_countChanged);
|
||||
}
|
||||
|
||||
CMappingComponent::~CMappingComponent()
|
||||
{ }
|
||||
|
||||
int CMappingComponent::countCurrentMappings() const
|
||||
{
|
||||
Q_ASSERT(this->ui->tvp_CurrentMappings);
|
||||
return this->ui->tvp_CurrentMappings->rowCount();
|
||||
}
|
||||
|
||||
int CMappingComponent::countAircraftModels() const
|
||||
{
|
||||
Q_ASSERT(this->ui->tvp_AircraftModels);
|
||||
return this->ui->tvp_AircraftModels->rowCount();
|
||||
}
|
||||
|
||||
void CMappingComponent::runtimeHasBeenSet()
|
||||
{
|
||||
Q_ASSERT(getIContextSimulator());
|
||||
connect(getIContextSimulator(), &IContextSimulator::installedAircraftModelsChanged, this, &CMappingComponent::ps_aircraftModelsLoaded);
|
||||
connect(getIContextSimulator(), &IContextSimulator::modelMatchingCompleted, this, &CMappingComponent::ps_modelMatched);
|
||||
}
|
||||
|
||||
void CMappingComponent::ps_aircraftModelsLoaded()
|
||||
{
|
||||
Q_ASSERT(getIContextSimulator());
|
||||
this->ui->tvp_AircraftModels->updateContainer(getIContextSimulator()->getInstalledModels());
|
||||
}
|
||||
|
||||
void CMappingComponent::ps_modelMatched(const BlackMisc::Network::CAircraftModel &model)
|
||||
{
|
||||
Q_UNUSED(model);
|
||||
ps_onMappingsChanged();
|
||||
}
|
||||
|
||||
void CMappingComponent::ps_onMappingsChanged()
|
||||
{
|
||||
Q_ASSERT(getIContextSimulator());
|
||||
this->ui->tvp_CurrentMappings->updateContainer(getIContextSimulator()->getCurrentlyMatchedModels());
|
||||
}
|
||||
|
||||
void CMappingComponent::ps_countChanged(int count)
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
int am = this->indexOf(this->ui->tb_AircraftModels);
|
||||
int cm = this->indexOf(this->ui->tb_CurrentMappings);
|
||||
QString a = this->tabBar()->tabText(am);
|
||||
QString c = this->tabBar()->tabText(cm);
|
||||
a = CGuiUtility::replaceTabCountValue(a, this->countAircraftModels());
|
||||
c = CGuiUtility::replaceTabCountValue(c, this->countCurrentMappings());
|
||||
this->tabBar()->setTabText(am, a);
|
||||
this->tabBar()->setTabText(cm, c);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
72
src/blackgui/components/mappingcomponent.h
Normal file
72
src/blackgui/components/mappingcomponent.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_MAPPINGCOMPONENT_H
|
||||
#define BLACKGUI_MAPPINGCOMPONENT_H
|
||||
|
||||
#include "blackgui/components/enableforruntime.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackmisc/nwaircraftmodel.h"
|
||||
#include <QTabWidget>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CMappingComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
//! Mappings, models etc.
|
||||
class CMappingComponent :
|
||||
public QTabWidget,
|
||||
public CEnableForDockWidgetInfoArea,
|
||||
public CEnableForRuntime
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CMappingComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CMappingComponent();
|
||||
|
||||
//! Number of current mappings
|
||||
int countCurrentMappings() const;
|
||||
|
||||
//! Numer of models
|
||||
int countAircraftModels() const;
|
||||
|
||||
protected:
|
||||
//! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet
|
||||
void runtimeHasBeenSet() override;
|
||||
|
||||
private slots:
|
||||
//! Aircraft models available
|
||||
void ps_aircraftModelsLoaded();
|
||||
|
||||
//! Mappings changed
|
||||
void ps_onMappingsChanged();
|
||||
|
||||
//! Model matched
|
||||
void ps_modelMatched(const BlackMisc::Network::CAircraftModel &model);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CMappingComponent> ui;
|
||||
|
||||
//! Changed count
|
||||
void ps_countChanged(int count);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
93
src/blackgui/components/mappingcomponent.ui
Normal file
93
src/blackgui/components/mappingcomponent.ui
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CMappingComponent</class>
|
||||
<widget class="QTabWidget" name="CMappingComponent">
|
||||
<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_CurrentMappings">
|
||||
<attribute name="title">
|
||||
<string>Current mappings</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="vl_CurrentMappings">
|
||||
<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::CAircraftModelView" name="tvp_CurrentMappings">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tb_AircraftModels">
|
||||
<attribute name="title">
|
||||
<string>Aircraft models</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="vl_AircraftModels">
|
||||
<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::CAircraftModelView" name="tvp_AircraftModels">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Views::CAircraftModelView</class>
|
||||
<extends>QTableView</extends>
|
||||
<header>blackgui/views/aircraftmodelview.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user