Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+283
@@ -0,0 +1,283 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ScriptChooser Payload UI
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-21
|
||||
*/
|
||||
|
||||
#include "script_chooser.h"
|
||||
#include "ui_script_chooser.h"
|
||||
|
||||
#include <ConnectDialog/connect_dialog_nt.h>
|
||||
#include <LtsDataView/search_model.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsWidgets/lts_global_wait_dialog.h>
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <Plugins/PresentationManagement/Gui/Common/pre_model.h>
|
||||
#include <QMessageBox>
|
||||
#include <QCloseEvent>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
|
||||
ScriptChooser::ScriptChooser(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<PresentationManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
bool isPlayerMode,
|
||||
bool isImportDialog,
|
||||
QWidget *parent)
|
||||
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
|
||||
, m_model(new PresentationManagementDialogModel(this))
|
||||
, m_proxy(new PresentationManagementDialogProxyModel(this))
|
||||
, m_selected(false)
|
||||
, m_isImportDialog(isImportDialog)
|
||||
, m_ui(new Ui::ScriptChooser)
|
||||
, m_logger(getLogger(QStringLiteral("ScriptChooser")))
|
||||
, m_ftc(ftc)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
if (!m_isImportDialog)
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->setVisible(false);
|
||||
|
||||
m_ui->setupUi(this);
|
||||
setWindowFlags( Qt::Dialog | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint ); // hints..
|
||||
|
||||
// only show Valid (= not deleted) scripts
|
||||
auto predicate = [](const PresentationManagement::Presentation & p)
|
||||
{
|
||||
return (!p.isDeleted() && p.fileStatus() == FileStatus::Valid);
|
||||
};
|
||||
m_model->initModel(dtc, opmDtc, predicate);
|
||||
m_proxy->setSourceModel(m_model);
|
||||
|
||||
m_ui->ltsDataView->seamless();
|
||||
// m_ui->ltsDataView->selectCustomView();
|
||||
m_ui->ltsDataView->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);
|
||||
m_ui->ltsDataView->setModel(m_proxy);//, [this]() { return new CustomViewExercise(this); }); TODO: custom widgets!
|
||||
int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
bool bSetOperator = m_ui->ltsDataView->setInitialSearchContent(
|
||||
PresentationManagementDialogModel::Columns::Operator, QVariant(LtsSessionData::LtsSessionData::getInstance()->getOperatorId())
|
||||
);
|
||||
if (!bSetOperator)
|
||||
WARNING_LOG(m_logger) << "could not set initial operator id to " << operatorId;
|
||||
|
||||
connect(m_ui->ltsDataView, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &ScriptChooser::onEnaDisa, Qt::QueuedConnection);
|
||||
connect(m_ui->ltsDataView, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &ScriptChooser::onScriptSelected, Qt::QueuedConnection);
|
||||
connect(m_ui->ltsDataView, &LtsDataView::LtsDataView::signalEnterPressed,
|
||||
this, &ScriptChooser::onScriptSelected, Qt::QueuedConnection);
|
||||
connect(m_ui->pbSelect, &QPushButton::clicked,
|
||||
this, &ScriptChooser::onScriptSelected, Qt::QueuedConnection);
|
||||
connect(m_ui->pbDeleteScript, &QPushButton::clicked,
|
||||
this, &ScriptChooser::onDeleteScript, Qt::QueuedConnection);
|
||||
|
||||
setSelectorMode(isPlayerMode); // has to be called BEFORE manually setVisible on the buttons!
|
||||
|
||||
if (!isImportDialog)
|
||||
{
|
||||
connect(m_ui->pbQuit, &QPushButton::clicked,
|
||||
this, &ScriptChooser::signalQuit, Qt::QueuedConnection);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->pbNewScript->setVisible(false);
|
||||
m_ui->pbEditQuit->setVisible(false);
|
||||
}
|
||||
|
||||
connect(m_ui->pbQuit, &QPushButton::clicked, this, [this]()
|
||||
{
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->setVisible(true);
|
||||
m_close = true;
|
||||
close();
|
||||
});
|
||||
|
||||
connect(m_ui->pbNewScript, &QPushButton::clicked,
|
||||
this, &ScriptChooser::signalNewScript, Qt::QueuedConnection);
|
||||
|
||||
connect(m_ui->pbEditQuit, &QPushButton::clicked,
|
||||
this, &ScriptChooser::signalEditQuit);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->ltsDataView->hideColumn(PresentationManagementDialogModel::Id);
|
||||
#endif
|
||||
m_ui->ltsDataView->setSortIndicator(PresentationManagementDialogModel::Name, Qt::AscendingOrder);
|
||||
|
||||
if (!m_isImportDialog)
|
||||
{
|
||||
qint32 scriptId = LtsSessionData::LtsSessionData::getInstance()->getScriptId();
|
||||
|
||||
if (scriptId == 0)
|
||||
return;
|
||||
|
||||
LtsSessionData::LtsSessionData::getInstance()->setScriptId(0);
|
||||
|
||||
if (scriptId < 0)
|
||||
{
|
||||
FATAL_LOG(m_logger) << "ScriptIdPreset " << scriptId << " is invalid!";
|
||||
Q_ASSERT(false);
|
||||
return;
|
||||
}
|
||||
|
||||
bool isExistingScriptId = false;
|
||||
qint32 rowCounter;
|
||||
|
||||
for (rowCounter = 0; rowCounter < m_model->rowCount(); ++rowCounter)
|
||||
{
|
||||
if (m_model->getRowData(rowCounter).id() == scriptId)
|
||||
{
|
||||
isExistingScriptId = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (scriptId < 0 || !isExistingScriptId)
|
||||
{
|
||||
FATAL_LOG(m_logger) << "ScriptIdPreset " << scriptId << " is invalid!";
|
||||
Q_ASSERT(false);
|
||||
return;
|
||||
}
|
||||
|
||||
QTimer::singleShot(100, this, [this, rowCounter]()
|
||||
{
|
||||
const Presentation p = m_model->getRowData(rowCounter);
|
||||
|
||||
if (p.id() <= 0)
|
||||
return;
|
||||
|
||||
setEnabled(false);
|
||||
|
||||
if (!m_isImportDialog)
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->setVisible(true);
|
||||
|
||||
emit signalSelectScript(p.id());
|
||||
m_close = true;
|
||||
close();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ScriptChooser::~ScriptChooser()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void ScriptChooser::reject()
|
||||
{
|
||||
if (!m_selected && !m_isImportDialog /* do not quit session if this dialog is misused as import dialog for a running app */)
|
||||
emit signalQuit();
|
||||
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
void ScriptChooser::onDeleteScript()
|
||||
{
|
||||
int ret = QMessageBox::warning(this, tr("DELETE SCRIPT"),
|
||||
tr("Do you really want to delete the selected script?"),
|
||||
QMessageBox::Yes | QMessageBox::Cancel);
|
||||
if(ret == QMessageBox::Yes)
|
||||
{
|
||||
const QModelIndex idx = m_ui->ltsDataView->currentIndex();
|
||||
const Presentation pre = m_model->getRowData(idx.row());
|
||||
const FileStatus fs = FileStatus::Deleted;
|
||||
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);
|
||||
});
|
||||
|
||||
auto srcIdx = m_ui->ltsDataView->proxyModel()->mapFromSource(idx);
|
||||
m_ui->ltsDataView->proxyModel()->removeRow(srcIdx.row());
|
||||
|
||||
if (m_requestHelper->failed())
|
||||
ERROR_LOG(m_logger) << "Failed to change status for presentation-script_chooser";
|
||||
}
|
||||
|
||||
}
|
||||
void ScriptChooser::onScriptSelected()
|
||||
{
|
||||
if (m_isImportDialog)
|
||||
{
|
||||
connect(new LtsWidgets::LtsMessageDialogNew(this, tr("You are about to import the selected script to the currently open script.<br />"
|
||||
"The import script will be inserted at the indicated position and moves all topics after the indicated position to after the to-be imported script's content.<br/>"
|
||||
"Info: The indicated position is indicated by the light blue vertical line. Its position can be changed by clicking on a topic or by clicking at the desired position in the header (where the time texts are drawn on).<br />"
|
||||
"This operation can't be reversed.<br />"
|
||||
"<br />"
|
||||
"Are you sure you want to import the selected script?<br />"
|
||||
"Click yes to import the script.<br />"
|
||||
"Click no to cancel this operation and don't import."), tr("Import script"), LtsWidgets::Behaviour::Modal, LtsWidgets::Button::Yes | LtsWidgets::Button::No),
|
||||
&LtsWidgets::LtsMessageDialogNew::yes,
|
||||
this, &ScriptChooser::onImportScript, Qt::QueuedConnection);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
onImportScript();
|
||||
}
|
||||
|
||||
|
||||
void ScriptChooser::onImportScript()
|
||||
{
|
||||
if (m_selected)
|
||||
return;
|
||||
|
||||
m_selected = true;
|
||||
|
||||
const QModelIndex idx = m_ui->ltsDataView->currentIndex();
|
||||
const Presentation p = m_model->getRowData(idx.row());
|
||||
|
||||
if (p.id() <= 0)
|
||||
return;
|
||||
|
||||
setEnabled(false);
|
||||
|
||||
if (!m_isImportDialog)
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->setVisible(true);
|
||||
|
||||
emit signalSelectScript(p.id());
|
||||
m_close = true;
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
void ScriptChooser::onEnaDisa()
|
||||
{
|
||||
m_ui->pbSelect->setEnabled(m_ui->ltsDataView->selectedRows().size() == 1);
|
||||
m_ui->pbDeleteScript->setEnabled(m_ui->ltsDataView->selectedRows().size() == 1);
|
||||
}
|
||||
|
||||
|
||||
void ScriptChooser::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (!m_close)
|
||||
{
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_isImportDialog)
|
||||
LtsWidgets::LtsGlobalWaitDialog::getInstance()->setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
void ScriptChooser::setSelectorMode(bool isPlayer)
|
||||
{
|
||||
m_ui->pbNewScript->setVisible(!isPlayer);
|
||||
m_ui->pbEditQuit->setVisible(isPlayer);
|
||||
}
|
||||
|
||||
} // namespace PresentationManagement
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ScriptChooser Payload UI
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-21
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/PresentationManagement/Gui/Script/Common/preguiscriptcommon_export.h>
|
||||
#include <Plugins/PresentationManagement/pre_data_plugin_interface.h>
|
||||
#include <Services/OperatorManagement/opm_dtc.h>
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <Services/PresentationManagement/pre_ftc.h>
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
namespace Ui { class ScriptChooser; }
|
||||
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
|
||||
class PresentationManagementDialogModel;
|
||||
class PresentationManagementDialogProxyModel;
|
||||
|
||||
|
||||
class PREGUISCRIPTCOMMON_EXPORT ScriptChooser : public LtsWidgets::LtsFramelessDialog
|
||||
, protected Interface::Ftc::PresentationRemoveReplyHandler
|
||||
, protected Interface::Ftc::PresentationChangeStatusReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ScriptChooser(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<PresentationManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
bool isPlayerMode,
|
||||
bool isImportDialog = false,
|
||||
QWidget *parent = nullptr);
|
||||
~ScriptChooser();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
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 setSelectorMode(bool isPlayer);
|
||||
|
||||
private slots:
|
||||
void reject() override;
|
||||
|
||||
void onDeleteScript();
|
||||
void onScriptSelected();
|
||||
void onImportScript();
|
||||
void onEnaDisa();
|
||||
|
||||
signals:
|
||||
void signalQuit();
|
||||
void signalSelectScript(int scriptId);
|
||||
void signalNewScript();
|
||||
void signalEditQuit();
|
||||
|
||||
private:
|
||||
PresentationManagementDialogModel *m_model { nullptr };
|
||||
PresentationManagementDialogProxyModel *m_proxy { nullptr };
|
||||
bool m_selected;
|
||||
bool m_close { false };
|
||||
bool m_isImportDialog;
|
||||
|
||||
Ui::ScriptChooser *m_ui { nullptr };
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
std::shared_ptr<PresentationManagement::Interface::Ftc> m_ftc;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
};
|
||||
|
||||
} // namespace PresentationManagement
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ScriptChooser</class>
|
||||
<widget class="QDialog" name="ScriptChooser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Select Script</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,0">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select Script:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="ltsDataView" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<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>
|
||||
<widget class="QPushButton" name="pbNewScript">
|
||||
<property name="text">
|
||||
<string>Add new Script</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbDeleteScript">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete Script</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbSelect">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbEditQuit">
|
||||
<property name="text">
|
||||
<string>Start Script Editor && Quit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbQuit">
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</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