mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
Ref T472, category UI component
This commit is contained in:
committed by
Mat Sutcliffe
parent
1b730dd0b1
commit
2aff3bb775
@@ -15,6 +15,7 @@
|
||||
#include "blackgui/components/dbdistributorcomponent.h"
|
||||
#include "blackgui/components/dbliverycomponent.h"
|
||||
#include "blackgui/components/dbmodelcomponent.h"
|
||||
#include "blackgui/components/dbaircraftcategorycomponent.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackmisc/icons.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
@@ -81,6 +82,11 @@ namespace BlackGui
|
||||
return ui->comp_DbCountries;
|
||||
}
|
||||
|
||||
CDbAircraftCategoryComponent *CDataInfoAreaComponent::getAircraftCategoryComponent() const
|
||||
{
|
||||
return ui->comp_DbAircraftCategories;
|
||||
}
|
||||
|
||||
bool CDataInfoAreaComponent::writeDbDataToResourceDir() const
|
||||
{
|
||||
if (!sGui || !sGui->getWebDataServices()->hasSuccesfullyConnectedSwiftDb())
|
||||
@@ -137,6 +143,7 @@ namespace BlackGui
|
||||
case InfoAreaLiveries:
|
||||
case InfoAreaModels:
|
||||
case InfoAreaCountries:
|
||||
case InfoAreaAircraftCategories:
|
||||
default:
|
||||
return QSize(800, 600);
|
||||
}
|
||||
@@ -148,11 +155,12 @@ namespace BlackGui
|
||||
switch (area)
|
||||
{
|
||||
case InfoAreaAircraftIcao: return CIcons::appAircraftIcao16();
|
||||
case InfoAreaAirlineIcao: return CIcons::appAirlineIcao16();
|
||||
case InfoAreaLiveries: return CIcons::appLiveries16();
|
||||
case InfoAreaAirlineIcao: return CIcons::appAirlineIcao16();
|
||||
case InfoAreaLiveries: return CIcons::appLiveries16();
|
||||
case InfoAreaDistributors: return CIcons::appDistributors16();
|
||||
case InfoAreaModels: return CIcons::appModels16();
|
||||
case InfoAreaCountries: return CIcons::appCountries16();
|
||||
case InfoAreaModels: return CIcons::appModels16();
|
||||
case InfoAreaCountries: return CIcons::appCountries16();
|
||||
case InfoAreaAircraftCategories: return CIcons::appAircraftCategories16();
|
||||
default: return CIcons::empty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace BlackGui
|
||||
class CDbDistributorComponent;
|
||||
class CDbLiveryComponent;
|
||||
class CDbModelComponent;
|
||||
class CDbAircraftCategoryComponent;
|
||||
|
||||
/**
|
||||
* Info area containing the DB data (models, liveries ...)
|
||||
@@ -48,13 +49,14 @@ namespace BlackGui
|
||||
enum InfoArea
|
||||
{
|
||||
// index must match tab index!
|
||||
InfoAreaModels = 0,
|
||||
InfoAreaLiveries = 1,
|
||||
InfoAreaDistributors = 2,
|
||||
InfoAreaAircraftIcao = 3,
|
||||
InfoAreaAirlineIcao = 4,
|
||||
InfoAreaCountries = 5,
|
||||
InfoAreaNone = -1
|
||||
InfoAreaModels = 0,
|
||||
InfoAreaLiveries = 1,
|
||||
InfoAreaDistributors = 2,
|
||||
InfoAreaAircraftIcao = 3,
|
||||
InfoAreaAirlineIcao = 4,
|
||||
InfoAreaCountries = 5,
|
||||
InfoAreaAircraftCategories = 6,
|
||||
InfoAreaNone = -1
|
||||
};
|
||||
|
||||
//! Constructor
|
||||
@@ -81,6 +83,9 @@ namespace BlackGui
|
||||
//! DB country component
|
||||
CDbCountryComponent *getCountryComponent() const;
|
||||
|
||||
//! DB aircraft category componentxs
|
||||
CDbAircraftCategoryComponent *getAircraftCategoryComponent() const;
|
||||
|
||||
public slots:
|
||||
//! Write to resource dir
|
||||
bool writeDbDataToResourceDir() const;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>485</width>
|
||||
<height>55</height>
|
||||
<width>349</width>
|
||||
<height>37</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -260,15 +260,6 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="fr_AircraftIcaoInner">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_AircraftIcaoCodeinner">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
@@ -312,7 +303,7 @@
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="qw_AirlineIcaoOuter">
|
||||
<layout class="QVBoxLayout" name="vlAirlineIcaoOuter">
|
||||
<layout class="QVBoxLayout" name="vl_AirlineIcaoOuter">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@@ -330,12 +321,6 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="fr_AirlineIcaoInner">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_AirlineIcaoInner">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
@@ -378,8 +363,8 @@
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="qw_Countries">
|
||||
<layout class="QVBoxLayout" name="vlAirlineIcaoOuter_2">
|
||||
<widget class="QWidget" name="qw_CountriesOuter">
|
||||
<layout class="QVBoxLayout" name="vl_CountriesOuter">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@@ -396,14 +381,8 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="fr_Countries">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_AirlineIcaoInner_2">
|
||||
<widget class="QFrame" name="fr_CountriesInner">
|
||||
<layout class="QVBoxLayout" name="vl_CountriesInner">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@@ -435,6 +414,67 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_AircraftCategories">
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::TopDockWidgetArea</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Aircraft categories</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>4</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="qw_AircraftCategoriesOuter">
|
||||
<layout class="QVBoxLayout" name="vl_AircraftCategoriesOuter">
|
||||
<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="QFrame" name="fr_AircraftCategoriesInner">
|
||||
<layout class="QVBoxLayout" name="vl_AircraftCategoriesInner">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CDbAircraftCategoryComponent" name="comp_DbAircraftCategories">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
@@ -479,6 +519,12 @@
|
||||
<header>blackgui/components/dbcountrycomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CDbAircraftCategoryComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/dbaircraftcategorycomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
80
src/blackgui/components/dbaircraftcategorycomponent.cpp
Normal file
80
src/blackgui/components/dbaircraftcategorycomponent.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
/* Copyright (C) 2019
|
||||
* 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 "dbaircraftcategorycomponent.h"
|
||||
#include "ui_dbaircraftcategorycomponent.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackcore/webdataservices.h"
|
||||
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackGui::Views;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CDbAircraftCategoryComponent::CDbAircraftCategoryComponent(QWidget *parent) :
|
||||
COverlayMessagesFrame(parent),
|
||||
ui(new Ui::CDbAircraftCategoryComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setViewWithIndicator(ui->tvp_AircraftCategoryView);
|
||||
|
||||
ui->tvp_AircraftCategoryView->setResizeMode(CAircraftCategoryView::ResizingOff);
|
||||
ui->tvp_AircraftCategoryView->allowDragDrop(true, false);
|
||||
ui->tvp_AircraftCategoryView->menuAddItems(CViewBaseNonTemplate::MenuCopy);
|
||||
// ui->tvp_AircraftCategoryView->setFilterWidget(ui->filter_AircraftIcao);
|
||||
|
||||
connect(ui->tvp_AircraftCategoryView, &CAircraftCategoryView::requestNewBackendData, this, &CDbAircraftCategoryComponent::onReload);
|
||||
connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbAircraftCategoryComponent::onCategoryRead, Qt::QueuedConnection);
|
||||
connect(sGui->getWebDataServices(), &CWebDataServices::entityDownloadProgress, this, &CDbAircraftCategoryComponent::onEntityDownloadProgress, Qt::QueuedConnection);
|
||||
this->onCategoryRead(CEntityFlags::AircraftCategoryEntity, CEntityFlags::ReadFinished, sGui->getWebDataServices()->getAircraftCategoriesCount());
|
||||
}
|
||||
|
||||
CDbAircraftCategoryComponent::~CDbAircraftCategoryComponent()
|
||||
{ }
|
||||
|
||||
void CDbAircraftCategoryComponent::onCategoryRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getWebDataServices()) { return; }
|
||||
if (!entity.testFlag(CEntityFlags::AircraftCategoryEntity)) { return; }
|
||||
|
||||
if (CEntityFlags::isFinishedReadState(readState))
|
||||
{
|
||||
this->showOverlayHTMLMessage(QStringLiteral("Updating"), 2000);
|
||||
const CAircraftCategoryList categories = sGui->getWebDataServices()->getAircraftCategories();
|
||||
ui->tvp_AircraftCategoryView->updateContainerMaybeAsync(categories);
|
||||
ui->tvp_AircraftCategoryTree->updateContainer(categories);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->showOverlayHTMLMessage(u"Current state: " % CEntityFlags::stateToString(readState), 10000);
|
||||
}
|
||||
}
|
||||
|
||||
void CDbAircraftCategoryComponent::onEntityDownloadProgress(CEntityFlags::Entity entity, int logId, int progress, qint64 current, qint64 max, const QUrl &url)
|
||||
{
|
||||
if (!entity.testFlag(CEntityFlags::AircraftCategoryEntity)) { return; }
|
||||
this->showDownloadProgress(progress, current, max, url, 5000);
|
||||
Q_UNUSED(logId);
|
||||
}
|
||||
|
||||
void CDbAircraftCategoryComponent::onReload()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
sGui->getWebDataServices()->triggerLoadingDirectlyFromDb(CEntityFlags::AircraftCategoryEntity, QDateTime());
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
60
src/blackgui/components/dbaircraftcategorycomponent.h
Normal file
60
src/blackgui/components/dbaircraftcategorycomponent.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* Copyright (C) 2019
|
||||
* 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_COMPONENTS_DBAIRCRAFTCATEGORYCOMPONENT_H
|
||||
#define BLACKGUI_COMPONENTS_DBAIRCRAFTCATEGORYCOMPONENT_H
|
||||
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/overlaymessagesframe.h"
|
||||
#include "blackgui/enableforviewbasedindicator.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/network/entityflags.h"
|
||||
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CDbAircraftCategoryComponent; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
/**
|
||||
* DB aircraft categories
|
||||
*/
|
||||
class BLACKGUI_EXPORT CDbAircraftCategoryComponent :
|
||||
public COverlayMessagesFrame,
|
||||
public CEnableForDockWidgetInfoArea,
|
||||
public CEnableForViewBasedIndicator
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CDbAircraftCategoryComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CDbAircraftCategoryComponent();
|
||||
|
||||
private:
|
||||
//! ICAO codes have been read
|
||||
void onCategoryRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count);
|
||||
|
||||
//! Download progress for an entity
|
||||
void onEntityDownloadProgress(BlackMisc::Network::CEntityFlags::Entity entity, int logId, int progress, qint64 current, qint64 max, const QUrl &url);
|
||||
|
||||
//! Reload models
|
||||
void onReload();
|
||||
|
||||
QScopedPointer<Ui::CDbAircraftCategoryComponent> ui;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
86
src/blackgui/components/dbaircraftcategorycomponent.ui
Normal file
86
src/blackgui/components/dbaircraftcategorycomponent.ui
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDbAircraftCategoryComponent</class>
|
||||
<widget class="QFrame" name="CDbAircraftCategoryComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>278</width>
|
||||
<height>235</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Aircraft category</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_AircraftCategoryComponent">
|
||||
<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="QTabWidget" name="tb_Views">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tb_TreeView">
|
||||
<attribute name="title">
|
||||
<string>Tree</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="vl_Tree">
|
||||
<item>
|
||||
<widget class="BlackGui::Views::CAircraftCategoryTreeView" name="tvp_AircraftCategoryTree">
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tb_TableView">
|
||||
<attribute name="title">
|
||||
<string>Table</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="vl_Table">
|
||||
<item>
|
||||
<widget class="BlackGui::Views::CAircraftCategoryView" name="tvp_AircraftCategoryView">
|
||||
<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>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Views::CAircraftCategoryView</class>
|
||||
<extends>QTableView</extends>
|
||||
<header>blackgui/views/aircraftcategoryview.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Views::CAircraftCategoryTreeView</class>
|
||||
<extends>QTreeView</extends>
|
||||
<header>blackgui/views/aircraftcategorytreeview.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user