From 008ea148126c9d623211896467d364ef346d1407 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 24 Sep 2015 00:10:13 +0200 Subject: [PATCH] refs #452 components for the DB entities * display in view * filter --- .../components/dbaircrafticaocomponent.cpp | 74 ++++++++++++++++ .../components/dbaircrafticaocomponent.h | 64 ++++++++++++++ .../components/dbaircrafticaocomponent.ui | 84 +++++++++++++++++++ .../components/dbairlineicaocomponent.cpp | 70 ++++++++++++++++ .../components/dbairlineicaocomponent.h | 59 +++++++++++++ .../components/dbairlineicaocomponent.ui | 78 +++++++++++++++++ .../components/dbcountrycomponent.cpp | 69 +++++++++++++++ src/blackgui/components/dbcountrycomponent.h | 61 ++++++++++++++ src/blackgui/components/dbcountrycomponent.ui | 78 +++++++++++++++++ .../components/dbdistributorcomponent.cpp | 65 ++++++++++++++ .../components/dbdistributorcomponent.h | 61 ++++++++++++++ .../components/dbdistributorcomponent.ui | 75 +++++++++++++++++ src/blackgui/components/dbliverycomponent.cpp | 75 +++++++++++++++++ src/blackgui/components/dbliverycomponent.h | 64 ++++++++++++++ src/blackgui/components/dbliverycomponent.ui | 73 ++++++++++++++++ src/blackgui/components/dbmodelcomponent.cpp | 79 +++++++++++++++++ src/blackgui/components/dbmodelcomponent.h | 63 ++++++++++++++ src/blackgui/components/dbmodelcomponent.ui | 84 +++++++++++++++++++ 18 files changed, 1276 insertions(+) create mode 100644 src/blackgui/components/dbaircrafticaocomponent.cpp create mode 100644 src/blackgui/components/dbaircrafticaocomponent.h create mode 100644 src/blackgui/components/dbaircrafticaocomponent.ui create mode 100644 src/blackgui/components/dbairlineicaocomponent.cpp create mode 100644 src/blackgui/components/dbairlineicaocomponent.h create mode 100644 src/blackgui/components/dbairlineicaocomponent.ui create mode 100644 src/blackgui/components/dbcountrycomponent.cpp create mode 100644 src/blackgui/components/dbcountrycomponent.h create mode 100644 src/blackgui/components/dbcountrycomponent.ui create mode 100644 src/blackgui/components/dbdistributorcomponent.cpp create mode 100644 src/blackgui/components/dbdistributorcomponent.h create mode 100644 src/blackgui/components/dbdistributorcomponent.ui create mode 100644 src/blackgui/components/dbliverycomponent.cpp create mode 100644 src/blackgui/components/dbliverycomponent.h create mode 100644 src/blackgui/components/dbliverycomponent.ui create mode 100644 src/blackgui/components/dbmodelcomponent.cpp create mode 100644 src/blackgui/components/dbmodelcomponent.h create mode 100644 src/blackgui/components/dbmodelcomponent.ui diff --git a/src/blackgui/components/dbaircrafticaocomponent.cpp b/src/blackgui/components/dbaircrafticaocomponent.cpp new file mode 100644 index 000000000..22029d717 --- /dev/null +++ b/src/blackgui/components/dbaircrafticaocomponent.cpp @@ -0,0 +1,74 @@ +/* Copyright (C) 2015 + * 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 "ui_dbaircrafticaocomponent.h" +#include "dbaircrafticaocomponent.h" +#include + +using namespace BlackMisc::Network; +using namespace BlackMisc::Aviation; +using namespace BlackGui::Views; + +namespace BlackGui +{ + namespace Components + { + + CDbAircraftIcaoComponent::CDbAircraftIcaoComponent(QWidget *parent) : + QFrame(parent), + ui(new Ui::CDbAircraftIcaoComponent) + { + ui->setupUi(this); + this->ui->tvp_AircraftIcao->setResizeMode(CViewBaseNonTemplate::ResizingOff); + connect(this->ui->tvp_AircraftIcao, &CAircraftIcaoCodeView::requestNewBackendData, this, &CDbAircraftIcaoComponent::ps_reload); + + this->ui->tvp_AircraftIcao->allowDragDropValueObjects(true, false); + this->ui->tvp_AircraftIcao->setFilterWidget(this->ui->filter_AircraftIcao); + } + + CDbAircraftIcaoComponent::~CDbAircraftIcaoComponent() + { } + + void CDbAircraftIcaoComponent::setProvider(IWebDataServicesProvider *webDataReaderProvider) + { + CWebDataServicesAware::setProvider(webDataReaderProvider); + this->ui->filter_AircraftIcao->setProvider(webDataReaderProvider); + connectSwiftDatabaseSignals( + this, + std::bind(&CDbAircraftIcaoComponent::ps_icaoRead, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3) + ); + int c = getAircraftIcaoCodesCount(); + if (c > 0) + { + ps_icaoRead(CDbFlags::AircraftIcaoEntity, CDbFlags::ReadFinished, c); + } + } + + void CDbAircraftIcaoComponent::filter(const CAircraftIcaoCode &icao) + { + this->ui->filter_AircraftIcao->filter(icao); + } + + void CDbAircraftIcaoComponent::ps_icaoRead(CDbFlags::Entity entity, CDbFlags::ReadState readState, int count) + { + Q_UNUSED(count); + if (entity.testFlag(CDbFlags::AircraftIcaoEntity) && readState == CDbFlags::ReadFinished) + { + this->ui->tvp_AircraftIcao->updateContainerMaybeAsync(this->getAircraftIcaoCodes()); + } + } + + void CDbAircraftIcaoComponent::ps_reload() + { + if (!hasProvider()) { return; } + triggerRead(CDbFlags::AircraftIcaoEntity); + } + + } // ns +} // ns diff --git a/src/blackgui/components/dbaircrafticaocomponent.h b/src/blackgui/components/dbaircrafticaocomponent.h new file mode 100644 index 000000000..5177ea354 --- /dev/null +++ b/src/blackgui/components/dbaircrafticaocomponent.h @@ -0,0 +1,64 @@ +/* Copyright (C) 2015 + * 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_DBAIRCRAFTICAOCOMPONENT_H +#define BLACKGUI_COMPONENTS_DBAIRCRAFTICAOCOMPONENT_H + +#include "blackgui/blackguiexport.h" +#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackmisc/network/webdataservicesprovider.h" +#include +#include + +namespace Ui { class CDbAircraftIcaoComponent; } + +namespace BlackGui +{ + namespace Components + { + /** + * DB aircraft ICAO data + */ + class BLACKGUI_EXPORT CDbAircraftIcaoComponent : + public QFrame, + public CEnableForDockWidgetInfoArea, + public BlackMisc::Network::CWebDataServicesAware + { + Q_OBJECT + + public: + //! Constructor + explicit CDbAircraftIcaoComponent(QWidget *parent = nullptr); + + //! Destructor + ~CDbAircraftIcaoComponent(); + + //! Set the provider + virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReaderProvider) override; + + public slots: + //! Filter by ICAO as default + void filter(const BlackMisc::Aviation::CAircraftIcaoCode &icao); + + private slots: + //! ICAO codes have been read + void ps_icaoRead(BlackMisc::Network::CDbFlags::Entity entity, BlackMisc::Network::CDbFlags::ReadState readState, int count); + + //! Reload models + void ps_reload(); + + private: + QScopedPointer ui; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/dbaircrafticaocomponent.ui b/src/blackgui/components/dbaircrafticaocomponent.ui new file mode 100644 index 000000000..65f3640fc --- /dev/null +++ b/src/blackgui/components/dbaircrafticaocomponent.ui @@ -0,0 +1,84 @@ + + + CDbAircraftIcaoComponent + + + + 0 + 0 + 400 + 300 + + + + Frame + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 4 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 16777215 + 100 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + + + + + + BlackGui::Views::CAircraftIcaoCodeView + QTableView +
blackgui/views/aircrafticaoview.h
+
+ + BlackGui::Filters::CAircraftIcaoFilterBar + QFrame +
blackgui/filters/aircrafticaofilterbar.h
+ 1 +
+
+ + +
diff --git a/src/blackgui/components/dbairlineicaocomponent.cpp b/src/blackgui/components/dbairlineicaocomponent.cpp new file mode 100644 index 000000000..9306da2fa --- /dev/null +++ b/src/blackgui/components/dbairlineicaocomponent.cpp @@ -0,0 +1,70 @@ +/* Copyright (C) 2015 + * 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 "dbairlineicaocomponent.h" +#include "ui_dbairlineicaocomponent.h" +#include "blackcore/webdataservices.h" +#include + +using namespace BlackCore; +using namespace BlackMisc::Network; +using namespace BlackGui::Views; + +namespace BlackGui +{ + namespace Components + { + CDbAirlineIcaoComponent::CDbAirlineIcaoComponent(QWidget *parent) : + QFrame(parent), + CWebDataServicesAware(nullptr), + ui(new Ui::CDbAirlineIcaoComponent) + { + ui->setupUi(this); + this->ui->tvp_AirlineIcao->setResizeMode(CViewBaseNonTemplate::ResizingOff); + this->ui->tvp_AirlineIcao->setResizeMode(CViewBaseNonTemplate::ResizingOff); + this->ui->tvp_AirlineIcao->allowDragDropValueObjects(true, false); + this->ui->tvp_AirlineIcao->setFilterWidget(this->ui->filter_AirlineIcao); + connect(this->ui->tvp_AirlineIcao, &CAirlineIcaoCodeView::requestNewBackendData, this, &CDbAirlineIcaoComponent::ps_reload); + } + + CDbAirlineIcaoComponent::~CDbAirlineIcaoComponent() + { } + + void CDbAirlineIcaoComponent::setProvider(IWebDataServicesProvider *webDataReaderProvider) + { + CWebDataServicesAware::setProvider(webDataReaderProvider); + this->ui->filter_AirlineIcao->setProvider(webDataReaderProvider); + webDataReaderProvider->connectSwiftDatabaseSignals( + this, + std::bind(&CDbAirlineIcaoComponent::ps_icaoRead, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3) + ); + int c = this->getAirlineIcaoCodesCount(); + if (c > 0) + { + this->ps_icaoRead(CDbFlags::AirlineIcaoEntity, CDbFlags::ReadFinished, c); + } + } + + void CDbAirlineIcaoComponent::ps_icaoRead(CDbFlags::Entity entity, CDbFlags::ReadState readState, int count) + { + Q_UNUSED(count); + if (entity.testFlag(CDbFlags::AirlineIcaoEntity) && readState == CDbFlags::ReadFinished) + { + this->ui->tvp_AirlineIcao->updateContainerMaybeAsync(this->getAirlineIcaoCodes()); + } + } + + void CDbAirlineIcaoComponent::ps_reload() + { + if (!hasProvider()) { return; } + triggerRead(CDbFlags::AirlineIcaoEntity); + } + + } // ns +} // ns diff --git a/src/blackgui/components/dbairlineicaocomponent.h b/src/blackgui/components/dbairlineicaocomponent.h new file mode 100644 index 000000000..41123e10c --- /dev/null +++ b/src/blackgui/components/dbairlineicaocomponent.h @@ -0,0 +1,59 @@ +/* Copyright (C) 2015 + * 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_DBAIRLINEICAOCOMPONENT_H +#define BLACKGUI_COMPONENTS_DBAIRLINEICAOCOMPONENT_H + +#include "blackgui/blackguiexport.h" +#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackmisc/network/webdataservicesprovider.h" +#include +#include + +namespace Ui { class CDbAirlineIcaoComponent; } + +namespace BlackGui +{ + namespace Components + { + /** + * Airline ICAO code + */ + class BLACKGUI_EXPORT CDbAirlineIcaoComponent : + public QFrame, + public CEnableForDockWidgetInfoArea, + public BlackMisc::Network::CWebDataServicesAware + { + Q_OBJECT + + public: + //! Constructor + explicit CDbAirlineIcaoComponent(QWidget *parent = nullptr); + + //! Destructor + ~CDbAirlineIcaoComponent(); + + //! Set the provider + virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReaderProvider) override; + + private slots: + //! ICAO codes have been read + void ps_icaoRead(BlackMisc::Network::CDbFlags::Entity entity, BlackMisc::Network::CDbFlags::ReadState readState, int count); + + //! Reload models + void ps_reload(); + + private: + QScopedPointer ui; + }; + } +} +#endif // guard diff --git a/src/blackgui/components/dbairlineicaocomponent.ui b/src/blackgui/components/dbairlineicaocomponent.ui new file mode 100644 index 000000000..2fde484fe --- /dev/null +++ b/src/blackgui/components/dbairlineicaocomponent.ui @@ -0,0 +1,78 @@ + + + CDbAirlineIcaoComponent + + + + 0 + 0 + 400 + 300 + + + + Frame + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 4 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + + + + + + BlackGui::Views::CAirlineIcaoCodeView + QTableView +
blackgui/views/airlineicaoview.h
+
+ + BlackGui::Filters::CAirlineIcaoFilterBar + QFrame +
blackgui/filters/airlineicaofilterbar.h
+ 1 +
+
+ + +
diff --git a/src/blackgui/components/dbcountrycomponent.cpp b/src/blackgui/components/dbcountrycomponent.cpp new file mode 100644 index 000000000..aa0b0bc18 --- /dev/null +++ b/src/blackgui/components/dbcountrycomponent.cpp @@ -0,0 +1,69 @@ +/* Copyright (C) 2015 + * 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 "dbcountrycomponent.h" +#include "ui_dbcountrycomponent.h" +#include "blackcore/webdataservices.h" +#include + +using namespace BlackCore; +using namespace BlackMisc::Network; +using namespace BlackGui::Views; + +namespace BlackGui +{ + namespace Components + { + CDbCountryComponent::CDbCountryComponent(QWidget *parent) : + QFrame(parent), + CWebDataServicesAware(nullptr), + ui(new Ui::CDbCountryComponent) + { + ui->setupUi(this); + this->ui->tvp_Countries->setResizeMode(CViewBaseNonTemplate::ResizingOnce); + connect(this->ui->tvp_Countries, &CCountryView::requestNewBackendData, this, &CDbCountryComponent::ps_reload); + + // filter and drag and drop + this->ui->tvp_Countries->setFilterWidget(this->ui->filter_CountryComponent); + this->ui->tvp_Countries->allowDragDropValueObjects(true, false); + } + + CDbCountryComponent::~CDbCountryComponent() + { } + + void CDbCountryComponent::setProvider(IWebDataServicesProvider *webDataReaderProvider) + { + CWebDataServicesAware::setProvider(webDataReaderProvider); + connectSwiftDatabaseSignals( + this, + std::bind(&CDbCountryComponent::ps_countriesRead, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3) + ); + int c = getCountriesCount(); + if (c > 0) + { + ps_countriesRead(CDbFlags::CountryEntity, CDbFlags::ReadFinished, c); + } + } + + void CDbCountryComponent::ps_countriesRead(CDbFlags::Entity entity, CDbFlags::ReadState readState, int count) + { + Q_UNUSED(count); + if (entity.testFlag(CDbFlags::CountryEntity) && readState == CDbFlags::ReadFinished) + { + this->ui->tvp_Countries->updateContainerMaybeAsync(this->getCountries()); + } + } + + void CDbCountryComponent::ps_reload() + { + if (!hasProvider()) { return; } + triggerRead(CDbFlags::CountryEntity); + } + } // ns +} // ns diff --git a/src/blackgui/components/dbcountrycomponent.h b/src/blackgui/components/dbcountrycomponent.h new file mode 100644 index 000000000..1c4f62dc4 --- /dev/null +++ b/src/blackgui/components/dbcountrycomponent.h @@ -0,0 +1,61 @@ +/* Copyright (C) 2015 + * 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_DBCOUNTRYCOMPONENT_H +#define BLACKGUI_COMPONENTS_DBCOUNTRYCOMPONENT_H + +#include "blackgui/blackguiexport.h" +#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackmisc/network/webdataservicesprovider.h" +#include +#include + +namespace Ui { class CDbCountryComponent; } + +namespace BlackGui +{ + namespace Components + { + /*! + * The countries + */ + class BLACKGUI_EXPORT CDbCountryComponent : + public QFrame, + public CEnableForDockWidgetInfoArea, + public BlackMisc::Network::CWebDataServicesAware + { + Q_OBJECT + + public: + //! Constructor + explicit CDbCountryComponent(QWidget *parent = nullptr); + + //! Destructor + ~CDbCountryComponent(); + + //! Set the provider + virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReaderProvider) override; + + private slots: + //! Countries have been read + void ps_countriesRead(BlackMisc::Network::CDbFlags::Entity entity, BlackMisc::Network::CDbFlags::ReadState readState, int count); + + //! Reload models + void ps_reload(); + + private: + QScopedPointer ui; + }; + + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/dbcountrycomponent.ui b/src/blackgui/components/dbcountrycomponent.ui new file mode 100644 index 000000000..b9ad9b779 --- /dev/null +++ b/src/blackgui/components/dbcountrycomponent.ui @@ -0,0 +1,78 @@ + + + CDbCountryComponent + + + + 0 + 0 + 400 + 300 + + + + Frame + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 4 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + + + + + + BlackGui::Views::CCountryView + QTableView +
blackgui/views/countryview.h
+
+ + BlackGui::Filters::CCountryFilterBar + QFrame +
blackgui/filters/countryfilterbar.h
+ 1 +
+
+ + +
diff --git a/src/blackgui/components/dbdistributorcomponent.cpp b/src/blackgui/components/dbdistributorcomponent.cpp new file mode 100644 index 000000000..2c98e3610 --- /dev/null +++ b/src/blackgui/components/dbdistributorcomponent.cpp @@ -0,0 +1,65 @@ +/* Copyright (C) 2015 + * 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 "ui_dbdistributorcomponent.h" +#include "dbdistributorcomponent.h" +#include +#include + +using namespace BlackMisc::Network; +using namespace BlackGui::Views; + +namespace BlackGui +{ + namespace Components + { + CDbDistributorComponent::CDbDistributorComponent(QWidget *parent) : + QFrame(parent), + CWebDataServicesAware(nullptr), + ui(new Ui::CDbDistributorComponent) + { + ui->setupUi(this); + this->ui->tvp_Distributors->setResizeMode(CViewBaseNonTemplate::ResizingAuto); + this->ui->tvp_Distributors->allowDragDropValueObjects(true, false); + connect(this->ui->tvp_Distributors, &CDistributorView::requestNewBackendData, this, &CDbDistributorComponent::ps_reload); + } + + CDbDistributorComponent::~CDbDistributorComponent() + { } + + void CDbDistributorComponent::setProvider(IWebDataServicesProvider *webDataReaderProvider) + { + CWebDataServicesAware::setProvider(webDataReaderProvider); + connectSwiftDatabaseSignals( + this, + std::bind(&CDbDistributorComponent::ps_distributorsRead, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3) + ); + int c = getDistributorsCount(); + if (c > 0) + { + ps_distributorsRead(CDbFlags::DistributorEntity, CDbFlags::ReadFinished, c); + } + } + + void CDbDistributorComponent::ps_distributorsRead(CDbFlags::Entity entity, CDbFlags::ReadState readState, int count) + { + Q_UNUSED(count); + if (entity.testFlag(CDbFlags::DistributorEntity) && readState == CDbFlags::ReadFinished) + { + this->ui->tvp_Distributors->updateContainer(this->getDistributors()); + } + } + + void CDbDistributorComponent::ps_reload() + { + if (!hasProvider()) { return; } + triggerRead(CDbFlags::DistributorEntity); + } + } // ns +} // ns diff --git a/src/blackgui/components/dbdistributorcomponent.h b/src/blackgui/components/dbdistributorcomponent.h new file mode 100644 index 000000000..5857dd309 --- /dev/null +++ b/src/blackgui/components/dbdistributorcomponent.h @@ -0,0 +1,61 @@ +/* Copyright (C) 2015 + * 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_DBDISTRIBUTORCOMPONENT_H +#define BLACKGUI_COMPONENTS_DBDISTRIBUTORCOMPONENT_H + +#include "blackgui/blackguiexport.h" +#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackmisc/network/webdataservicesprovider.h" +#include +#include + +namespace Ui { class CDbDistributorComponent; } + +namespace BlackGui +{ + namespace Components + { + /** + * Distributors + */ + class BLACKGUI_EXPORT CDbDistributorComponent : + public QFrame, + public CEnableForDockWidgetInfoArea, + public BlackMisc::Network::CWebDataServicesAware + { + Q_OBJECT + + public: + //! Constructor + explicit CDbDistributorComponent(QWidget *parent = nullptr); + + //! Destructor + ~CDbDistributorComponent(); + + //! Set the provider + virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReaderProvider) override; + + private slots: + //! Distributors have been read + void ps_distributorsRead(BlackMisc::Network::CDbFlags::Entity entity, BlackMisc::Network::CDbFlags::ReadState readState, int count); + + //! Reload models + void ps_reload(); + + private: + QScopedPointer ui; + }; + + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/dbdistributorcomponent.ui b/src/blackgui/components/dbdistributorcomponent.ui new file mode 100644 index 000000000..011d01b86 --- /dev/null +++ b/src/blackgui/components/dbdistributorcomponent.ui @@ -0,0 +1,75 @@ + + + CDbDistributorComponent + + + + 0 + 0 + 400 + 300 + + + + Frame + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 4 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + QAbstractItemView::DragOnly + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + + + + + + BlackGui::Views::CDistributorView + QTableView +
blackgui/views/distributorview.h
+
+
+ + +
diff --git a/src/blackgui/components/dbliverycomponent.cpp b/src/blackgui/components/dbliverycomponent.cpp new file mode 100644 index 000000000..2d2cf8da2 --- /dev/null +++ b/src/blackgui/components/dbliverycomponent.cpp @@ -0,0 +1,75 @@ +/* Copyright (C) 2015 + * 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 "ui_dbliverycomponent.h" +#include "dbliverycomponent.h" +#include "blackcore/webdataservices.h" +#include + +using namespace BlackCore; +using namespace BlackGui::Views; +using namespace BlackMisc::Network; + +namespace BlackGui +{ + namespace Components + { + CDbLiveryComponent::CDbLiveryComponent(QWidget *parent) : + QFrame(parent), + CWebDataServicesAware(nullptr), + ui(new Ui::CDbLiveryComponent) + { + ui->setupUi(this); + connect(this->ui->tvp_Liveries, &CLiveryView::requestNewBackendData, this, &CDbLiveryComponent::ps_reload); + + // filter and drag and drop + this->ui->tvp_Liveries->setFilterWidget(this->ui->filter_Livery); + this->ui->tvp_Liveries->allowDragDropValueObjects(true, false); + } + + CDbLiveryComponent::~CDbLiveryComponent() + { } + + void CDbLiveryComponent::setProvider(IWebDataServicesProvider *webDataReaderProvider) + { + CWebDataServicesAware::setProvider(webDataReaderProvider); + connectSwiftDatabaseSignals( + this, + std::bind(&CDbLiveryComponent::ps_liveriesRead, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3) + ); + int c = getLiveriesCount(); + if (c > 0) + { + ps_liveriesRead(CDbFlags::LiveryEntity, CDbFlags::ReadFinished, c); + } + } + + void CDbLiveryComponent::filter(const BlackMisc::Aviation::CLivery &livery) + { + this->ui->filter_Livery->filter(livery); + } + + void CDbLiveryComponent::ps_liveriesRead(CDbFlags::Entity entity, CDbFlags::ReadState readState, int count) + { + Q_UNUSED(count); + if (entity.testFlag(CDbFlags::LiveryEntity) && readState == CDbFlags::ReadFinished) + { + this->ui->tvp_Liveries->updateContainerMaybeAsync(this->getLiveries()); + } + } + + void CDbLiveryComponent::ps_reload() + { + if (!hasProvider()) { return; } + triggerRead(CDbFlags::LiveryEntity); + } + + } // ns +} // ns + diff --git a/src/blackgui/components/dbliverycomponent.h b/src/blackgui/components/dbliverycomponent.h new file mode 100644 index 000000000..d78988afb --- /dev/null +++ b/src/blackgui/components/dbliverycomponent.h @@ -0,0 +1,64 @@ +/* Copyright (C) 2015 + * 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_DBLIVERYCOMPONENT_H +#define BLACKGUI_COMPONENTS_DBLIVERYCOMPONENT_H + +#include "blackgui/blackguiexport.h" +#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackmisc/network/webdataservicesprovider.h" +#include +#include + +namespace Ui { class CDbLiveryComponent; } + +namespace BlackGui +{ + namespace Components + { + /*! + * Liveries from DB + */ + class BLACKGUI_EXPORT CDbLiveryComponent : + public QFrame, + public CEnableForDockWidgetInfoArea, + public BlackMisc::Network::CWebDataServicesAware + { + Q_OBJECT + + public: + //! Constructor + explicit CDbLiveryComponent(QWidget *parent = nullptr); + + //! Destructor + virtual ~CDbLiveryComponent(); + + //! Set the provider + virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReaderProvider) override; + + public slots: + //! Filter by livery as default + void filter(const BlackMisc::Aviation::CLivery &livery); + + private slots: + //! Liveries codes have been read + void ps_liveriesRead(BlackMisc::Network::CDbFlags::Entity entity, BlackMisc::Network::CDbFlags::ReadState readState, int count); + + //! Reload models + void ps_reload(); + + private: + QScopedPointer ui; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/dbliverycomponent.ui b/src/blackgui/components/dbliverycomponent.ui new file mode 100644 index 000000000..6927fa35b --- /dev/null +++ b/src/blackgui/components/dbliverycomponent.ui @@ -0,0 +1,73 @@ + + + CDbLiveryComponent + + + Liveries + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + + 4 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + + + + + + BlackGui::Views::CLiveryView + QTableView +
blackgui/views/liveryview.h
+
+ + BlackGui::Filters::CLiveryFilterBar + QFrame +
blackgui/filters/liveryfilterbar.h
+ 1 +
+
+ + +
diff --git a/src/blackgui/components/dbmodelcomponent.cpp b/src/blackgui/components/dbmodelcomponent.cpp new file mode 100644 index 000000000..ca4e69214 --- /dev/null +++ b/src/blackgui/components/dbmodelcomponent.cpp @@ -0,0 +1,79 @@ +/* Copyright (C) 2015 + * 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 "dbmodelcomponent.h" +#include "blackgui/stylesheetutility.h" +#include "ui_dbmodelcomponent.h" +#include + +using namespace BlackMisc; +using namespace BlackMisc::Network; +using namespace BlackGui::Views; +using namespace BlackGui::Models; + +namespace BlackGui +{ + namespace Components + { + CDbModelComponent::CDbModelComponent(QWidget *parent) : + QFrame(parent), + CWebDataServicesAware(nullptr), // provider not yet available + ui(new Ui::CDbModelComponent) + { + ui->setupUi(this); + this->ui->tvp_AircraftModel->setAircraftModelMode(CAircraftModelListModel::Database); + connect(this->ui->tvp_AircraftModel, &CAircraftModelView::requestNewBackendData, this, &CDbModelComponent::ps_reload); + connect(&CStyleSheetUtility::instance(), &CStyleSheetUtility::styleSheetsChanged, this, &CDbModelComponent::ps_onStyleSheetChanged); + + // filter and drag and drop + this->ui->tvp_AircraftModel->setFilterWidget(this->ui->filter_AircraftModelFilter); + this->ui->tvp_AircraftModel->allowDragDropValueObjects(true, false); + } + + CDbModelComponent::~CDbModelComponent() + { + gracefulShutdown(); + } + + void CDbModelComponent::setProvider(IWebDataServicesProvider *webDataReaderProvider) + { + CWebDataServicesAware::setProvider(webDataReaderProvider); + webDataReaderProvider->connectSwiftDatabaseSignals( + this, + std::bind(&CDbModelComponent::ps_modelsRead, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3) + ); + int c = getModelsCount(); + if (c > 0) + { + ps_modelsRead(CDbFlags::ModelEntity, CDbFlags::ReadFinished, c); + } + } + + void CDbModelComponent::ps_modelsRead(CDbFlags::Entity entity, CDbFlags::ReadState readState, int count) + { + Q_UNUSED(count); + if (entity.testFlag(CDbFlags::ModelEntity) && readState == CDbFlags::ReadFinished) + { + this->ui->tvp_AircraftModel->updateContainer(this->getModels()); + } + } + + void CDbModelComponent::ps_reload() + { + if (!hasProvider()) { return; } + triggerRead(CDbFlags::ModelEntity); + } + + void CDbModelComponent::ps_onStyleSheetChanged() + { + // code goes here + } + + } // ns +} // ns diff --git a/src/blackgui/components/dbmodelcomponent.h b/src/blackgui/components/dbmodelcomponent.h new file mode 100644 index 000000000..569482783 --- /dev/null +++ b/src/blackgui/components/dbmodelcomponent.h @@ -0,0 +1,63 @@ +/* Copyright (C) 2015 + * 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 BLACKUI_COMPONENTS_DBMODELCOMPONENT_H +#define BLACKUI_COMPONENTS_DBMODELCOMPONENT_H + +#include "blackgui/blackguiexport.h" +#include "blackgui/components/enablefordockwidgetinfoarea.h" +#include "blackmisc/network/webdataservicesprovider.h" +#include +#include + +namespace Ui { class CDbModelComponent; } + +namespace BlackGui +{ + namespace Components + { + /** + * Database models from DB + */ + class BLACKGUI_EXPORT CDbModelComponent : + public QFrame, + public CEnableForDockWidgetInfoArea, + public BlackMisc::Network::CWebDataServicesAware + { + Q_OBJECT + + public: + //! Constructor + explicit CDbModelComponent(QWidget *parent = nullptr); + + //! Destructor + virtual ~CDbModelComponent(); + + //! Set the provider + virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReaderProvider) override; + + private slots: + //! Models have been read + void ps_modelsRead(BlackMisc::Network::CDbFlags::Entity entity, BlackMisc::Network::CDbFlags::ReadState readState, int count); + + //! Reload models + void ps_reload(); + + //! Style sheet changed + void ps_onStyleSheetChanged(); + + private: + QScopedPointer ui; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/dbmodelcomponent.ui b/src/blackgui/components/dbmodelcomponent.ui new file mode 100644 index 000000000..0a9089c37 --- /dev/null +++ b/src/blackgui/components/dbmodelcomponent.ui @@ -0,0 +1,84 @@ + + + CDbModelComponent + + + + 0 + 0 + 258 + 212 + + + + Database aircraft models + + + QFrame::StyledPanel + + + QFrame::Plain + + + 0 + + + + 4 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + false + + + + + + + + BlackGui::Views::CAircraftModelView + QTableView +
blackgui/views/aircraftmodelview.h
+
+ + BlackGui::Filters::CAircraftModelFilterBar + QFrame +
blackgui/filters/aircraftmodelfilterbar.h
+ 1 +
+
+ + +