new_docker_build.sh gains Group 12 (212 GUI/Data plugins); fixes LtsUtilsGuiDds visibility (LTO-stripped exports), LtsProjectionWorkstation unity name shadow, 6 unity-off dirs (dup file-scope statics, ddsftc INTERFACE sources) and reconfigures BUILD_FILTERMANAGEMENT/BUILD_PLUGINS_SERVICEMONITOR=ON
95 lines
2.9 KiB
C++
Executable File
95 lines
2.9 KiB
C++
Executable File
|
|
|
|
|
|
#include "ism_combobox.h"
|
|
#include <utility>
|
|
#include <InfrastructureManagement/ism_translation.h>
|
|
#include <LtsUtilsCore/json_object.h>
|
|
|
|
namespace InfrastructureManagement
|
|
{
|
|
bool IsmComboBox::fill(LtsWidgets::LtsComboBox *cbx, IsmComboBoxType type, LtsSession::LtsSession *session,
|
|
const std::shared_ptr<Interface::Dtc> &dtc, int filter)
|
|
{
|
|
Q_UNUSED(session);
|
|
cbx->clear();
|
|
switch (type)
|
|
{
|
|
case IsmComboBoxType::CbRadioStations:
|
|
{
|
|
auto cb = [cbx,filter](const InfrastructureManagement::MainStructureElement &mse)
|
|
{
|
|
if (mse.structureElementTypeId == InfrastructureManagement::StructureElementType::RadioStation && !mse.isDeleted && mse.id > 0 )
|
|
{
|
|
const RadioStation &rs = RadioStation::fromMSE(mse);
|
|
if (((filter >= 0) && rs.radios.contains(static_cast<FrequencyBand>(filter))) ||
|
|
(filter < 0))
|
|
{
|
|
cbx->addItem(QString::fromStdString(mse.name), mse.id);
|
|
cbx->setItemData(cbx->findData(mse.id), rs.radioStationId, Qt::UserRole + 1);
|
|
}
|
|
}
|
|
};
|
|
dtc->mainStructureElements(cb);
|
|
break;
|
|
}
|
|
case IsmComboBoxType::CbApproachingPoints:
|
|
{
|
|
auto cb = [cbx](const InfrastructureManagement::MainStructureElement &mse)
|
|
{
|
|
if ((mse.structureElementTypeId == InfrastructureManagement::StructureElementType::ApproachingPoint) && !mse.isDeleted && (mse.id > 0))
|
|
{
|
|
cbx->addItem(QString::fromStdString(mse.name), mse.id);
|
|
cbx->setItemData(cbx->findData(mse.id), mse.angle, Qt::UserRole + 1);
|
|
}
|
|
};
|
|
dtc->mainStructureElements(cb);
|
|
break;
|
|
}
|
|
case IsmComboBoxType::CbScheduleStatus:
|
|
{
|
|
cbx->addItem(toString(ScheduleStatus::Active), static_cast<int>(ScheduleStatus::Active));
|
|
cbx->addItem(toString(ScheduleStatus::Inactive), static_cast<int>(ScheduleStatus::Inactive));
|
|
break;
|
|
}
|
|
case IsmComboBoxType::CbBridgeStatus:
|
|
{
|
|
cbx->addItem(toString(BridgeStatus::Intact), static_cast<int>(BridgeStatus::Intact));
|
|
cbx->addItem(toString(BridgeStatus::Broken), static_cast<int>(BridgeStatus::Broken));
|
|
}
|
|
case IsmComboBoxType::CbUnknown:
|
|
default:
|
|
break;
|
|
}
|
|
|
|
return cbx->count() > 0;
|
|
}
|
|
|
|
RadioStation RadioStation::fromMSE(const MainStructureElement &mse)
|
|
{
|
|
RadioStation rs;
|
|
rs.mse_id = mse.id;
|
|
rs.name = QString::fromStdString(mse.name);
|
|
|
|
LtsUtils::JsonObject jo = LtsUtils::JsonObject::fromJson(mse.properties);
|
|
LtsUtils::JsonArray radios = jo.valueOr<LtsUtils::JsonArray>("radios", {});
|
|
|
|
|
|
|
|
|
|
|
|
const QVector<LtsUtils::JsonObject> &radiosAsVector = radios.toVector<LtsUtils::JsonObject>();
|
|
for (const LtsUtils::JsonObject &radio : std::as_const(radiosAsVector))
|
|
{
|
|
FrequencyBand fb = static_cast<FrequencyBand>(radio.valueOr<int>("frequencyBand", -1));
|
|
int count = radio.valueOr<int>("count", 0);
|
|
if (fb != FrequencyBand::INVALID)
|
|
rs.radios.insert(fb,count);
|
|
}
|
|
|
|
rs.radioStationId = jo.valueOr<int>("stationId", 0);
|
|
return rs;
|
|
}
|
|
|
|
}
|