Adds initial intermediate qt6 porting state
This commit is contained in:
11247 files changed
+1891537
No files matched your search
+339
@@ -0,0 +1,339 @@
|
||||
|
||||
|
||||
|
||||
#include "bdv_building_edit.h"
|
||||
#include "bdv_edit_item.h"
|
||||
#include "ui_bdv_building_edit.h"
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
#include <Buildings/bld_operator_rights.h>
|
||||
#include <Buildings/bld.hpp>
|
||||
#include <Buildings/bld_ftc.h>
|
||||
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
BuildingEdit::BuildingEdit(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::BuildingEdit)
|
||||
, m_logger(getLogger("BuildingViewer::BuildingEdit"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->hide();
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &BuildingEdit::slotEditItem);
|
||||
|
||||
bool userHasRightsToEdit = LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::BuildingViewerSettingsEdit);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setVisible(userHasRightsToEdit);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->setVisible(userHasRightsToEdit);
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setEnabled(false);
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableGuiDestroyRooms = ps->value(QStringLiteral("bld"),
|
||||
QStringLiteral("enableGuiDestroyRooms")).toBool();
|
||||
|
||||
auto btnDestroy = m_buttonBox->getButton(LtsWidgets::DialogButton::Add);
|
||||
btnDestroy->setText(tr("Destroy"));
|
||||
btnDestroy->setVisible(enableGuiDestroyRooms);
|
||||
|
||||
connect(btnDestroy, &QPushButton::pressed, this, &BuildingEdit::onDestroyElement);
|
||||
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Building_Viewer-Building_List"));
|
||||
}
|
||||
|
||||
|
||||
BuildingEdit::~BuildingEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Building Edit: %1").arg(m_buildingName));
|
||||
}
|
||||
|
||||
|
||||
bool BuildingEdit::init(int32_t buildingDatabaseId,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Ftc> &ismFtc,
|
||||
const std::shared_ptr<Buildings::Interface::Dtc> &bldDtc,
|
||||
const std::shared_ptr<Buildings::Interface::Ftc> &bldFtc)
|
||||
{
|
||||
if (m_ismDtc)
|
||||
return false;
|
||||
m_buildingDatabaseId = buildingDatabaseId;
|
||||
|
||||
m_ismDtc = ismDtc;
|
||||
m_ismFtc = ismFtc;
|
||||
m_bldDtc = bldDtc;
|
||||
m_bldFtc = bldFtc;
|
||||
|
||||
|
||||
InfrastructureManagement::MainStructureElement building = m_ismDtc->mainStructureElement(m_buildingDatabaseId);
|
||||
m_buildingId = building.id();
|
||||
|
||||
buildModel();
|
||||
m_buildingName = m_model->getBuildingName();
|
||||
|
||||
if (LtsSessionData::LtsSessionData::getInstance()->hasOperatorRight(OperatorRights::BuildingViewerSettingsEdit))
|
||||
{
|
||||
connect(m_ui->treeViewEdit, &QTreeView::clicked, this, &BuildingEdit::slotTreeViewClicked);
|
||||
connect(m_ui->treeViewEdit, &QTreeView::doubleClicked, this, &BuildingEdit::slotDoubleClicked);
|
||||
connect(m_model, &BuildingEditModel::signalModelDataChanged, this, &BuildingEdit::slotChangesMade);
|
||||
}
|
||||
|
||||
connect(m_ismDtc.get(), &InfrastructureManagement::Interface::Dtc::mainStructureElementChanged,
|
||||
this, &BuildingEdit::slotMainStructureElementChanged);
|
||||
|
||||
connect(m_bldDtc.get(), &Buildings::Interface::Dtc::buildingStateChanged,
|
||||
this, &BuildingEdit::slotBuildingStateChanged);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::slotTreeViewClicked()
|
||||
{
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setEnabled(selectedIndexView().isValid());
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::buildModel()
|
||||
{
|
||||
m_model = new BuildingEditModel(this, m_ismDtc, m_bldDtc);
|
||||
|
||||
|
||||
m_proxyModel = new BuildingEditProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
|
||||
|
||||
m_ui->treeViewEdit->setModel(m_proxyModel);
|
||||
m_ui->treeViewEdit->expandAll();
|
||||
m_ui->treeViewEdit->sortByColumn(BuildingEditModel::Building, Qt::AscendingOrder);
|
||||
|
||||
|
||||
m_ui->treeViewEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
m_model->init(m_buildingDatabaseId);
|
||||
m_ui->treeViewEdit->expandAll();
|
||||
m_ui->treeViewEdit->setColumnWidth(BuildingEditModel::Building, 230);
|
||||
#ifdef LTS_DEBUG
|
||||
m_ui->treeViewEdit->setColumnWidth(BuildingEditModel::Name, 150);
|
||||
m_ui->treeViewEdit->setColumnWidth(BuildingEditModel::MountingPointId, 120);
|
||||
m_ui->treeViewEdit->setColumnWidth(BuildingEditModel::StructureElementId, 80);
|
||||
#else
|
||||
m_ui->treeViewEdit->hideColumn(BuildingEditModel::Name);
|
||||
m_ui->treeViewEdit->hideColumn(BuildingEditModel::MountingPointId);
|
||||
m_ui->treeViewEdit->hideColumn(BuildingEditModel::StructureElementId);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
QModelIndex BuildingEdit::selectedIndexView() const
|
||||
{
|
||||
QItemSelectionModel *selectionModel = m_ui->treeViewEdit->selectionModel();
|
||||
QModelIndexList indexL = selectionModel->selectedRows(0);
|
||||
if (indexL.size() == 0)
|
||||
return QModelIndex();
|
||||
|
||||
return m_proxyModel->mapToSource(indexL.at(0));
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::slotEditItem()
|
||||
{
|
||||
QModelIndex selIndex = selectedIndexView();
|
||||
if (!selIndex.isValid())
|
||||
return;
|
||||
|
||||
BuildingViewer::TreeItem data = m_model->privateData(selIndex)->data().value<TreeItem>();
|
||||
|
||||
ParticipantEditItemWidget *newItemDlg = new ParticipantEditItemWidget(m_buildingName, data, this);
|
||||
newItemDlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
connect(newItemDlg, &ParticipantEditItemWidget::signalItemUpdated,
|
||||
m_model, &BuildingEditModel::slotUpdateRow);
|
||||
|
||||
newItemDlg->show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool BuildingEdit::apply()
|
||||
{
|
||||
|
||||
|
||||
const auto fortifyFactors = m_model->getRoomsWithChangedFortifyFactors();
|
||||
|
||||
|
||||
|
||||
DEBUG_LOG(m_logger) << "fortifyFactors.size()=" << fortifyFactors.size();
|
||||
if (fortifyFactors.size())
|
||||
{
|
||||
m_requestHelper->addRequest([this, fortifyFactors]()
|
||||
{
|
||||
Buildings::SetFortifyFactorRequest fortifyRequest;
|
||||
fortifyRequest.buildingId(m_buildingDatabaseId);
|
||||
|
||||
|
||||
fortifyRequest.fortifyFactors().reserve(fortifyFactors.size());
|
||||
for (const auto &e : fortifyFactors)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "push_back= databaseId=" << e.structureElementId()
|
||||
<< " fortifyFactor=" << e.fortifyFactor();
|
||||
fortifyRequest.fortifyFactors().push_back(Buildings::FortifyFactor(e.structureElementId(), e.fortifyFactor()));
|
||||
}
|
||||
|
||||
return m_bldFtc->setFortifyFactorRequest(fortifyRequest, this);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const auto displayNames = m_model->getRoomsWithChangedDisplayNames();
|
||||
|
||||
|
||||
|
||||
if (displayNames.size())
|
||||
{
|
||||
std::vector<InfrastructureManagement::StructureElement> vecModifiedRooms;
|
||||
vecModifiedRooms.reserve(displayNames.size());
|
||||
InfrastructureManagement::MainStructureElement building = m_ismDtc->mainStructureElement(m_buildingDatabaseId);
|
||||
|
||||
for (const auto &treeItem : displayNames)
|
||||
{
|
||||
|
||||
for (const auto &room : building.elements())
|
||||
{
|
||||
if (room.id() == treeItem.structureElementId())
|
||||
{
|
||||
auto copy = room;
|
||||
copy.displayName(treeItem.displayName().toStdString());
|
||||
vecModifiedRooms.push_back(copy);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_requestHelper->addRequest([this, vecModifiedRooms]()
|
||||
{
|
||||
InfrastructureManagement::StructureElementModifyRequest request(m_buildingDatabaseId, vecModifiedRooms);
|
||||
return m_ismFtc->structureElementModifyRequest(request, this);
|
||||
});
|
||||
}
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::selectRoomRow(int mountingPointId)
|
||||
{
|
||||
QModelIndex mIndex = m_model->modelIndexByStructureElementId(mountingPointId);
|
||||
m_ui->treeViewEdit->setCurrentIndex(mIndex);
|
||||
m_ui->treeViewEdit->selectionModel()->setCurrentIndex(mIndex, QItemSelectionModel::ClearAndSelect);
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::reinitModel()
|
||||
{
|
||||
m_model->init(m_buildingDatabaseId);
|
||||
m_ui->treeViewEdit->expandAll();
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::slotDoubleClicked(const QModelIndex &selIndex)
|
||||
{
|
||||
if (!selIndex.isValid())
|
||||
return;
|
||||
|
||||
slotEditItem();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void BuildingEdit::slotMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &mse, DataModification modType)
|
||||
{
|
||||
if(modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
if(mse.id() == m_buildingDatabaseId)
|
||||
{
|
||||
|
||||
slotHandleExternalDdsChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::slotBuildingStateChanged(const Buildings::BuildingState &state, DataModification modType)
|
||||
{
|
||||
if(modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
if(state.id() == m_buildingDatabaseId)
|
||||
{
|
||||
|
||||
slotHandleExternalDdsChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BuildingEdit::slotHandleExternalDdsChange()
|
||||
{
|
||||
reinitModel();
|
||||
}
|
||||
|
||||
bool BuildingEdit::sendBuildingStateRequest(ProjectDataManagement::VulnerabilityState state, std::vector<int32_t> structureElementIds)
|
||||
{
|
||||
|
||||
m_requestHelper->addRequest([this, state, structureElementIds]()
|
||||
{
|
||||
Buildings::Building building;
|
||||
std::vector< Buildings::Building > buildings;
|
||||
buildings.resize(1);
|
||||
Buildings::SetBuildingStatesRequest requestData;
|
||||
|
||||
building.buildingId(m_buildingId);
|
||||
building.roomIds().set(structureElementIds);
|
||||
buildings[0] = building;
|
||||
requestData.buildings(buildings);
|
||||
requestData.vulnerabilityState(state);
|
||||
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << "currentData: " << state;
|
||||
|
||||
return m_bldFtc->setBuildingStatesRequest(requestData, this);
|
||||
});
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
void BuildingEdit::onDestroyElement()
|
||||
{
|
||||
QModelIndex selIndex = selectedIndexView();
|
||||
if (!selIndex.isValid())
|
||||
return;
|
||||
|
||||
std::vector<int32_t> structureElementIds;
|
||||
getStructureElementIds(m_model->privateData(selIndex), structureElementIds);
|
||||
|
||||
sendBuildingStateRequest(ProjectDataManagement::VulnerabilityState_def::CatastrophicKill, structureElementIds);
|
||||
}
|
||||
|
||||
void BuildingEdit::getStructureElementIds(NGLTreeItem *item, std::vector<int32_t> &structureElementIds)
|
||||
{
|
||||
for (NGLTreeItem *child : item->children())
|
||||
getStructureElementIds(child, structureElementIds);
|
||||
|
||||
BuildingViewer::TreeItem data = item->data().value<TreeItem>();
|
||||
if (data.isRoom())
|
||||
structureElementIds.push_back(data.structureElementId());
|
||||
}
|
||||
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "bdv_edit_model.h"
|
||||
|
||||
|
||||
#include <Common/logger.h>
|
||||
#include <Plugins/Buildings/bld_data_plugin_interface.h>
|
||||
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class BuildingEdit;
|
||||
}
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
class BuildingEdit : public LtsWidgets::LtsDialog
|
||||
, protected Buildings::Interface::Ftc::SetFortifyFactorReplyHandler
|
||||
, protected Buildings::Interface::Ftc::SetBuildingStatesReplyHandler
|
||||
, protected InfrastructureManagement::Interface::Ftc::StructureElementModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BuildingEdit(QWidget *parent = nullptr);
|
||||
~BuildingEdit();
|
||||
|
||||
bool init(int32_t buildingDatabaseId,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Ftc> &ismFtc,
|
||||
const std::shared_ptr<Buildings::Interface::Dtc> &bldDtc,
|
||||
const std::shared_ptr<Buildings::Interface::Ftc> &bldFtc);
|
||||
|
||||
void onSetFortifyFactorReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onSetBuildingStatesReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onStructureElementModifyReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void selectRoomRow(int mountingPointId);
|
||||
|
||||
signals:
|
||||
void signalAccept();
|
||||
|
||||
private slots:
|
||||
void slotEditItem();
|
||||
void slotDoubleClicked(const QModelIndex &selIndex);
|
||||
void slotMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &mse, DataModification modType);
|
||||
void slotBuildingStateChanged(const Buildings::BuildingState &state, DataModification modType);
|
||||
void slotHandleExternalDdsChange();
|
||||
void slotTreeViewClicked();
|
||||
|
||||
bool sendBuildingStateRequest(ProjectDataManagement::VulnerabilityState state, std::vector<int32_t> structureElementId);
|
||||
void onDestroyElement();
|
||||
|
||||
protected:
|
||||
void retranslate() override;
|
||||
bool apply() override;
|
||||
|
||||
private:
|
||||
void getStructureElementIds(NGLTreeItem *item, std::vector<int32_t> &structureElementIds);
|
||||
void buildModel();
|
||||
QModelIndex selectedIndexView() const;
|
||||
void reinitModel();
|
||||
|
||||
private:
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Ftc> m_ismFtc;
|
||||
std::shared_ptr<Buildings::Interface::Dtc> m_bldDtc;
|
||||
std::shared_ptr<Buildings::Interface::Ftc> m_bldFtc;
|
||||
|
||||
BuildingEditModel *m_model = nullptr;
|
||||
BuildingEditProxyModel *m_proxyModel = nullptr;
|
||||
LtsUtils::RequestHelper *m_requestHelper = nullptr;
|
||||
Ui::BuildingEdit *m_ui = nullptr;
|
||||
|
||||
QString m_buildingName;
|
||||
int32_t m_buildingDatabaseId = 0;
|
||||
int32_t m_buildingId = 0;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BuildingEdit</class>
|
||||
<widget class="QWidget" name="BuildingEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>279</width>
|
||||
<height>246</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">setwindowtitle in source</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QTreeView" name="treeViewEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<attribute name="headerShowSortIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
|
||||
|
||||
|
||||
#include "bdv_edit_item.h"
|
||||
#include "ui_bdv_edit_item.h"
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
ParticipantEditItemWidget::ParticipantEditItemWidget(const QString &buildingName,
|
||||
const BuildingViewer::TreeItem &itemValue,
|
||||
QWidget *parent)
|
||||
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
|
||||
, m_itemValue(itemValue)
|
||||
, m_ui(new Ui::BuildingEditItemWidget)
|
||||
, m_buttonBox(new LtsWidgets::LtsDialogButtonBox(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->leBuildingDescription->setText(buildingName);
|
||||
m_ui->leRoomDesription->setText(m_itemValue.displayName());
|
||||
m_ui->sbFortifyFactor->setValue(m_itemValue.fortifyFactor());
|
||||
|
||||
layout()->addWidget(m_buttonBox);
|
||||
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Apply), &QPushButton::clicked, this, &ParticipantEditItemWidget::slotApply);
|
||||
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this, &ParticipantEditItemWidget::accept);
|
||||
|
||||
if ( itemValue.isBuilding() )
|
||||
{
|
||||
m_ui->lbBuildingName->hide();
|
||||
m_ui->leBuildingDescription->hide();
|
||||
m_ui->lbRoomDesription->setText(tr("Building Name:"));
|
||||
m_ui->sbFortifyFactor->setValue(1.0);
|
||||
}
|
||||
else if ( itemValue.isFloor() )
|
||||
{
|
||||
m_ui->lbRoomDesription->setText(tr("Floor:"));
|
||||
m_ui->sbFortifyFactor->setValue(1.0);
|
||||
}
|
||||
|
||||
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->show();
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->setEnabled(false);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->hide();
|
||||
connect(m_ui->leRoomDesription, &QLineEdit::textChanged, this, [this]()
|
||||
{
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->setEnabled(true);
|
||||
});
|
||||
connect(m_ui->sbFortifyFactor, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, [this]()
|
||||
{
|
||||
m_fortifyFactorChanged = true;
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Apply)->setEnabled(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
ParticipantEditItemWidget::~ParticipantEditItemWidget()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantEditItemWidget::slotApply()
|
||||
{
|
||||
if (m_ui->leRoomDesription->text().isEmpty())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Enter at least one character"));
|
||||
return;
|
||||
}
|
||||
|
||||
m_itemValue.setDisplayName(m_ui->leRoomDesription->text());
|
||||
|
||||
if (m_itemValue.isRoom() || !m_itemValue.hasDisplayNameChanged() || m_fortifyFactorChanged)
|
||||
m_itemValue.setFortifyFactor(m_ui->sbFortifyFactor->value());
|
||||
|
||||
if (m_itemValue.hasDisplayNameChanged() || m_itemValue.hasFortifyFactorChanged())
|
||||
emit signalItemUpdated(m_itemValue, m_fortifyFactorChanged);
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "bdv_treemodel_item.h"
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <LtsWidgets/lts_dialog_button_box.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class BuildingEditItemWidget;
|
||||
}
|
||||
namespace BuildingViewer
|
||||
{
|
||||
|
||||
class ParticipantEditItemWidget : public LtsWidgets::LtsFramelessDialog
|
||||
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParticipantEditItemWidget(const QString &buildingName,
|
||||
const TreeItem &itemValue,
|
||||
QWidget *parent = nullptr);
|
||||
~ParticipantEditItemWidget();
|
||||
|
||||
signals:
|
||||
void signalItemUpdated(const TreeItem &editData, const bool fortifyChanged);
|
||||
|
||||
private slots:
|
||||
void slotApply();
|
||||
|
||||
private:
|
||||
bool m_fortifyFactorChanged = false;
|
||||
TreeItem m_itemValue;
|
||||
Ui::BuildingEditItemWidget *m_ui;
|
||||
LtsWidgets::LtsDialogButtonBox *m_buttonBox;
|
||||
};
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BuildingEditItemWidget</class>
|
||||
<widget class="QWidget" name="BuildingEditItemWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>350</width>
|
||||
<height>109</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>350</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="sbFortifyFactor">
|
||||
<property name="toolTip">
|
||||
<string>Specify a value between 0 and 8</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>8.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.230000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbFortifyFactor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fortify Factor:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="leBuildingDescription">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leRoomDesription">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>40</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbBuildingName">
|
||||
<property name="text">
|
||||
<string>Building Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbRoomDesription">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Room Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>17</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>leRoomDesription</tabstop>
|
||||
<tabstop>sbFortifyFactor</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+297
@@ -0,0 +1,297 @@
|
||||
|
||||
|
||||
|
||||
#include "bdv_edit_model.h"
|
||||
#include <Common/logger.h>
|
||||
#include <Services/InfrastructureManagement/ism.hpp>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QTableWidget>
|
||||
#include <QPalette>
|
||||
#include <QApplication>
|
||||
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
BuildingEditModel::BuildingEditModel(QObject *parent,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
const std::shared_ptr<Buildings::Interface::Dtc> &bldDtc)
|
||||
: NGLTreeModel(parent, new NGLTreeItem(QVariant()), {
|
||||
tr("Selected Building"),
|
||||
QStringLiteral("Name (DEBUG)"),
|
||||
QStringLiteral("MountingPointId (DEBUG)"),
|
||||
QStringLiteral("StructureElementId (DEBUG)"),
|
||||
tr("Fortify Factor"),
|
||||
tr("Damage Percent")})
|
||||
, m_ismDtc(ismDtc)
|
||||
, m_bldDtc(bldDtc)
|
||||
, m_buildingName(QString())
|
||||
, m_logger(getLogger("BuildingViewer::BuildingEdit"))
|
||||
{}
|
||||
|
||||
QVariant BuildingEditModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid() || (role != Qt::BackgroundRole && role != Qt::DisplayRole))
|
||||
return {};
|
||||
|
||||
|
||||
NGLTreeItem *pNGLTreeItem = privateData(index);
|
||||
|
||||
if (pNGLTreeItem->data().canConvert<BuildingViewer::TreeItem>())
|
||||
{
|
||||
BuildingViewer::TreeItem item = pNGLTreeItem->data().value<BuildingViewer::TreeItem>();
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (item.hasDisplayNameChanged() || item.hasFortifyFactorChanged())
|
||||
return QGuiApplication::palette().color(QPalette::Highlight);
|
||||
}
|
||||
else if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case BuildingEditModel::Building:
|
||||
return item.displayName();
|
||||
case BuildingEditModel::Name:
|
||||
return item.name();
|
||||
case BuildingEditModel::MountingPointId:
|
||||
if (item.hasMountingPointId())
|
||||
return item.mountingPointId();
|
||||
break;
|
||||
case BuildingEditModel::StructureElementId:
|
||||
return item.structureElementId();
|
||||
case BuildingEditModel::FortifyFactor:
|
||||
if (item.isRoom())
|
||||
return QString::number(item.fortifyFactor(),'f',1);
|
||||
break;
|
||||
case BuildingEditModel::DamagePercent:
|
||||
if (item.isRoom())
|
||||
return QString::number(item.damagePercent());
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
bool BuildingEditModel::slotUpdateRow(const BuildingViewer::TreeItem &room, const bool fortifyChanged)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "slotUpdateRow isBuilding=" << room.isBuilding()
|
||||
<< " isFloor" << room.isFloor()
|
||||
<< " isRoom" << room.isRoom();
|
||||
|
||||
|
||||
QModelIndex idx = modelIndexByStructureElementId(room.structureElementId());
|
||||
|
||||
if (fortifyChanged && ( !room.isRoom() || !qFuzzyIsNull(room.fortifyFactor())))
|
||||
{
|
||||
for (auto *item : privateData(idx)->children())
|
||||
{
|
||||
TreeItem childItem = item->data().value<TreeItem>();
|
||||
childItem.setFortifyFactor(room.fortifyFactor());
|
||||
slotUpdateRow(childItem, fortifyChanged);
|
||||
}
|
||||
}
|
||||
|
||||
if (room.hasDisplayNameChanged())
|
||||
m_mapRoomsWithChangedDisplayName[room.structureElementId()] = room;
|
||||
if (fortifyChanged && (room.isRoom() && room.hasFortifyFactorChanged()))
|
||||
m_mapRoomsWithChangedFortifyFactor[room.structureElementId()] = room;
|
||||
|
||||
QVariant data;
|
||||
data.setValue(room);
|
||||
|
||||
emit signalModelDataChanged();
|
||||
return setItemData(idx, data, QIcon());
|
||||
}
|
||||
|
||||
|
||||
bool BuildingEditModel::onInsertRow(int &row, const QModelIndex &parent, const BuildingViewer::TreeItem &folderData)
|
||||
{
|
||||
row = rowCount(parent);
|
||||
QVariant data;
|
||||
data.setValue(folderData);
|
||||
NGLTreeItem *item = new NGLTreeItem(data, QIcon());
|
||||
item->setModified(true);
|
||||
|
||||
emit signalModelDataChanged();
|
||||
|
||||
return NGLTreeModel::insertRow(row, parent, item);
|
||||
}
|
||||
|
||||
|
||||
bool BuildingEditModel::init(int32_t mseId)
|
||||
{
|
||||
INFO_LOG(m_logger) << "init mseId=" << mseId;
|
||||
NGLTreeModel::resetModel();
|
||||
m_mapRoomsWithChangedFortifyFactor.clear();
|
||||
|
||||
QMap<qint32, BuildingViewer::TreeItem> treemap;
|
||||
QMap<qint32, qint32> lookupFloorId2TreeId;
|
||||
QString rootName;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
InfrastructureManagement::MainStructureElement building = m_ismDtc->mainStructureElement(mseId);
|
||||
int rootId = 0;
|
||||
qint32 mapId = 0;
|
||||
|
||||
const std::vector<InfrastructureManagement::StructureElement> &vecElements = building.elements();
|
||||
for (const auto &se : vecElements)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "se: " << se;
|
||||
if (se.structureElementTypeId() == InfrastructureManagement::StructureElementType::Building)
|
||||
{
|
||||
BuildingViewer::TreeItem rootItemBuilding(se);
|
||||
rootName =rootItemBuilding.name();
|
||||
m_buildingName = rootItemBuilding.displayName();
|
||||
mapId = rootId;
|
||||
treemap[mapId++] = rootItemBuilding;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (const auto &se : vecElements)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "se: =" << se;
|
||||
if (se.structureElementTypeId() == InfrastructureManagement::StructureElementType_def::Floor)
|
||||
{
|
||||
BuildingViewer::TreeItem itemRoom(se);
|
||||
itemRoom.setSuperior(rootId);
|
||||
|
||||
lookupFloorId2TreeId[se.id()] = mapId;
|
||||
treemap[mapId++] = itemRoom;
|
||||
}
|
||||
}
|
||||
|
||||
m_bldDtc->enableBuildingState();
|
||||
m_bldDtc->waitForHistoricalDataBuildingState(1000);
|
||||
|
||||
auto bs = m_bldDtc->buildingState(mseId);
|
||||
|
||||
QMap<int32_t, Buildings::RoomState> roomStates;
|
||||
for (const auto &e : bs.roomStates())
|
||||
roomStates[e.id()] = e;
|
||||
|
||||
|
||||
for (const auto &se : vecElements)
|
||||
{
|
||||
if (se.structureElementTypeId() == InfrastructureManagement::StructureElementType_def::Room)
|
||||
{
|
||||
|
||||
double fortifyFactor = 1.0;
|
||||
qint32 damagePercent = bs.damagePercent();
|
||||
if (roomStates.contains(se.id()))
|
||||
{
|
||||
fortifyFactor = roomStates[se.id()].fortifyFactor();
|
||||
damagePercent = roomStates[se.id()].damagePercent();
|
||||
}
|
||||
|
||||
BuildingViewer::TreeItem itemRoom(se, fortifyFactor, damagePercent);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
int32_t floorID = se.path()[1];
|
||||
itemRoom.setSuperior(lookupFloorId2TreeId[floorID]);
|
||||
}
|
||||
catch (const std::out_of_range &e)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Caught exception while trying to get superior id for building " << rootName << " with room with mounting point id: " << se.mountingPointId() << ": " << e.what();
|
||||
return false;
|
||||
}
|
||||
|
||||
treemap[mapId++] = itemRoom;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QHash<int, QPersistentModelIndex> parentItemIndexCache;
|
||||
parentItemIndexCache.insert(rootId, QModelIndex());
|
||||
|
||||
for (auto iter = treemap.constBegin(); iter != treemap.constEnd(); ++iter)
|
||||
{
|
||||
int itemDatabaseId = iter.key();
|
||||
const BuildingViewer::TreeItem &item = iter.value();
|
||||
|
||||
QVariant data;
|
||||
data.setValue(item);
|
||||
|
||||
int parentId = item.hasSuperior() ? item.getSuperior() : rootId;
|
||||
if (!parentItemIndexCache.contains(parentId))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid building structure! Tree can not be built!";
|
||||
return false;
|
||||
}
|
||||
|
||||
QModelIndex pIndex = parentItemIndexCache.value(parentId);
|
||||
int rowPos = -1;
|
||||
|
||||
onInsertRow(rowPos, pIndex, item);
|
||||
|
||||
QPersistentModelIndex mIndex = index(rowPos, 0, pIndex);
|
||||
m_mapModelIndices[item.structureElementId()] = mIndex;
|
||||
parentItemIndexCache.insert(itemDatabaseId, mIndex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QModelIndex BuildingEditModel::modelIndexByMountingPointId(int mountingPointId) const
|
||||
{
|
||||
for(const QPersistentModelIndex &mi : qAsConst(m_mapModelIndices))
|
||||
{
|
||||
if (privateData(mi)->data().value<TreeItem>().mountingPointId() == mountingPointId)
|
||||
return mi;
|
||||
}
|
||||
WARNING_LOG(m_logger)<<"Could not find modelindex for given room mountig point id: " << mountingPointId;
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
QModelIndex BuildingEditModel::modelIndexByStructureElementId(int structureElementId) const
|
||||
{
|
||||
auto it = m_mapModelIndices.find(structureElementId);
|
||||
if (it == m_mapModelIndices.end())
|
||||
{
|
||||
WARNING_LOG(m_logger)<<"Could not find modelindex for given room structreElementId: " << structureElementId;
|
||||
return {};
|
||||
}
|
||||
return it.value();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BuildingEditProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<BuildingEditModel*>(sourceModel);
|
||||
QSortFilterProxyModel::setSourceModel(m_sourceModel);
|
||||
}
|
||||
|
||||
bool BuildingEditProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
||||
{
|
||||
if (!m_sourceModel ||
|
||||
left.column() != 0 || right.column() != 0)
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
|
||||
NGLTreeItem *itemLeft = m_sourceModel->privateData(left);
|
||||
NGLTreeItem *itemRight = m_sourceModel->privateData(right);
|
||||
if (itemLeft && itemRight)
|
||||
return (itemLeft->row() < itemRight->row());
|
||||
|
||||
return QSortFilterProxyModel::lessThan(left, right);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Common/logger.h>
|
||||
|
||||
#include <Plugins/Buildings/bld_data_plugin_interface.h>
|
||||
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
|
||||
#include "bdv_treemodel_item.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <functional>
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
class BuildingEditModel : public NGLTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Building,
|
||||
Name,
|
||||
MountingPointId,
|
||||
StructureElementId,
|
||||
FortifyFactor,
|
||||
DamagePercent,
|
||||
ColumnCount,
|
||||
};
|
||||
|
||||
BuildingEditModel(QObject *parent,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
const std::shared_ptr<Buildings::Interface::Dtc> &bldDtc);
|
||||
|
||||
QList<BuildingViewer::TreeItem> getRoomsWithChangedFortifyFactors() const { return m_mapRoomsWithChangedFortifyFactor.values(); }
|
||||
QList<BuildingViewer::TreeItem> getRoomsWithChangedDisplayNames() const { return m_mapRoomsWithChangedDisplayName.values(); }
|
||||
|
||||
bool init(int32_t buildingDatabaseId);
|
||||
QModelIndex modelIndexByMountingPointId(int mountingPointId) const;
|
||||
QModelIndex modelIndexByStructureElementId(int structureElementId) const;
|
||||
QString getBuildingName() const {return m_buildingName;}
|
||||
|
||||
public slots:
|
||||
bool slotUpdateRow(const BuildingViewer::TreeItem &room, const bool fortifyChanged);
|
||||
|
||||
signals:
|
||||
void signalModelDataChanged();
|
||||
|
||||
private:
|
||||
QVariant data(const QModelIndex &index, int role) const override final;
|
||||
bool onInsertRow(int &row, const QModelIndex &parent, const BuildingViewer::TreeItem &folderData);
|
||||
|
||||
QMap<int, QPersistentModelIndex> m_mapModelIndices;
|
||||
|
||||
|
||||
QMap<int32_t, BuildingViewer::TreeItem> m_mapRoomsWithChangedFortifyFactor;
|
||||
QMap<int32_t, BuildingViewer::TreeItem> m_mapRoomsWithChangedDisplayName;
|
||||
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<Buildings::Interface::Dtc> m_bldDtc;
|
||||
|
||||
QString m_buildingName;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class BuildingEditProxyModel final : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using QSortFilterProxyModel::QSortFilterProxyModel;
|
||||
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
||||
private:
|
||||
BuildingEditModel *m_sourceModel = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(BuildingViewer::TreeItem)
|
||||
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <Services/InfrastructureManagement/ism.hpp>
|
||||
|
||||
namespace BuildingViewer
|
||||
{
|
||||
class TreeItem
|
||||
{
|
||||
public:
|
||||
TreeItem() = default;
|
||||
|
||||
|
||||
explicit TreeItem(const InfrastructureManagement::MainStructureElement &mse)
|
||||
: m_displayName(toQString(mse.name()))
|
||||
, m_structureElementId(mse.id())
|
||||
, m_name(toQString(mse.name()) + QStringLiteral(" (ModelId: ") + QString::number(mse.modelId()) + QStringLiteral(")"))
|
||||
{}
|
||||
|
||||
|
||||
explicit TreeItem(const InfrastructureManagement::StructureElement &se)
|
||||
: m_displayName(toQString(se.displayName()))
|
||||
, m_isFloor(true)
|
||||
, m_structureElementId(se.id())
|
||||
, m_mountingPointId(se.mountingPointId())
|
||||
, m_name(toQString(se.name()))
|
||||
{}
|
||||
|
||||
|
||||
explicit TreeItem(const InfrastructureManagement::StructureElement &se
|
||||
, double fortifyFactor
|
||||
, qint32 damagePercent)
|
||||
: m_displayName(toQString(se.displayName()))
|
||||
, m_fortifyFactor(fortifyFactor)
|
||||
, m_damagePercent(damagePercent)
|
||||
, m_isRoom(true)
|
||||
, m_structureElementId(se.id())
|
||||
, m_mountingPointId(se.mountingPointId())
|
||||
, m_name(toQString(se.name()))
|
||||
{}
|
||||
|
||||
int32_t structureElementId() const
|
||||
{
|
||||
return m_structureElementId;
|
||||
}
|
||||
|
||||
|
||||
bool hasSuperior() const
|
||||
{
|
||||
return m_hasSuperior;
|
||||
}
|
||||
|
||||
qint32 getSuperior() const
|
||||
{
|
||||
return m_superior;
|
||||
}
|
||||
|
||||
void setSuperior(int id)
|
||||
{
|
||||
m_hasSuperior = true;
|
||||
m_superior = id;
|
||||
}
|
||||
|
||||
bool hasMountingPointId() const
|
||||
{
|
||||
|
||||
return !isBuilding();
|
||||
}
|
||||
|
||||
bool isBuilding() const
|
||||
{
|
||||
return !m_hasSuperior;
|
||||
}
|
||||
|
||||
bool isFloor() const
|
||||
{
|
||||
return m_isFloor;
|
||||
}
|
||||
|
||||
bool isRoom() const
|
||||
{
|
||||
return m_isRoom;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const QString &name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
void setStructureElementId(const int32_t structureElementId)
|
||||
{
|
||||
m_structureElementId = structureElementId;
|
||||
}
|
||||
|
||||
qint32 mountingPointId() const
|
||||
{
|
||||
return m_mountingPointId;
|
||||
}
|
||||
|
||||
void setDisplayName(const QString &strDisplayName)
|
||||
{
|
||||
m_displayNameChanged = m_displayNameChanged || (strDisplayName != m_displayName);
|
||||
m_displayName = strDisplayName;
|
||||
}
|
||||
|
||||
const QString &displayName() const
|
||||
{
|
||||
return m_displayName;
|
||||
}
|
||||
|
||||
bool hasDisplayNameChanged() const
|
||||
{
|
||||
return m_displayNameChanged;
|
||||
}
|
||||
|
||||
void setFortifyFactor(double fortifyFactor)
|
||||
{
|
||||
m_fortifyFactorChanged = m_fortifyFactorChanged || !qFuzzyCompare(fortifyFactor, m_fortifyFactor);
|
||||
m_fortifyFactor = fortifyFactor;
|
||||
}
|
||||
|
||||
double fortifyFactor() const
|
||||
{
|
||||
return m_fortifyFactor;
|
||||
}
|
||||
|
||||
bool hasFortifyFactorChanged() const
|
||||
{
|
||||
return m_fortifyFactorChanged;
|
||||
}
|
||||
|
||||
void setDamagePercent(qint32 damagePercent)
|
||||
{
|
||||
m_damagePercentChanged = m_damagePercentChanged || (damagePercent != m_damagePercent);
|
||||
m_damagePercent = damagePercent;
|
||||
}
|
||||
|
||||
qint32 damagePercent() const
|
||||
{
|
||||
return m_damagePercent;
|
||||
}
|
||||
|
||||
bool hasDamagePercentChanged() const
|
||||
{
|
||||
return m_damagePercentChanged;
|
||||
}
|
||||
|
||||
private:
|
||||
static QString toQString(const std::string &strDds)
|
||||
{
|
||||
return QString::fromStdString(strDds);
|
||||
}
|
||||
|
||||
|
||||
QString m_displayName;
|
||||
double m_fortifyFactor = 0.0;
|
||||
qint32 m_damagePercent = 0;
|
||||
|
||||
bool m_displayNameChanged = false;
|
||||
bool m_fortifyFactorChanged = false;
|
||||
bool m_damagePercentChanged = false;
|
||||
|
||||
bool m_hasSuperior = false;
|
||||
qint32 m_superior = 0;
|
||||
|
||||
bool m_isFloor = false;
|
||||
bool m_isRoom = false;
|
||||
|
||||
int32_t m_structureElementId = 0;
|
||||
|
||||
qint32 m_mountingPointId = 0;
|
||||
QString m_name;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user