Files
pilotclient/src/blackgui/components/dbaircrafticaocomponent.cpp
2017-04-18 00:05:41 +01:00

78 lines
3.0 KiB
C++

/* 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 "blackcore/webdataservices.h"
#include "blackgui/components/dbaircrafticaocomponent.h"
#include "blackgui/filters/aircrafticaofilterbar.h"
#include "blackgui/guiapplication.h"
#include "blackgui/views/aircrafticaoview.h"
#include "blackgui/views/viewbase.h"
#include "dbaircrafticaocomponent.h"
#include "ui_dbaircrafticaocomponent.h"
#include <QDateTime>
#include <QtGlobal>
using namespace BlackCore;
using namespace BlackMisc::Network;
using namespace BlackMisc::Aviation;
using namespace BlackGui;
using namespace BlackGui::Views;
namespace BlackGui
{
namespace Components
{
CDbAircraftIcaoComponent::CDbAircraftIcaoComponent(QWidget *parent) :
QFrame(parent),
ui(new Ui::CDbAircraftIcaoComponent)
{
ui->setupUi(this);
this->setViewWithIndicator(ui->tvp_AircraftIcao);
ui->tvp_AircraftIcao->setResizeMode(CAircraftIcaoCodeView::ResizingOff);
connect(ui->tvp_AircraftIcao, &CAircraftIcaoCodeView::requestNewBackendData, this, &CDbAircraftIcaoComponent::ps_reload);
ui->tvp_AircraftIcao->allowDragDrop(true, false);
ui->tvp_AircraftIcao->setFilterWidget(ui->filter_AircraftIcao);
ui->tvp_AircraftIcao->menuAddItems(CViewBaseNonTemplate::MenuCopy);
connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbAircraftIcaoComponent::ps_icaoRead);
this->ps_icaoRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFinished, sGui->getWebDataServices()->getAircraftIcaoCodesCount());
}
CDbAircraftIcaoComponent::~CDbAircraftIcaoComponent()
{ }
BlackGui::Views::CAircraftIcaoCodeView *CDbAircraftIcaoComponent::view() const
{
return ui->tvp_AircraftIcao;
}
void CDbAircraftIcaoComponent::filter(const CAircraftIcaoCode &icao)
{
ui->filter_AircraftIcao->filter(icao);
}
void CDbAircraftIcaoComponent::ps_icaoRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
{
Q_UNUSED(count);
if (entity.testFlag(CEntityFlags::AircraftIcaoEntity) && readState == CEntityFlags::ReadFinished)
{
ui->tvp_AircraftIcao->updateContainerMaybeAsync(sGui->getWebDataServices()->getAircraftIcaoCodes());
}
}
void CDbAircraftIcaoComponent::ps_reload()
{
if (!sGui) { return; }
sGui->getWebDataServices()->triggerLoadingDirectlyFromDb(CEntityFlags::AircraftIcaoEntity, QDateTime());
}
} // ns
} // ns