mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
committed by
Mathew Sutcliffe
parent
f29929111b
commit
008ea14812
79
src/blackgui/components/dbmodelcomponent.cpp
Normal file
79
src/blackgui/components/dbmodelcomponent.cpp
Normal 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
|
||||
Reference in New Issue
Block a user