refs #452 components for the DB entities

* display in view
* filter
This commit is contained in:
Klaus Basan
2015-09-24 00:10:13 +02:00
committed by Mathew Sutcliffe
parent f29929111b
commit 008ea14812
18 changed files with 1276 additions and 0 deletions

View File

@@ -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 <functional>
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

View File

@@ -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 <QFrame>
#include <QScopedPointer>
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::CDbAircraftIcaoComponent> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDbAircraftIcaoComponent</class>
<widget class="QFrame" name="CDbAircraftIcaoComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_AircraftIcaoComponent">
<property name="spacing">
<number>4</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="BlackGui::Filters::CAircraftIcaoFilterBar" name="filter_AircraftIcao">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="BlackGui::Views::CAircraftIcaoCodeView" name="tvp_AircraftIcao">
<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>
<customwidgets>
<customwidget>
<class>BlackGui::Views::CAircraftIcaoCodeView</class>
<extends>QTableView</extends>
<header>blackgui/views/aircrafticaoview.h</header>
</customwidget>
<customwidget>
<class>BlackGui::Filters::CAircraftIcaoFilterBar</class>
<extends>QFrame</extends>
<header>blackgui/filters/aircrafticaofilterbar.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -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 <functional>
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

View File

@@ -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 <QFrame>
#include <QScopedPointer>
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::CDbAirlineIcaoComponent> ui;
};
}
}
#endif // guard

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDbAirlineIcaoComponent</class>
<widget class="QFrame" name="CDbAirlineIcaoComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_AirlineIcaoComponent">
<property name="spacing">
<number>4</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="BlackGui::Filters::CAirlineIcaoFilterBar" name="filter_AirlineIcao">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="BlackGui::Views::CAirlineIcaoCodeView" name="tvp_AirlineIcao">
<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>
<customwidgets>
<customwidget>
<class>BlackGui::Views::CAirlineIcaoCodeView</class>
<extends>QTableView</extends>
<header>blackgui/views/airlineicaoview.h</header>
</customwidget>
<customwidget>
<class>BlackGui::Filters::CAirlineIcaoFilterBar</class>
<extends>QFrame</extends>
<header>blackgui/filters/airlineicaofilterbar.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -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 <functional>
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

View File

@@ -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 <QFrame>
#include <QScopedPointer>
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::CDbCountryComponent> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDbCountryComponent</class>
<widget class="QFrame" name="CDbCountryComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_CountryComponent">
<property name="spacing">
<number>4</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="BlackGui::Filters::CCountryFilterBar" name="filter_CountryComponent">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="BlackGui::Views::CCountryView" name="tvp_Countries">
<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>
<customwidgets>
<customwidget>
<class>BlackGui::Views::CCountryView</class>
<extends>QTableView</extends>
<header>blackgui/views/countryview.h</header>
</customwidget>
<customwidget>
<class>BlackGui::Filters::CCountryFilterBar</class>
<extends>QFrame</extends>
<header>blackgui/filters/countryfilterbar.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -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 <QFrame>
#include <QScopedPointer>
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

View File

@@ -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 <QFrame>
#include <QScopedPointer>
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::CDbDistributorComponent> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDbDistributorComponent</class>
<widget class="QFrame" name="CDbDistributorComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_DistributorComponent">
<property name="spacing">
<number>4</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_Selector">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="BlackGui::Views::CDistributorView" name="tvp_Distributors">
<property name="dragDropMode">
<enum>QAbstractItemView::DragOnly</enum>
</property>
<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>
<customwidgets>
<customwidget>
<class>BlackGui::Views::CDistributorView</class>
<extends>QTableView</extends>
<header>blackgui/views/distributorview.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -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 <functional>
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

View File

@@ -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 <QFrame>
#include <QScopedPointer>
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::CDbLiveryComponent> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDbLiveryComponent</class>
<widget class="QFrame" name="CDbLiveryComponent">
<property name="windowTitle">
<string>Liveries</string>
</property>
<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_LiveryComponent">
<property name="spacing">
<number>4</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="BlackGui::Filters::CLiveryFilterBar" name="filter_Livery">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="BlackGui::Views::CLiveryView" name="tvp_Liveries">
<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>
<customwidgets>
<customwidget>
<class>BlackGui::Views::CLiveryView</class>
<extends>QTableView</extends>
<header>blackgui/views/liveryview.h</header>
</customwidget>
<customwidget>
<class>BlackGui::Filters::CLiveryFilterBar</class>
<extends>QFrame</extends>
<header>blackgui/filters/liveryfilterbar.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -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 <functional>
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

View File

@@ -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 <QFrame>
#include <QScopedPointer>
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::CDbModelComponent> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDbModelComponent</class>
<widget class="QFrame" name="CDbModelComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>258</width>
<height>212</height>
</rect>
</property>
<property name="windowTitle">
<string>Database aircraft models</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="vl_DbModelComponent">
<property name="spacing">
<number>4</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="BlackGui::Filters::CAircraftModelFilterBar" name="filter_AircraftModelFilter">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="BlackGui::Views::CAircraftModelView" name="tvp_AircraftModel">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Views::CAircraftModelView</class>
<extends>QTableView</extends>
<header>blackgui/views/aircraftmodelview.h</header>
</customwidget>
<customwidget>
<class>BlackGui::Filters::CAircraftModelFilterBar</class>
<extends>QFrame</extends>
<header>blackgui/filters/aircraftmodelfilterbar.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>