Adds initial intermediate qt6 porting state
This commit is contained in:
11247 files changed
+1891537
No files matched your search
+112
@@ -0,0 +1,112 @@
|
||||
|
||||
|
||||
|
||||
#include "tgt_shootback_target_model.h"
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
namespace TargetMa nagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
ShootbackTargetModel::ShootbackTargetModel(QObject *parent)
|
||||
: BaseClass({tr("Id"),
|
||||
tr("TargetId"),
|
||||
tr("Name"),
|
||||
tr("TargetParticipantId"),
|
||||
tr("Position"),
|
||||
tr("ActivateLaserDesignation"),
|
||||
tr("ActivateLights"),
|
||||
tr("ActivatePopupAutomatic"),
|
||||
tr("HitsToKill"),
|
||||
tr("PermanentInstalledTarget"),
|
||||
tr("VisibleParticipants"),
|
||||
tr("Is Used")},
|
||||
parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_logger(getLogger("ShootbackTargetModel"))
|
||||
{}
|
||||
|
||||
bool ShootbackTargetModel::initModel(const std::shared_ptr<TargetManagement::Interface::Dtc> &dtc)
|
||||
{
|
||||
if (!dtc)
|
||||
return false;
|
||||
|
||||
m_dtc = dtc;
|
||||
|
||||
connect(m_dtc.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged,
|
||||
this, &ShootbackTargetModel::onDataChanged);
|
||||
|
||||
connect(m_dtc.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged, [](const TargetManagement::ShootbackTarget &data, DataModification modType) {
|
||||
ShootbackTargetModel::onDataChanged(data, modType);
|
||||
});
|
||||
|
||||
|
||||
m_dtc->shootbackTargets([this](const TargetManagement::ShootbackTarget & shootbackTarget)
|
||||
{
|
||||
insertRow(shootbackTarget);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
QString toStringLocal(const std::vector< int32_t > &ids)
|
||||
{
|
||||
QString ret;
|
||||
for (auto id : ids)
|
||||
ret.append(QString::number(id));
|
||||
return ret;
|
||||
}
|
||||
|
||||
QVariant ShootbackTargetModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const TargetManagement::ShootbackTarget &shootbackTarget = m_vecData.at(index.row());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return shootbackTarget.id();
|
||||
case TargetDataId:
|
||||
return shootbackTarget.targetDataId();
|
||||
case Name:
|
||||
return QString::fromStdString(shootbackTarget.name());
|
||||
case TargetParticipantId:
|
||||
return shootbackTarget.targetParticipantId();
|
||||
case Position:
|
||||
{
|
||||
const Core::GeoPosition2D &pos = shootbackTarget.position();
|
||||
return LtsCoordTrans::mgrsFromGeographic(pos.lon(), pos.lat());
|
||||
}
|
||||
case ActivateLaserDesignation:
|
||||
return shootbackTarget.activateLaserDesignation() ? tr("Yes") : tr("No");
|
||||
case ActivateLights:
|
||||
return shootbackTarget.activateLights() ? tr("Yes") : tr("No");
|
||||
case ActivatePopupAutomatic:
|
||||
return shootbackTarget.activatePopupAutomatic() ? tr("Yes") : tr("No");
|
||||
case HitsToKill:
|
||||
return shootbackTarget.hitsToKill();
|
||||
case PermanentInstalledTarget:
|
||||
return shootbackTarget.permanentInstalledTarget() ? tr("Yes") : tr("No");
|
||||
case VisibleParticipants:
|
||||
return TargetManagement::toStringLocal(shootbackTarget.visibleParticipants());
|
||||
case IsUsedBy:
|
||||
return shootbackTarget.isUsed() ? tr("Yes") : tr("No");
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Services/TargetManagement/tgt_dtc.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <TargetManagement/logger.h>
|
||||
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
class ShootbackTargetModel final : public LtsWidgets::LtsAbstractTableModel<TargetManagement::ShootbackTarget>
|
||||
{
|
||||
using BaseClass = LtsWidgets::LtsAbstractTableModel<TargetManagement::ShootbackTarget>;
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
TargetDataId,
|
||||
Name,
|
||||
|
||||
|
||||
TargetParticipantId,
|
||||
|
||||
Position,
|
||||
ActivateLaserDesignation,
|
||||
ActivateLights,
|
||||
ActivatePopupAutomatic,
|
||||
HitsToKill,
|
||||
PermanentInstalledTarget,
|
||||
VisibleParticipants,
|
||||
IsUsedBy
|
||||
};
|
||||
|
||||
explicit ShootbackTargetModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(const std::shared_ptr<TargetManagement::Interface::Dtc> &dtc);
|
||||
|
||||
QVariant data(const QModelIndex &, int) const override;
|
||||
|
||||
protected:
|
||||
bool isFiltered(const ShootbackTarget &data, DataModification modType) const override
|
||||
{
|
||||
return BaseClass::isFiltered(data, modType);
|
||||
}
|
||||
private:
|
||||
std::shared_ptr<TargetManagement::Interface::Dtc> m_dtc;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
}
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
|
||||
|
||||
|
||||
#include "tgt_shootback_target_view.h"
|
||||
#include "ui_tgt_shootback_target_view.h"
|
||||
|
||||
#include "tgt_shootback_target_edit.h"
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
|
||||
ShootbackTargetView::ShootbackTargetView(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::ShootbackTargetView)
|
||||
, m_logger(getLogger("ShootbackTargetView"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &ShootbackTargetView::enaDisa);
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &ShootbackTargetView::onEditShootbackTarget);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalEnterPressed, this, &ShootbackTargetView::onEditShootbackTarget);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ShootbackTargetView::onEditShootbackTarget);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ShootbackTargetView::onPrint);
|
||||
|
||||
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Load, tr("Synchronize Parties"));
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Administrator-ShootbackTargets"));
|
||||
}
|
||||
|
||||
ShootbackTargetView::~ShootbackTargetView()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ShootbackTargetView::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("ShootbackTargets"));
|
||||
}
|
||||
|
||||
bool ShootbackTargetView::init(const std::shared_ptr<TargetManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<TargetManagement::Interface::Ftc> &ftc)
|
||||
{
|
||||
if (!dtc || !ftc)
|
||||
return false;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_model = new ShootbackTargetModel(this);
|
||||
m_model->initModel(m_dtc);
|
||||
m_ui->widget->setModel(m_model);
|
||||
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->hideColumn(ShootbackTargetModel::Id);
|
||||
#endif
|
||||
|
||||
m_ui->widget->setSortingEnabled(false);
|
||||
|
||||
connect(m_model, &ShootbackTargetModel::rowsInserted, this, &ShootbackTargetView::enaDisa);
|
||||
connect(m_model, &ShootbackTargetModel::rowsRemoved, this, &ShootbackTargetView::enaDisa);
|
||||
|
||||
enaDisa();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ShootbackTargetView::enaDisa()
|
||||
{
|
||||
|
||||
|
||||
bool bAddVisible = false;
|
||||
bool bEditEnabled = false;
|
||||
bool bRemoveEnabled = false;
|
||||
bool bRemoveVisible = false;
|
||||
bool bLoadEnabled = true;
|
||||
bool bLoadVisible = (m_session->exerciseId() > 0);
|
||||
|
||||
|
||||
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Add, bAddVisible);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, bEditEnabled);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, bRemoveEnabled);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Remove, bRemoveVisible);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, bLoadEnabled);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, bLoadVisible);
|
||||
}
|
||||
|
||||
void ShootbackTargetView::onEditShootbackTarget()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
const TargetManagement::ShootbackTarget &target = m_model->getRowData(row);
|
||||
ShootbackTargetEdit *dialog = new ShootbackTargetEdit(this);
|
||||
dialog->init(m_dtc, m_ftc, nullptr, target);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("tgtShootbackTarget") + QString::number(target.id()), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void ShootbackTargetView::onAddParty()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ShootbackTargetView::onRemoveParty()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ShootbackTargetView::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
}
|
||||
|
||||
void ShootbackTargetView::onSyncParties()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "tgt_shootback_target_model.h"
|
||||
#include <TargetManagement/logger.h>
|
||||
#include <Services/TargetManagement/tgt_dtc.h>
|
||||
#include <Services/TargetManagement/tgt_ftc.h>
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ShootbackTargetView;
|
||||
}
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
|
||||
class ShootbackTargetView : public LtsWidgets::LtsDialog
|
||||
|
||||
|
||||
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ShootbackTargetView(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~ShootbackTargetView();
|
||||
bool init(const std::shared_ptr<TargetManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<TargetManagement::Interface::Ftc> &ftc);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
|
||||
|
||||
|
||||
void enaDisa();
|
||||
void onEditShootbackTarget();
|
||||
void onAddParty();
|
||||
void onRemoveParty();
|
||||
void onPrint();
|
||||
void onSyncParties();
|
||||
|
||||
private:
|
||||
QString m_menuGroup;
|
||||
ShootbackTargetModel *m_model{nullptr};
|
||||
std::shared_ptr<TargetManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<TargetManagement::Interface::Ftc> m_ftc;
|
||||
LtsUtils::RequestHelper *m_requestHelper{nullptr};
|
||||
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
Ui::ShootbackTargetView *m_ui{nullptr};
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ShootbackTargetView</class>
|
||||
<widget class="QWidget" name="ShootbackTargetView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>455</width>
|
||||
<height>341</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>250</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in new issue
Block a user