236 lines
7.9 KiB
C++
Executable File
236 lines
7.9 KiB
C++
Executable File
/**
|
||
**
|
||
** @RDE_HEADER@
|
||
** plan_overlay_dialog.h
|
||
** $Id$
|
||
** $HeadURL$
|
||
** $Author$
|
||
**
|
||
** -----------------------------------------------------------------------------------------------
|
||
**
|
||
** Hardware-Environment: Intel-PC
|
||
** Software-Environment: Windows 7, Qt 5.7. ArcGIS 100
|
||
**
|
||
** Language ........: C++ 11
|
||
**
|
||
** -----------------------------------------------------------------------------------------------
|
||
**
|
||
** Author ...........: Jörg Turla, SPD G, Tel. 3132
|
||
**
|
||
** -----------------------------------------------------------------------------------------------
|
||
**
|
||
** Notes .........:
|
||
**
|
||
** 14.07.2017, JT : First edition for use with Qt5
|
||
**
|
||
** -----------------------------------------------------------------------------------------------
|
||
*/
|
||
|
||
#pragma once
|
||
|
||
#include <LtsSession/lts_session.h>
|
||
|
||
#include <LtsWidgets/lts_dialog.h>
|
||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||
|
||
#include <Services/FileManagement/flm_dtc.h>
|
||
#include <Services/OperatorManagement/opm_dtc.h>
|
||
#include <Services/ExerciseManagement/exm_dtc.h>
|
||
|
||
#include <QtWidgets/QVBoxLayout>
|
||
#include <QtWidgets/QApplication>
|
||
#include <QtWidgets/QDesktopWidget>
|
||
#include <QtWidgets/QDialog>
|
||
#include <QtWidgets/QPushButton>
|
||
|
||
|
||
namespace SituationMap
|
||
{
|
||
class ForeignGuiInterface;
|
||
}
|
||
|
||
|
||
namespace PlanOverlaysPlugin
|
||
{
|
||
class PlanOverlayModel;
|
||
|
||
//
|
||
// class PlanOverlayDialogWidget
|
||
//
|
||
class PlanOverlayDialogWidget : public QWidget
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
|
||
explicit PlanOverlayDialogWidget(LtsSession::LtsSession *session, SituationMap::ForeignGuiInterface *situationMapGui, PlanOverlayModel *planOverlayModel, QWidget *parent);
|
||
virtual ~PlanOverlayDialogWidget();
|
||
|
||
bool initFileManagement(const std::shared_ptr<FileManagement::Interface::Dtc> &dtc
|
||
, const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc
|
||
, const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc
|
||
, const std::function<void(int selectedFileId)> &doRead
|
||
, const std::function<void(int planId)> &doReload
|
||
, const std::function<void(int planId)> &doUnload
|
||
, bool isOc = false);
|
||
|
||
PlanOverlayModel *planOverlayModel() const;
|
||
|
||
bool isInModalDialog() const;
|
||
void setIsInModalDialog(bool on = true);
|
||
|
||
|
||
private slots:
|
||
|
||
void onLoadPlan();
|
||
|
||
void onRequestMinScaleFromUser(int planId, const QString &planName);
|
||
void onRequestMaxScaleFromUser(int planId, const QString &planName);
|
||
|
||
void onEnableOverlaySection(bool on);
|
||
|
||
signals:
|
||
|
||
void requestDialogShow();
|
||
|
||
private:
|
||
|
||
struct InternalData;
|
||
|
||
InternalData *m_internal;
|
||
|
||
}; // PlanOverlayDialogWidget
|
||
|
||
|
||
//
|
||
// Dialog
|
||
//
|
||
|
||
class Dialog : public LtsWidgets::LtsDialog
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
|
||
explicit Dialog(QWidget *parent, LtsWidgets::ButtonCombination buttonCombination = LtsWidgets::ButtonCombination::CloseOnly, bool closeable = true)
|
||
: LtsWidgets::LtsDialog(parent, buttonCombination, closeable)
|
||
{
|
||
setUnchangeable();
|
||
} // Dialog
|
||
|
||
virtual ~Dialog() = default;
|
||
|
||
void retranslate() {;}
|
||
|
||
}; // Dialog
|
||
|
||
|
||
template<class DialogClass> void createPlanOverlayDialog(DialogClass *&dlgPtr, QWidget *parent);
|
||
|
||
template<> inline void createPlanOverlayDialog<QDialog>(QDialog *&dlgPtr, QWidget *parent)
|
||
{
|
||
dlgPtr = new QDialog(parent);
|
||
dlgPtr -> setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowStaysOnTopHint | Qt::Dialog);
|
||
dlgPtr -> setWindowTitle(QObject::tr("Plan Overlays"));
|
||
} // template<> void createPlanOverlayDialog<QDialog>( QDialog *& dlgPtr, QWidget * parent )
|
||
|
||
|
||
template<> inline void createPlanOverlayDialog<LtsWidgets::LtsFramelessDialog>(LtsWidgets::LtsFramelessDialog *&dlgPtr, QWidget *parent)
|
||
{
|
||
dlgPtr = new LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal);
|
||
} // template<> void createPlanOverlayDialog<LtsWidgets::LtsFramelessDialog>( LtsWidgets::LtsFramelessDialog *&dlgPtr, QWidget * parent )
|
||
|
||
|
||
//
|
||
// PlanOverlayDialog
|
||
//
|
||
template<class DialogClass> class PlanOverlayDialog
|
||
{
|
||
DialogClass *m_dialog;
|
||
PlanOverlayDialogWidget *m_dialogWidget;
|
||
LtsSession::LtsSession *m_session;
|
||
|
||
public:
|
||
|
||
// explicit PlanOverlayDialog(LtsSession::LtsSession *session, SituationMap::ForeignGuiInterface *situationMapGui, PlanOverlayModel *planOverlayModel, QWidget *parent)
|
||
// : m_dialog(nullptr), m_dialogWidget(nullptr), m_session(session)
|
||
// {
|
||
// static_assert(std::is_same<DialogClass, LtsWidgets::LtsDialog>::value, "This ctor of template class PlanOverlayDialog can only be used with LtsWidgets::LtsDialog");
|
||
|
||
// Dialog *dlg = new Dialog(parent);
|
||
// PlanOverlayDialogWidget *m_dialogWidget = new PlanOverlayDialogWidget(session, situationMapGui, planOverlayModel, dlg);
|
||
|
||
// //QObject::connect(situationMapGui->map(), &QObject::destroyed, m_dialogWidget, &QObject::deleteLater);
|
||
|
||
// session->addWidget(dlg, m_dialogWidget->windowTitle(), QLatin1String("PlanOverlayDialog"), LtsWidgets::LayoutArea::eDialogTab, false);
|
||
|
||
// m_dialog = dlg;
|
||
|
||
// QObject::connect(m_dialogWidget, &PlanOverlayDialogWidget::requestDialogShow, m_dialog, &DialogClass::show);
|
||
|
||
// m_dialogWidget->setIsInModalDialog(false);
|
||
|
||
// m_dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
||
|
||
// } // PlanOverlayDialog( LtsSession::LtsSession * session, SituationMap::ForeignGuiInterface * situationMapGui, PlanOverlayModel * planOverlayModel, QWidget * parent)
|
||
|
||
|
||
explicit PlanOverlayDialog(SituationMap::ForeignGuiInterface *situationMapGui, PlanOverlayModel *planOverlayModel, QWidget *parent, LtsSession::LtsSession *session)
|
||
: m_dialog(nullptr), m_dialogWidget(nullptr), m_session(session)
|
||
{
|
||
static_assert(std::is_same<DialogClass, LtsWidgets::LtsFramelessDialog>::value || std::is_same<DialogClass, QDialog>::value
|
||
, "This ctor of template class PlanOverlayDialog can only be used with QDialog and LtsWidgets::LtsFramelessDialog");
|
||
|
||
createPlanOverlayDialog(m_dialog, parent);
|
||
|
||
m_dialogWidget = new PlanOverlayDialogWidget(m_session, situationMapGui, planOverlayModel, m_dialog);
|
||
|
||
//QObject::connect(situationMapGui->map(), &QObject::destroyed, m_dialogWidget, &QObject::deleteLater);
|
||
|
||
QVBoxLayout *layout = new QVBoxLayout(m_dialog);
|
||
LtsWidgets::LtsDialogButtonBox *buttonBox = new LtsWidgets::LtsDialogButtonBox(parent);
|
||
|
||
QPushButton *btn = buttonBox->getButton(LtsWidgets::DialogButton::Help);
|
||
if (btn && m_session)
|
||
{
|
||
QObject::connect(btn, &QPushButton::clicked, m_dialog, [this]() // 'this' can´t be used as 3rd para. So use m_dialog instead
|
||
{
|
||
if (m_session)
|
||
m_session->slotShowOnlineHelp(QStringLiteral("Situation-Plan_Overlays"));
|
||
});
|
||
|
||
btn->setVisible(true);
|
||
}
|
||
|
||
layout->addWidget(m_dialogWidget, 2);
|
||
layout->addWidget(buttonBox);
|
||
|
||
buttonBox->setButtonVisible(LtsWidgets::DialogButton::Apply, false);
|
||
buttonBox->setButtonVisible(LtsWidgets::DialogButton::Ok, false);
|
||
|
||
QObject::connect(buttonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, m_dialog, &DialogClass::close);
|
||
|
||
m_dialog->setMinimumHeight(int(QApplication::desktop()->availableGeometry(m_dialogWidget).height() * 0.9));
|
||
|
||
QObject::connect(m_dialogWidget, &PlanOverlayDialogWidget::requestDialogShow, m_dialog, &DialogClass::show);
|
||
|
||
|
||
m_dialogWidget->setIsInModalDialog(std::is_same<DialogClass, LtsWidgets::LtsFramelessDialog>::value);
|
||
|
||
m_dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
||
} // PlanOverlayDialog( SituationMap::ForeignGuiInterface * situationMapGui, PlanOverlayModel * planOverlayModel, QWidget * parent )
|
||
|
||
|
||
virtual ~PlanOverlayDialog() = default;
|
||
PlanOverlayDialog(const PlanOverlayDialog &) = delete;
|
||
PlanOverlayDialog &operator = (const PlanOverlayDialog &) = delete;
|
||
|
||
PlanOverlayDialogWidget *dialogWidget() const { return m_dialogWidget; }
|
||
void show() { if (m_dialog) m_dialog->show(); }
|
||
|
||
}; // PlanOverlayDialog
|
||
|
||
|
||
|
||
} // namespace PlanOverlaysPlugin
|