Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+178
@@ -0,0 +1,178 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Topic Editor for the Plan Topic in the Script Editor
|
||||
* $Id: topic_editor.cpp 48499 2019-09-26 07:56:34Z ojog_i $
|
||||
* $HeadURL: svn://slssvn/TDS/branches/product/devel/trunk/Lts/Plugins/FileManagement/Gui/Explorer/TopicEditor/topic_editor.cpp $
|
||||
* $Author: ojog_i $
|
||||
*
|
||||
* Created by Mike Wille, NLE, 2019-11-11
|
||||
*/
|
||||
|
||||
#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"))
|
||||
{
|
||||
// init UI
|
||||
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]()
|
||||
{
|
||||
// fake data to test compatibility mode:
|
||||
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;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// PRIVATE
|
||||
|
||||
void PlanTopicEditor::updateInternalData()
|
||||
{
|
||||
if (!hasTopicDataProperties())
|
||||
return;
|
||||
|
||||
m_planItems = QJsonArray(); // reset
|
||||
|
||||
// compatibility for old plan type topics (old topic only had ONE plan and was determined by only its 'FileId')
|
||||
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; // otherwise opacity is 0 and the user can't see it
|
||||
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)"))));
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// PRIVATE SLOTS
|
||||
|
||||
bool PlanTopicEditor::apply2()
|
||||
{
|
||||
m_topicData.properties.remove(QStringLiteral("FileId")); // remove old plan file id (if available)
|
||||
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); // disable until already opened plan overlay dialog was closed or fully disable because essentials view was closed
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace PlanOverlaysPlugin
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Topic Editor for the Situation Topic in the Script Editor
|
||||
* $Id: topic_editor.h 47904 2019-08-09 09:11:38Z ehrlicher $
|
||||
* $HeadURL: svn://slssvn/TDS/branches/product/devel/trunk/Lts/Plugins/FileManagement/Gui/Explorer/TopicEditor/topic_editor.h $
|
||||
* $Author: ehrlicher $
|
||||
*
|
||||
* Created by Mike Wille, NLE, 2019-11-11
|
||||
*/
|
||||
|
||||
#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();
|
||||
|
||||
// void updatePreview();
|
||||
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
} // namespace PlanOverlaysPlugin
|
||||
@@ -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><html><head/><body><p><span style=" color:#d69545;">Start the essentials view before opening this topic editor to be able to edit plans.</span></p></body></html></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>
|
||||
Reference in new issue
Block a user