refs #445, data entry GUI

* component for main info area
* component for data mapping
* new subproject
This commit is contained in:
Klaus Basan
2015-07-10 01:31:29 +02:00
committed by Mathew Sutcliffe
parent a2527e69e3
commit d7bd20dd26
15 changed files with 954 additions and 0 deletions

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 "blackgui/components/logcomponent.h"
#include "blackgui/components/datamappingcomponent.h"
#include "blackgui/components/datamaininfoareacomponent.h"
#include "ui_datamaininfoareacomponent.h"
#include "blackmisc/icons.h"
using namespace BlackMisc;
using namespace BlackGui;
using namespace BlackGui::Components;
namespace BlackGui
{
namespace Components
{
CDataMainInfoAreaComponent::CDataMainInfoAreaComponent(QWidget *parent) :
CInfoArea(parent),
ui(new Ui::CDataMainInfoAreaComponent)
{
ui->setupUi(this);
initInfoArea(); // init base class
this->setWindowIcon(CIcons::swiftDatabase24());
}
CDataMainInfoAreaComponent::~CDataMainInfoAreaComponent()
{ }
CLogComponent *CDataMainInfoAreaComponent::getLogComponent() const
{
return this->ui->comp_Log;
}
CDataMappingComponent *CDataMainInfoAreaComponent::getMappingComponent() const
{
return this->ui->comp_Mapping;
}
QSize CDataMainInfoAreaComponent::getPreferredSizeWhenFloating(int areaIndex) const
{
InfoArea area = static_cast<InfoArea>(areaIndex);
switch (area)
{
case InfoAreaMapping:
case InfoAreaSettings:
case InfoAreaLog:
default:
return QSize(800, 600);
}
}
const QPixmap &CDataMainInfoAreaComponent::indexToPixmap(int areaIndex) const
{
InfoArea area = static_cast<InfoArea>(areaIndex);
switch (area)
{
case InfoAreaMapping:
return CIcons::appMappings16();
case InfoAreaSettings:
return CIcons::appSettings16();
case InfoAreaLog:
return CIcons::appLog16();
default:
return CIcons::empty();
}
}
} // ns
} // ns

View File

