/** * @RDE_HEADER@ * GUI Plugin for ParticipantManagement - ParticipantTemplate * $Id$ * $HeadURL$ * $Author$ * Created by Patric Karwat, SLSE, 2016-10-05 */ #include "participant_templates_gui_plugin.h" #include "participant_template_chooser.h" #include "participant_template_chooser_model.h" #include "participant_template_edit.h" #include #include #include #include #include namespace ParticipantManagement { std::shared_ptr GuiPlugin::createGuiInterface(LtsSession::LtsSession *session) { return std::make_shared(session); } InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session) : GuiPluginBase::Interface(session, getLogger("Plugins.Gui.Ppm.ParticipantTemplates")) , m_dtc(nullptr) , m_ftc(nullptr) , m_ppmGuiCbxIfc(nullptr) , m_ppmGuiOrgChartIfc(nullptr) {} QVector InterfaceImpl::getActions() { QVector ret; //no dialoges in exercise if(m_session->partitionType() == IDL::PartitionType::Exercise) return ret; LtsWidgets::PluginData pd; pd.menuGroup = menuGroup(); pd.layoutArea = LtsWidgets::LayoutArea::eDialogTab; pd.menuText = tr("Participant Templates"); pd.identifier = QStringLiteral("viewTemplates"); pd.menuIcon = QIcon(QLatin1String("icon:define_force_templates.svg")); pd.createWidgetFunc = [this](QWidget *parent) { return onShowTemplateChooser(parent, false); }; pd.operatorRight = OperatorRights::ParticipantTemplates::ParticipantTemplatesShow; pd.exercisePart = LtsWidgets::ExercisePart::ePlanning; ret.append(pd); pd.menuText = tr("Support Templates"); pd.identifier = QStringLiteral("viewSupTemplates"); pd.menuIcon = QIcon(QLatin1String("icon:define_force_templates.svg")); pd.createWidgetFunc = [this](QWidget *parent) { return onShowTemplateChooser(parent, true); }; pd.operatorRight = OperatorRights::ParticipantTemplates::SupportParticipantTemplatesShow; pd.exercisePart = LtsWidgets::ExercisePart::ePlanning; ret.append(pd); return ret; } QString InterfaceImpl::menuGroup() const { return tr("Participants"); } bool InterfaceImpl::getTemplateModel(QTreeView *treeView, bool asSupportService) { ParticipantTemplateChooserModel *model = new ParticipantTemplateChooserModel(asSupportService, treeView); if (model->initModel(m_session, m_dtc)) { treeView->setModel(model); return true; } return false; } bool InterfaceImpl::fetchInterfaces() { if (!m_session->getDtc(m_dtc)) return false; if (!m_session->getFtc(m_ftc)) return false; if (!m_session->getForeignGuiInterface(m_ppmGuiCbxIfc)) return false; //optional m_session->getForeignGuiInterface(m_ppmGuiOrgChartIfc); return true; } void InterfaceImpl::clearInterfaces() { m_dtc = nullptr; m_ftc = nullptr; m_ppmGuiCbxIfc = nullptr; m_ppmGuiOrgChartIfc = nullptr; } LtsWidgets::LtsDialog *InterfaceImpl::onShowTemplateChooser(QWidget *parent, bool asSupportService) { return LtsWidgets::initDialog(new ParticipantTemplateChooser(menuGroup(), asSupportService, m_session, parent), m_dtc, m_ftc, m_ppmGuiCbxIfc, m_ppmGuiOrgChartIfc); } } // namespace ParticipantManagement