mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refs #475, added a utility class so the load indicator of a view can be triggered from the framing component
This commit is contained in:
committed by
Mathew Sutcliffe
parent
2507ce6715
commit
6fda875e8f
@@ -25,6 +25,7 @@ namespace BlackGui
|
||||
ui(new Ui::CDbAircraftIcaoComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setViewWithIndicator(this->ui->tvp_AircraftIcao);
|
||||
this->ui->tvp_AircraftIcao->setResizeMode(CViewBaseNonTemplate::ResizingOff);
|
||||
connect(this->ui->tvp_AircraftIcao, &CAircraftIcaoCodeView::requestNewBackendData, this, &CDbAircraftIcaoComponent::ps_reload);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define BLACKGUI_COMPONENTS_DBAIRCRAFTICAOCOMPONENT_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/enableforviewbasedindicator.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackmisc/network/webdataservicesprovider.h"
|
||||
#include <QFrame>
|
||||
@@ -30,6 +31,7 @@ namespace BlackGui
|
||||
class BLACKGUI_EXPORT CDbAircraftIcaoComponent :
|
||||
public QFrame,
|
||||
public CEnableForDockWidgetInfoArea,
|
||||
public CEnableForViewBasedIndicator,
|
||||
public BlackMisc::Network::CWebDataServicesAware
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -22,10 +22,10 @@ namespace BlackGui
|
||||
{
|
||||
CDbAirlineIcaoComponent::CDbAirlineIcaoComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
CWebDataServicesAware(nullptr),
|
||||
ui(new Ui::CDbAirlineIcaoComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setViewWithIndicator(this->ui->tvp_AirlineIcao);
|
||||
this->ui->tvp_AirlineIcao->setResizeMode(CViewBaseNonTemplate::ResizingOff);
|
||||
this->ui->tvp_AirlineIcao->setResizeMode(CViewBaseNonTemplate::ResizingOff);
|
||||
this->ui->tvp_AirlineIcao->allowDragDropValueObjects(true, false);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define BLACKGUI_COMPONENTS_DBAIRLINEICAOCOMPONENT_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/enableforviewbasedindicator.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackmisc/network/webdataservicesprovider.h"
|
||||
#include <QFrame>
|
||||
@@ -30,6 +31,7 @@ namespace BlackGui
|
||||
class BLACKGUI_EXPORT CDbAirlineIcaoComponent :
|
||||
public QFrame,
|
||||
public CEnableForDockWidgetInfoArea,
|
||||
public BlackGui::CEnableForViewBasedIndicator,
|
||||
public BlackMisc::Network::CWebDataServicesAware
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -22,10 +22,10 @@ namespace BlackGui
|
||||
{
|
||||
CDbCountryComponent::CDbCountryComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
CWebDataServicesAware(nullptr),
|
||||
ui(new Ui::CDbCountryComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setViewWithIndicator(this->ui->tvp_Countries);
|
||||
this->ui->tvp_Countries->setResizeMode(CViewBaseNonTemplate::ResizingOnce);
|
||||
connect(this->ui->tvp_Countries, &CCountryView::requestNewBackendData, this, &CDbCountryComponent::ps_reload);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define BLACKGUI_COMPONENTS_DBCOUNTRYCOMPONENT_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/enableforviewbasedindicator.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackmisc/network/webdataservicesprovider.h"
|
||||
#include <QFrame>
|
||||
@@ -30,6 +31,7 @@ namespace BlackGui
|
||||
class BLACKGUI_EXPORT CDbCountryComponent :
|
||||
public QFrame,
|
||||
public CEnableForDockWidgetInfoArea,
|
||||
public BlackGui::CEnableForViewBasedIndicator,
|
||||
public BlackMisc::Network::CWebDataServicesAware
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -21,10 +21,10 @@ namespace BlackGui
|
||||
{
|
||||
CDbDistributorComponent::CDbDistributorComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
CWebDataServicesAware(nullptr),
|
||||
ui(new Ui::CDbDistributorComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setViewWithIndicator(this->ui->tvp_Distributors);
|
||||
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);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define BLACKGUI_COMPONENTS_DBDISTRIBUTORCOMPONENT_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/enableforviewbasedindicator.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackmisc/network/webdataservicesprovider.h"
|
||||
#include <QFrame>
|
||||
@@ -30,6 +31,7 @@ namespace BlackGui
|
||||
class BLACKGUI_EXPORT CDbDistributorComponent :
|
||||
public QFrame,
|
||||
public CEnableForDockWidgetInfoArea,
|
||||
public BlackGui::CEnableForViewBasedIndicator,
|
||||
public BlackMisc::Network::CWebDataServicesAware
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace BlackGui
|
||||
ui(new Ui::CDbLiveryComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setViewWithIndicator(this->ui->tvp_Liveries);
|
||||
connect(this->ui->tvp_Liveries, &CLiveryView::requestNewBackendData, this, &CDbLiveryComponent::ps_reload);
|
||||
|
||||
// filter and drag and drop
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define BLACKGUI_COMPONENTS_DBLIVERYCOMPONENT_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/enableforviewbasedindicator.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackmisc/network/webdataservicesprovider.h"
|
||||
#include <QFrame>
|
||||
@@ -30,6 +31,7 @@ namespace BlackGui
|
||||
class BLACKGUI_EXPORT CDbLiveryComponent :
|
||||
public QFrame,
|
||||
public CEnableForDockWidgetInfoArea,
|
||||
public BlackGui::CEnableForViewBasedIndicator,
|
||||
public BlackMisc::Network::CWebDataServicesAware
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/project.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
#include "blackgui/roles.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
@@ -54,10 +55,11 @@ namespace BlackGui
|
||||
|
||||
void CDbMappingComponent::initVPilotLoading()
|
||||
{
|
||||
if (CProject::isRunningOnWindowsNtPlatform() && CProject::isCompiledWithMsFlightSimulatorSupport())
|
||||
if (CRoles::roles().isAdmin() &&
|
||||
CProject::isRunningOnWindowsNtPlatform() &&
|
||||
CProject::isCompiledWithMsFlightSimulatorSupport())
|
||||
{
|
||||
this->m_withVPilot = true;
|
||||
this->ui->tab_VPilot->setEnabled(true);
|
||||
this->ui->tvp_AircraftModelsForVPilot->setCustomMenu(new CMappingVPilotMenu(this));
|
||||
this->ui->tvp_AircraftModelsForVPilot->setDisplayAutomatically(true);
|
||||
connect(ui->tvp_AircraftModelsForVPilot, &CAircraftModelView::doubleClicked, this, &CDbMappingComponent::ps_onModelRowSelected);
|
||||
@@ -67,8 +69,10 @@ namespace BlackGui
|
||||
else
|
||||
{
|
||||
this->m_withVPilot = false;
|
||||
this->ui->tab_VPilot->setEnabled(false);
|
||||
}
|
||||
this->ui->tab_VPilot->setEnabled(m_withVPilot);
|
||||
this->ui->tab_VPilot->setVisible(m_withVPilot);
|
||||
this->ui->tw_ModelsToBeMapped->removeTab(1);
|
||||
}
|
||||
|
||||
bool CDbMappingComponent::initModelLoader(const CSimulatorInfo &simInfo)
|
||||
@@ -365,8 +369,11 @@ namespace BlackGui
|
||||
CDbMappingComponent *mapComp = qobject_cast<CDbMappingComponent *>(this->parent());
|
||||
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "Cannot access parent");
|
||||
|
||||
menu.addAction(CIcons::appMappings16(), "Load vPilot Rules", mapComp, SLOT(ps_loadVPilotData()));
|
||||
menu.addSeparator();
|
||||
if (CRoles::roles().isAdmin())
|
||||
{
|
||||
menu.addAction(CIcons::appMappings16(), "Load vPilot Rules", mapComp, SLOT(ps_loadVPilotData()));
|
||||
menu.addSeparator();
|
||||
}
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/overlaymessagesframe.h"
|
||||
#include "blackgui/menudelegate.h"
|
||||
#include "blackgui/enableforviewbasedindicator.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackmisc/simulation/aircraftmodelloader.h"
|
||||
#include "blackmisc/simulation/fscommon/vpilotrulesreader.h"
|
||||
@@ -35,6 +36,7 @@ namespace BlackGui
|
||||
class BLACKGUI_EXPORT CDbMappingComponent :
|
||||
public BlackGui::COverlayMessagesFrame,
|
||||
public CEnableForDockWidgetInfoArea,
|
||||
public BlackGui::CEnableForViewBasedIndicator,
|
||||
public BlackMisc::Network::CWebDataServicesAware
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -23,10 +23,10 @@ namespace BlackGui
|
||||
{
|
||||
CDbModelComponent::CDbModelComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
CWebDataServicesAware(nullptr), // provider not yet available
|
||||
ui(new Ui::CDbModelComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setViewWithIndicator(this->ui->tvp_AircraftModel);
|
||||
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);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define BLACKUI_COMPONENTS_DBMODELCOMPONENT_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/enableforviewbasedindicator.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackmisc/network/webdataservicesprovider.h"
|
||||
#include <QFrame>
|
||||
@@ -30,6 +31,7 @@ namespace BlackGui
|
||||
class BLACKGUI_EXPORT CDbModelComponent :
|
||||
public QFrame,
|
||||
public CEnableForDockWidgetInfoArea,
|
||||
public BlackGui::CEnableForViewBasedIndicator,
|
||||
public BlackMisc::Network::CWebDataServicesAware
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
55
src/blackgui/enableforviewbasedindicator.cpp
Normal file
55
src/blackgui/enableforviewbasedindicator.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#include "enableforviewbasedindicator.h"
|
||||
#include "blackgui/views/viewbase.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui;
|
||||
using namespace BlackGui::Views;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
void CEnableForViewBasedIndicator::enableLoadIndicator(bool enable)
|
||||
{
|
||||
Q_ASSERT_X(m_viewWithIndicator, Q_FUNC_INFO, "Missing view to display indicator");
|
||||
if (m_viewWithIndicator) { m_viewWithIndicator->enableLoadIndicator(enable); }
|
||||
}
|
||||
|
||||
bool CEnableForViewBasedIndicator::isShowingLoadIndicator() const
|
||||
{
|
||||
Q_ASSERT_X(m_viewWithIndicator, Q_FUNC_INFO, "Missing view to display indicator");
|
||||
if (m_viewWithIndicator) { return m_viewWithIndicator->isShowingLoadIndicator(); }
|
||||
return false;
|
||||
}
|
||||
|
||||
void CEnableForViewBasedIndicator::showLoadIndicator()
|
||||
{
|
||||
Q_ASSERT_X(m_viewWithIndicator, Q_FUNC_INFO, "Missing view to display indicator");
|
||||
if (m_viewWithIndicator) { m_viewWithIndicator->showLoadIndicator(); }
|
||||
}
|
||||
|
||||
void CEnableForViewBasedIndicator::hideLoadIndicator()
|
||||
{
|
||||
Q_ASSERT_X(m_viewWithIndicator, Q_FUNC_INFO, "Missing view to display indicator");
|
||||
if (m_viewWithIndicator) { m_viewWithIndicator->hideLoadIndicator(); }
|
||||
}
|
||||
|
||||
CEnableForViewBasedIndicator::CEnableForViewBasedIndicator(BlackGui::Views::CViewBaseNonTemplate *viewWithIndicator)
|
||||
: m_viewWithIndicator(viewWithIndicator)
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
void CEnableForViewBasedIndicator::setViewWithIndicator(BlackGui::Views::CViewBaseNonTemplate *viewWithIndicator)
|
||||
{
|
||||
this->m_viewWithIndicator = viewWithIndicator;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
50
src/blackgui/enableforviewbasedindicator.h
Normal file
50
src/blackgui/enableforviewbasedindicator.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* 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_ENABLEFORVIEWBASEDINDICATOR_H
|
||||
#define BLACKGUI_ENABLEFORVIEWBASEDINDICATOR_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
|
||||
namespace BlackGui { namespace Views { class CViewBaseNonTemplate; }}
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
//! Hand over indication task to an embedded view
|
||||
class BLACKGUI_EXPORT CEnableForViewBasedIndicator
|
||||
{
|
||||
public:
|
||||
//! Enable loading indicator
|
||||
void enableLoadIndicator(bool enable);
|
||||
|
||||
//! Showing load indicator
|
||||
bool isShowingLoadIndicator() const;
|
||||
|
||||
//! Show loading indicator
|
||||
void showLoadIndicator();
|
||||
|
||||
//! Hide loading indicator
|
||||
void hideLoadIndicator();
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CEnableForViewBasedIndicator(BlackGui::Views::CViewBaseNonTemplate *viewWithIndicator = nullptr);
|
||||
|
||||
//! Set the corresponding view
|
||||
void setViewWithIndicator(BlackGui::Views::CViewBaseNonTemplate *viewWithIndicator);
|
||||
|
||||
private:
|
||||
BlackGui::Views::CViewBaseNonTemplate *m_viewWithIndicator = nullptr;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user