84 lines
2.6 KiB
C++
Executable File
84 lines
2.6 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* CustomView for Mine Single Virtual
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Hanna E. Rathje, SLSE, 2023-07-14
|
|
*/
|
|
|
|
#include "aes_booby_trap.h"
|
|
#include "ui_aes_booby_trap.h"
|
|
|
|
#include "aes_booby_trap_model.h"
|
|
#include <Services/AreaEffectSimulation/Utils/polygons.h>
|
|
|
|
namespace AreaEffectSimulation
|
|
{
|
|
CustomViewBoobyTrap::CustomViewBoobyTrap(QWidget *parent)
|
|
: AbstractDisplayWidget(parent)
|
|
, m_ui(new Ui::CustomViewBoobyTrap)
|
|
{
|
|
m_ui->setupUi(this);
|
|
}
|
|
|
|
CustomViewBoobyTrap::~CustomViewBoobyTrap()
|
|
{
|
|
delete m_ui;
|
|
}
|
|
|
|
bool CustomViewBoobyTrap::init(const QModelIndex &idx)
|
|
{
|
|
if (!idx.isValid())
|
|
return false;
|
|
|
|
m_ui->lbName->setText(rowData(idx, AreaEffectSimulation::BoobyTrapModel::BcName).toString());
|
|
m_ui->lbType->setText(rowData(idx, AreaEffectSimulation::BoobyTrapModel::BcChargeType).toString());
|
|
m_ui->lbState->setText(rowData(idx, AreaEffectSimulation::BoobyTrapModel::BcEffectState).toString());
|
|
m_ui->lbTime->setText(rowData(idx, AreaEffectSimulation::BoobyTrapModel::BcEffectStart).toString());
|
|
m_ui->lblIcon->clear();
|
|
m_ui->lblIcon->setAutoFillBackground(true);
|
|
|
|
const AesItemSortFilterProxyModel *sfpm = qobject_cast<const AesItemSortFilterProxyModel*>(idx.model());
|
|
if (!sfpm)
|
|
return false;
|
|
const BoobyTrapModel *aesModel = qobject_cast<const BoobyTrapModel*>(sfpm->sourceModel());
|
|
if (!aesModel)
|
|
return false;
|
|
const auto srcIdx = sfpm->mapToSource(idx);
|
|
BoobyTrap bcContamin = aesModel->getRowData(srcIdx.row());
|
|
calculateIcon(bcContamin, sfpm->partyColor(idx.row()));
|
|
|
|
qint64 durationMSecs = rowData(idx, AreaEffectSimulation::BoobyTrapModel::BcEffectDuration).toInt();
|
|
if (durationMSecs > 0)
|
|
{
|
|
QString duration;
|
|
if (durationMSecs % 1000 == 0 || durationMSecs > 60 * 1000)
|
|
duration = QString::number(durationMSecs / 1000.0, 'f', 0);
|
|
else
|
|
duration = QString::number(durationMSecs / 1000.0, 'f', 3);
|
|
|
|
m_ui->lbDuration->setText(duration);
|
|
}
|
|
else
|
|
{
|
|
m_ui->label_4->hide();
|
|
m_ui->lbDuration->hide();
|
|
m_ui->label_6->hide();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool CustomViewBoobyTrap::calculateIcon(const BoobyTrap &bt, const QColor &color)
|
|
{
|
|
QPointF impactPosition = QPointF(bt.impactPosition().lon(), bt.impactPosition().lat());
|
|
const QPolygonF poly = Polygons::circle(impactPosition, bt.triggerRadius());
|
|
|
|
Qt::BrushStyle bStyle = PixmapLabel::checkForBrushStyle(bt.effectStateId());
|
|
const auto pix = Polygons::pixmapFromPolygon(PixmapLabel::geographic2Utm(poly), color, ICON_RESOLUTION, bStyle);
|
|
m_ui->lblIcon->setPixmap(pix);
|
|
|
|
return true;
|
|
}
|
|
} // namespace AreaEffectSimulation
|