diff --git a/src/blackgui/components/datainfoareacomponent.cpp b/src/blackgui/components/datainfoareacomponent.cpp
index c6dd20be6..3ecdca277 100644
--- a/src/blackgui/components/datainfoareacomponent.cpp
+++ b/src/blackgui/components/datainfoareacomponent.cpp
@@ -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();
}
}
diff --git a/src/blackgui/components/datainfoareacomponent.h b/src/blackgui/components/datainfoareacomponent.h
index d4902c5ee..39fe9c229 100644
--- a/src/blackgui/components/datainfoareacomponent.h
+++ b/src/blackgui/components/datainfoareacomponent.h
@@ -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;
diff --git a/src/blackgui/components/datainfoareacomponent.ui b/src/blackgui/components/datainfoareacomponent.ui
index 2d97239bd..adde95fc6 100644
--- a/src/blackgui/components/datainfoareacomponent.ui
+++ b/src/blackgui/components/datainfoareacomponent.ui
@@ -6,8 +6,8 @@
0
0
- 485
- 55
+ 349
+ 37
@@ -260,15 +260,6 @@
-
-
- QFrame::NoFrame
-
-
- QFrame::Plain
-
-
- 0
-
0
@@ -312,7 +303,7 @@
4
-
+
0
@@ -330,12 +321,6 @@
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
0
@@ -378,8 +363,8 @@
4
-
-
+
+
0
@@ -396,14 +381,8 @@
0
-
-
-
- QFrame::StyledPanel
-
-
- QFrame::Raised
-
-
+
+
0
@@ -435,6 +414,67 @@
+
+
+ Qt::TopDockWidgetArea
+
+
+ Aircraft categories
+
+
+ 4
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+
+ 0
+
+
+ 0
+
+
+ 2
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
+
+
+
+
+
+
@@ -479,6 +519,12 @@
blackgui/components/dbcountrycomponent.h
1
+
+ BlackGui::Components::CDbAircraftCategoryComponent
+ QFrame
+ blackgui/components/dbaircraftcategorycomponent.h
+ 1
+
diff --git a/src/blackgui/components/dbaircraftcategorycomponent.cpp b/src/blackgui/components/dbaircraftcategorycomponent.cpp
new file mode 100644
index 000000000..48ea8538f
--- /dev/null
+++ b/src/blackgui/components/dbaircraftcategorycomponent.cpp
@@ -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
+
+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
diff --git a/src/blackgui/components/dbaircraftcategorycomponent.h b/src/blackgui/components/dbaircraftcategorycomponent.h
new file mode 100644
index 000000000..1a5dff342
--- /dev/null
+++ b/src/blackgui/components/dbaircraftcategorycomponent.h
@@ -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
+
+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;
+ };
+ } // ns
+} // ns
+
+#endif // guard
diff --git a/src/blackgui/components/dbaircraftcategorycomponent.ui b/src/blackgui/components/dbaircraftcategorycomponent.ui
new file mode 100644
index 000000000..d6eb915b6
--- /dev/null
+++ b/src/blackgui/components/dbaircraftcategorycomponent.ui
@@ -0,0 +1,86 @@
+
+
+ CDbAircraftCategoryComponent
+
+
+
+ 0
+ 0
+ 278
+ 235
+
+
+
+ Aircraft category
+
+
+
+ 2
+
+
+ 2
+
+
+ 2
+
+
+ 2
+
+ -
+
+
+ 0
+
+
+
+ Tree
+
+
+
-
+
+
+ false
+
+
+
+
+
+
+
+ Table
+
+
+ -
+
+
+ QAbstractItemView::SingleSelection
+
+
+ QAbstractItemView::SelectRows
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+ BlackGui::Views::CAircraftCategoryView
+ QTableView
+ blackgui/views/aircraftcategoryview.h
+
+
+ BlackGui::Views::CAircraftCategoryTreeView
+ QTreeView
+ blackgui/views/aircraftcategorytreeview.h
+
+
+
+
+