Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,44 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# Created by Mike Wille, SLSE, 2016-03-15
|
||||
#
|
||||
|
||||
SET(pre_edit_gui_SRCS
|
||||
pre_edit_gui_plugin.cpp
|
||||
pre_edit_gui_plugin.h
|
||||
pre_dialog.h
|
||||
pre_dialog.cpp
|
||||
pre_mobile_dialog.h
|
||||
pre_mobile_dialog.cpp
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(pre_edit_gui_SRCS
|
||||
pre_dialog.ui
|
||||
pre_mobile_dialog.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS PreEditGuiPlugin MODULE ${pre_edit_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(PreEditGuiPlugin
|
||||
NGLLogger
|
||||
LtsSession
|
||||
svcAvmCommon
|
||||
svcAsmCommon
|
||||
PreDataPluginInterface
|
||||
PrePresentationGuiPluginInterface
|
||||
PreGuiCommon
|
||||
svcPreCommon
|
||||
Qt5::Widgets
|
||||
Qt5::Network
|
||||
LtsWidgets
|
||||
LtsDataView
|
||||
LtsUtilsGuiDds
|
||||
ProjectConfig
|
||||
dbAdminCopyExercise
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(PreEditGuiPlugin)
|
||||
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* PresentationManagement - Script Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-15
|
||||
*/
|
||||
|
||||
#include "pre_dialog.h"
|
||||
#include "ui_pre_dialog.h"
|
||||
|
||||
#include <Plugins/PresentationManagement/Gui/Common/pre_edit_dialog.h>
|
||||
#include <Plugins/PresentationManagement/Gui/Common/pre_model.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
PresentationManagementDialog::PresentationManagementDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_model(new PresentationManagementDialogModel(this))
|
||||
, m_ui(new Ui::PresentationManagementDialog)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(getLogger("PresentationManagementDialog"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "PresentationManagementDialog ctor";
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
PresentationManagementDialog::~PresentationManagementDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void PresentationManagementDialog::retranslate()
|
||||
{
|
||||
switch (m_modeDialog)
|
||||
{
|
||||
case ScriptsDialogMode::modeAdmin:
|
||||
translate(m_ui, tr("Admin Scripts"));
|
||||
break;
|
||||
case ScriptsDialogMode::modeEdit:
|
||||
translate(m_ui, tr("Edit Scripts"));
|
||||
break;
|
||||
case ScriptsDialogMode::modeView:
|
||||
translate(m_ui, tr("View Scripts"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PresentationManagementDialog::enaDisa()
|
||||
{
|
||||
int selected = m_ui->widget->selectedRows().size();
|
||||
Presentation pre = m_model->getRowData(m_ui->widget->currentIndex().row());
|
||||
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Add, false);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Remove, false);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, false);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Save, false);
|
||||
|
||||
if (m_modeDialog == ScriptsDialogMode::modeAdmin)
|
||||
{
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Add, true);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Edit, true);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Remove, true);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, true);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Save, true);
|
||||
}
|
||||
else if (m_modeDialog == ScriptsDialogMode::modeEdit)
|
||||
{
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Add, true);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Edit, true);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Remove, false);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, true);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Save, false);
|
||||
}
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, true);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, (selected == 1));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, (selected == 1 && pre.id() != m_loadedScriptId));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, (selected == 1 && pre.id() != m_loadedScriptId && pre.fileStatus() == FileStatus::Valid) );
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, (selected == 1 && pre.fileStatus() == FileStatus::Deleted));
|
||||
}
|
||||
|
||||
void PresentationManagementDialog::slotAdd()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "PresentationManagementDialog::slotAdd";
|
||||
PresentationEditDialog *dialog = new PresentationEditDialog(this);
|
||||
if (!dialog->init(-1 /* new presentation */, m_dtc, m_ftc, m_opmDtc))
|
||||
{
|
||||
dialog->deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
QObject::connect(dialog, &PresentationEditDialog::rejected, dialog, &PresentationEditDialog::deleteLater);
|
||||
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
void PresentationManagementDialog::slotEdit()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "PresentationManagementDialog::slotEdit";
|
||||
PresentationEditDialog *dialog = new PresentationEditDialog(this);
|
||||
|
||||
|
||||
if (!dialog->init(m_model->getRowData(m_ui->widget->currentIndex().row()).id() /* existing - edit presentation */, m_dtc, m_ftc, m_opmDtc))
|
||||
{
|
||||
dialog->deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
QObject::connect(dialog, &PresentationEditDialog::newScript, this, [this](int scriptId)
|
||||
{
|
||||
m_loadedScriptId = scriptId;
|
||||
QString scriptName = QString::fromStdString(m_dtc->presentation(scriptId).name());
|
||||
m_session->baseLayout()->setCustomText(tr("Script: %1").arg(scriptName));
|
||||
});
|
||||
QObject::connect(dialog, &PresentationEditDialog::rejected, dialog, &PresentationEditDialog::deleteLater);
|
||||
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
void PresentationManagementDialog::slotRemove()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "PresentationManagementDialog::slotRemove";
|
||||
QModelIndex selIndex = m_ui->widget->currentIndex();
|
||||
if (!selIndex.isValid())
|
||||
return;
|
||||
|
||||
Core::RemoveElementRequest req(m_model->getRowData(selIndex.row()).id());
|
||||
DEBUG_LOG(m_logger) << "Removing presentation id = " << req.id();
|
||||
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->presentationRemoveRequest(req, this);
|
||||
});
|
||||
|
||||
if (m_requestHelper->failed())
|
||||
ERROR_LOG(m_logger) << "Failed to remove presentation";
|
||||
}
|
||||
|
||||
void PresentationManagementDialog::slotDelete()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "PresentationManagementDialog::slotDelete";
|
||||
changeStatus(FileStatus::Deleted);
|
||||
}
|
||||
|
||||
void PresentationManagementDialog::slotRestore()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "PresentationManagementDialog::slotRestore";
|
||||
changeStatus(FileStatus::Valid);
|
||||
}
|
||||
|
||||
void PresentationManagementDialog::changeStatus(const FileStatus &fs)
|
||||
{
|
||||
QModelIndex selIndex = m_ui->widget->currentIndex();
|
||||
|
||||
if (!selIndex.isValid()) // no valid index
|
||||
return;
|
||||
|
||||
Presentation pre = m_model->getRowData(m_ui->widget->currentIndex().row());
|
||||
|
||||
if (pre.fileStatus() == fs) // nothing to do
|
||||
return;
|
||||
|
||||
PresentationChangeStatusRequest req;
|
||||
req.id(pre.id());
|
||||
req.fileStatus(fs);
|
||||
req.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
req.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
DEBUG_LOG(m_logger) << "Changing status for presentation id = " << pre.id();
|
||||
m_requestHelper->startSingleRequest([this, req]()
|
||||
{
|
||||
return m_ftc->presentationChangeStatusRequest(PresentationChangeStatusRequest(req), this);
|
||||
});
|
||||
|
||||
if (m_requestHelper->failed())
|
||||
ERROR_LOG(m_logger) << "Failed to change status for presentation";
|
||||
|
||||
}
|
||||
|
||||
void PresentationManagementDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool PresentationManagementDialog::init(const ScriptsDialogMode &dlgMode,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
LtsSession::LtsSession *session)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "PresentationManagementDialog::init";
|
||||
m_modeDialog = dlgMode;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_opmDtc = opmDtc;
|
||||
m_session = session;
|
||||
|
||||
m_model = new PresentationManagementDialogModel(this);
|
||||
auto predicate = [](const PresentationManagement::Presentation & p)
|
||||
{
|
||||
return (!p.isDeleted());
|
||||
};
|
||||
m_model->initModel(dtc, opmDtc, predicate);
|
||||
|
||||
m_proxyModel = new PresentationManagementDialogProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_ui->widget->setModel(m_proxyModel);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->hideColumn(PresentationManagementDialogModel::Id);
|
||||
#endif
|
||||
|
||||
m_ui->widget->setSortIndicator(PresentationManagementDialogModel::Name, Qt::AscendingOrder);
|
||||
|
||||
const QMap<qint32, PresentationManagement::Presentation> presentations = dtc->presentations();
|
||||
for (const auto &p : presentations)
|
||||
DEBUG_LOG(m_logger) << "Presentation: id = " << p.id() << ", name = " << p.name().c_str() << ", desc = " << p.description().c_str();
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &PresentationManagementDialog::enaDisa, Qt::UniqueConnection);
|
||||
|
||||
m_loadedScriptId = m_session->getSavegame()[QStringLiteral("ScriptId")].toInt();
|
||||
ERROR_LOG(m_logger) << "Loaded script id = " << m_loadedScriptId;
|
||||
|
||||
if (m_modeDialog != ScriptsDialogMode::modeView)
|
||||
{
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &PresentationManagementDialog::slotAdd, Qt::UniqueConnection);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &PresentationManagementDialog::slotEdit, Qt::UniqueConnection);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &PresentationManagementDialog::slotRemove, Qt::UniqueConnection);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Remove)->setText(tr("Remove"));
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Load, this, &PresentationManagementDialog::slotDelete, Qt::UniqueConnection);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Load)->setText(tr("Delete"));
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this, &PresentationManagementDialog::slotRestore, Qt::UniqueConnection);
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Restore"));
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &PresentationManagementDialog::slotEdit, Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
enaDisa();
|
||||
|
||||
switch (m_modeDialog)
|
||||
{
|
||||
case ScriptsDialogMode::modeAdmin:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Administrator_Scripts"));
|
||||
break;
|
||||
case ScriptsDialogMode::modeEdit:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Edit_Scripts"));
|
||||
break;
|
||||
case ScriptsDialogMode::modeView:
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-View_Scripts"));
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void PresentationManagementDialog::slotSetScriptName(int scriptId)
|
||||
{
|
||||
m_loadedScriptId = scriptId;
|
||||
QString scriptName = QString::fromStdString(m_dtc->presentation(scriptId).name());
|
||||
m_session->baseLayout()->setCustomText(tr("Script: %1").arg(scriptName));
|
||||
}
|
||||
|
||||
} // namespace PresentationManagement
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* PresentationManagement - Script Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-15
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Services/PresentationManagement/pre_dtc.h>
|
||||
#include <Services/PresentationManagement/pre_ftc.h>
|
||||
#include <Services/PresentationManagement/logger.h>
|
||||
#include <Services/OperatorManagement/opm_dtc.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class PresentationManagementDialog;
|
||||
}
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
enum class ScriptsDialogMode
|
||||
{
|
||||
modeView = 0,
|
||||
modeEdit = 1,
|
||||
modeAdmin = 2
|
||||
};
|
||||
|
||||
class PresentationManagementDialogModel;
|
||||
class PresentationManagementDialogProxyModel;
|
||||
|
||||
class PresentationManagementDialog : public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::PresentationRemoveReplyHandler
|
||||
, protected Interface::Ftc::PresentationChangeStatusReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PresentationManagementDialog(QWidget *parent = nullptr);
|
||||
~PresentationManagementDialog();
|
||||
|
||||
bool init(const ScriptsDialogMode &dlgMode,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
LtsSession::LtsSession *session);
|
||||
|
||||
protected:
|
||||
void onPresentationRemoveReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onPresentationChangeStatusReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void changeStatus(const FileStatus &fs);
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
PresentationManagementDialogModel *m_model;
|
||||
PresentationManagementDialogProxyModel *m_proxyModel;
|
||||
Ui::PresentationManagementDialog *m_ui;
|
||||
std::shared_ptr<PresentationManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<PresentationManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
ScriptsDialogMode m_modeDialog;
|
||||
LtsSession::LtsSession *m_session;
|
||||
|
||||
int m_loadedScriptId {-1};
|
||||
|
||||
LOGGER_T m_logger;
|
||||
|
||||
private slots:
|
||||
void slotAdd();
|
||||
void slotEdit();
|
||||
void slotRemove();
|
||||
void slotDelete();
|
||||
void slotRestore();
|
||||
void enaDisa();
|
||||
void slotSetScriptName(int scriptId);
|
||||
|
||||
};
|
||||
|
||||
} // namespace PresentationManagement
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PresentationManagementDialog</class>
|
||||
<widget class="QWidget" name="PresentationManagementDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Presentation Management</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="widget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>250</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for PresentationManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-15
|
||||
*/
|
||||
|
||||
#include "pre_edit_gui_plugin.h"
|
||||
#include "pre_dialog.h"
|
||||
#include "pre_mobile_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Services/PresentationManagement/pre_operator_rights.h>
|
||||
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
|
||||
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
|
||||
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
}
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: GuiPluginBase::Interface(session, getLogger("Plugins.Gui.Pre.Edit"))
|
||||
{}
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
QString menuGroupString(menuGroup());
|
||||
|
||||
if (m_session->app() == LtsAppDescriptor::App::Scripts)
|
||||
{
|
||||
{
|
||||
LtsWidgets::PluginData plData;
|
||||
plData.menuGroup = menuGroupString;
|
||||
plData.menuText = tr("Edit Scripts");
|
||||
plData.identifier = QLatin1String("preEditScripts");
|
||||
plData.menuIcon = QIcon(QStringLiteral("icon:document-edit.svg"));
|
||||
plData.operatorRight = OperatorRights::PresentationScriptsEdit;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eAfterAction;
|
||||
plData.createWidgetFunc = [this](QWidget *parent)
|
||||
{
|
||||
return onEditPresentationDialog(parent);
|
||||
};
|
||||
|
||||
ret.append(plData);
|
||||
}
|
||||
|
||||
{
|
||||
LtsWidgets::PluginData plData;
|
||||
plData.menuGroup = menuGroupString;
|
||||
plData.menuText = tr("Admin Scripts");
|
||||
plData.identifier = QLatin1String("preAdminScripts");
|
||||
plData.menuIcon = QIcon(QStringLiteral("icon:document-open.svg"));
|
||||
plData.operatorRight = OperatorRights::PresentationScriptsAdmin;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eAfterAction;
|
||||
plData.createWidgetFunc = [this](QWidget *parent)
|
||||
{
|
||||
return onAdminPresentationDialog(parent);
|
||||
};
|
||||
|
||||
ret.append(plData);
|
||||
}
|
||||
}
|
||||
else if (m_session->app() == LtsAppDescriptor::App::Situation)
|
||||
{
|
||||
if (m_asmDtc->isAARWorkstation(LtsSession::LtsSession::workstationName()))
|
||||
{
|
||||
LtsWidgets::PluginData plData;
|
||||
plData.menuGroup = menuGroupString;
|
||||
plData.menuText = tr("Download Scripts for Mobile AAR");
|
||||
plData.identifier = QLatin1String("preMobileScripts");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:import_documents.svg"));
|
||||
plData.operatorRight = OperatorRights::PresentationScriptsShow;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eAfterAction;
|
||||
plData.createWidgetFunc = [this](QWidget *parent)
|
||||
{
|
||||
return onPresentationMobileDialog(parent);
|
||||
};
|
||||
|
||||
ret.append(plData);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<PresentationManagement::DataInterface>(m_dtc))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "getDtc for PresentationManagement::DataInterface failed.";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getFtc<PresentationManagement::DataInterface>(m_ftc))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "getFtc for PresentationManagement::DataInterface failed.";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getDtc<OperatorManagement::DataInterface>(m_opmDtc))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "getDtc for OperatorManagement::DataInterface failed.";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getDtc<AssetManagement::DataInterface>(m_asmDtc))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "getDtc for AssetManagement::DataInterface failed.";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getForeignDataInterface_NEW(m_avmDataIfc))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "getForeignDataInterface for AVM::DataInterface failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_opmDtc = nullptr;
|
||||
m_ftc = nullptr;
|
||||
m_dtc = nullptr;
|
||||
m_avmDataIfc = nullptr;
|
||||
}
|
||||
|
||||
QString InterfaceImpl::menuGroup() const
|
||||
{
|
||||
return tr("Presentation");
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowPresentationDialog(QWidget *parent)
|
||||
{
|
||||
return LtsWidgets::initDialog(new PresentationManagementDialog(parent),
|
||||
PresentationManagement::ScriptsDialogMode::modeView, m_dtc, m_ftc, m_opmDtc, m_session);
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onEditPresentationDialog(QWidget *parent)
|
||||
{
|
||||
return LtsWidgets::initDialog(new PresentationManagementDialog(parent),
|
||||
PresentationManagement::ScriptsDialogMode::modeEdit, m_dtc, m_ftc, m_opmDtc, m_session);
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onAdminPresentationDialog(QWidget *parent)
|
||||
{
|
||||
return LtsWidgets::initDialog(new PresentationManagementDialog(parent),
|
||||
PresentationManagement::ScriptsDialogMode::modeAdmin, m_dtc, m_ftc, m_opmDtc, m_session);
|
||||
}
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onPresentationMobileDialog(QWidget *parent)
|
||||
{
|
||||
return LtsWidgets::initDialog(new PreMobileDialog(parent), m_dtc, m_ftc, m_opmDtc, m_avmDataIfc, m_session);
|
||||
}
|
||||
|
||||
} // namespace PresentationManagement
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for PresentationManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-15
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PresentationManagement/logger.h>
|
||||
#include <Services/OperatorManagement/opm_dtc.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <Plugins/PresentationManagement/pre_data_plugin_interface.h>
|
||||
#include <Plugins/PresentationManagement/pre_presentation_gui_plugin_interface.h>
|
||||
#include <Plugins/AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
#include <Plugins/AssetManagement/asm_data_plugin_interface.h>
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:pre.edit")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return ForeignPresentationGuiInterface::pluginName(); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override
|
||||
{
|
||||
return partition == IDL::PartitionType::Exercise;
|
||||
}
|
||||
};
|
||||
|
||||
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
QString menuGroup() const override;
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Exercise; }
|
||||
|
||||
private:
|
||||
LtsWidgets::LtsDialog *onShowPresentationDialog(QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onEditPresentationDialog(QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onAdminPresentationDialog(QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onPresentationMobileDialog(QWidget *parent);
|
||||
|
||||
std::shared_ptr<PresentationManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<PresentationManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
std::shared_ptr<AudioVideoManagement::DataInterface> m_avmDataIfc;
|
||||
std::shared_ptr<AssetManagement::Interface::Dtc> m_asmDtc;
|
||||
};
|
||||
|
||||
} // namespace PresentationManagement
|
||||
+409
@@ -0,0 +1,409 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* PresentationManagement - Script Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-15
|
||||
*/
|
||||
|
||||
#include "pre_mobile_dialog.h"
|
||||
#include "ui_pre_mobile_dialog.h"
|
||||
|
||||
#include <Plugins/PresentationManagement/Gui/Common/pre_edit_dialog.h>
|
||||
#include <Plugins/PresentationManagement/Gui/Common/pre_mobile_model.h>
|
||||
#include <Plugins/AudioVideoManagement/Gui/AVMenuEdit/topic_replay.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsScriptTimeline/track_entry_painters.h>
|
||||
|
||||
#include <Tools/DBAdministration/settings.h>
|
||||
#include <ngldb/dbconnection.h>
|
||||
|
||||
#include <AudioVideoManagement/ava_control.h>
|
||||
#include <AudioVideoManagement/ava_session.h>
|
||||
|
||||
#include <QHostInfo>
|
||||
#include <QDateTime>
|
||||
#include <QJsonDocument>
|
||||
#include <QProgressBar>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
PreMobileDialog::PreMobileDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_model(nullptr)
|
||||
, m_ui(new Ui::PreMobileDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_copyExercise(getLogger("CopyExercise"), DBAdministration::CopyExercise::CopyForAAR, this)
|
||||
, m_widgetProgressBar(new QWidget)
|
||||
, m_progressBar(nullptr)
|
||||
, m_label(nullptr)
|
||||
, m_avScriptsCount(0)
|
||||
, m_avScriptsActualDone(0)
|
||||
, m_logger(getLogger("PreMobileDialog"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "PreMobileDialog ctor";
|
||||
connect(&m_copyExercise, &DBAdministration::CopyExercise::copyDbFailed, this, &PreMobileDialog::onCopyDbFailed);
|
||||
connect(&m_copyExercise, &DBAdministration::CopyExercise::copyDbFinished, this, &PreMobileDialog::onCopyDbFinished);
|
||||
|
||||
m_ui->setupUi(this);
|
||||
QVBoxLayout *vlayout = new QVBoxLayout();
|
||||
m_widgetProgressBar->setLayout(vlayout);
|
||||
|
||||
m_progressBar = new QProgressBar();
|
||||
m_label = new QLabel();
|
||||
connect(m_label, &QLabel::destroyed, this, [this]()
|
||||
{ERROR_LOG(m_logger) << "Label destroyed";});
|
||||
m_widgetProgressBar->layout()->addWidget(m_label);
|
||||
m_widgetProgressBar->layout()->addWidget(m_progressBar);
|
||||
m_progressBar->setMinimum(0);
|
||||
m_progressBar->setMaximum(100);
|
||||
m_progressBar->show();
|
||||
m_progressBar->setValue(50);
|
||||
|
||||
}
|
||||
|
||||
PreMobileDialog::~PreMobileDialog()
|
||||
{
|
||||
// will be deleted with m_widgetProgressBar
|
||||
//delete m_progressBar;
|
||||
//delete m_label
|
||||
delete m_widgetProgressBar;
|
||||
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void PreMobileDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Download AAR Scripts"));
|
||||
}
|
||||
|
||||
void PreMobileDialog::enaDisa()
|
||||
{
|
||||
bool enable = !m_model->getDownloadedScriptIds().isEmpty();
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Export, enable);
|
||||
}
|
||||
|
||||
void PreMobileDialog::slotDownload()
|
||||
{
|
||||
if (!m_avmDataIfc->hasAvsSession())
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(this, tr("AVS session not available - do you still want to start the download?"));
|
||||
return;
|
||||
}
|
||||
|
||||
AudioVideoManagement::AvaSession *avaSession = m_avmDataIfc->avaSession();
|
||||
if (!avaSession->isEstablished())
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(this, tr("AVS session not available - do you still want to start the download?"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Export, false);
|
||||
int exerciseId = m_session->exerciseId();
|
||||
|
||||
QString hostname = QHostInfo::localHostName().toUpper();
|
||||
|
||||
QString destDb = QStringLiteral("lts_db_") + QString::number(exerciseId);
|
||||
m_copyExercise.init(exerciseId,
|
||||
DBAdministration::Settings::serverDatabaseHost(),
|
||||
DBAdministration::Settings::serverDatabaseName(),
|
||||
hostname,
|
||||
destDb);
|
||||
|
||||
m_progressBar->setValue(0);
|
||||
m_label->setText(tr("Download database data"));
|
||||
setOverlay(m_widgetProgressBar);
|
||||
|
||||
|
||||
connect(&m_copyExercise, &DBAdministration::CopyExercise::nextProgress, this, &PreMobileDialog::onProgressBar);
|
||||
|
||||
if (!m_copyExercise.doCopy(exerciseId))
|
||||
ERROR_LOG(m_logger) << "Failed to copy database from " << DBAdministration::Settings::serverDatabaseHost() << " to " << hostname;
|
||||
|
||||
/*
|
||||
if (!m_progressDialog)
|
||||
m_progressDialog = new QProgressDialog(this);
|
||||
m_progressDialog->setLabelText(tr("Downloading data ..."));
|
||||
m_progressDialog->setMinimum(0);
|
||||
m_progressDialog->setMaximum(0);
|
||||
m_progressDialog->show();
|
||||
*/
|
||||
|
||||
const QVector<int> downloadScriptIds = m_model->getDownloadedScriptIds();
|
||||
m_copyExercise.setDownloadScriptIds(downloadScriptIds);
|
||||
|
||||
}
|
||||
|
||||
void PreMobileDialog::onProgressBar(int nextProgress)
|
||||
{
|
||||
m_progressBar->setValue(nextProgress);
|
||||
|
||||
// 1/4 done
|
||||
if (nextProgress == 25)
|
||||
m_label->setText(tr("Download of database finished"));
|
||||
|
||||
// 2/4 done
|
||||
if (nextProgress == 30)
|
||||
m_label->setText(tr("Dropping old database finished"));
|
||||
|
||||
// 3/4 done
|
||||
if (nextProgress == 35)
|
||||
m_label->setText(tr("Creating new database finished"));
|
||||
|
||||
if (nextProgress == 36)
|
||||
m_label->setText(tr("Importing data into local database"));
|
||||
|
||||
if (nextProgress >= 100)
|
||||
{
|
||||
m_copyExercise.stopPing();
|
||||
new LtsWidgets::LtsMessageDialogNew(this, tr("Download finished"));
|
||||
unsetOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
bool PreMobileDialog::init(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
const std::shared_ptr<AudioVideoManagement::DataInterface> &avmDataIfc,
|
||||
LtsSession::LtsSession *session)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "PreMobileDialog::init";
|
||||
m_session = session;
|
||||
m_avmDataIfc = avmDataIfc;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
|
||||
m_model = new PreMobileDialogModel(this);
|
||||
auto predicate = [](const PresentationManagement::Presentation & p)
|
||||
{
|
||||
return (!p.isDeleted());
|
||||
};
|
||||
m_model->initModel(dtc, opmDtc, predicate);
|
||||
|
||||
m_proxyModel = new PresentationManagementDialogProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
connect(m_model, &PreMobileDialogModel::checkboxClicked, this, &PreMobileDialog::enaDisa);
|
||||
m_ui->widget->setModel(m_proxyModel);
|
||||
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->hideColumn(PreMobileDialogModel::Id);
|
||||
#endif
|
||||
|
||||
m_ui->widget->setSortIndicator(PreMobileDialogModel::Name, Qt::AscendingOrder);
|
||||
|
||||
const QMap<qint32, PresentationManagement::Presentation> presentations = dtc->presentations();
|
||||
for (const auto &p : presentations)
|
||||
DEBUG_LOG(m_logger) << "Presentation: id = " << p.id() << ", name = " << p.name().c_str() << ", desc = " << p.description().c_str();
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &PreMobileDialog::enaDisa, Qt::UniqueConnection);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Load, this, &PreMobileDialog::slotDownload, Qt::UniqueConnection);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Mobile_AAR_Scripts"));
|
||||
enaDisa();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PreMobileDialog::onCopyDbFailed()
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(this, tr("Could not download data - Dump failed"));
|
||||
m_copyExercise.stopPing();
|
||||
enaDisa();
|
||||
unsetOverlay();
|
||||
}
|
||||
|
||||
void PreMobileDialog::onCopyDbFinished()
|
||||
{
|
||||
enaDisa();
|
||||
|
||||
if (!downloadAVScripts())
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(this, tr("Could not download data - Audio/Video download failed. <br> But scripts without video can be used"));
|
||||
unsetOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PreMobileDialog::getAVScripts()
|
||||
{
|
||||
const auto scriptIds(m_model->getDownloadedScriptIds());
|
||||
for (int scriptId : scriptIds)
|
||||
{
|
||||
auto req = [this, scriptId]()
|
||||
{
|
||||
return m_ftc->getPresentationContentRequest(GetPresentationContentRequest(scriptId), this);
|
||||
};
|
||||
m_requestHelper->addRequest(req);
|
||||
}
|
||||
m_requestHelper->startRequests(); // blocks
|
||||
}
|
||||
|
||||
void PreMobileDialog::onGetPresentationContentReply(const GetPresentationContentReply &reply)
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
if (!reply.errorString().empty())
|
||||
return;
|
||||
handlePresentationContent(reply);
|
||||
}
|
||||
|
||||
void PreMobileDialog::handlePresentationContent(const GetPresentationContentReply &reply)
|
||||
{
|
||||
const auto &contentList = reply.content();
|
||||
|
||||
if (contentList.empty())
|
||||
{
|
||||
WARNING_LOG(m_logger) << "No content for Script Id = " << reply.id();
|
||||
return;
|
||||
}
|
||||
|
||||
std::string audioStr = LtsScriptTimeline::trackEntryTypeName(LtsScriptTimeline::TrackEntryType::Audio).toStdString();
|
||||
std::string videoStr = LtsScriptTimeline::trackEntryTypeName(LtsScriptTimeline::TrackEntryType::Video).toStdString();
|
||||
|
||||
for (const auto &p : contentList)
|
||||
{
|
||||
QJsonObject attributes = QJsonDocument::fromJson(QByteArray::fromStdString(p.attributes())).object();
|
||||
//NOTICE_LOG(m_logger) << "p.id: " << p.id() << "attributes" << p.attributes();
|
||||
|
||||
if (p.presentationTopicType() == audioStr ||
|
||||
p.presentationTopicType() == videoStr )
|
||||
{
|
||||
m_vecScripts.append(attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool PreMobileDialog::downloadAVScripts()
|
||||
{
|
||||
INFO_LOG(m_logger) << "IN downloadAVScripts";
|
||||
int nextProgress = 76;
|
||||
m_progressBar->setValue(nextProgress);
|
||||
|
||||
if (!m_avmDataIfc->hasAvsSession())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "avm hasAvsSession failed";
|
||||
m_copyExercise.stopPing();
|
||||
return false;
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "hasAVsSession ok";
|
||||
|
||||
AudioVideoManagement::AvaSession *avaSession = m_avmDataIfc->avaSession();
|
||||
if (!avaSession->isEstablished())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "avaSession not established, abort";
|
||||
m_copyExercise.stopPing();
|
||||
return false;
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "avaSession established";
|
||||
|
||||
m_avaControl = avaSession->control();
|
||||
|
||||
getAVScripts();
|
||||
|
||||
m_avScriptsCount = m_vecScripts.count();
|
||||
QString labelText = tr("Downloaded Audio Video Data: ") + QString::number(m_avScriptsActualDone) + QStringLiteral(" / ") + QString::number(m_avScriptsCount);
|
||||
// 3/4 done
|
||||
m_label->setText(labelText);
|
||||
|
||||
if (m_vecScripts.isEmpty())
|
||||
{
|
||||
onProgressBar(100);
|
||||
return true;
|
||||
}
|
||||
|
||||
const QJsonObject obj = m_vecScripts.takeFirst();
|
||||
const AudioVideoManagement::AvaTopicData topicData(obj);
|
||||
m_lastScriptName = topicData.scriptName();
|
||||
|
||||
m_avaControl->setScript(QStringLiteral("LOCAL_RECORD"), topicData.scriptName(),
|
||||
topicData.isAudio() ? AudioVideoManagement::AvaScriptSource::ServerAudio : AudioVideoManagement::AvaScriptSource::ServerVideo,
|
||||
topicData.streamList(),
|
||||
LtsUtils::createConnection(m_avaControl, &AudioVideoManagement::AvaControl::setScriptResponse,
|
||||
this, &PreMobileDialog::slotScriptSet));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PreMobileDialog::slotScriptSet(const AudioVideoManagement::AvaStreamInfo &streamInfo, AudioVideoManagement::AvaStreamState streamState)
|
||||
{
|
||||
if (streamState == AudioVideoManagement::AvaStreamState::NotPossible)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Script " << m_lastScriptName << " not correctly downloaded";
|
||||
slotScriptDownloaded(streamState);
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "ScriptName: " << m_lastScriptName;
|
||||
DEBUG_LOG(m_logger) << "streamInfo: start" << streamInfo.duration.count();
|
||||
DEBUG_LOG(m_logger) << "streamState: " << static_cast<int>(streamState);
|
||||
|
||||
m_avaControl->startScript(QStringLiteral("LOCAL_RECORD"), m_lastScriptName,
|
||||
LtsUtils::createConnection(m_avaControl, &AudioVideoManagement::AvaControl::startScriptResponse,
|
||||
this, &PreMobileDialog::slotScriptDownloaded));
|
||||
}
|
||||
|
||||
void PreMobileDialog::slotScriptDownloaded(AudioVideoManagement::AvaStreamState streamState)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "streamState: " << static_cast<int>(streamState);
|
||||
|
||||
m_avScriptsActualDone += 1;
|
||||
QString labelText = tr("Downloaded Audio Video Data: ") + QString::number(m_avScriptsActualDone) + QStringLiteral(" / ") + QString::number(m_avScriptsCount);
|
||||
// 3/4 done
|
||||
m_label->setText(labelText);
|
||||
m_progressBar->setValue(m_progressBar->value()+1);
|
||||
|
||||
if (streamState == AudioVideoManagement::AvaStreamState::NotPossible)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Script " << m_lastScriptName << " not correctly downloaded";
|
||||
QString msg = tr("Could not download data - Audio/Video download - Script %1 failed").arg(m_lastScriptName);
|
||||
auto x = new LtsWidgets::LtsMessageDialogNew(this, msg);
|
||||
connect(x, &LtsWidgets::LtsMessageDialogNew::ok,
|
||||
this, &PreMobileDialog::slotScriptDownloadedStep2);
|
||||
return;
|
||||
}
|
||||
|
||||
slotScriptDownloadedStep2();
|
||||
}
|
||||
|
||||
|
||||
void PreMobileDialog::slotScriptDownloadedStep2()
|
||||
{
|
||||
m_avaControl->releaseScript(QStringLiteral("LOCAL_RECORD"), m_lastScriptName);
|
||||
|
||||
|
||||
if (m_vecScripts.isEmpty())
|
||||
{
|
||||
QString labelText = tr("Download Audio Video Data done");
|
||||
// 4/4 done
|
||||
m_label->setText(labelText);
|
||||
onProgressBar(100);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
fprintf(stderr, "slotScriptDownloaded - WAITING....\n");
|
||||
QTimer::singleShot(2500, this, [this]()
|
||||
{
|
||||
fprintf(stderr, "slotScriptDownloaded - GO!!!\n");
|
||||
const QJsonObject obj = m_vecScripts.takeFirst();
|
||||
const AudioVideoManagement::AvaTopicData topicData(obj);
|
||||
m_lastScriptName = topicData.scriptName();
|
||||
|
||||
m_avaControl->setScript(QStringLiteral("LOCAL_RECORD"), topicData.scriptName(),
|
||||
topicData.isAudio() ? AudioVideoManagement::AvaScriptSource::ServerAudio : AudioVideoManagement::AvaScriptSource::ServerVideo,
|
||||
topicData.streamList(),
|
||||
LtsUtils::createConnection(m_avaControl, &AudioVideoManagement::AvaControl::setScriptResponse,
|
||||
this, &PreMobileDialog::slotScriptSet));
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace PresentationManagement
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* PresentationManagement - Script Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-15
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Services/PresentationManagement/pre_dtc.h>
|
||||
#include <Services/PresentationManagement/pre_ftc.h>
|
||||
#include <Services/PresentationManagement/logger.h>
|
||||
#include <Services/OperatorManagement/opm_dtc.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Tools/DBAdministration/copy_exercise.h>
|
||||
|
||||
#include <Plugins/AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
|
||||
#include <QProgressDialog>
|
||||
|
||||
|
||||
namespace AudioVideoManagement {
|
||||
class AvaControl;
|
||||
}
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class PreMobileDialog;
|
||||
}
|
||||
class QSortFilterProxyModel;
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
class PreMobileDialogModel;
|
||||
|
||||
class PreMobileDialog : public LtsWidgets::LtsDialog
|
||||
, protected PresentationManagement::Interface::Ftc::GetPresentationContentReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PreMobileDialog(QWidget *parent = nullptr);
|
||||
~PreMobileDialog();
|
||||
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<PresentationManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
const std::shared_ptr<AudioVideoManagement::DataInterface> &avmDataIfc,
|
||||
LtsSession::LtsSession *session);
|
||||
|
||||
void getAVScripts();
|
||||
|
||||
private slots:
|
||||
void onCopyDbFailed();
|
||||
void onCopyDbFinished();
|
||||
void slotScriptSet(const AudioVideoManagement::AvaStreamInfo &streamInfo, AudioVideoManagement::AvaStreamState streamState);
|
||||
void slotScriptDownloaded(AudioVideoManagement::AvaStreamState streamState);
|
||||
void slotScriptDownloadedStep2();
|
||||
void onProgressBar(int nextProgress);
|
||||
private:
|
||||
void retranslate() override;
|
||||
void changeStatus(const FileStatus &fs);
|
||||
bool downloadAVScripts();
|
||||
void handlePresentationContent(const GetPresentationContentReply &reply);
|
||||
void onGetPresentationContentReply(const GetPresentationContentReply &reply) override;
|
||||
|
||||
PreMobileDialogModel *m_model;
|
||||
QSortFilterProxyModel *m_proxyModel;
|
||||
Ui::PreMobileDialog *m_ui;
|
||||
LtsSession::LtsSession *m_session;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
std::shared_ptr<PresentationManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<PresentationManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<AudioVideoManagement::DataInterface> m_avmDataIfc;
|
||||
DBAdministration::CopyExercise m_copyExercise;
|
||||
QVector<QJsonObject> m_vecScripts;
|
||||
AudioVideoManagement::AvaControl* m_avaControl;
|
||||
QString m_lastScriptName;
|
||||
QWidget *m_widgetProgressBar;
|
||||
QProgressBar *m_progressBar;
|
||||
QLabel *m_label;
|
||||
int m_avScriptsCount;
|
||||
int m_avScriptsActualDone;
|
||||
LOGGER_T m_logger;
|
||||
|
||||
private slots:
|
||||
void slotDownload();
|
||||
void enaDisa();
|
||||
|
||||
};
|
||||
|
||||
} // namespace PresentationManagement
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PreMobileDialog</class>
|
||||
<widget class="QWidget" name="PreMobileDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Presentation Management</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="widget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>250</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in new issue
Block a user