Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
# Created by Mike Wille, SLSE, 2017-03-21
|
||||
#
|
||||
|
||||
#
|
||||
# Common
|
||||
#
|
||||
SET(pre_common_SRCS
|
||||
topic_assignment.h
|
||||
pre_model.h
|
||||
pre_model.cpp
|
||||
pre_mobile_model.h
|
||||
pre_mobile_model.cpp
|
||||
pre_edit_dialog.h
|
||||
pre_edit_dialog.cpp
|
||||
toolz.h
|
||||
toolz.cpp
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(pre_common_SRCS
|
||||
pre_edit_dialog.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY2(WS PreGuiCommon SHARED ${pre_common_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(PreGuiCommon
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
PreDataPluginInterface
|
||||
NGLLogger
|
||||
LtsUtilsGuiDds
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsScriptTimeline
|
||||
TopicReplayInterface
|
||||
ngltools
|
||||
OpmDataPluginInterface
|
||||
)
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* PresentationManagement - Script Create / Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-20
|
||||
*/
|
||||
|
||||
#include "pre_edit_dialog.h"
|
||||
#include "ui_pre_edit_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <PresentationManagement/pre_translation.h>
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
PresentationEditDialog::PresentationEditDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsFramelessDialog(parent, LtsWidgets::Behaviour::Modal)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_opmDtc(nullptr)
|
||||
, m_presentationId(-1)
|
||||
, m_ui(new Ui::PresentationEditDialog)
|
||||
, m_logger(getLogger("PresentationEditDialog"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "PresentationEditDialog ctor";
|
||||
// setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint | Qt::Dialog); // hints..
|
||||
|
||||
m_ui->setupUi(this);
|
||||
setWindowFlags( Qt::Dialog | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint ); // hints..
|
||||
|
||||
connect(m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, this, &PresentationEditDialog::close);
|
||||
|
||||
connect(m_ui->leName, &QLineEdit::textChanged, this, &PresentationEditDialog::validate);
|
||||
connect(m_ui->leName, &QLineEdit::returnPressed, this, &PresentationEditDialog::onReturnPressed);
|
||||
|
||||
// TODO: undo this all:
|
||||
m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Apply)->hide();
|
||||
m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Ok)->hide();
|
||||
|
||||
m_ui->ltsDialogButtonBox->setText(LtsWidgets::DialogButton::Add, tr("OK"));
|
||||
m_ui->ltsDialogButtonBox->connectButton(LtsWidgets::DialogButton::Add, this, &PresentationEditDialog::onSavePresentation,
|
||||
Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
PresentationEditDialog::~PresentationEditDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool PresentationEditDialog::init(int presentationId,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "PresentationEditDialog::init";
|
||||
m_presentationId = presentationId;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_opmDtc = opmDtc;
|
||||
|
||||
m_ui->lblFileStatus->setVisible(false);
|
||||
m_ui->leFileStatus->setVisible(false);
|
||||
|
||||
m_ui->lblLastModified->setVisible(false);
|
||||
m_ui->leLastModified->setVisible(false);
|
||||
|
||||
m_ui->lblOperator->setVisible(false);
|
||||
m_ui->leOperator->setVisible(false);
|
||||
|
||||
if (m_presentationId > 0) //edit
|
||||
{
|
||||
PresentationManagement::Presentation p = m_dtc->presentation(m_presentationId);
|
||||
m_ui->leName->setText(QString::fromStdString(p.name()));
|
||||
m_ui->teDesc->setText(QString::fromStdString(p.description()));
|
||||
|
||||
m_ui->lblFileStatus->setVisible(true);
|
||||
m_ui->leFileStatus->setVisible(true);
|
||||
|
||||
m_ui->lblLastModified->setVisible(true);
|
||||
m_ui->leLastModified->setVisible(true);
|
||||
|
||||
m_ui->lblOperator->setVisible(true);
|
||||
m_ui->leOperator->setVisible(true);
|
||||
|
||||
m_ui->leOperator->setText(QString::fromStdString(m_opmDtc->user(p.operatorId()).name()));
|
||||
m_ui->leLastModified->setText(DTG::toStringMSec(p.lastModified()));
|
||||
m_ui->leFileStatus->setText(PresentationManagement::toString(p.fileStatus()));
|
||||
|
||||
}
|
||||
m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Add)->setDisabled(m_ui->leName->text().isEmpty());
|
||||
|
||||
//touchable
|
||||
#ifdef TABLET_MODE
|
||||
m_ui->leName->setFocusPolicy(Qt::ClickFocus);
|
||||
m_ui->teDesc->setFocusPolicy(Qt::ClickFocus);
|
||||
#else
|
||||
m_ui->leName->setFocus();
|
||||
#endif
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PresentationEditDialog::validate(const QString &fileName)
|
||||
{
|
||||
m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Add)->setDisabled(fileName.isEmpty());
|
||||
}
|
||||
|
||||
void PresentationEditDialog::onReturnPressed()
|
||||
{
|
||||
if (m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Add)->isEnabled())
|
||||
m_ui->ltsDialogButtonBox->getButton(LtsWidgets::DialogButton::Add)->setFocus();
|
||||
}
|
||||
|
||||
void PresentationEditDialog::onSavePresentation()
|
||||
{
|
||||
if (apply())
|
||||
close();
|
||||
}
|
||||
|
||||
bool PresentationEditDialog::apply()
|
||||
{
|
||||
PresentationModifyRequest req;
|
||||
req.id(m_presentationId);
|
||||
req.name(m_ui->leName->text().toStdString());
|
||||
req.description(m_ui->teDesc->toPlainText().toStdString());
|
||||
req.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
|
||||
req.lastModified(QDateTime::currentMSecsSinceEpoch());
|
||||
req.fileStatus(FileStatus::Valid);
|
||||
|
||||
try
|
||||
{
|
||||
if (m_presentationId > 0) // first request already saved content
|
||||
{
|
||||
auto reply(m_ftc->getPresentationContentRequest(GetPresentationContentRequest(m_presentationId)));
|
||||
|
||||
m_content = reply.content();
|
||||
if (m_content.empty())
|
||||
{
|
||||
throw std::runtime_error(QStringLiteral("No content for presentation with id %1").arg(reply.id()).toStdString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "Content size = " << m_content.size() << " for presentationId: " << m_presentationId;
|
||||
req.content(m_content);
|
||||
|
||||
m_presentationId = m_ftc->presentationModifyRequest(req);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Failed to save the script. Please try again later."));
|
||||
return false;
|
||||
}
|
||||
|
||||
emit newScript(m_presentationId);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace PresentationManagement
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* PresentationManagement - Script Create / Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Services/PresentationManagement/logger.h>
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <Services/PresentationManagement/pre_dtc.h>
|
||||
#include <Services/PresentationManagement/pre_ftc.h>
|
||||
#include <Services/OperatorManagement/opm_dtc.h>
|
||||
#include <Plugins/PresentationManagement/Gui/Common/preguicommon_export.h>
|
||||
|
||||
namespace LtsWidgets
|
||||
{
|
||||
class UiRequirementList;
|
||||
}
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class PresentationEditDialog;
|
||||
}
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
|
||||
class PREGUICOMMON_EXPORT PresentationEditDialog : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PresentationEditDialog(QWidget *parent = nullptr);
|
||||
~PresentationEditDialog();
|
||||
|
||||
bool init(int presentationId,
|
||||
const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc);
|
||||
|
||||
signals:
|
||||
void newScript(int scriptId);
|
||||
|
||||
private slots:
|
||||
void onSavePresentation();
|
||||
void validate(const QString &fileName);
|
||||
void onReturnPressed();
|
||||
|
||||
private:
|
||||
bool apply();
|
||||
|
||||
std::shared_ptr<Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
int m_presentationId;
|
||||
std::vector<PresentationManagement::PresentationContent> m_content;
|
||||
Ui::PresentationEditDialog *m_ui;
|
||||
LOGGER_T m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PresentationEditDialog</class>
|
||||
<widget class="QWidget" name="PresentationEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>662</width>
|
||||
<height>290</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Presentation Editor</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblName">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leName"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblDesc">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QTextEdit" name="teDesc"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lblOperator">
|
||||
<property name="text">
|
||||
<string>Operator:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="leOperator">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lblLastModified">
|
||||
<property name="text">
|
||||
<string>Last modified:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="leLastModified">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lblFileStatus">
|
||||
<property name="text">
|
||||
<string>File Status:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="leFileStatus">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LtsWidgets::LtsDialogButtonBox" name="ltsDialogButtonBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsDialogButtonBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsWidgets/lts_dialog_button_box.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* PresentationManangement - Script Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-15
|
||||
*/
|
||||
|
||||
#include "pre_mobile_model.h"
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
PreMobileDialogModel::PreMobileDialogModel(QObject *parent)
|
||||
: PresentationManagementDialogModel(parent)
|
||||
, m_logger(getLogger("PreMobileDialogModel"))
|
||||
{
|
||||
//m_vecColumns.append(tr("Download"));
|
||||
m_checkboxColumn = 1;
|
||||
}
|
||||
|
||||
|
||||
PreMobileDialogModel::~PreMobileDialogModel()
|
||||
{}
|
||||
|
||||
QVariant PreMobileDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role == Qt::CheckStateRole &&
|
||||
index.column() == m_checkboxColumn &&
|
||||
indexIsValid(index))
|
||||
{
|
||||
if (m_vecDownload.size() <= index.row())
|
||||
return Qt::Unchecked;
|
||||
return m_vecDownload.at(index.row()) ? Qt::Checked : Qt::Unchecked;
|
||||
}
|
||||
|
||||
return PresentationManagementDialogModel::data(index, role);
|
||||
}
|
||||
|
||||
bool PreMobileDialogModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
Q_UNUSED(value);
|
||||
if (role == Qt::CheckStateRole)
|
||||
{
|
||||
switchCheckbox(index);
|
||||
emit checkboxClicked();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PreMobileDialogModel::switchCheckbox(const QModelIndex &index)
|
||||
{
|
||||
if (m_vecDownload.size() <= index.row())
|
||||
m_vecDownload.resize(index.row() + 1);
|
||||
|
||||
m_vecDownload[index.row()] = !m_vecDownload.at(index.row());
|
||||
emit dataChanged(index, index, {Qt::CheckStateRole});
|
||||
}
|
||||
|
||||
Qt::ItemFlags PreMobileDialogModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
Qt::ItemFlags flags(PresentationManagementDialogModel::flags(index) & ~Qt::ItemIsSelectable);
|
||||
if (index.column() == m_checkboxColumn)
|
||||
flags.setFlag(Qt::ItemIsUserCheckable);
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
QVector<int> PreMobileDialogModel::getDownloadedScriptIds() const
|
||||
{
|
||||
QVector<int> ret;
|
||||
|
||||
for (int i = 0; i < m_vecData.size(); ++i)
|
||||
{
|
||||
const Presentation &p = m_vecData.at(i);
|
||||
|
||||
if (m_vecDownload.size() <= i) // lazy init in switchCheckBox
|
||||
break;
|
||||
if (m_vecDownload.at(i))
|
||||
ret.push_back(p.id());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace PresentationManagement
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* PresentationManangement - Script Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-15
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Services/PresentationManagement/logger.h>
|
||||
#include <Plugins/PresentationManagement/Gui/Common/preguicommon_export.h>
|
||||
|
||||
#include <Plugins/PresentationManagement/Gui/Common/pre_model.h>
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
|
||||
class PREGUICOMMON_EXPORT PreMobileDialogModel : public PresentationManagementDialogModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PreMobileDialogModel(QObject *parent = nullptr);
|
||||
~PreMobileDialogModel();
|
||||
|
||||
QVariant data(const QModelIndex &, int) const override final;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
|
||||
QVector<int> getDownloadedScriptIds() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void checkboxClicked();
|
||||
protected:
|
||||
void switchCheckbox(const QModelIndex &index);
|
||||
private:
|
||||
friend class PreMobileDialogProxyModel;
|
||||
|
||||
QVector<bool> m_vecDownload;
|
||||
|
||||
int m_checkboxColumn;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
}
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* PresentationManangement - Script Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-15
|
||||
*/
|
||||
|
||||
#include "pre_model.h"
|
||||
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <PresentationManagement/pre_translation.h>
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QPalette>
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
PresentationManagementDialogModel::PresentationManagementDialogModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<Presentation>({tr("Id"),
|
||||
tr("Name"),
|
||||
tr("Description"),
|
||||
tr("Operator"),
|
||||
tr("LastModified"),
|
||||
tr("Status")},
|
||||
parent)
|
||||
, m_logger(getLogger("PresentationManagementDialogModel"))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PresentationManagementDialogModel::~PresentationManagementDialogModel()
|
||||
{}
|
||||
|
||||
|
||||
bool PresentationManagementDialogModel::initModel(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
const std::function<bool(const Presentation &)> &predicate)
|
||||
{
|
||||
m_opmDtc = opmDtc;
|
||||
m_predicate = predicate;
|
||||
connect(dtc.get(), &Interface::Dtc::presentationChanged,
|
||||
this, &PresentationManagementDialogModel::onDataChanged);
|
||||
dtc->presentations([this](const Presentation &p) { insertRow(p); m_scriptUsers.append(p.operatorId()); });
|
||||
|
||||
|
||||
QMap<qint32, OperatorManagement::User> users = opmDtc->users();
|
||||
m_users.clear();
|
||||
for (auto it = users.constBegin(); it != users.constEnd(); ++it)
|
||||
{
|
||||
if (m_scriptUsers.contains(it->id()))
|
||||
m_users.insert(static_cast<int>(it.value().id()), QString::fromStdString(it.value().name()));
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "initModel - #presentations: " << m_vecData.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QVariant PresentationManagementDialogModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role == LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole &&
|
||||
orientation == Qt::Horizontal &&
|
||||
section == Columns::Operator)
|
||||
{
|
||||
LtsWidgets::ComboboxFilterContent cfc;
|
||||
cfc.data.reserve(m_users.size());
|
||||
LtsWidgets::ComboboxFilterData cfd;
|
||||
for (auto it = m_users.constBegin(); it != m_users.constEnd(); ++it)
|
||||
{
|
||||
cfd.data = it.key();
|
||||
cfd.text = it.value();
|
||||
cfc.data.push_back(cfd);
|
||||
}
|
||||
cfc.sortItems = true;
|
||||
return cfc.toVariant();
|
||||
}
|
||||
else
|
||||
return LtsAbstractTableModel::headerData(section, orientation, role);
|
||||
}
|
||||
|
||||
QVariant PresentationManagementDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if ((role != Qt::DisplayRole && role != Qt::BackgroundRole && role != LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole) ||
|
||||
!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const PresentationManagement::Presentation &pre = m_vecData.at(index.row());
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (pre.fileStatus() == PresentationManagement::FileStatus::Deleted)
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase);
|
||||
return QGuiApplication::palette().color(QPalette::Active, QPalette::Base);
|
||||
}
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return pre.id();
|
||||
case Name:
|
||||
return QString::fromStdString(pre.name());
|
||||
case Description:
|
||||
return QString::fromStdString(pre.description());
|
||||
case Operator:
|
||||
return QString::fromStdString(m_opmDtc->user(pre.operatorId()).name());
|
||||
case LastModified:
|
||||
return QDateTime::fromMSecsSinceEpoch(pre.lastModified());
|
||||
case Status:
|
||||
return PresentationManagement::toString(pre.fileStatus());
|
||||
}
|
||||
}
|
||||
|
||||
if (role == LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case Columns::Operator:
|
||||
return pre.operatorId();
|
||||
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void PresentationManagementDialogProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast< PresentationManagementDialogModel*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool PresentationManagementDialogProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
{
|
||||
if (!m_sourceModel ||
|
||||
source_left.column() != source_right.column() ||
|
||||
!source_left.isValid() ||
|
||||
!source_right.isValid())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
|
||||
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
|
||||
switch (source_left.column())
|
||||
{
|
||||
case PresentationManagementDialogModel::LastModified:
|
||||
return dataLeft.lastModified() < dataRight.lastModified();
|
||||
case PresentationManagementDialogModel::Id:
|
||||
case PresentationManagementDialogModel::Name:
|
||||
case PresentationManagementDialogModel::Description:
|
||||
case PresentationManagementDialogModel::Operator:
|
||||
|
||||
case PresentationManagementDialogModel::Status:
|
||||
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
|
||||
} // namespace PresentationManagement
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* PresentationManangement - Script Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-03-15
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Services/PresentationManagement/pre_dtc.h>
|
||||
#include <Services/PresentationManagement/logger.h>
|
||||
#include <Plugins/PresentationManagement/Gui/Common/preguicommon_export.h>
|
||||
#include <Services/OperatorManagement/opm_dtc.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
|
||||
class PREGUICOMMON_EXPORT PresentationManagementDialogModel : public LtsWidgets::LtsAbstractTableModel<Presentation>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id = 0,
|
||||
Name,
|
||||
Description,
|
||||
Operator,
|
||||
LastModified,
|
||||
Status
|
||||
};
|
||||
|
||||
explicit PresentationManagementDialogModel(QObject *parent = nullptr);
|
||||
~PresentationManagementDialogModel();
|
||||
|
||||
bool initModel(const std::shared_ptr<Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
|
||||
const std::function<bool(const Presentation &)> &predicate);
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||
QVariant data(const QModelIndex &, int) const override;
|
||||
|
||||
protected:
|
||||
bool isFiltered(const Presentation &data, DataModification modType) const override
|
||||
{
|
||||
if (!m_predicate(data))
|
||||
return true;
|
||||
return LtsWidgets::LtsAbstractTableModel<Presentation>::isFiltered(data, modType);
|
||||
}
|
||||
private:
|
||||
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
|
||||
std::function<bool(const Presentation &)> m_predicate;
|
||||
friend class PresentationManagementDialogProxyModel;
|
||||
|
||||
QMap<int, QString> m_users;
|
||||
QVector <int> m_scriptUsers;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
|
||||
class PREGUICOMMON_EXPORT PresentationManagementDialogProxyModel final : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
private:
|
||||
PresentationManagementDialogModel *m_sourceModel = nullptr;
|
||||
};
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#include "toolz.h"
|
||||
|
||||
#include <LtsScriptTimeline/script_timeline.h>
|
||||
#include <LtsScriptTimeline/track_widget.h>
|
||||
#include <LtsScriptTimeline/track_content_widget.h>
|
||||
#include <LtsScriptTimeline/track_entry_painters.h>
|
||||
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
void prepareScriptTimeline(LtsScriptTimeline::ScriptTimeline *scriptTimeline, const QString &screen1Text, const QString &screen2Text, const QString &replayText, const QString &audioText)
|
||||
{
|
||||
LtsScriptTimeline::TrackWidget *twScreen2 = scriptTimeline->addTrack(screen2Text);
|
||||
twScreen2->setInternalName(QStringLiteral("Screen 2"));
|
||||
twScreen2->getTrackContentWidget()->addDisallowedType(LtsScriptTimeline::TrackEntryType::SituationReplay);
|
||||
twScreen2->getTrackContentWidget()->addDisallowedType(LtsScriptTimeline::TrackEntryType::Snapshot);
|
||||
twScreen2->getTrackContentWidget()->addDisallowedType(LtsScriptTimeline::TrackEntryType::Audio);
|
||||
|
||||
|
||||
LtsScriptTimeline::TrackWidget *twScreen1 = scriptTimeline->addTrack(screen1Text);
|
||||
twScreen1->setInternalName(QStringLiteral("Screen 1"));
|
||||
twScreen1->getTrackContentWidget()->addDisallowedType(LtsScriptTimeline::TrackEntryType::SituationReplay);
|
||||
twScreen1->getTrackContentWidget()->addDisallowedType(LtsScriptTimeline::TrackEntryType::Snapshot);
|
||||
twScreen1->getTrackContentWidget()->addDisallowedType(LtsScriptTimeline::TrackEntryType::Audio);
|
||||
|
||||
|
||||
// Give both trackwidgets knowledge of each other which allows detecting collisions on both TrackEntryWidgets
|
||||
twScreen1->addCorrespondingTrackWidget(twScreen2->getTrackContentWidget());
|
||||
twScreen2->addCorrespondingTrackWidget(twScreen1->getTrackContentWidget());
|
||||
|
||||
|
||||
LtsScriptTimeline::TrackWidget *twReplay = scriptTimeline->addTrack(replayText, false);
|
||||
twReplay->setInternalName(QStringLiteral("Replay"));
|
||||
twReplay->getTrackContentWidget()->addAllowedType(LtsScriptTimeline::TrackEntryType::SituationReplay);
|
||||
twReplay->getTrackContentWidget()->addAllowedType(LtsScriptTimeline::TrackEntryType::Snapshot);
|
||||
twReplay->getTrackContentWidget()->addDisallowedType(LtsScriptTimeline::TrackEntryType::Audio);
|
||||
|
||||
// add replay to screens and vice versa
|
||||
twScreen1->addCorrespondingTrackWidget(twReplay->getTrackContentWidget());
|
||||
twScreen2->addCorrespondingTrackWidget(twReplay->getTrackContentWidget());
|
||||
twReplay->addCorrespondingTrackWidget(twScreen1->getTrackContentWidget());
|
||||
twReplay->addCorrespondingTrackWidget(twScreen2->getTrackContentWidget());
|
||||
|
||||
|
||||
LtsScriptTimeline::TrackWidget *twAudio = scriptTimeline->addTrack(audioText, false);
|
||||
twAudio->setInternalName(QStringLiteral("Audio"));
|
||||
twAudio->getTrackContentWidget()->addAllowedType(LtsScriptTimeline::TrackEntryType::Audio);
|
||||
}
|
||||
} // namespace PresentationManagement
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <Plugins/PresentationManagement/Gui/Common/preguicommon_export.h>
|
||||
#include <QString>
|
||||
|
||||
|
||||
namespace LtsScriptTimeline
|
||||
{
|
||||
class ScriptTimeline;
|
||||
class TrackEntry;
|
||||
}
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
PREGUICOMMON_EXPORT void prepareScriptTimeline(LtsScriptTimeline::ScriptTimeline *scriptTimeline, const QString &screen1Text, const QString &screen2Text, const QString &replayText, const QString &audioText);
|
||||
} // namespace PresentationManagement
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Topic Assignment Class
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Mike Wille, SLSE, 2017-04-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <TopicEditorBase/topic_editor_utils.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace TopicReplay { class Factory; }
|
||||
namespace TopicEditorBase { class Interface; }
|
||||
|
||||
|
||||
namespace PresentationManagement
|
||||
{
|
||||
|
||||
struct TopicAssignment
|
||||
{
|
||||
QString topicName;
|
||||
TopicEditorBase::TopicType topicType;
|
||||
std::shared_ptr<TopicEditorBase::Interface> topicEditorIfc; // Script Editor
|
||||
std::shared_ptr<TopicReplay::Factory> topicReplayFactory; // Script Player
|
||||
std::shared_ptr<TopicReplay::Factory> topicExportFactory; // Export Script
|
||||
};
|
||||
|
||||
} // namespace PresentationManagements
|
||||
Reference in new issue
Block a user