diff --git a/src/blackgui/editors/aircrafticaoform.cpp b/src/blackgui/editors/aircrafticaoform.cpp new file mode 100644 index 000000000..4fb26de1b --- /dev/null +++ b/src/blackgui/editors/aircrafticaoform.cpp @@ -0,0 +1,158 @@ +/* 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 "blackgui/guiutility.h" +#include "blackmisc/aviation/aircrafticaocodelist.h" +#include "aircrafticaoform.h" +#include "ui_aircrafticaoform.h" + +using namespace BlackMisc; +using namespace BlackMisc::Aviation; +using namespace BlackGui::Components; + +namespace BlackGui +{ + namespace Editors + { + CAircraftIcaoForm::CAircraftIcaoForm(QWidget *parent) : + CForm(parent), + ui(new Ui::CAircraftIcaoForm) + { + ui->setupUi(this); + this->ui->lai_id->set(CIcons::appAircraftIcao16(), "Id:"); + this->ui->le_Updated->setReadOnly(true); + this->ui->le_Id->setReadOnly(true); + this->ui->aircraft_Selector->withIcaoDescription(false); + connect(this->ui->aircraft_Selector, &CDbAircraftIcaoSelectorComponent::changedAircraftIcao, this, &CAircraftIcaoForm::setValue); + + // drag and drop + connect(this->ui->drop_DropData, &CDropSite::droppedValueObject, this, &CAircraftIcaoForm::ps_droppedCode); + this->ui->drop_DropData->setInfoText(""); + this->ui->drop_DropData->setAcceptedMetaTypeIds({ qMetaTypeId(), qMetaTypeId()}); + } + + CAircraftIcaoForm::~CAircraftIcaoForm() + { } + + void CAircraftIcaoForm::setValue(const BlackMisc::Aviation::CAircraftIcaoCode &icao) + { + this->m_aircraft = icao; + this->ui->le_Id->setText(icao.getDbKeyAsString()); + this->ui->aircraft_Selector->setAircraftIcao(icao); + this->ui->le_Manufacturer->setText(icao.getManufacturer()); + this->ui->le_ModelDescription->setText(icao.getModelDescription()); + + this->ui->cb_Legacy->setChecked(icao.isLegacyAircraft()); + this->ui->cb_Military->setChecked(icao.isMilitary()); + this->ui->cb_RealWorld->setChecked(icao.isRealWorld()); + this->ui->combined_TypeSelector->setCombinedType(icao.getCombinedType()); + + QString rank(icao.getRankString()); + QString wtc(icao.getWtc()); + CGuiUtility::setComboBoxValueByStartingString(this->ui->cb_Rank, rank, "unspecified"); + CGuiUtility::setComboBoxValueByStartingString(this->ui->cb_Wtc, wtc, "unspecified"); + + this->ui->le_Updated->setText(icao.getFormattedUtcTimestampYmdhms()); + } + + const CAircraftIcaoCode &CAircraftIcaoForm::getValue() const + { + CAircraftIcaoCode icao(this->ui->aircraft_Selector->getAircraftIcao()); + if (icao.hasCompleteData()) + { + m_aircraft = icao; + } + QString manufacturer(this->ui->le_Manufacturer->text().trimmed().toUpper()); + QString modelDescription(this->ui->le_ModelDescription->text()); + QString wtc(ui->cb_Wtc->currentText().left(1)); + QString combined(ui->combined_TypeSelector->getCombinedType()); + bool ok; + int rank = this->ui->cb_Rank->currentText().toInt(&ok); + if (!ok) { rank = 10; } + bool legacy = this->ui->cb_Legacy->isChecked(); + bool military = this->ui->cb_Military->isChecked(); + bool realWorld = this->ui->cb_RealWorld->isChecked(); + m_aircraft.setManufacturer(manufacturer); + m_aircraft.setModelDescription(modelDescription); + m_aircraft.setWtc(wtc); + m_aircraft.setCodeFlags(military, legacy, realWorld); + m_aircraft.setRank(rank); + m_aircraft.setCombinedType(combined); + return m_aircraft; + } + + CStatusMessageList CAircraftIcaoForm::validate() const + { + CAircraftIcaoCode code(getValue()); + CStatusMessageList msgs(code.validate()); + this->ui->val_Indicator->setState(msgs); + return msgs; + } + + void CAircraftIcaoForm::allowDrop(bool allowDrop) + { + this->ui->drop_DropData->allowDrop(allowDrop); + } + + bool CAircraftIcaoForm::isDropAllowed() const + { + return ui->drop_DropData->isDropAllowed(); + } + + void CAircraftIcaoForm::setReadOnly(bool readOnly) + { + this->m_readOnly = readOnly; + this->ui->aircraft_Selector->setReadOnly(readOnly); + this->ui->le_Manufacturer->setReadOnly(readOnly); + this->ui->le_ModelDescription->setReadOnly(readOnly); + + this->ui->cb_Legacy->setCheckable(!readOnly); + this->ui->cb_Military->setCheckable(!readOnly); + this->ui->cb_RealWorld->setCheckable(!readOnly); + } + + void CAircraftIcaoForm::clear() + { + setValue(CAircraftIcaoCode()); + } + + void CAircraftIcaoForm::setMappingMode() + { + this->setReadOnly(true); + this->ui->aircraft_Selector->setReadOnly(false); + } + + void CAircraftIcaoForm::setProvider(Network::IWebDataServicesProvider *webDataReaderProvider) + { + CWebDataServicesAware::setProvider(webDataReaderProvider); + this->ui->aircraft_Selector->setProvider(webDataReaderProvider); + } + + void CAircraftIcaoForm::ps_droppedCode(const BlackMisc::CVariant &variantDropped) + { + CAircraftIcaoCode icao; + if (variantDropped.canConvert()) + { + icao = variantDropped.value(); + } + else if (variantDropped.canConvert()) + { + CAircraftIcaoCodeList icaoList(variantDropped.value()); + if (icaoList.isEmpty()) { return; } + icao = icaoList.front(); + } + else + { + return; + } + this->setValue(icao); + } + + } // ns +} // ns diff --git a/src/blackgui/editors/aircrafticaoform.h b/src/blackgui/editors/aircrafticaoform.h new file mode 100644 index 000000000..bedd4e360 --- /dev/null +++ b/src/blackgui/editors/aircrafticaoform.h @@ -0,0 +1,83 @@ +/* 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_EDITORS_AIRCRAFTICAOFORM_H +#define BLACKGUI_EDITORS_AIRCRAFTICAOFORM_H + +#include "blackgui/editors/form.h" +#include "blackmisc/aviation/aircrafticaocode.h" +#include "blackmisc/network/webdataservicesprovider.h" +#include "blackmisc/statusmessagelist.h" +#include + +namespace Ui { class CAircraftIcaoForm; } + +namespace BlackGui +{ + namespace Editors + { + /*! + * Aircraft ICAO form + */ + class CAircraftIcaoForm : + public CForm, + public BlackMisc::Network::CWebDataServicesAware + { + Q_OBJECT + + public: + //! Constructor + explicit CAircraftIcaoForm(QWidget *parent = nullptr); + + //! Destructor + ~CAircraftIcaoForm(); + + //! Get value + const BlackMisc::Aviation::CAircraftIcaoCode &getValue() const; + + //! Validate, empty list means OK + BlackMisc::CStatusMessageList validate() const; + + //! Allow to drop + void allowDrop(bool allowDrop); + + //! Is drop allowed? + bool isDropAllowed() const; + + //! \copydoc CEditor::setReadOnly + virtual void setReadOnly(bool readOnly) override; + + //! Clear + void clear(); + + //! Mapping mode + void setMappingMode(); + + //! \copydoc CWebDataReaderAware::setProvider + virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReaderProvider) override; + + public slots: + //! Set value + void setValue(const BlackMisc::Aviation::CAircraftIcaoCode &icao); + + private slots: + //! Variant has been dropped + void ps_droppedCode(const BlackMisc::CVariant &variantDropped); + + private: + QScopedPointer ui; + mutable BlackMisc::Aviation::CAircraftIcaoCode m_aircraft; + }; + + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/editors/aircrafticaoform.ui b/src/blackgui/editors/aircrafticaoform.ui new file mode 100644 index 000000000..4c793d412 --- /dev/null +++ b/src/blackgui/editors/aircrafticaoform.ui @@ -0,0 +1,386 @@ + + + CAircraftIcaoForm + + + + 0 + 0 + 388 + 223 + + + + + 0 + 220 + + + + Frame + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Aircraft ICAO + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + 0 + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 7 + + + + + 8 + + + + + 9 + + + + + Unspecified + + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Wake turbulence category + + + + L + + + + + M + + + + + H + + + + + Unspecified + + + + + + + + WTC + + + + + + + Real + + + + + + + Legacy + + + + + + + Military + + + Mil. + + + + + + + + + + + 20 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + e.g. Boeing, Airbus + + + + + + + Model: + + + + + + + Aircraft model + + + + + + + Type / Engine / Engine count + + + Combined type: + + + + + + + Misc.: + + + + + + + Last updated: + + + + + + + true + + + + + + + Design./Rank: + + + + + + + Manufacturer: + + + + + + + + 75 + 16777215 + + + + true + + + Id + + + + + + + Drop data here + + + + + + + + 10 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + BlackGui::CDropSite + QLabel +
blackgui/dropsite.h
+
+ + BlackGui::CLabelAndIcon + QFrame +
blackgui/labelandicon.h
+ 1 +
+ + BlackGui::Editors::CValidationIndicator + QFrame +
blackgui/editors/validationindicator.h
+ 1 +
+ + BlackGui::CAircraftCombinedTypeSelector + QFrame +
blackgui/aircraftcombinedtypeselector.h
+ 1 +
+ + BlackGui::Components::CDbAircraftIcaoSelectorComponent + QFrame +
blackgui/components/dbaircrafticaoselectorcomponent.h
+ 1 +
+
+ + le_Id + cb_Rank + le_Manufacturer + le_ModelDescription + cb_Wtc + cb_RealWorld + cb_Legacy + cb_Military + le_Updated + + + +
diff --git a/src/blackgui/editors/airlineicaoform.cpp b/src/blackgui/editors/airlineicaoform.cpp new file mode 100644 index 000000000..c3ae3b9ca --- /dev/null +++ b/src/blackgui/editors/airlineicaoform.cpp @@ -0,0 +1,127 @@ +/* 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 "blackmisc/aviation/airlineicaocodelist.h" +#include "blackmisc/country.h" +#include "airlineicaoform.h" +#include "ui_airlineicaoform.h" + +using namespace BlackMisc; +using namespace BlackMisc::Aviation; +using namespace BlackGui::Components; + +namespace BlackGui +{ + namespace Editors + { + CAirlineIcaoForm::CAirlineIcaoForm(QWidget *parent) : + CForm(parent), + BlackMisc::Network::CWebDataServicesAware(nullptr), + ui(new Ui::CAirlineIcaoForm) + { + ui->setupUi(this); + this->ui->le_Updated->setReadOnly(true); + this->ui->le_Id->setReadOnly(true); + this->ui->lai_Id->set(CIcons::appAirlineIcao16(), "Id:"); + + this->ui->airline_Selector->withIcaoDescription(false); + connect(this->ui->airline_Selector, &CDbAirlineIcaoSelectorComponent::changedAirlineIcao, this, &CAirlineIcaoForm::setValue); + + // drag and drop + connect(this->ui->drop_DropData, &CDropSite::droppedValueObject, this, &CAirlineIcaoForm::ps_droppedCode); + this->ui->drop_DropData->setInfoText(""); + this->ui->drop_DropData->setAcceptedMetaTypeIds({ qMetaTypeId(), qMetaTypeId()}); + } + + CAirlineIcaoForm::~CAirlineIcaoForm() + { } + + void CAirlineIcaoForm::setValue(const BlackMisc::Aviation::CAirlineIcaoCode &icao) + { + this->m_airline = icao; + this->ui->airline_Selector->setAirlineIcao(icao); + this->ui->le_Id->setText(icao.getDbKeyAsString()); + this->ui->le_TelephonyDesignator->setText(icao.getTelephonyDesignator()); + this->ui->le_Name->setText(icao.getName()); + this->ui->le_Updated->setText(icao.getFormattedUtcTimestampYmdhms()); + this->ui->cb_Va->setChecked(icao.isVirtualAirline()); + this->ui->country_Selector->setCountry(icao.getCountry()); + this->ui->lbl_AirlineIcon->setPixmap(icao.toPixmap()); + } + + const CAirlineIcaoCode &CAirlineIcaoForm::getValue() const + { + m_airline.setVirtualAirline(this->ui->cb_Va->isChecked()); + m_airline.setCountry(this->ui->country_Selector->getCountry()); + m_airline.setName(this->ui->le_Name->text()); + m_airline.setTelephonyDesignator(this->ui->le_TelephonyDesignator->text()); + return m_airline; + } + + CStatusMessageList CAirlineIcaoForm::validate() const + { + CAirlineIcaoCode code(getValue()); + CStatusMessageList msgs(code.validate()); + this->ui->val_Indicator->setState(msgs); + return msgs; + } + + void CAirlineIcaoForm::allowDrop(bool allowDrop) + { + this->ui->drop_DropData->allowDrop(allowDrop); + } + + bool CAirlineIcaoForm::isDropAllowed() const + { + return this->ui->drop_DropData->isDropAllowed(); + } + + void CAirlineIcaoForm::setReadOnly(bool readOnly) + { + this->ui->airline_Selector->setReadOnly(readOnly); + this->ui->le_TelephonyDesignator->setReadOnly(readOnly); + this->ui->le_Name->setReadOnly(readOnly); + this->ui->country_Selector->setReadOnly(readOnly); + this->ui->cb_Va->setEnabled(!readOnly); + } + + void CAirlineIcaoForm::clear() + { + setValue(CAirlineIcaoCode()); + } + + void CAirlineIcaoForm::setProvider(Network::IWebDataServicesProvider *webDataReaderProvider) + { + CWebDataServicesAware::setProvider(webDataReaderProvider); + this->ui->country_Selector->setProvider(webDataReaderProvider); + this->ui->airline_Selector->setProvider(webDataReaderProvider); + } + + void CAirlineIcaoForm::ps_droppedCode(const BlackMisc::CVariant &variantDropped) + { + CAirlineIcaoCode icao; + if (variantDropped.canConvert()) + { + icao = variantDropped.value(); + } + else if (variantDropped.canConvert()) + { + CAirlineIcaoCodeList icaoList(variantDropped.value()); + if (icaoList.isEmpty()) { return; } + icao = icaoList.front(); + } + else + { + return; + } + this->setValue(icao); + } + + } // ns +} // ns diff --git a/src/blackgui/editors/airlineicaoform.h b/src/blackgui/editors/airlineicaoform.h new file mode 100644 index 000000000..f462869e1 --- /dev/null +++ b/src/blackgui/editors/airlineicaoform.h @@ -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. + */ + +//! \file + +#ifndef BLACKGUI_EDITORS_AIRLINEICAOFORM_H +#define BLACKGUI_EDITORS_AIRLINEICAOFORM_H + +#include "blackmisc/aviation/airlineicaocode.h" +#include "blackmisc/network/webdataservicesprovider.h" +#include "blackmisc/statusmessagelist.h" +#include "blackgui/editors/form.h" +#include + +namespace Ui { class CAirlineIcaoForm; } + +namespace BlackGui +{ + namespace Editors + { + /*! + * Airline ICAO code form + */ + class CAirlineIcaoForm : + public CForm, + public BlackMisc::Network::CWebDataServicesAware + { + Q_OBJECT + + public: + //! Constructor + explicit CAirlineIcaoForm(QWidget *parent = nullptr); + + //! Destructor + ~CAirlineIcaoForm(); + + //! Set value + void setValue(const BlackMisc::Aviation::CAirlineIcaoCode &icao = BlackMisc::Aviation::CAirlineIcaoCode()); + + //! Get value + const BlackMisc::Aviation::CAirlineIcaoCode &getValue() const; + + //! Validate, empty list means OK + BlackMisc::CStatusMessageList validate() const; + + //! Allow to drop + void allowDrop(bool allowDrop); + + //! Is drop allowed? + bool isDropAllowed() const; + + //! \copydoc CEditor::setReadOnly + virtual void setReadOnly(bool readOnly) override; + + //! Clear + void clear(); + + //! \copydoc CWebDataReaderAware::setProvider + virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReaderProvider) override; + + private slots: + //! Variant has been dropped + void ps_droppedCode(const BlackMisc::CVariant &variantDropped); + + private: + QScopedPointer ui; + mutable BlackMisc::Aviation::CAirlineIcaoCode m_airline; // object allowing to override values + }; + + } // ns +} //ns + +#endif // guard diff --git a/src/blackgui/editors/airlineicaoform.ui b/src/blackgui/editors/airlineicaoform.ui new file mode 100644 index 000000000..5d204a9e5 --- /dev/null +++ b/src/blackgui/editors/airlineicaoform.ui @@ -0,0 +1,303 @@ + + + CAirlineIcaoForm + + + + 0 + 0 + 255 + 196 + + + + + 0 + 190 + + + + Frame + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 10 + 0 + + + + Airline ICAO + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + true + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + 4 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 75 + 16777215 + + + + true + + + Id + + + + + + + + + + + + + + + + + + 20 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + VA? + + + + + + + + + + Country: + + + + + + + Designator/VA?: + + + + + + + Name: + + + + + + + Last updated + + + + + + + Airline's name (e.g. Lufthansa) + + + + + + + How airline is called via radio + + + + + + + Telephony: + + + + + + + Drop data here + + + + + + + + 10 + 100 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + BlackGui::Components::CDbCountrySelectorComponent + QFrame +
blackgui/components/dbcountryselectorcomponent.h
+ 1 +
+ + BlackGui::CDropSite + QLabel +
blackgui/dropsite.h
+
+ + BlackGui::CLabelAndIcon + QFrame +
blackgui/labelandicon.h
+ 1 +
+ + BlackGui::Components::CDbAirlineIcaoSelectorComponent + QFrame +
blackgui/components/dbairlineicaoselectorcomponent.h
+ 1 +
+ + BlackGui::Editors::CValidationIndicator + QFrame +
blackgui/editors/validationindicator.h
+ 1 +
+
+ + le_Id + cb_Va + le_TelephonyDesignator + le_Name + le_Updated + + + +
diff --git a/src/blackgui/editors/distributorform.cpp b/src/blackgui/editors/distributorform.cpp new file mode 100644 index 000000000..9efe0f820 --- /dev/null +++ b/src/blackgui/editors/distributorform.cpp @@ -0,0 +1,133 @@ +/* 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 "blackmisc/simulation/distributorlist.h" +#include "blackmisc/country.h" +#include "distributorform.h" +#include "ui_distributorform.h" + +using namespace BlackMisc; +using namespace BlackMisc::Simulation; +using namespace BlackGui::Components; + +namespace BlackGui +{ + namespace Editors + { + CDistributorForm::CDistributorForm(QWidget *parent) : + CForm(parent), + BlackMisc::Network::CWebDataServicesAware(nullptr), + ui(new Ui::CDistributorForm) + { + ui->setupUi(this); + this->ui->le_Updated->setReadOnly(true); + this->ui->distributor_Selector->withDistributorDescription(false); + ui->lai_Id->set(CIcons::appDistributors16(), "Id:"); + + // drag and drop + connect(this->ui->drop_DropData, &CDropSite::droppedValueObject, this, &CDistributorForm::ps_droppedCode); + connect(this->ui->distributor_Selector, &CDbDistributorSelectorComponent::changedDistributor, this, &CDistributorForm::setValue); + this->ui->drop_DropData->setInfoText(""); + this->ui->drop_DropData->setAcceptedMetaTypeIds({ qMetaTypeId(), qMetaTypeId()}); + } + + CDistributorForm::~CDistributorForm() + { } + + void CDistributorForm::setValue(const BlackMisc::Simulation::CDistributor &distributor) + { + this->m_distributor = distributor; + this->ui->distributor_Selector->setDistributor(distributor); + this->ui->le_Description->setText(distributor.getDescription()); + this->ui->le_Alias1->setText(distributor.getAlias1()); + this->ui->le_Alias2->setText(distributor.getAlias2()); + this->ui->le_Updated->setText(distributor.getFormattedUtcTimestampYmdhms()); + } + + const CDistributor &CDistributorForm::getValue() const + { + CDistributor d(ui->distributor_Selector->getDistributor()); + if (d.hasCompleteData()) { this->m_distributor = d;} + + m_distributor.setAlias1(this->ui->le_Alias1->text()); + m_distributor.setAlias2(this->ui->le_Alias2->text()); + m_distributor.setDescription(this->ui->le_Description->text()); + return m_distributor; + } + + CStatusMessageList CDistributorForm::validate() const + { + CDistributor distributor(getValue()); + CStatusMessageList msgs; + if (!distributor.getDbKey().isEmpty()) + { + // optional distributor + msgs = distributor.validate(); + } + this->ui->val_Indicator->setState(msgs); + return msgs; + } + + void CDistributorForm::allowDrop(bool allowDrop) + { + this->ui->drop_DropData->allowDrop(allowDrop); + } + + bool CDistributorForm::isDropAllowed() const + { + return this->ui->drop_DropData->isDropAllowed(); + } + + void CDistributorForm::setReadOnly(bool readOnly) + { + this->ui->le_Alias1->setReadOnly(readOnly); + this->ui->le_Alias2->setReadOnly(readOnly); + this->ui->le_Description->setReadOnly(readOnly); + this->ui->distributor_Selector->setReadOnly(readOnly); + } + + void CDistributorForm::clear() + { + setValue(CDistributor()); + this->ui->distributor_Selector->setReadOnly(false); + } + + void CDistributorForm::setMappingMode() + { + this->setReadOnly(true); + } + + void CDistributorForm::setProvider(Network::IWebDataServicesProvider *webDataReaderProvider) + { + CWebDataServicesAware::setProvider(webDataReaderProvider); + this->ui->distributor_Selector->setProvider(webDataReaderProvider); + } + + void CDistributorForm::ps_droppedCode(const BlackMisc::CVariant &variantDropped) + { + CDistributor distributor; + if (variantDropped.canConvert()) + { + distributor = variantDropped.value(); + } + else if (variantDropped.canConvert()) + { + CDistributorList icaoList(variantDropped.value()); + if (icaoList.isEmpty()) { return; } + distributor = icaoList.front(); + } + else + { + return; + } + this->setValue(distributor); + } + + } // ns +} // ns diff --git a/src/blackgui/editors/distributorform.h b/src/blackgui/editors/distributorform.h new file mode 100644 index 000000000..de9b2d3a5 --- /dev/null +++ b/src/blackgui/editors/distributorform.h @@ -0,0 +1,84 @@ +/* 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_EDITORS_DISTRIBUTORFORM_H +#define BLACKGUI_EDITORS_DISTRIBUTORFORM_H + +#include "blackgui/editors/form.h" +#include "blackmisc/simulation/distributor.h" +#include "blackmisc/network/webdataservicesprovider.h" +#include "blackmisc/statusmessagelist.h" +#include + +namespace Ui { class CDistributorForm; } + +namespace BlackGui +{ + namespace Editors + { + /*! + * Distributor form + */ + class CDistributorForm : + public CForm, + public BlackMisc::Network::CWebDataServicesAware + { + Q_OBJECT + + public: + //! Constructor + explicit CDistributorForm(QWidget *parent = nullptr); + + //! Destructor + ~CDistributorForm(); + + //! Get value + const BlackMisc::Simulation::CDistributor &getValue() const; + + //! Validate, empty list means OK + BlackMisc::CStatusMessageList validate() const; + + //! Allow to drop + void allowDrop(bool allowDrop); + + //! Is drop allowed? + bool isDropAllowed() const; + + //! \copydoc CEditor::setReadOnly + void setReadOnly(bool readOnly); + + //! Clear + void clear(); + + //! Mapping mode + void setMappingMode(); + + //! \copydoc CWebDataReaderAware::setProvider + virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReaderProvider); + + public slots: + //! Set value + void setValue(const BlackMisc::Simulation::CDistributor &distributor = BlackMisc::Simulation::CDistributor()); + + private slots: + //! Variant has been dropped + void ps_droppedCode(const BlackMisc::CVariant &variantDropped); + + private: + QScopedPointer ui; + mutable BlackMisc::Simulation::CDistributor m_distributor; // object allowing to override values + bool m_readOnly = false; + }; + + } // ns +} //ns + +#endif // guard diff --git a/src/blackgui/editors/distributorform.ui b/src/blackgui/editors/distributorform.ui new file mode 100644 index 000000000..91eb5c5ee --- /dev/null +++ b/src/blackgui/editors/distributorform.ui @@ -0,0 +1,205 @@ + + + CDistributorForm + + + + 0 + 0 + 240 + 178 + + + + + 0 + 175 + + + + Distributor editor + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 4 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Distributor + + + + + + + 0 + 20 + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + true + + + + + + + + + + + 20 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Last updated + + + + + + + Alias 2: + + + + + + + Description: + + + + + + + An alias + + + + + + + Alias1: + + + + + + + Another alias + + + + + + + Describe distributor + + + + + + + Drop data here + + + + + + + + 10 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + BlackGui::CDropSite + QLabel +
blackgui/dropsite.h
+
+ + BlackGui::CLabelAndIcon + QFrame +
blackgui/labelandicon.h
+ 1 +
+ + BlackGui::Editors::CValidationIndicator + QFrame +
blackgui/editors/validationindicator.h
+ 1 +
+ + BlackGui::Components::CDbDistributorSelectorComponent + QFrame +
blackgui/components/dbdistributorselectorcomponent.h
+ 1 +
+
+ + +
diff --git a/src/blackgui/editors/form.cpp b/src/blackgui/editors/form.cpp new file mode 100644 index 000000000..bf3ebc8dd --- /dev/null +++ b/src/blackgui/editors/form.cpp @@ -0,0 +1,23 @@ +/* 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 "form.h" + +namespace BlackGui +{ + namespace Editors + { + CForm::CForm(QWidget *parent) : + QFrame(parent) + { } + + CForm::~CForm() { } + + } // ns +} // ns diff --git a/src/blackgui/editors/form.h b/src/blackgui/editors/form.h new file mode 100644 index 000000000..9c5645e5c --- /dev/null +++ b/src/blackgui/editors/form.h @@ -0,0 +1,48 @@ +/* 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_EDITORS_FORM_H +#define BLACKGUI_EDITORS_FORM_H + +#include + +namespace BlackGui +{ + namespace Editors + { + /*! + * Form base class + */ + class CForm : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CForm(QWidget *parent = nullptr); + + //! Destructor + ~CForm(); + + //! Set editable + virtual void setReadOnly(bool readOnly) = 0; + + //! Is read only? + bool isReadOnly() const { return m_readOnly; } + + protected: + bool m_readOnly = false; //!< read only + }; + + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/editors/liveryform.cpp b/src/blackgui/editors/liveryform.cpp new file mode 100644 index 000000000..f81419c55 --- /dev/null +++ b/src/blackgui/editors/liveryform.cpp @@ -0,0 +1,123 @@ +/* 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 "blackmisc/aviation/liverylist.h" +#include "liveryform.h" +#include "ui_liveryform.h" + +using namespace BlackMisc; +using namespace BlackMisc::Aviation; + +namespace BlackGui +{ + namespace Editors + { + CLiveryForm::CLiveryForm(QWidget *parent) : + CForm(parent), + ui(new Ui::CLiveryForm) + { + ui->setupUi(this); + this->ui->le_Id->setReadOnly(true); + this->ui->le_Updated->setReadOnly(true); + this->ui->lai_Id->set(CIcons::appLiveries16(), "Id:"); + + // drag and drop + connect(this->ui->drop_DropData, &CDropSite::droppedValueObject, this, &CLiveryForm::ps_droppedLivery); + this->ui->drop_DropData->setInfoText(""); + this->ui->drop_DropData->setAcceptedMetaTypeIds({ qMetaTypeId(), qMetaTypeId()}); + } + + CLiveryForm::~CLiveryForm() { } + + void CLiveryForm::setProvider(BlackMisc::Network::IWebDataServicesProvider *provider) + { + CWebDataServicesAware::setProvider(provider); + this->ui->editor_AirlineIcao->setProvider(provider); + } + + const CLivery &CLiveryForm::getValue() const + { + CAirlineIcaoCode airline(this->ui->editor_AirlineIcao->getValue()); + this->m_livery.setCombinedCode(this->ui->le_Code->text()); + this->m_livery.setAirlineIcaoCode(airline); + this->m_livery.setDescription(this->ui->le_Description->text()); + return m_livery; + } + + void CLiveryForm::setValue(const CLivery &livery) + { + this->m_livery = livery; + this->ui->le_Id->setText(livery.getDbKeyAsString()); + this->ui->le_Code->setText(livery.getCombinedCode()); + this->ui->le_Description->setText(livery.getDescription()); + this->ui->le_Updated->setText(livery.getFormattedUtcTimestampYmdhms()); + this->ui->color_Fuselage->setColor(livery.getColorFuselage()); + this->ui->color_Tail->setColor(livery.getColorTail()); + + this->ui->editor_AirlineIcao->setValue(livery.getAirlineIcaoCode()); + } + + CStatusMessageList CLiveryForm::validate(bool withNestedForms) const + { + CLivery livery(getValue()); + CStatusMessageList msgs(livery.validate()); + if (withNestedForms && (livery.hasValidDbKey() || !livery.getAirlineIcaoCodeDesignator().isEmpty())) + { + msgs.push_back(this->ui->editor_AirlineIcao->validate()); + } + this->ui->val_Indicator->setState(msgs); + return msgs; + } + + void CLiveryForm::allowDrop(bool allowDrop) + { + this->ui->drop_DropData->allowDrop(allowDrop); + } + + bool CLiveryForm::isDropAllowed() const + { + return this->ui->drop_DropData->isDropAllowed(); + } + + void CLiveryForm::setReadOnly(bool readOnly) + { + this->m_readOnly = readOnly; + this->ui->le_Code->setReadOnly(readOnly); + this->ui->le_Description->setReadOnly(readOnly); + } + + void CLiveryForm::setMappingMode() + { + this->setReadOnly(true); + } + + void CLiveryForm::clear() + { + this->setValue(CLivery()); + } + + void CLiveryForm::ps_droppedLivery(const BlackMisc::CVariant &variantDropped) + { + CLivery livery; + if (variantDropped.canConvert()) + { + livery = variantDropped.value(); + } + else if (variantDropped.canConvert()) + { + CLiveryList liveryList(variantDropped.value()); + if (liveryList.isEmpty()) { return; } + livery = liveryList.front(); + } + else { return; } + this->setValue(livery); + } + + } // ns +} // ns diff --git a/src/blackgui/editors/liveryform.h b/src/blackgui/editors/liveryform.h new file mode 100644 index 000000000..7d7fbac67 --- /dev/null +++ b/src/blackgui/editors/liveryform.h @@ -0,0 +1,81 @@ +/* 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_EDITORS_LIVERYFORM_H +#define BLACKGUI_EDITORS_LIVERYFORM_H + +#include "blackgui/editors/form.h" +#include "blackmisc/aviation/livery.h" +#include "blackmisc/network/webdataservicesprovider.h" +#include "blackmisc/statusmessagelist.h" + +namespace Ui { class CLiveryForm; } + +namespace BlackGui +{ + namespace Editors + { + /*! + * Livery form class + */ + class CLiveryForm : + public CForm, + public BlackMisc::Network::CWebDataServicesAware + { + Q_OBJECT + + public: + //! Constructor + explicit CLiveryForm(QWidget *parent = nullptr); + + //! Destructor + ~CLiveryForm(); + + //! \copydoc CWebDataReaderAware::setProvider + virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *provider) override; + + //! Value + const BlackMisc::Aviation::CLivery &getValue() const; + + //! Value + void setValue(const BlackMisc::Aviation::CLivery &livery); + + //! Validate, empty list means OK + BlackMisc::CStatusMessageList validate(bool withNestedForms) const; + + //! Allow to drop + void allowDrop(bool allowDrop); + + //! Is drop allowed? + bool isDropAllowed() const; + + //! \copydoc CEditor::setReadOnly + virtual void setReadOnly(bool readOnly) override; + + //! Mapping mode + void setMappingMode(); + + //! Clear data + void clear(); + + private slots: + //! Livery dropped + void ps_droppedLivery(const BlackMisc::CVariant &variantDropped); + + private: + QScopedPointer ui; + mutable BlackMisc::Aviation::CLivery m_livery; //!< object whose values will be overridden + }; + + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/editors/liveryform.ui b/src/blackgui/editors/liveryform.ui new file mode 100644 index 000000000..fd43902cc --- /dev/null +++ b/src/blackgui/editors/liveryform.ui @@ -0,0 +1,247 @@ + + + CLiveryForm + + + Livery editor + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Livery + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Livery code + + + + + + + + + + + 4 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Code: + + + + + + + Description: + + + + + + + Last updated: + + + + + + + true + + + + + + + + 75 + 16777215 + + + + true + + + Id + + + + + + + Fuselage/Tail: + + + + + + + Livery description + + + + + + + Drop data here + + + + + + + + 10 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + BlackGui::CColorSelector + QFrame +
blackgui/colorselector.h
+ 1 +
+ + BlackGui::CDropSite + QLabel +
blackgui/dropsite.h
+
+ + BlackGui::CLabelAndIcon + QFrame +
blackgui/labelandicon.h
+ 1 +
+ + BlackGui::Editors::CValidationIndicator + QFrame +
blackgui/editors/validationindicator.h
+ 1 +
+ + BlackGui::Editors::CAirlineIcaoForm + QFrame +
blackgui/editors/airlineicaoform.h
+ 1 +
+
+ + le_Id + le_Code + le_Description + le_Updated + + + +
diff --git a/src/blackgui/editors/modelmappingform.cpp b/src/blackgui/editors/modelmappingform.cpp new file mode 100644 index 000000000..da1c07bd1 --- /dev/null +++ b/src/blackgui/editors/modelmappingform.cpp @@ -0,0 +1,68 @@ +/* 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 "modelmappingform.h" +#include "ui_modelmappingform.h" + +using namespace BlackMisc; +using namespace BlackMisc::Simulation; + +namespace BlackGui +{ + namespace Editors + { + CModelMappingForm::CModelMappingForm(QWidget *parent) : + CForm(parent), + ui(new Ui::CModelMappingForm) + { + ui->setupUi(this); + ui->le_LastUpdated->setReadOnly(true); + ui->le_Id->setReadOnly(true); + ui->lai_Id->set(CIcons::appMappings16(), "Id:"); + connect(ui->pb_Save, &QPushButton::clicked, this, &CModelMappingForm::requestSave); + } + + CModelMappingForm::~CModelMappingForm() + { } + + const BlackMisc::Simulation::CAircraftModel &CModelMappingForm::getValue() const + { + m_model.setSimulatorInfo(this->ui->selector_Simulator->getValue()); + m_model.setDescription(this->ui->le_Description->text()); + m_model.setModelString(this->ui->le_ModelKey->text()); + m_model.setName(this->ui->le_Name->text()); + return m_model; + } + + CStatusMessageList CModelMappingForm::validate(bool withNestedForms) const + { + CAircraftModel model(getValue()); + CStatusMessageList msgs(model.validate(withNestedForms)); + this->ui->val_Indicator->setState(msgs); + return msgs; + } + + void CModelMappingForm::setReadOnly(bool readOnly) + { + this->ui->le_Description->setReadOnly(readOnly); + this->ui->le_ModelKey->setReadOnly(readOnly); + this->ui->le_Name->setReadOnly(readOnly); + } + + void CModelMappingForm::setValue(BlackMisc::Simulation::CAircraftModel &model) + { + ui->le_ModelKey->setText(model.getModelString()); + ui->le_LastUpdated->setText(model.getFormattedUtcTimestampYmdhms()); + ui->le_Id->setText(model.getDbKeyAsString()); + ui->le_Description->setText(model.getDescription()); + ui->le_Name->setText(model.getName()); + ui->selector_Simulator->setValue(model.getSimulatorInfo()); + } + } // ns +} // ns diff --git a/src/blackgui/editors/modelmappingform.h b/src/blackgui/editors/modelmappingform.h new file mode 100644 index 000000000..4c0b798d9 --- /dev/null +++ b/src/blackgui/editors/modelmappingform.h @@ -0,0 +1,67 @@ +/* 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_EDITORS_MODELMAPPINGFORM_H +#define BLACKGUI_EDITORS_MODELMAPPINGFORM_H + +#include "blackgui/editors/form.h" +#include "blackmisc/simulation/aircraftmodel.h" +#include + +namespace Ui { class CModelMappingForm; } + +namespace BlackGui +{ + namespace Editors + { + /*! + * Model mapping form + */ + class CModelMappingForm : public CForm + { + Q_OBJECT + + public: + //! Constructor + explicit CModelMappingForm(QWidget *parent = nullptr); + + //! Destructor + ~CModelMappingForm(); + + //! Value + const BlackMisc::Simulation::CAircraftModel &getValue() const; + + //! Validate + BlackMisc::CStatusMessageList validate(bool withNestedForms) const; + + //! \copydoc CEditor::setReadOnly + virtual void setReadOnly(bool readOnly) override; + + public slots: + //! Set model + void setValue(BlackMisc::Simulation::CAircraftModel &model); + + signals: + //! Request validation + void requestValidation(); + + //! Save + void requestSave(); + + private: + QScopedPointer ui; + mutable BlackMisc::Simulation::CAircraftModel m_model; //!< cached last value + }; + + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/editors/modelmappingform.ui b/src/blackgui/editors/modelmappingform.ui new file mode 100644 index 000000000..aba090ee9 --- /dev/null +++ b/src/blackgui/editors/modelmappingform.ui @@ -0,0 +1,186 @@ + + + CModelMappingForm + + + + 0 + 0 + 592 + 87 + + + + Model editor + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Simulator model + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Stash + + + + + + + Description: + + + + + + + Save + + + + + + + Model description + + + + + + + Last updated: + + + + + + + Model key: + + + + + + + + + + + 75 + 16777215 + + + + Id + + + + + + + Model key + + + + + + + Name + + + + + + + Name: + + + + + + + + 10 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + BlackGui::CSimulatorSelector + QFrame +
blackgui/simulatorselector.h
+ 1 +
+ + BlackGui::CLabelAndIcon + QFrame +
blackgui/labelandicon.h
+ 1 +
+ + BlackGui::Editors::CValidationIndicator + QFrame +
blackgui/editors/validationindicator.h
+ 1 +
+
+ + +
diff --git a/src/blackgui/editors/validationindicator.cpp b/src/blackgui/editors/validationindicator.cpp new file mode 100644 index 000000000..7d2f53dc5 --- /dev/null +++ b/src/blackgui/editors/validationindicator.cpp @@ -0,0 +1,118 @@ +/* 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 "validationindicator.h" +#include "ui_validationindicator.h" +#include "blackgui/stylesheetutility.h" +#include "blackmisc/statusmessage.h" +#include + +using namespace BlackMisc; + +namespace BlackGui +{ + namespace Editors + { + CValidationIndicator::CValidationIndicator(QWidget *parent) : + QFrame(parent), + ui(new Ui::CValidationIndicator) + { + ui->setupUi(this); + this->clear(); + this->setFrameStyle(QFrame::StyledPanel); + this->setFrameShadow(QFrame::Raised); + this->setAutoFillBackground(true); + this->m_originalStyleSheet = this->styleSheet(); + connect(&this->m_resetTimer, &QTimer::timeout, this, &CValidationIndicator::clear); + this->m_resetTimer.setObjectName(this->objectName().append(":").append("resetTimer")); + this->m_resetTimer.start(ResetInterval); + } + + CValidationIndicator::~CValidationIndicator() + { } + + void CValidationIndicator::passed() + { + this->show(); + setBackgroundColor("green"); + ui->lbl_Icon->setPixmap(CIcons::tick16()); + } + + void CValidationIndicator::failed() + { + this->show(); + setBackgroundColor("red"); + ui->lbl_Icon->setPixmap(CStatusMessage::convertToIcon(CStatusMessage::SeverityError)); + } + + void CValidationIndicator::warnings() + { + this->show(); + setBackgroundColor("yellow"); + ui->lbl_Icon->setPixmap(CStatusMessage::convertToIcon(CStatusMessage::SeverityWarning)); + } + + void CValidationIndicator::clear() + { + setBackgroundColor(""); + ui->lbl_Icon->clear(); + this->hide(); + } + + void CValidationIndicator::setState(bool ok) + { + if (ok) + { + passed(); + } + else + { + failed(); + } + } + + void CValidationIndicator::setState(const BlackMisc::CStatusMessageList &msgs) + { + if (msgs.hasErrorMessages()) + { + this->failed(); + } + else if (msgs.hasWarningMessages()) + { + this->warnings(); + } + else + { + this->passed(); + } + } + + void CValidationIndicator::paintEvent(QPaintEvent *paintEvent) + { + CStyleSheetUtility::useStyleSheetInDerivedWidget(this); + Q_UNUSED(paintEvent); + } + + void CValidationIndicator::setBackgroundColor(const QString colorName) + { + if (colorName.isEmpty()) + { + this->setStyleSheet(this->m_originalStyleSheet); + } + else + { + // I have to clean up any potential background image derived from style sheet + const QString s("background-color: %1; background-image: url(:/own/icons/own/transparent1px.png);"); + this->setStyleSheet(s.arg(colorName)); + m_resetTimer.start(ResetInterval); // restart + } + } + + } // ns +} // ns diff --git a/src/blackgui/editors/validationindicator.h b/src/blackgui/editors/validationindicator.h new file mode 100644 index 000000000..ea91cc719 --- /dev/null +++ b/src/blackgui/editors/validationindicator.h @@ -0,0 +1,77 @@ +/* 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_EDITOR_VALIDATIONINDICATOR_H +#define BLACKGUI_EDITOR_VALIDATIONINDICATOR_H + +#include "blackmisc/statusmessagelist.h" +#include +#include +#include + +namespace Ui { class CValidationIndicator; } + +namespace BlackGui +{ + namespace Editors + { + /*! + * Indication state of validation + */ + class CValidationIndicator : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CValidationIndicator(QWidget *parent = nullptr); + + //! Destructor + ~CValidationIndicator(); + + //! Validation passed + void passed(); + + //! Passed with warnings + void warnings(); + + //! Validation failed + void failed(); + + //! Ok or failed validation? + void setState(bool ok); + + //! Messages from status messages + void setState(const BlackMisc::CStatusMessageList &msgs); + + public slots: + //! Cleared state + void clear(); + + protected: + //! \copydoc QFrame::paintEvent + virtual void paintEvent(QPaintEvent *paintEvent) override; + + private: + const int ResetInterval = 5000; + QScopedPointer ui; + + //! Set background color + void setBackgroundColor(const QString colorName); + + QTimer m_resetTimer { this}; //!< reset to neutral + QString m_originalStyleSheet; //!< stored, to be able to reset + }; + + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/editors/validationindicator.ui b/src/blackgui/editors/validationindicator.ui new file mode 100644 index 000000000..92c86a41b --- /dev/null +++ b/src/blackgui/editors/validationindicator.ui @@ -0,0 +1,66 @@ + + + CValidationIndicator + + + + 0 + 0 + 18 + 18 + + + + + 10 + 10 + + + + + 25 + 16777215 + + + + Validation Indicator + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + :/diagona/icons/diagona/icons/tick.png + + + + + + + + + +