Adds initial intermediate qt6 porting state

This commit is contained in:
torsten committed 2026-08-17 17:54:56 +02:00
1 parent 99136e9460
commit d176b5e0d7
11247 files changed
+1891537

No files matched your search

@@ -0,0 +1,171 @@
#include "topic_editor.h"
#include "ui_topic_editor.h"
#include "../plan_overlays_gui_plugin.h"
#include <LtsSession/lts_session_data.h>
#include <NGLLogger/NGLLoggerBootstrap.h>
#include <TopicEditorBase/topic_previewer.h>
#include <QInputDialog>
#include <QJsonObject>
#include <QJsonArray>
#include <QMessageBox>
#include <QPushButton>
namespace PlanOverlaysPlugin
{
PlanTopicEditor::PlanTopicEditor(
ForeignGuiInterface **ifc, const std::shared_ptr<FileManagement::Interface::Dtc> &flmDtc, QWidget *parent
)
: TopicEditorBase::TopicEditor(parent)
, m_ifc(ifc)
, m_flmDtc(flmDtc)
, m_model(nullptr)
, m_ui(new Ui::PlanTopicEditor)
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("PlanTopicEditor"))
{
m_ui->setupUi(this);
init(m_ui->widget);
m_buttonBox->setText(LtsWidgets::DialogButton::Edit, tr("Manage Plan Overlays"));
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &PlanTopicEditor::onOpenPlanOverlayDialog);
if ((*m_ifc) == nullptr)
{
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
return;
}
else
m_ui->lblReadOnly->hide();
m_model = (*m_ifc)->planOverlayModel();
#ifndef LTS_DEBUG
if (LtsSessionData::LtsSessionData::getInstance()->debugFlagValue(QStringLiteral("PlanOverlays.TopicEditor.ShowFakeButton")) == QVariant(true))
#endif
{
QPushButton *pb = new QPushButton(QStringLiteral("[fake compatibility mode data]"));
layout()->addWidget(pb);
connect(pb, &QPushButton::clicked,
this, [this]()
{
m_topicData.properties = QJsonObject();
bool k = true;
int fileId = QInputDialog::getInt(this, QStringLiteral("fileId"), QStringLiteral("Enter the file id of an existing plan overlay"), 1003, 0, 999999, 1, &k);
if (!k)
{
QMessageBox::critical(this, QStringLiteral("nan"), QStringLiteral("nan!"));
return;
}
m_topicData.properties[QStringLiteral("FileId")] = fileId;
updateInternalData();
});
}
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_Tactical_Plan_Topic"));
}
PlanTopicEditor::~PlanTopicEditor()
{
delete m_ui;
}
void PlanTopicEditor::updateInternalData()
{
if (!hasTopicDataProperties())
return;
m_planItems = QJsonArray();
int fileId = getTopicDataValue(QStringLiteral("FileId")).toInt(-1);
if (fileId != -1)
{
DEBUG_LOG(m_logger) << "topic compatibility mode - converting..";
QJsonObject fakePlanItem;
fakePlanItem[QStringLiteral("keyId")] = 0;
fakePlanItem[QStringLiteral("fileId")] = fileId;
QString fileName;
if (m_flmDtc)
fileName = QString::fromStdString(m_flmDtc->fileContent(fileId).name());
if (fileName.isEmpty())
fileName = tr("Plan file id %1").arg(fileId);
fakePlanItem[QStringLiteral("fileName")] = fileName;
fakePlanItem[QStringLiteral("opacity")] = 1.0;
m_planItems += fakePlanItem;
}
else
m_planItems = getTopicDataValue(QStringLiteral("PlanItems")).toArray();
if (m_planItems.isEmpty())
{
WARNING_LOG(m_logger) << "topic empty";
return;
}
retable();
}
void PlanTopicEditor::retranslate()
{
translate(m_ui, tr("Plan Topic Editor"));
}
void PlanTopicEditor::retable()
{
while (m_ui->plans->rowCount())
m_ui->plans->removeRow(m_ui->plans->rowCount() - 1);
for (auto i = m_planItems.constBegin(); i != m_planItems.constEnd(); ++i)
{
m_ui->plans->insertRow(0);
m_ui->plans->setItem(0, 0, new QTableWidgetItem((*i).toObject()[QStringLiteral("fileName")].toString(tr("(unknown)"))));
}
}
bool PlanTopicEditor::apply2()
{
m_topicData.properties.remove(QStringLiteral("FileId"));
setTopicDataProperty(QStringLiteral("PlanItems"), m_planItems);
setDescription(m_ui->widget->description());
m_ui->widget->previewer()->setTopicData(m_topicData);
return true;
}
void PlanTopicEditor::onOpenPlanOverlayDialog()
{
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
if ((*m_ifc) == nullptr)
{
new LtsWidgets::LtsMessageDialogNew(this, tr("Plans can't be edited because essentials view was closed"));
return;
}
connect((*m_ifc)->openPlanOverlayDialog(m_planItems, true), &QWidget::destroyed, this, [this]()
{
m_planItems = m_model->toJson();
retable();
slotChangesMade();
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit);
});
}
}
@@ -0,0 +1,60 @@
#pragma once
#include <FileManagement/logger.h>
#include <FileManagement/Data/flm_data_plugin.h>
#include <LtsSession/lts_session.h>
#include <TopicEditorBase/topic_editor_base.h>
#include <QJsonArray>
namespace Ui { class PlanTopicEditor; }
namespace PlanOverlaysPlugin
{
class ForeignGuiInterface;
class PlanOverlayModel;
class PlanTopicEditor : public TopicEditorBase::TopicEditor
{
Q_OBJECT
public:
explicit PlanTopicEditor(
ForeignGuiInterface **ifc, const std::shared_ptr<FileManagement::Interface::Dtc> &flmDtc, QWidget *parent = nullptr
);
~PlanTopicEditor();
private:
void updateInternalData() override final;
void retranslate() override final;
void retable();
void enaDisa();
private slots:
bool apply2() override final;
void onOpenPlanOverlayDialog();
private:
ForeignGuiInterface **m_ifc { nullptr };
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc { nullptr };
QJsonArray m_planItems;
PlanOverlayModel *m_model { nullptr };
Ui::PlanTopicEditor *m_ui { nullptr };
NGL::INGLLogger &m_logger;
};
}
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PlanTopicEditor</class>
<widget class="QWidget" name="PlanTopicEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>623</width>
<height>357</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">File Topic Editor</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0">
<widget class="TopicEditorBase::TopicPreviewWidget" name="widget" native="true"/>
</item>
<item row="3" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="2">
<widget class="QTableWidget" name="plans">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Plan name</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Selected Plans:</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="lblReadOnly">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#d69545;&quot;&gt;Start the essentials view before opening this topic editor to be able to edit plans.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>TopicEditorBase::TopicPreviewWidget</class>
<extends>QWidget</extends>
<header>TopicEditorBase/topic_preview_widget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>