273 lines
7.9 KiB
C++
Executable File
273 lines
7.9 KiB
C++
Executable File
/**
|
|
**
|
|
** @RDE_HEADER@
|
|
** plan_editor_internal.h
|
|
** $Id$
|
|
** $HeadURL$
|
|
** $Author$
|
|
**
|
|
** -----------------------------------------------------------------------------------------------
|
|
**
|
|
** Hardware-Environment: Intel-PC
|
|
** Software-Environment: Windows 7, Qt 5.4. ArcGIS 10.2.5
|
|
**
|
|
** Language ........: C++ 11
|
|
**
|
|
** -----------------------------------------------------------------------------------------------
|
|
**
|
|
** Author ...........: Jörg Turla, SPD G, Tel. 3132
|
|
**
|
|
** -----------------------------------------------------------------------------------------------
|
|
**
|
|
** Notes .........:
|
|
**
|
|
** 09.12.2015, JT : First edition for use with Qt5
|
|
**
|
|
** -----------------------------------------------------------------------------------------------
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "plan_editor.h"
|
|
|
|
#include <LtsWidgets/lts_base_layout_widget.h>
|
|
#include <LtsWidgets/lts_drag_icon.h>
|
|
#include <LtsWidgets/lts_tab_widget.h>
|
|
#include <LtsWidgets/lts_tool_bar_area.h>
|
|
|
|
#include <LtsSession/lts_session.h>
|
|
|
|
#include <QtWidgets/QWidget>
|
|
#include <QPointer>
|
|
|
|
|
|
namespace PlanEditor
|
|
{
|
|
|
|
class PlanEditorSession
|
|
{
|
|
QPointer<LtsSession::LtsSession> m_session;
|
|
QWidget *m_topLevelParent;
|
|
QPointer<LtsWidgets::LtsBaseLayoutWidget> m_baseLayoutWidget;
|
|
|
|
public:
|
|
|
|
explicit PlanEditorSession( LtsSession::LtsSession *ltsSession
|
|
, PlanEditor *planEditor)
|
|
: m_session(ltsSession)
|
|
, m_topLevelParent(nullptr)
|
|
, m_baseLayoutWidget(nullptr)
|
|
{
|
|
if (m_session)
|
|
{
|
|
LtsWidgets::LtsBaseLayoutWidget *baseLayout = ltsSession->baseLayout();
|
|
if (baseLayout)
|
|
{
|
|
m_topLevelParent = baseLayout;
|
|
baseLayout->setAppName(QStringLiteral("PlanEditor"));
|
|
|
|
QObject::connect(baseLayout, &LtsWidgets::LtsBaseLayoutWidget::signalNotifyUnsavedChanges, planEditor, &PlanEditor::onAskRejectChanges, Qt::ConnectionType::DirectConnection);
|
|
|
|
QObject::connect(baseLayout, &LtsWidgets::LtsBaseLayoutWidget::signalClose, planEditor, &PlanEditor::onSignalClose, Qt::ConnectionType::DirectConnection);
|
|
|
|
}
|
|
}
|
|
} // PlanEditorSession
|
|
|
|
|
|
explicit PlanEditorSession(LtsWidgets::LtsBaseLayoutWidget *baseLayout, PlanEditor * planEditor )
|
|
: m_topLevelParent(baseLayout)
|
|
, m_baseLayoutWidget(baseLayout)
|
|
{
|
|
if (m_baseLayoutWidget)
|
|
{
|
|
m_baseLayoutWidget->setAppName(QStringLiteral("PlanEditor"));
|
|
|
|
QObject::connect( m_baseLayoutWidget.data(), &LtsWidgets::LtsBaseLayoutWidget::signalNotifyUnsavedChanges, planEditor, &PlanEditor::onAskRejectChanges, Qt::ConnectionType::DirectConnection );
|
|
QObject::connect( m_baseLayoutWidget.data(), &LtsWidgets::LtsBaseLayoutWidget::signalClose , planEditor, &PlanEditor::onQuit );
|
|
QObject::connect( m_baseLayoutWidget.data(), &LtsWidgets::LtsBaseLayoutWidget::signalLogout , planEditor, &PlanEditor::onQuit );
|
|
}
|
|
} // PlanEditorSession
|
|
|
|
PlanEditorSession(const PlanEditorSession &) = default;
|
|
|
|
QWidget *topLevelWidget() const { return m_topLevelParent; }
|
|
|
|
bool isLtsSession() const { return (m_session);}
|
|
QPointer<LtsSession::LtsSession> ltsSession() { return m_session; }
|
|
|
|
|
|
bool isSnapshot() const
|
|
{
|
|
return isPartitionTypeReplay(); // until some correct is available
|
|
} // bool isSnapshot() const
|
|
|
|
|
|
bool isPartitionTypeReplay() const
|
|
{
|
|
return (m_session) ? m_session->partitionType() == IDL::PartitionType::Replay : false;
|
|
} // bool isPartitionTypeReplay() const
|
|
|
|
|
|
LtsWidgets::LtsDragIcon *addMenuAction(const LtsWidgets::PluginData &plData) const
|
|
{
|
|
if (m_session)
|
|
return m_session->addAction(plData,true);
|
|
if (m_baseLayoutWidget)
|
|
return m_baseLayoutWidget->addMenuAction(plData,true);
|
|
return nullptr;
|
|
} // LtsWidgets::LtsDragIcon * addMenuAction(const LtsWidgets::PluginData & plData) const
|
|
|
|
|
|
void removeMenuAction(LtsWidgets::LtsDragIcon *action) const
|
|
{
|
|
if (nullptr == action) return;
|
|
if (m_session)
|
|
{
|
|
m_session->removeMenuAction(action);
|
|
return;
|
|
}
|
|
if (m_baseLayoutWidget)
|
|
{
|
|
m_baseLayoutWidget->removeMenuAction(action);
|
|
return;
|
|
}
|
|
} // void removeMenuAction( LtsWidgets::LtsDragIcon * action )
|
|
|
|
|
|
bool addWidget(LtsWidgets::LtsDialog *widget
|
|
, const QString &menuGroup
|
|
, const QString &identifier
|
|
, LtsWidgets::LayoutArea area = LtsWidgets::LayoutArea::eUnknown
|
|
, bool setClosable = true) const
|
|
{
|
|
if (m_session)
|
|
{
|
|
return m_session->addWidget(widget, menuGroup, identifier, area, setClosable);
|
|
}
|
|
if (m_baseLayoutWidget)
|
|
{
|
|
return m_baseLayoutWidget->addWidget(widget, menuGroup, identifier, area, setClosable);
|
|
}
|
|
return false;
|
|
} // bool addWidget(...)
|
|
|
|
|
|
bool addOrReplaceWidget(LtsWidgets::LtsDialog *widget
|
|
, const QString &menuGroup
|
|
, const QString &identifier
|
|
, LtsWidgets::LayoutArea area = LtsWidgets::LayoutArea::eUnknown
|
|
, bool setClosable = true) const
|
|
{
|
|
if (m_session)
|
|
{
|
|
LtsWidgets::LtsBaseLayoutWidget *baseLayout = m_session->baseLayout();
|
|
if (baseLayout)
|
|
{
|
|
return baseLayout->addOrReplaceWidget(widget, menuGroup, identifier, area, setClosable);
|
|
}
|
|
}
|
|
if (m_baseLayoutWidget)
|
|
{
|
|
return m_baseLayoutWidget->addOrReplaceWidget(widget, menuGroup, identifier, area, setClosable);
|
|
}
|
|
return false;
|
|
} // bool addWidget(...)
|
|
|
|
void hideAnimated() const
|
|
{
|
|
// (m_session) ? m_session -> :
|
|
if (m_baseLayoutWidget)
|
|
m_baseLayoutWidget->onHideAnimated();
|
|
} // void hideAnimated(LtsWidgets::LayoutArea area) const
|
|
|
|
|
|
void focusTab(QWidget *widget, LtsWidgets::LayoutArea area, const QString &menuGroup, const QString &identifier) const
|
|
{
|
|
LtsWidgets::LtsTabWidget *ltsTabWidget = nullptr;
|
|
|
|
if (m_session)
|
|
ltsTabWidget = m_session->locateWidget(widget, area);
|
|
if (m_baseLayoutWidget)
|
|
ltsTabWidget = m_baseLayoutWidget->getTabFromLayoutArea(area);
|
|
if (nullptr == ltsTabWidget)
|
|
return;
|
|
ltsTabWidget->focusTab(menuGroup, identifier);
|
|
|
|
} // void focusTab( QWidget * widget, LtsWidgets::LayoutArea area, const QString & menuGroup, const QString & identifier ) const
|
|
|
|
|
|
void makeCurrentWidget(QWidget *widget, LtsWidgets::LayoutArea area) const
|
|
{
|
|
LtsWidgets::LtsTabWidget *ltsTabWidget = nullptr;
|
|
|
|
if (m_session)
|
|
ltsTabWidget = m_session->locateWidget(widget, area);
|
|
if (m_baseLayoutWidget)
|
|
ltsTabWidget = m_baseLayoutWidget->getTabFromLayoutArea(area);
|
|
if (nullptr == ltsTabWidget)
|
|
return;
|
|
ltsTabWidget -> setCurrentWidget(widget);
|
|
} // void makeCurrentWidget( QWidget * widget, LtsWidgets::LayoutArea area ) const
|
|
|
|
|
|
void setToolBarEnabled(bool on) const
|
|
{
|
|
QWidget *ltsWidget = m_baseLayoutWidget ? m_baseLayoutWidget->getToolbar() : nullptr;
|
|
|
|
if (m_session)
|
|
{
|
|
// ToDo: enable /disable via session
|
|
// ltsWidget =
|
|
}
|
|
if (ltsWidget) ltsWidget->setEnabled(on);
|
|
#ifdef LTS_DEBUG
|
|
else qCritical() << __FUNCTION__ << ": Function not implemented in case of using LtsSession.";
|
|
#endif
|
|
} // void setToolBarEnabled(bool on) const
|
|
|
|
|
|
void setMenuEnabled(bool on) const
|
|
{
|
|
if (m_baseLayoutWidget)
|
|
{
|
|
QWidget *ltsMenu = m_baseLayoutWidget->getMenu();
|
|
if (ltsMenu)
|
|
{
|
|
ltsMenu->setEnabled(on);
|
|
}
|
|
return;
|
|
}
|
|
if (m_session)
|
|
{
|
|
m_session->enableBaseLayoutMenu(on);
|
|
return;
|
|
}
|
|
} // void setMenuEnabled(bool on) const
|
|
|
|
|
|
void setTabLayoutAreaEnabled(LtsWidgets::LayoutArea area, bool on) const
|
|
{
|
|
if (m_baseLayoutWidget)
|
|
{
|
|
QWidget *ltsWidget = m_baseLayoutWidget->getTabFromLayoutArea(area);
|
|
if (ltsWidget)
|
|
{
|
|
ltsWidget->setEnabled(on);
|
|
}
|
|
return;
|
|
}
|
|
if (m_session)
|
|
{
|
|
m_session->enableBaseLayoutArea(area,on);
|
|
return;
|
|
}
|
|
} // void setTabLayoutAreaEnabled(LtsWidgets::LayoutArea area, bool on) const
|
|
|
|
|
|
}; // PlanEditorSession
|
|
|
|
|
|
|
|
} // namespace PlanEditor
|