@@ -0,0 +1,73 @@
/* Copyright (C) 2014
* 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_DATAMAININFOAREACOMPONENT_H
#define BLACKGUI_DATAMAININFOAREACOMPONENT_H
#include "blackgui/blackguiexport.h"
#include "blackgui/infoarea.h"
#include <QMainWindow>
#include <QScopedPointer>
namespace Ui { class CDataMainInfoAreaComponent; }
namespace BlackGui
{
namespace Components
{
class CLogComponent;
class CDataMappingComponent;
/**
* Main info area for data entry tool
*/
class BLACKGUI_EXPORT CDataMainInfoAreaComponent : public BlackGui::CInfoArea
{
Q_OBJECT
public:
//! Info areas
enum InfoArea
{
// index must match tab index!
InfoAreaMapping = 0,
InfoAreaLog = 1,
InfoAreaSettings = 2,
InfoAreaNone = -1
};
//! Constructor
explicit CDataMainInfoAreaComponent(QWidget *parent = nullptr);
//! Destructor
~CDataMainInfoAreaComponent();
//! Log component
BlackGui::Components::CLogComponent *getLogComponent() const;
//! Model component
BlackGui::Components::CDataMappingComponent *getMappingComponent() const;
protected:
//! \copydoc CInfoArea::getPreferredSizeWhenFloating
virtual QSize getPreferredSizeWhenFloating(int areaIndex) const override;
//! \copydoc CInfoArea::indexToPixmap
virtual const QPixmap &indexToPixmap(int areaIndex) const override;
private:
QScopedPointer <Ui::CDataMainInfoAreaComponent> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,178 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDataMainInfoAreaComponent</class>
<widget class="QMainWindow" name="CDataMainInfoAreaComponent">
<property name="minimumSize">
<size>
<width>500</width>
<height>400</height>
</size>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="qw_centralEmptyWidget"/>
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Mapping">
<property name="allowedAreas">
<set>Qt::TopDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Models</string>
</property>
<attribute name="dockWidgetArea">
<number>4</number>
</attribute>
<widget class="QWidget" name="qw_MappingOuter">
<layout class="QVBoxLayout" name="vl_MissingModelsOuter">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="fr_MappingInner">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_MissingModelsInner">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="BlackGui::Components::CDataMappingComponent" name="comp_Mapping">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="BlackGui::CDockWidgetInfoArea" name="dwp_Log">
<property name="minimumSize">
<size>
<width>80</width>
<height>400</height>
</size>
</property>
<property name="allowedAreas">
<set>Qt::TopDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Logging</string>
</property>
<attribute name="dockWidgetArea">
<number>4</number>
</attribute>
<widget class="QWidget" name="qw_LogOuter">
<layout class="QVBoxLayout" name="vl_LogOuter">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="fr_LogInner">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_LogInner">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="BlackGui::Components::CLogComponent" name="comp_Log">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::CDockWidgetInfoArea</class>
<extends>QDockWidget</extends>
<header>blackgui/dockwidgetinfoarea.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CLogComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/logcomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CDataMappingComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/datamappingcomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,87 @@
/* 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 "datamappingcomponent.h"
#include "ui_datamappingcomponent.h"
#include "blackcore/web_datareader.h"
using namespace BlackGui::Views;
using namespace BlackCore;
namespace BlackGui
{
namespace Components
{
CDataMappingComponent::CDataMappingComponent(QWidget *parent) :
QFrame(parent),
ui(new Ui::CDataMappingComponent)
{
ui->setupUi(this);
connect(this->ui->tvp_Distributors, &CDistributorView::requestUpdate, this, &CDataMappingComponent::ps_requestModelDataUpdate);
connect(this->ui->tvp_Liveries, &CLiveryView::requestUpdate, this, &CDataMappingComponent::ps_requestModelDataUpdate);
connect(this->ui->tvp_Models, &CLiveryView::requestUpdate, this, &CDataMappingComponent::ps_requestModelDataUpdate);
}
CDataMappingComponent::~CDataMappingComponent()
{ }
void CDataMappingComponent::readersInitialized(CWebDataReader *webReaders)
{
Q_ASSERT_X(webReaders, Q_FUNC_INFO, "Missing readers");
if (this->m_webDataReader) { return; }
if (!this->m_webReaderSignalConnections.isEmpty()) { return; }
this->m_webDataReader = webReaders;
this->m_webReaderSignalConnections = this->m_webDataReader->connectSwiftDatabaseSignals(
this, // the object here must be the same as in the bind
std::bind(&CDataMappingComponent::ps_aircraftIcaoCodeRead, this, std::placeholders::_1),
std::bind(&CDataMappingComponent::ps_airlineIcaoCodeRead, this, std::placeholders::_1),
std::bind(&CDataMappingComponent::ps_liveriesRead, this, std::placeholders::_1),
std::bind(&CDataMappingComponent::ps_distributorsRead, this, std::placeholders::_1),
std::bind(&CDataMappingComponent::ps_modelsRead, this, std::placeholders::_1));
}
void CDataMappingComponent::ps_aircraftIcaoCodeRead(int number)
{
Q_UNUSED(number);
}
void CDataMappingComponent::ps_airlineIcaoCodeRead(int number)
{
Q_UNUSED(number);
}
void CDataMappingComponent::ps_liveriesRead(int number)
{
Q_ASSERT_X(this->m_webDataReader, Q_FUNC_INFO, "Missing reader");
Q_UNUSED(number);
this->ui->tvp_Liveries->updateContainerMaybeAsync(this->m_webDataReader->getLiveries());
}
void CDataMappingComponent::ps_distributorsRead(int number)
{
Q_ASSERT_X(this->m_webDataReader, Q_FUNC_INFO, "Missing reader");
Q_UNUSED(number);
this->ui->tvp_Distributors->updateContainerMaybeAsync(this->m_webDataReader->getDistributors());
}
void CDataMappingComponent::ps_modelsRead(int number)
{
Q_ASSERT_X(this->m_webDataReader, Q_FUNC_INFO, "Missing reader");
Q_UNUSED(number);
this->ui->tvp_Models->updateContainerMaybeAsync(this->m_webDataReader->getModels());
}
void CDataMappingComponent::ps_requestModelDataUpdate()
{
Q_ASSERT_X(this->m_webDataReader, Q_FUNC_INFO, "Missing reader");
this->m_webDataReader->readModelDataInBackground();
}
} // ns
} // ns

View File

@@ -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.
*/
#ifndef BLACKGUI_DATAMAPPINGCOMPONENT_H
#define BLACKGUI_DATAMAPPINGCOMPONENT_H
#include "blackgui/blackguiexport.h"
#include <QFrame>
namespace Ui { class CDataMappingComponent; }
namespace BlackCore { class CWebDataReader; }
namespace BlackGui
{
namespace Components
{
/**
* Mappings from/for the database
*/
class BLACKGUI_EXPORT CDataMappingComponent : public QFrame
{
Q_OBJECT
public:
//! Contructor
explicit CDataMappingComponent(QWidget *parent = nullptr);
//! Destructor
~CDataMappingComponent();
//! Readers have been initialized
void readersInitialized(BlackCore::CWebDataReader *webReaders);
private slots:
//! Aircraft ICAO codes read
void ps_aircraftIcaoCodeRead(int number);
//! Airline ICAO codes read
void ps_airlineIcaoCodeRead(int number);
//! Liveries read
void ps_liveriesRead(int number);
//! Distributors read
void ps_distributorsRead(int number);
//! Models read
void ps_modelsRead(int number);
//! Request distributor update
void ps_requestModelDataUpdate();
private:
QScopedPointer<Ui::CDataMappingComponent> ui;
BlackCore::CWebDataReader *m_webDataReader = nullptr;
QList<QMetaObject::Connection> m_webReaderSignalConnections;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,159 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDataMappingComponent</class>
<widget class="QFrame" name="CDataMappingComponent">
<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_DataMappingComponent">
<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="QTabWidget" name="tw_DataMappingComponent">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tb_Models">
<attribute name="title">
<string>Models</string>
</attribute>
<layout class="QVBoxLayout" name="vl_TabModels">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="BlackGui::Views::CAircraftModelView" name="tvp_Models">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_Liveries">
<attribute name="title">
<string>Liveries</string>
</attribute>
<layout class="QVBoxLayout" name="vl_TabLiveries">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="BlackGui::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>
<widget class="QWidget" name="tb_Distributors">
<attribute name="title">
<string>Distributors</string>
</attribute>
<layout class="QVBoxLayout" name="vl_TabDistributors">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="BlackGui::Views::CDistributorView" name="tvp_Distributors">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Views::CAircraftModelView</class>
<extends>QTableView</extends>
<header>blackgui/views/aircraftmodelview.h</header>
</customwidget>
<customwidget>
<class>BlackGui::Views::CDistributorView</class>
<extends>QTableView</extends>
<header>blackgui/views/distributorview.h</header>
</customwidget>
<customwidget>
<class>BlackGui::Views::CLiveryView</class>
<extends>QTableView</extends>
<header>blackgui/views/liveryview.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>