remove all unneeded module listed from Niklas

This commit is contained in:
berrux-dev committed 2026-09-14 21:15:42 +02:00
1 parent be912de9d6
commit 92ad7d4686
895 files changed
-327561

No files matched your search

@@ -1,91 +0,0 @@
#
# $Id$
# $HeadURL$
# $Author$
#
# Created by Mike Wille, SLSE, 2016-03-17
#
# Make ${Qt6_Widgets} optional
if(QT6_GUI_AVAILABLE AND TARGET Qt6::Widgets)
set(Qt6_Widgets ${Qt6_Widgets})
else()
set(Qt6_Widgets "")
endif()
SET(pre_script_gui_SRCS
pre_script_gui_plugin.cpp
pre_script_gui_plugin.h
pre_script_dialog.h
pre_script_dialog.cpp
pre_storyboard.cpp
pre_storyboard.h
pre_journal_types.h
pre_journal_types.cpp
pre_journal_dialog.h
pre_journal_dialog.cpp
pre_screen.h
pre_screen.cpp
filter_topic.h
filter_topic.cpp
)
QT5_WRAP_UI(pre_script_gui_SRCS
pre_storyboard.ui
pre_script_dialog.ui
pre_journal_dialog.ui
)
NGL_ADD_LIBRARY(WS PreScriptGuiPlugin MODULE ${pre_script_gui_SRCS})
if(QT6_GUI_AVAILABLE)
NGL_TARGET_LINK_LIBRARIES(PreScriptGuiPlugin
NGLLogger
LtsSession
PreDataPluginInterface
PrePresentationGuiPluginInterface
PreGuiCommon
PreGuiScriptCommon
svcPreCommon
${Qt6_Widgets}
LtsWidgets
LtsDataView
LtsUtilsGuiDds
LtsSessionData
ProjectConfig
LtsScriptTimeline
LtsMultiMonitor
LtsAppManager # start replay app
LtsSessionData # set partition preset for replay app
TopicEditorInterface
TopicEditorBase
LtsPluginManager # manipulate apps
# for Topics
EvlGuiPluginInterface
SrmDataPluginInterface # start playback
LtsPrinting
SituationMapGuiPluginInterface
# Script Player Controls:
SrpGuiPluginInterface
# file topic
FlmExplorerGuiPluginInterface
# building topic
BdvViewerGuiPluginInterface
# report topic
RepGuiPluginInterface
LtsReportDisplay
MrkCommon # for ApplyFilter @ SitmapFilter
LtsUtilsSettings
ngltools # DTG
situationMap # set time string on map
ExportBdvTopicSetting
)
endif()
NGL_INSTALL_TARGET(PreScriptGuiPlugin)
@@ -1,17 +0,0 @@
#include "filter_topic.h"
namespace PresentationManagement
{
FilterTopic::~FilterTopic()
{
}
FilterTopic::FilterTopic(const FilterTopic &other)
{
mainTopicId = other.mainTopicId;
filterTopic = other.filterTopic;
}
}
@@ -1,28 +0,0 @@
#pragma once
#include <LtsScriptTimeline/track_entry.h>
namespace PresentationManagement
{
class FilterTopic
{
public:
FilterTopic()
: mainTopicId(-1)
, filterTopic(nullptr)
{}
FilterTopic(int _mainTopicId, LtsScriptTimeline::TrackEntry *_filterTopic)
: mainTopicId(_mainTopicId)
, filterTopic(_filterTopic)
{}
FilterTopic(const FilterTopic &other);
~FilterTopic();
int mainTopicId;
LtsScriptTimeline::TrackEntry *filterTopic;
};
}
@@ -1,82 +0,0 @@
#include "pre_journal_dialog.h"
#include <utility>
#include "ui_pre_journal_dialog.h"
#include <LtsPrinting/printing.h>
namespace PresentationManagement
{
JournalDialog::JournalDialog(LtsSession::LtsSession *session, QWidget *parent)
: LtsWidgets::LtsDialog(parent)
, m_ui(new Ui::JournalDialog)
, m_journal(nullptr)
, m_session(session)
{
m_ui->setupUi(this);
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &JournalDialog::slotPrint);
}
JournalDialog::~JournalDialog()
{
delete m_ui;
}
void JournalDialog::slotPrint()
{
LtsPrinting::printView(m_session, this, m_ui->listWidget);
}
bool JournalDialog::init(MainJournal *journal)
{
m_journal = journal;
return true;
}
void JournalDialog::retranslate()
{
translate(m_ui, tr("Script Journal"));
fillJournal();
}
void JournalDialog::fillJournal()
{
m_ui->listWidget->clear();
if (!m_journal)
return;
m_ui->listWidget->addItem(m_journal->getText());
for (const Journal *j : std::as_const(m_journal->journalList))
m_ui->listWidget->addItem(j->getText());
}
}
@@ -1,37 +0,0 @@
#pragma once
#include "pre_journal_types.h"
#include <LtsWidgets/lts_dialog.h>
#include <LtsSession/lts_session.h>
namespace Ui
{
class JournalDialog;
}
namespace PresentationManagement
{
class JournalDialog : public LtsWidgets::LtsDialog
{
Q_OBJECT
public:
explicit JournalDialog(LtsSession::LtsSession *session, QWidget *parent);
~JournalDialog();
bool init(MainJournal *journal);
void retranslate() override final;
private slots:
void slotPrint();
private:
void fillJournal();
Ui::JournalDialog *m_ui;
MainJournal *m_journal;
LtsSession::LtsSession *m_session;
};
}
@@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>JournalDialog</class>
<widget class="QWidget" name="JournalDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>707</width>
<height>464</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Script Editor</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>9</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QListWidget" name="listWidget">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -1,90 +0,0 @@
#include "pre_journal_types.h"
#include <QtCore/QDateTime>
#include <ngltools/ngltools_dtg.h>
namespace PresentationManagement
{
QString ttt(qint64 msecsSinceEpoch)
{
return DTG::toStringMSec(msecsSinceEpoch);
}
QString pttt(int presentationTime)
{
return QTime::fromMSecsSinceStartOfDay(presentationTime * 1000).toString();
}
Journal::Journal()
: m_started(QDateTime::currentMSecsSinceEpoch())
{}
QString Journal::started() const
{
return ttt(m_started);
}
MainJournal::~MainJournal()
{
qDeleteAll(journalList);
}
QString MainJournal::getText() const
{
return Journal::tr("Script Player started on %1").arg(ttt(started));
}
NextTopicJournal::NextTopicJournal(int presentationTime, bool isFilter, const QString &topicTypeName, int length)
: Journal()
, m_isFilter(isFilter)
, m_topicTypeName(topicTypeName)
, m_length(length)
, m_presentationTime(presentationTime)
{}
QString NextTopicJournal::getText() const
{
return Journal::tr("%1 '%2' started at %3 for %4 seconds on %5").arg(m_isFilter ? tr("FilterTopic") : tr("Topic"),
m_topicTypeName, pttt(m_presentationTime)).arg(m_length).arg(started());
}
QString PlayJournal::getText() const
{
return Journal::tr("Started / resumed script at %1 on %2").arg(pttt(m_presentationTime), started());
}
QString PauseJournal::getText() const
{
return Journal::tr("Paused script at %1 on %2").arg(pttt(m_presentationTime), started());
}
QString EndedJournal::getText() const
{
return Journal::tr("Script ended at %1 on %2").arg(pttt(m_presentationTime), started());
}
QString StopJournal::getText() const
{
return Journal::tr("Script stopped at %1 on %2").arg(pttt(m_presentationTime), started());
}
QString SetTimeJournal::getText() const
{
return Journal::tr("Position time set to %1 on %2").arg(pttt(m_toPresentationTime), started());
}
}
@@ -1,131 +0,0 @@
#pragma once
#include <QtCore/QCoreApplication>
#include <QtCore/QVector>
namespace PresentationManagement
{
class Journal
{
Q_DECLARE_TR_FUNCTIONS(Journal)
public:
Journal();
virtual ~Journal() = default;
QString started() const;
virtual QString getText() const = 0;
qint64 m_started;
};
class MainJournal
{
public:
~MainJournal();
QString getText() const;
qint64 started = 0;
QVector<Journal *> journalList;
};
class NextTopicJournal : public Journal
{
public:
NextTopicJournal(int presentationTime, bool isFilter, const QString &topicTypeName, int length);
QString getText() const override final;
bool m_isFilter;
QString m_topicTypeName;
int m_length;
int m_presentationTime;
};
class PlayJournal : public Journal
{
public:
explicit PlayJournal(int presentationTime)
: Journal()
, m_presentationTime(presentationTime)
{}
QString getText() const override final;
int m_presentationTime;
};
class PauseJournal : public Journal
{
public:
explicit PauseJournal(int presentationTime)
: Journal()
, m_presentationTime(presentationTime)
{}
QString getText() const override final;
int m_presentationTime;
};
class EndedJournal : public Journal
{
public:
explicit EndedJournal(int presentationTime)
: Journal()
, m_presentationTime(presentationTime)
{}
QString getText() const override final;
int m_presentationTime;
};
class StopJournal : public Journal
{
public:
explicit StopJournal(int presentationTime)
: Journal()
, m_presentationTime(presentationTime)
{}
QString getText() const override final;
int m_presentationTime;
};
class SetTimeJournal : public Journal
{
public:
explicit SetTimeJournal(int toPresentationTime)
: Journal()
, m_toPresentationTime(toPresentationTime)
{}
QString getText() const override final;
int m_toPresentationTime;
};
}
@@ -1,35 +0,0 @@
#include "pre_screen.h"
#include <QStyleOption>
#include <QtGui/QPainter>
Screen::Screen()
: QWidget()
{
setBgColor(QColor("black"));
setContentsMargins(0, 0, 0, 0);
}
Screen::~Screen()
{
const auto p1Widgets = findChildren<QWidget *>(QString(), Qt::FindDirectChildrenOnly);
for (QWidget *w : p1Widgets)
w->setParent(nullptr);
}
void Screen::setBgColor(const QColor &color)
{
setStyleSheet(QStringLiteral("Screen { background: %1; background-color: %1; }").arg(color.name()));
}
void Screen::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
@@ -1,18 +0,0 @@
#pragma once
#include <QtWidgets/QWidget>
class Screen : public QWidget
{
Q_OBJECT
public:
Screen();
virtual ~Screen();
void setBgColor(const QColor &color);
private:
void paintEvent(QPaintEvent *) override;
};
@@ -1,392 +0,0 @@
#pragma once
#include "pre_screen.h"
#include "pre_journal_types.h"
#include "pre_storyboard.h"
#include "filter_topic.h"
#include <Core/core_dtc.h>
#include <PluginInterfaces/topic_replay_interface.h>
#include <LtsPluginManager/lts_plugin_manager.h>
#include <LtsWidgets/lts_dialog.h>
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
#include <LtsScriptTimeline/track_entry_painters.h>
#include <LtsScriptTimeline/temporary_pointer_vector.h>
#include <LtsSession/lts_session.h>
#include <PresentationManagement/Common/topic_assignment.h>
#include <PresentationManagement/pre_dtc.h>
#include <PresentationManagement/pre_ftc.h>
#include <PresentationManagement/logger.h>
#include <SituationReplayManagement/srm_ftc.h>
#include <OperatorManagement/opm_dtc.h>
#include <SituationReplay/srp_gui_plugin_interface.h>
#include <SituationMapPlugin/situation_map_gui_plugin_interface.h>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QMap>
#include <functional>
#include <memory>
namespace TakeHomePackageGenerator
{
class ExportProcess;
}
namespace Ui
{
class ScriptDialog;
}
namespace LtsScriptTimeline
{
class TrackEntry;
}
namespace SituationReplayManagement
{
class ForeignDataInterface;
}
namespace LtsPluginManager
{
class LtsPluginManager;
}
namespace Ui
{
class ScriptPlayerDialog;
}
namespace LtsScriptTimeline
{
class TrackEntry;
}
namespace LtsUtils
{
class Promise;
}
namespace PresentationManagement
{
class TopicDesigner;
namespace Interface
{
class Ftc;
}
class ScriptDialog : public LtsWidgets::LtsDialog
, protected PresentationManagement::Interface::Ftc::PresentationModifyReplyHandler
, protected PresentationManagement::Interface::Ftc::GetPresentationContentReplyHandler
, protected SituationReplayManagement::Interface::Ftc::ReplayPartitionCreateReplyHandler
, protected SituationReplayManagement::Interface::Ftc::ReplayPartitionRemoveReplyHandler
{
public:
Q_OBJECT
public:
explicit ScriptDialog(const QString &menuGroup, QWidget *parent = nullptr);
~ScriptDialog();
LtsSession::LtsSession *eVSession() { return m_essentialsViewSession; }
bool init(LtsSession::LtsSession *session,
const int scriptId,
const std::shared_ptr<Interface::Dtc> &dtc,
const std::shared_ptr<Interface::Ftc> &ftc,
const std::shared_ptr<SituationReplayManagement::ForeignDataInterface> &srmForeign,
const std::shared_ptr<Core::Interface::Dtc> &coreDtc,
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc);
void loadScript();
TopicEditorBase::TopicEditor *createTopic(const TopicAssignment &ta);
TopicEditorBase::TopicEditor *createTopic(const LtsScriptTimeline::TrackEntry &data);
void createTopicFromTrackEntry(LtsScriptTimeline::TrackEntry *data);
bool topicStringToType(const QString &typeName, LtsScriptTimeline::TrackEntryType &tet) const;
int getCurrentScriptEndTime() const;
bool isEssentialsViewOpened() const;
static LtsScriptTimeline::TrackEntry *trackEntryFromContent(const PresentationManagement::PresentationContent &content,
int topicId,
LtsScriptTimeline::TrackEntryType trackType);
bool importTrackEntries(const QVector<LtsScriptTimeline::TrackEntry *> &tes);
std::shared_ptr<SituationReplay::ForeignGuiInterface> getReplayGuiIfc() const
{
return m_essentialsViewsSrpGuiIfc;
}
private:
enum class ProjectionWidget
{
Unknown = 0,
Screen1,
Screen2,
};
enum class SpecialTopicType
{
NonSpecial = 0,
ReplayTopic,
FilterTopic,
};
class PlayingTopic
{
public:
PlayingTopic() = default;
~PlayingTopic()
{
if (topicReplayIfc != nullptr)
{
topicReplayIfc->playbackStop();
delete topicReplayIfc;
}
}
QString topicTypeName;
LtsScriptTimeline::TrackEntry *topic = nullptr;
TopicReplay::Interface *topicReplayIfc = nullptr;
QWidget *replayWidget = nullptr;
LtsScriptTimeline::TrackEntryType trackEntryType = LtsScriptTimeline::TrackEntryType::INVALID;
bool isFilter = false;
};
void onPresentationModifyReply(const Core::FunctionReplyObject &replyObject) override { if (m_requestHelper != nullptr) m_requestHelper->requestReply(replyObject); }
void onGetPresentationContentReply(const GetPresentationContentReply &reply) override { if (m_requestHelper != nullptr) m_requestHelper->requestReply(reply); }
void onReplayPartitionCreateReply(const Core::FunctionReplyObject &reply) override { if (m_requestHelper != nullptr) m_requestHelper->requestReply(reply); }
void onReplayPartitionRemoveReply(const Core::FunctionReplyObject &) override { }
void retranslate() override;
bool apply() override;
void aboutToClose() override;
void getPresentationContent();
TopicEditorBase::TopicEditor *createTopicEditor(LtsScriptTimeline::TrackEntry *te);
bool topicTypeOnEssentialsView(LtsScriptTimeline::TrackEntryType tet) const;
void startEssentialsViewStage2(const Core::ReplayPartition &replay);
bool tryAddTopics(QStringList &resultList);
void fillTopicVector();
void createSitMapApp();
void startReplaySession();
void exportPresentationContent(const Core::FunctionReply &baseReply);
void disableSessionDialog(LtsSession::LtsSession *pSession, bool disable);
void deletePlayingTopic(PlayingTopic *playingTopic);
static QString toReadableTime(qint64 seconds);
ProjectionWidget identifyProjectionWidget(LtsScriptTimeline::TrackEntry *topic) const;
bool usesAvsWindow(LtsScriptTimeline::TrackEntryType trackEntryType) const;
void playTopic(LtsScriptTimeline::TrackEntry *topic);
bool enableFireEventFlash(bool enable);
void pausePlayingTopics();
static bool isFilter(LtsScriptTimeline::TrackEntryType tet);
void initProjectionWidget(Screen **pointerToWidgetPointer);
void deleteProjectionWidget(Screen **pointerToWidgetPointer);
bool _tryAddTopic(LtsScriptTimeline::TrackEntryType trackEntryType,
const std::shared_ptr<TopicEditorBase::Interface> &topicEditorIfc,
const std::shared_ptr<TopicReplay::Factory> &topicReplayFactory,
const std::shared_ptr<TopicReplay::Factory> &topicExportFactory,
QStringList &resultList,
const SpecialTopicType &specialTopicType = SpecialTopicType::NonSpecial);
void initFailed(int reason);
void setFreestanding(bool freestanding, const ProjectionWidget &pw);
void setReplayWidgetFreestanding(PlayingTopic *playingTopic, bool freestanding);
void printCurrentlyPlayingTopics();
void addReplayWidget(PlayingTopic *playingTopic, QWidget *replayWidget);
Screen *getProjectionWidget(const ScriptDialog::ProjectionWidget &projectionWidget);
bool isScreenFreestanding(const ProjectionWidget &pw) const;
void previewSecond(int time, int ignoreTopicForReplay = -1);
void setReplayWidgetPosition(PlayingTopic *playingTopic);
void avsFreestandingHack(bool freestanding, QWidget *projectionWidget, QWidget **parentForScreen);
void avsVisibilityHack(QWidget *parentForScreen, bool visible);
void stop(bool ended = false, bool ignoreFireEventFlashing = false);
void changelogCheck();
int previousTopicTime() const;
bool hasPreviousTopic() const { return previousTopicTime() > -1; }
int nextTopicTime() const;
bool hasNextTopic() const { return nextTopicTime() > -1; }
void setPositionTime(int positionTime, bool setByUser = false);
void setPositionTimeActive(int positionTime, bool setByUser = false);
template <typename TopicEditorInterface>
std::shared_ptr<TopicEditorBase::Interface> getTopicEditorIfc(LtsScriptTimeline::TrackEntryType trackEntryType)
{
std::shared_ptr<TopicEditorBase::Interface> topicEditorIfc;
if (!m_exerciseSession->interfaceFromGui<TopicEditorInterface>(topicEditorIfc))
{
ERROR_LOG(m_logger) << "getTopicEditorIfc failed: Cannot add topic type "
<< LtsScriptTimeline::trackEntryTypeName(trackEntryType)
<< " because topic editor ifc is missing.";
return nullptr;
}
return topicEditorIfc;
}
template <typename TopicReplayInterface>
std::shared_ptr<TopicReplay::Factory> getTopicReplayFactory(LtsScriptTimeline::TrackEntryType trackEntryType)
{
std::shared_ptr<TopicReplay::Factory> topicReplayFactory;
if (!m_replaySession->interfaceFromGui<TopicReplayInterface>(topicReplayFactory))
{
ERROR_LOG(m_logger) << "getTopicIfcFactory failed: Cannot add topic type "
<< LtsScriptTimeline::trackEntryTypeName(trackEntryType)
<< " because topic ifc factory is missing.";
return nullptr;
}
return topicReplayFactory;
}
template <typename TopicEditorGuiInterface,
typename TopicReplayFactory = TopicReplay::Factory,
typename TopicExportFactory = TopicReplayFactory>
bool tryAddTopic(LtsScriptTimeline::TrackEntryType trackEntryType,
QStringList &resultList,
const SpecialTopicType &specialTopicType = SpecialTopicType::NonSpecial)
{
std::shared_ptr<TopicEditorBase::Interface> topicEditorIfc;
std::shared_ptr<TopicReplay::Factory> topicReplayFactory;
std::shared_ptr<TopicReplay::Factory> topicExportFactory;
if (!std::is_same<TopicEditorBase::Interface, TopicEditorGuiInterface>::value)
{
topicEditorIfc = getTopicEditorIfc<TopicEditorGuiInterface>(trackEntryType);
if (topicEditorIfc == nullptr)
{
resultList.append(LtsScriptTimeline::trackEntryTypeName(trackEntryType));
return false;
}
}
if (!std::is_same<TopicReplay::Factory, TopicReplayFactory>::value)
{
topicReplayFactory = getTopicReplayFactory<TopicReplayFactory>(trackEntryType);
if (topicReplayFactory == nullptr)
{
resultList.append(LtsScriptTimeline::trackEntryTypeName(trackEntryType));
return false;
}
}
if (!std::is_same<TopicReplay::Factory, TopicExportFactory>::value)
{
topicExportFactory = getTopicReplayFactory<TopicExportFactory>(trackEntryType);
if (topicExportFactory == nullptr)
{
resultList.append(LtsScriptTimeline::trackEntryTypeName(trackEntryType));
return false;
}
}
else
topicExportFactory = topicReplayFactory;
return _tryAddTopic(trackEntryType, topicEditorIfc, topicReplayFactory, topicExportFactory, resultList, specialTopicType);
}
Ui::ScriptDialog *m_ui;
LtsSession::LtsSession *m_essentialsViewSession;
std::shared_ptr<SituationReplay::ForeignGuiInterface> m_essentialsViewsSrpGuiIfc;
std::shared_ptr<PresentationManagement::Interface::Dtc> m_dtc;
std::shared_ptr<PresentationManagement::Interface::Ftc> m_ftc;
std::shared_ptr<SituationReplayManagement::ForeignDataInterface> m_srmForeign;
std::shared_ptr<Core::Interface::Dtc> m_coreDtc;
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
QString m_menuGroup;
LtsUtils::RequestHelper *m_requestHelper;
int m_selectedTeId;
TopicEditorBase::TopicEditor *m_currentTopicEditor;
int m_scriptId;
QMap<QString, TopicAssignment> m_trackEntryAssignments;
QMap<LtsScriptTimeline::TrackEntryType, TopicAssignment> m_trackEntryToTopicAssignment;
LtsPluginManager::LtsPluginManager *m_essentialsViewApp;
QString m_scriptName;
QString m_scriptOwner;
qint64 m_lastModified = 0;
QVector<LtsScriptTimeline::TrackEntry *> m_topicVector;
QMultiMap<int, LtsScriptTimeline::TrackEntry *> m_topicMap;
QVector<FilterTopic> m_filterTopicVector;
TakeHomePackageGenerator::ExportProcess *m_exportProcess;
LtsSession::LtsSession *m_exerciseSession;
LtsSession::LtsSession *m_replaySession;
QTimer *m_presentationTimer;
int m_lowestTime;
int m_highestTime;
int m_positionTime;
int m_duration;
int m_nextPauseTime;
QVector<PlayingTopic *> m_currentlyPlayingTopics;
Screen *m_projectionWidget1;
Screen *m_projectionWidget2;
MainJournal m_journal;
int m_scriptsExerciseId;
QString m_exerciseName;
LtsPluginManager::LtsPluginManager *m_sitMapApp;
LtsSession::LtsSession *m_sitMapSession;
bool m_currentlyFreestandingTopicsScreen1;
bool m_currentlyFreestandingTopicsScreen2;
TopicReplay::Interface *m_sitMapTopicIfc;
bool m_firstPlayAfterStop;
bool m_enableApply;
bool m_stopAfterPlayingFilterTopic;
QWidget *m_previousParentForScreen1;
QWidget *m_previousParentForScreen2;
int m_ignoreTopicForReplay;
QPointer<TopicDesigner> m_currentTopicDesigner;
bool m_avsVisibilityHackActive;
QPointer<StoryboardDialog> m_storyboardDialog;
bool m_ignoreChanges;
bool m_scriptRunning;
bool m_bTimerTickRecursionGuard;
bool m_isPlayTopicMethodStillRunning;
private slots:
void slotEditEntry(const int topicId);
void slotTrackEntrySelectionChanged(LtsScriptTimeline::TrackEntry *);
void slotChangesWereMade();
void slotTrackEntryModified();
void slotNull(QObject *obj);
void slotDiscard();
void slotStartEssentialsView();
void slotLoadScript();
void slotExportScript();
void slotExportSuccessful(const QString &path, const QString &failedTopics);
void slotBurnDvD(const QString &strExportPath);
void slotBurningFinished(bool success);
void slotPlay();
void slotPause();
void slotStop();
void slotTimerTick();
void slotShowStoryboard();
void slotShowJournal();
void slotToNextTopic();
void slotToPreviousTopic();
void slotPlayUntilNextTopic();
void slotSetTopicPosition(QWidget *previewWidget, int ignoreTopicForReplay);
void slotTrackEntryDeleted(const int topicId);
void slotEditSelectedEntry();
void slotCheckNewTopicLength(int newLength, LtsUtils::Promise *promise);
void slotAddFakeLegacyPlanTopic();
void slotChangesMade();
};
}
@@ -1,320 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ScriptDialog</class>
<widget class="QWidget" name="ScriptDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1010</width>
<height>587</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Script Editor</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="999,0">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="LtsScriptTimeline::ScriptTimeline" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="replayControls">
<property name="title">
<string>Replay Controls</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QWidget" name="replayControlsWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,999">
<item>
<layout class="QHBoxLayout" name="replayControlsLayout">
<item>
<layout class="QVBoxLayout" name="replayControlsMainLayout">
<item>
<layout class="QHBoxLayout" name="replayControlsScreensLayout">
<item>
<widget class="QPushButton" name="pbInitScr1">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Set Screen 1</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbInitScr2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Set Screen 2</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="pbStop">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Stop</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbPause">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Pause</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbPlay">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Play</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="replayControlsJumpLayout">
<item>
<widget class="QPushButton" name="pbUntilNextTopic">
<property name="text">
<string>Play Until Next Topic</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbPreviousTopic">
<property name="text">
<string>Previous Topic</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbNextTopic">
<property name="text">
<string>Next Topic</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QFormLayout" name="replayInfoLayout">
<property name="horizontalSpacing">
<number>9</number>
</property>
<property name="verticalSpacing">
<number>9</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="durationLabel">
<property name="text">
<string>Presentation duration:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="lblDuration">
<property name="text">
<string notr="true"> - </string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="posLabel">
<property name="text">
<string>Pos:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="posSlider">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="const" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="currentPosLabel">
<property name="text">
<string>Current position:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="currentositionLayout">
<item>
<widget class="QLabel" name="lblPos">
<property name="text">
<string notr="true">0</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="slashLabel">
<property name="text">
<string>/</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblMax">
<property name="text">
<string notr="true">0</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="statusLayout">
<item>
<widget class="QLabel" name="statusLabel">
<property name="text">
<string>Status:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="lwStatus">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerPixel</enum>
</property>
<property name="movement">
<enum>QListView::Free</enum>
</property>
<property name="isWrapping" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LtsScriptTimeline::ScriptTimeline</class>
<extends>QWidget</extends>
<header location="global">LtsScriptTimeline/script_timeline.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
@@ -1,369 +0,0 @@
#include "pre_script_gui_plugin.h"
#include "pre_script_dialog.h"
#include <OperatorManagement/opm_data_plugin_interface.h>
#include <PresentationManagement/Script/Common/ScriptChooser/script_chooser.h>
#include <PresentationManagement/Common/pre_edit_dialog.h>
#include <LtsWidgets/lts_base_layout_widget.h>
#include <LtsSession/lts_session.h>
#include <LtsSession/lts_session_manager.h>
#include <LtsSession/lts_session_data.h>
#include <LtsWidgets/lts_background_widget.h>
#include <LtsWidgets/lts_message_dialog.h>
#include <LtsScriptTimeline/track_entry.h>
#include <LtsScriptTimeline/temporary_pointer_vector.h>
#include <Common/TopicEditorBase/topic_editor_base.h>
#include <SituationReplay/srp_gui_plugin_interface.h>
#include <SituationMapPlugin/situation_map_gui_plugin_interface.h>
#include <FileManagement/flm_explorer_gui_plugin_interface.h>
#include <BuildingViewer/bdv_viewer_gui_plugin_interface.h>
#include <AudioVideoManagement/avm_menu_edit_gui_plugin_interface.h>
#include <SituationMapPlugin/situation_map_script_filter_gui_plugin_interface.h>
#include <MarkerManagement/mrk_gui_plugin_interface.h>
#include <Evaluations/evl_gui_plugin_interface.h>
#include <ReportManagement/rep_gui_plugin_interface.h>
#include <PlanOverlays/plan_overlays_plugin_interface.h>
#include <PresentationManagement/pre_operator_rights.h>
#include <PresentationManagement/pre_dtc.h>
#include <QtCore/QDir>
#include <QJsonParseError>
#include <QtCore/QJsonDocument>
#include <QtWidgets/QProgressDialog>
#include <QtCore/QTimer>
#include <QtWidgets/QFileDialog>
#include <QtWidgets/QVBoxLayout>
#include <QtCore/QDateTime>
#include <stdlib.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.Script"))
, m_dtc(nullptr)
, m_opmDtc(nullptr)
, m_ftc(nullptr)
, m_repForeign(nullptr)
, m_scriptDialog(nullptr)
, m_scriptId(0)
, m_requestHelper(new LtsUtils::RequestHelper(this))
{
connect(this, &InterfaceImpl::signalSuccess, m_session, &LtsSession::LtsSession::slotExecuteNextPayload, Qt::QueuedConnection);
}
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
{
QVector<LtsWidgets::PluginData> ret;
{
LtsWidgets::PluginData data;
data.menuGroup = menuGroup();
data.identifier = QStringLiteral("PresentationManagement.ScriptDialog");
data.menuText = tr("Show Script Editor");
if (getFlags().testFlag(LtsAppDescriptor::PluginInfo::Flag::MAIN))
{
data.layoutArea = LtsWidgets::LayoutArea::eMainTab;
data.createInstant = LtsWidgets::CreateInstantType::CreateInstantAndDiscardAction;
data.closable = false;
}
else
{
data.layoutArea = LtsWidgets::LayoutArea::eDialogTab;
}
data.operatorRight = OperatorRights::ScriptEditorShow;
data.createWidgetFunc = [this](QWidget *parent)
{
return onShowScriptDialog(parent);
};
ret.append(data);
}
{
LtsWidgets::PluginData data;
data.menuGroup = menuGroup();
data.identifier = QLatin1String("PresentationManagement.ScriptDialog.ImportScript");
data.menuIcon = QIcon(QLatin1String("icon:import_documents.svg"));
data.menuText = tr("Insert Script");
data.operatorRight = OperatorRights::ScriptEditorEdit;
data.directFunc = [this](const LtsWidgets::PluginData &)
{
return onImportScript();
};
data.createWidgetFunc = nullptr;
ret.append(data);
}
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<SituationReplayManagement::DataInterface>(m_coreDtc))
{
DEBUG_LOG(m_logger) << "getDtc for SituationReplayManagement::DataInterface failed.";
return false;
}
if (!m_session->getForeignDataInterface<SituationReplayManagement::DataInterface>(m_repForeign))
{
WARNING_LOG(m_logger) << "getForeignDataInterface for SituationReplayManagement::DataInterface failed.";
return false;
}
return true;
}
void InterfaceImpl::clearInterfaces()
{
m_repForeign = nullptr;
m_coreDtc = nullptr;
m_opmDtc = nullptr;
m_ftc = nullptr;
m_dtc = nullptr;
}
QString InterfaceImpl::menuGroup() const
{
return tr("Presentation");
}
LtsWidgets::LtsDialog *InterfaceImpl::onShowScriptDialog(QWidget *parent)
{
m_scriptDialog = new ScriptDialog(menuGroup(), parent);
if (!m_scriptDialog->init(m_session, m_scriptId, m_dtc, m_ftc, m_repForeign, m_coreDtc, m_opmDtc))
{
m_scriptDialog->deleteLater();
m_scriptDialog = nullptr;
emit m_session->signalClose();
}
return m_scriptDialog.data();
}
void InterfaceImpl::onImportScript()
{
ScriptChooser *scriptChooser = new ScriptChooser(m_dtc, m_opmDtc, false, true);
scriptChooser->setAttribute(Qt::WA_DeleteOnClose);
connect(scriptChooser, &ScriptChooser::signalSelectScript,
this, &InterfaceImpl::slotImportScript, Qt::QueuedConnection);
connect(scriptChooser, &ScriptChooser::signalQuit,
m_session, &LtsSession::LtsSession::signalQuit);
if (!LtsSessionData::LtsSessionData::getInstance()->isTablet())
scriptChooser->setModal(true);
scriptChooser->show();
}
void InterfaceImpl::slotNewScript()
{
PresentationModifyRequest req;
req.name(tr("New Script").toStdString());
req.description(tr("No description available.").toStdString());
req.operatorId(LtsSessionData::LtsSessionData::getInstance()->getOperatorId());
req.lastModified(QDateTime::currentMSecsSinceEpoch());
req.fileStatus(FileStatus::Valid);
if (m_requestHelper->startSingleRequest([this, req]()
{
return m_ftc->presentationModifyRequest(req, this);
}))
{
}
}
void InterfaceImpl::slotAddScript()
{
PresentationEditDialog *dialog = new PresentationEditDialog(nullptr);
if (!dialog->init(-1 , m_dtc, m_ftc, m_opmDtc))
{
delete dialog;
return;
}
QObject::connect(dialog, &PresentationEditDialog::rejected, dialog, &PresentationEditDialog::deleteLater);
dialog->show();
}
void InterfaceImpl::executePayload(LtsWidgets::LtsBackgroundWidget *mainBackground)
{
Q_UNUSED(mainBackground);
if (m_session->partitionType() != IDL::PartitionType::Exercise)
{
emit signalSuccess();
return;
}
int scriptId = m_session->getSavegame()[QStringLiteral("ScriptId")].toInt();
if (scriptId > 0)
{
slotSelectScript(scriptId);
return;
}
ScriptChooser *scriptChooser = new ScriptChooser(m_dtc, m_opmDtc, false, false, mainBackground);
scriptChooser->setAttribute(Qt::WA_DeleteOnClose);
connect(scriptChooser, &ScriptChooser::signalSelectScript,
this, &InterfaceImpl::slotSelectScript, Qt::QueuedConnection);
connect(scriptChooser, &ScriptChooser::signalQuit,
m_session, &LtsSession::LtsSession::signalQuit);
connect(scriptChooser, &ScriptChooser::signalNewScript,
this, &InterfaceImpl::slotAddScript);
if (!LtsSessionData::LtsSessionData::getInstance()->isTablet())
scriptChooser->setModal(true);
scriptChooser->show();
}
void InterfaceImpl::slotSelectScript(int scriptId)
{
m_scriptId = scriptId;
emit signalSuccess();
}
void InterfaceImpl::slotImportScript(int scriptId)
{
if (m_scriptId == scriptId)
{
ERROR_LOG(m_logger) << "Not possible to import same script!";
LtsWidgets::LtsMessageDialog::showMessage(m_session->baseLayout(), tr("Not possible to import same script!"));
return;
}
if (!importScript(scriptId))
{
ERROR_LOG(m_logger) << "Failed to import script Id " << scriptId;
LtsWidgets::LtsMessageDialog::showMessage(m_session->baseLayout(), tr("Failed to import Script Id %1").arg(scriptId));
return;
}
DEBUG_LOG(m_logger) << "Succesfully imported script Id " << scriptId ;
}
bool InterfaceImpl::importScript(int idSource)
{
if (!m_scriptDialog)
{
ERROR_LOG(m_logger) << "no script dialog open for import script";
return false;
}
PresentationManagement::Presentation preSource = m_dtc->presentation(idSource);
if (preSource.id() < 1)
return false;
std::function<void(const Core::FunctionReply &baseReply)> importPresentationContent = [&](const Core::FunctionReply &baseReply)
{
const GetPresentationContentReply &reply = static_cast<const GetPresentationContentReply &>(baseReply);
const auto &contentList = reply.content();
if (contentList.size() < 1)
{
ERROR_LOG(m_logger) << "No Presentation Content for Script Id " << reply.id();
return;
}
LtsScriptTimeline::TemporaryPointerVector<LtsScriptTimeline::TrackEntry *> importedTes;
for (const PresentationManagement::PresentationContent &content : contentList)
{
LtsScriptTimeline::TrackEntryType tet = LtsScriptTimeline::TrackEntryType::INVALID;
if (!m_scriptDialog->topicStringToType(QString::fromStdString(content.presentationTopicType()), tet))
{
ERROR_LOG(m_logger) << "Topic ignored - invalid topic type for presentation's content id " << content.id();
continue;
}
importedTes.append(ScriptDialog::trackEntryFromContent(content, 0, tet));
}
if (m_scriptDialog->importTrackEntries(importedTes))
importedTes.setDiscardable(false);
};
GetPresentationContentRequest req(idSource);
req.presentationId(idSource);
if (!m_requestHelper->startSingleRequest([req, this]()
{
return m_ftc->getPresentationContentRequest(req, this);
}, importPresentationContent))
{
LtsWidgets::LtsMessageDialog::showMessage(m_session->baseLayout(), tr("There is no content to import for this script."));
return false;
}
return true;
}
}
@@ -1,93 +0,0 @@
#pragma once
#include <PresentationManagement/logger.h>
#include <PluginInterfaces/gui_plugin_interface.h>
#include <PresentationManagement/pre_data_plugin_interface.h>
#include <PresentationManagement/pre_script_gui_plugin_interface.h>
#include <PresentationManagement/pre_ftc.h>
#include <OperatorManagement/opm_dtc.h>
#include <SituationReplayManagement/srm_data_plugin_interface.h>
#include <Lts/Common/ProjectConfig/project_defines.h>
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
#include <LtsScriptTimeline/track_entry_painters.h>
#include "pre_script_dialog.h"
#include <LtsSession/lts_session.h>
#include <PluginInterfaces/gui_plugin_interface.h>
#include <PluginInterfaces/topic_replay_interface.h>
#include <PresentationManagement/Common/topic_assignment.h>
namespace PresentationManagement
{
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "gui:3:pre.script.edit")
Q_INTERFACES(GuiPluginBase::Plugin)
public:
explicit GuiPlugin() = default;
~GuiPlugin() = default;
QString pluginName() override { return ForeignScriptDialogGuiInterface::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
, protected PresentationManagement::Interface::Ftc::PresentationModifyReplyHandler
, protected PresentationManagement::Interface::Ftc::GetPresentationContentReplyHandler
{
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; }
int executionPriority() const override { return 9999; }
void executePayload(LtsWidgets::LtsBackgroundWidget *mainBackground) override;
protected:
void onPresentationModifyReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
void onGetPresentationContentReply(const GetPresentationContentReply &reply) override { m_requestHelper->requestReply(reply); }
private:
LtsWidgets::LtsDialog *onShowScriptDialog(QWidget *parent);
void onImportScript();
bool importScript(int idSource);
std::shared_ptr<PresentationManagement::Interface::Dtc> m_dtc;
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
std::shared_ptr<PresentationManagement::Interface::Ftc> m_ftc;
std::shared_ptr<SituationReplayManagement::ForeignDataInterface> m_repForeign;
std::shared_ptr<Core::Interface::Dtc> m_coreDtc;
QPointer<PresentationManagement::ScriptDialog> m_scriptDialog;
int m_scriptId;
LtsUtils::RequestHelper *m_requestHelper;
signals:
void signalSuccess();
private slots:
void slotSelectScript(int scriptId);
void slotNewScript();
void slotImportScript(int scriptId);
void slotAddScript();
};
}
@@ -1,153 +0,0 @@
#include "pre_storyboard.h"
#include <utility>
#include "ui_pre_storyboard.h"
#include <LtsPrinting/printing.h>
#include <LtsScriptTimeline/track_entry.h>
#include <ngltools/ngltools_dtg.h>
using namespace LtsScriptTimeline;
namespace PresentationManagement
{
StoryboardDialog::StoryboardDialog(QWidget *parent, LtsSession::LtsSession *session)
: LtsWidgets::LtsDialog(parent)
, m_ui(new Ui::StoryboardDialog)
, m_session(session)
, m_alreadyTranslated(false)
{
m_ui->setupUi(this);
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &StoryboardDialog::slotPrint);
}
StoryboardDialog::~StoryboardDialog()
{
delete m_ui;
}
void StoryboardDialog::slotPrint()
{
QString headingHtml = (QStringLiteral("<H1>"));
headingHtml.append (tr("Scriptname:"));
headingHtml.append(m_scriptName);
headingHtml.append(QStringLiteral("</H1>"));
headingHtml.append(QStringLiteral("<H3>"));
headingHtml.append(tr("Script Owner: "));
headingHtml.append(m_scriptOwner);
headingHtml.append(QStringLiteral("</H3>"));
headingHtml.append(QStringLiteral("<H3>"));
headingHtml.append(tr("Last modified: "));
headingHtml.append(DTG::toStringMSec(m_lastModified));
headingHtml.append(QStringLiteral("<br>"));
headingHtml.append(tr("Duration: "));
QString durationStr = m_duration;
headingHtml.append(durationStr);
headingHtml.append(QStringLiteral("</H3><br>"));
LtsPrinting::printView(m_session, this, m_ui->listWidget, headingHtml);
}
bool StoryboardDialog::init(const QVector<LtsScriptTimeline::TrackEntry *> &topicVector,
const QVector<FilterTopic> &filterTopicVector,
const QString &scriptName,
const QString &scriptOwner,
const qint64 lastModified,
const QString duration)
{
m_topicVector = topicVector;
m_filterTopicVector = filterTopicVector;
m_scriptName = scriptName;
m_scriptOwner = scriptOwner;
m_lastModified = lastModified;
m_duration = duration;
std::sort(m_topicVector.begin(), m_topicVector.end(), [](const TrackEntry *a, const TrackEntry *b) -> bool
{
return a->m_startTime < b->m_startTime;
});
return true;
}
void StoryboardDialog::retranslate()
{
translate(m_ui, tr("Script Storyboard"));
if (m_alreadyTranslated)
return;
fillStoryboard();
m_alreadyTranslated = true;
}
void StoryboardDialog::fillStoryboard()
{
m_ui->listWidget->clear();
QVector<FilterTopic> correspondingFilterTopics;
int ii1 = 1;
for (const LtsScriptTimeline::TrackEntry *te : std::as_const(m_topicVector))
{
QString itemText = tr("Topic %1: %2 - %3 (%4 seconds)\n Type: %5").arg(
ii1).arg(QTime::fromMSecsSinceStartOfDay(te->m_startTime * 1000).toString(),
QTime::fromMSecsSinceStartOfDay((te->m_startTime + te->m_length) * 1000).toString()).arg(
te->m_length).arg(LtsScriptTimeline::translateTrackEntryType(te->m_type));
if (!te->m_description.isEmpty())
itemText += QStringLiteral("\n ") + tr("Description: %1").arg(te->m_description);
m_ui->listWidget->addItem(itemText);
correspondingFilterTopics.clear();
for (const FilterTopic &_ft : std::as_const(m_filterTopicVector))
{
if (_ft.mainTopicId != te->m_topicId)
continue;
correspondingFilterTopics.append(_ft);
}
std::sort(correspondingFilterTopics.begin(), correspondingFilterTopics.end(), [](const FilterTopic &a, const FilterTopic &b) -> bool
{
return a.filterTopic->m_startTime < b.filterTopic->m_startTime;
});
int ii2 = 1;
for (const FilterTopic &_ft : std::as_const(correspondingFilterTopics))
{
if (_ft.mainTopicId != te->m_topicId)
continue;
const LtsScriptTimeline::TrackEntry *fte = _ft.filterTopic;
QString filterItemText = tr(" > Filter %1: %2 - %3 (%4 seconds)\n Type: %5").arg(
ii2).arg(QTime::fromMSecsSinceStartOfDay(fte->m_startTime * 1000).toString(),
QTime::fromMSecsSinceStartOfDay((fte->m_startTime + te->m_length) * 1000).toString()).arg(
fte->m_length).arg(LtsScriptTimeline::translateTrackEntryType(te->m_type));
if (!fte->m_description.isEmpty())
filterItemText += QStringLiteral("\n ") + tr("Description: %1").arg(fte->m_description);
m_ui->listWidget->addItem(filterItemText);
ii2++;
}
ii1++;
}
}
}
@@ -1,50 +0,0 @@
#pragma once
#include "filter_topic.h"
#include <LtsWidgets/lts_dialog.h>
#include <LtsScriptTimeline/track_entry.h>
#include <LtsSession/lts_session.h>
#include <QtCore/QVector>
namespace Ui
{
class StoryboardDialog;
}
namespace PresentationManagement
{
class StoryboardDialog : public LtsWidgets::LtsDialog
{
Q_OBJECT
public:
StoryboardDialog(QWidget *parent, LtsSession::LtsSession *session);
~StoryboardDialog();
bool init(const QVector<LtsScriptTimeline::TrackEntry *> &topicVector,
const QVector<FilterTopic> &filterTopicVector,
const QString &scriptName,
const QString &scriptOwner,
const qint64 lastModified,
const QString duration);
void fillStoryboard();
void retranslate() override final;
private:
Ui::StoryboardDialog *m_ui;
QVector<LtsScriptTimeline::TrackEntry *> m_topicVector;
QVector<FilterTopic> m_filterTopicVector;
LtsSession::LtsSession *m_session;
QString m_scriptName = QString();
QString m_scriptOwner = QString();
qint64 m_lastModified = 0;
QString m_duration = QString();
bool m_alreadyTranslated;
public slots:
void slotPrint();
};
}
@@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>StoryboardDialog</class>
<widget class="QWidget" name="StoryboardDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>707</width>
<height>464</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Script Editor</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>9</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QListWidget" name="listWidget">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -1,62 +0,0 @@
#include "pre_topic_designer_dialog.h"
#include "ui_pre_topic_designer_dialog.h"
namespace PresentationManagement
{
TopicDesignerDialog::TopicDesignerDialog(QWidget *parent)
: LtsDialog(parent)
, m_ui(new Ui::TopicDesignerDialog)
{
m_ui->setupUi(this);
setFocusPolicy(Qt::StrongFocus);
connect(m_ui->widget, &TopicDesigner::signalTopicSelected,
this, &TopicDesignerDialog::signalTopicSelected);
connect(m_ui->widget, &TopicDesigner::signalDeleteTrackEntry,
this, &TopicDesignerDialog::signalDeleteTrackEntry);
connect(m_ui->widget, &TopicDesigner::signalUnselect,
this, &TopicDesignerDialog::signalUnselect);
connect(m_ui->widget, &TopicDesigner::signalChangesMade,
this, &LtsWidgets::LtsDialog::signalChangesMade);
}
void TopicDesignerDialog::retranslate()
{
translate(m_ui, tr("Topic Designer"));
}
TopicDesignerDialog::~TopicDesignerDialog()
{
delete m_ui;
}
QVector<LtsScriptTimeline::TrackEntry *> TopicDesignerDialog::exportTopicList() const
{
return m_ui->widget->exportTopicList();
}
void TopicDesignerDialog::selectTopic(int topicId)
{
m_ui->widget->selectTopic(topicId);
}
void TopicDesignerDialog::loadTopicList(const QVector<LtsScriptTimeline::TrackEntry *> &topicsList)
{
m_ui->widget->loadTopicList(topicsList);
}
}
@@ -1,50 +0,0 @@
#pragma once
#include <LtsWidgets/lts_dialog.h>
#include <QtCore/QVector>
namespace Ui
{
class TopicDesignerDialog;
}
namespace LtsScriptTimeline
{
class TrackEntry;
}
namespace PresentationManagement
{
class TopicDesignerDialog : public LtsWidgets::LtsDialog
{
public:
Q_OBJECT
public:
explicit TopicDesignerDialog(QWidget *parent = nullptr);
~TopicDesignerDialog();
void loadTopicList(const QVector<LtsScriptTimeline::TrackEntry *> &topicsList);
QVector<LtsScriptTimeline::TrackEntry *> exportTopicList() const;
void selectTopic(int topicId);
signals:
void signalTopicSelected(int topicId);
void signalDeleteTrackEntry(int topicId);
void signalUnselect();
private:
void retranslate() override;
Ui::TopicDesignerDialog *m_ui;
};
}
@@ -1,122 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TopicDesignerDialog</class>
<widget class="QWidget" name="TopicDesignerDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>338</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Script Editor</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string notr="true">Some text</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="pbToFront">
<property name="text">
<string>To Front</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbIncIdx">
<property name="text">
<string>Inc Idx</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbDecIdx">
<property name="text">
<string>Dec Idx</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbToBack">
<property name="text">
<string>To Back</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="PresentationManagement::TopicDesigner" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>300</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>PresentationManagement::TopicDesigner</class>
<extends>QWidget</extends>
<header>topic_designer.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
@@ -1,28 +0,0 @@
#
# $Id$
# $HeadURL$
# $Author$
# Created by Mike Wille, SLSE, 2016-03-30
#
ADD_SUBDIRECTORY(Data)
ADD_SUBDIRECTORY(Gui)
#
# Gui Plugin Interface
#
ADD_INTERFACE_LIBRARY(ScmGuiPluginInterface
${CMAKE_CURRENT_SOURCE_DIR}/scm_gui_plugin_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/..
GuiPluginInterface
)
#
# Data Plugin Interface
#
ADD_INTERFACE_LIBRARY(ScmDataPluginInterface
${CMAKE_CURRENT_SOURCE_DIR}/scm_data_plugin_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/..
DataPluginInterface
svcScmCommon
)
@@ -1,20 +0,0 @@
#
# $Id$
# $HeadURL$
# $Author$
# Created by Mike Wille, SLSE, 2016-09-06
#
#
# Data Plugin
#
NGL_ADD_LIBRARY(WS ScmDataPlugin MODULE scm_data_plugin.cpp scm_data_plugin.h)
set_target_properties(ScmDataPlugin PROPERTIES AUTOMOC ON)
NGL_TARGET_LINK_LIBRARIES(ScmDataPlugin
Qt6::Core
ScmDataPluginInterface
svcScmClient
NGLLogger
LtsSessionDataDds
)
NGL_INSTALL_TARGET(ScmDataPlugin)
@@ -1,27 +0,0 @@
#include "scm_data_plugin.h"
#include <DDS/DDSConnector/dds_connector.h>
#include <LtsSession/lts_session_data_dds.h>
namespace ServiceManagement
{
std::shared_ptr<DataPluginBase::Interface> DataPlugin::createDataInterface(LtsSession::LtsSessionDataDds *session)
{
std::shared_ptr<ServiceManagement::Interface::Dtc> dtc;
std::shared_ptr<ServiceManagement::Interface::Ftc> ftc;
if (!session->createTopicClient(dtc, ftc, false ,true))
return std::shared_ptr<DataPluginBase::Interface>();
return std::make_shared<DataInterfaceImpl>(dtc, ftc);
}
DataInterfaceImpl::DataInterfaceImpl(const std::shared_ptr<ServiceManagement::Interface::Dtc> &dtc,
const std::shared_ptr<ServiceManagement::Interface::Ftc> &ftc)
: DataInterface()
, m_dtc(dtc)
, m_ftc(ftc)
{}
}
@@ -1,45 +0,0 @@
#pragma once
#include <ServiceManagement/scm_data_plugin_interface.h>
namespace ServiceManagement
{
class DataPlugin final : public DataPluginBase::Plugin
{
Q_PLUGIN_METADATA(IID "data:3:scm")
Q_OBJECT
public:
DataPlugin() = default;
~DataPlugin() = default;
QString pluginName() const override { return QStringLiteral("ServiceManagement"); }
std::shared_ptr<DataPluginBase::Interface> createDataInterface(LtsSession::LtsSessionDataDds *session) override;
bool availableInPartition(IDL::PartitionType partition) const override
{
return partition == IDL::PartitionType::Global;
}
};
class DataInterfaceImpl final : public DataInterface
{
public:
explicit DataInterfaceImpl(const std::shared_ptr<ServiceManagement::Interface::Dtc> &dtc,
const std::shared_ptr<ServiceManagement::Interface::Ftc> &ftc);
std::shared_ptr<ServiceManagement::Interface::Dtc> getDtc() override { return m_dtc; }
std::shared_ptr<ServiceManagement::Interface::Ftc> getFtc() override { return m_ftc; }
private:
std::shared_ptr<ServiceManagement::Interface::Dtc> m_dtc;
std::shared_ptr<ServiceManagement::Interface::Ftc> m_ftc;
};
}
@@ -1,8 +0,0 @@
#
# $Id$
# $HeadURL$
# $Author$
# Created by Mike Wille, SLSE, 2016-03-30
#
ADD_SUBDIRECTORY(ServiceEdit)
@@ -1,48 +0,0 @@
#
# $Id$
# $HeadURL$
# $Author$
# Created by Mike Wille, SLSE, 2016-03-30
#
# Make ${Qt6_Widgets} optional
if(QT6_GUI_AVAILABLE AND TARGET Qt6::Widgets)
set(Qt6_Widgets ${Qt6_Widgets})
else()
set(Qt6_Widgets "")
endif()
SET(scm_edit_gui_SRCS
scm_edit_gui_plugin.cpp
scm_edit_gui_plugin.h
scm_dialog.cpp
scm_dialog.h
scm_dialog_service.cpp
scm_dialog_service.h
scm_dialog_group.cpp
scm_dialog_group.h
)
NGL_WRAP_UI(scm_edit_gui_SRCS
scm_dialog.ui
scm_dialog_service.ui
scm_dialog_group.ui
)
NGL_ADD_LIBRARY(WS ScmEditGuiPlugin MODULE ${scm_edit_gui_SRCS})
if(QT6_GUI_AVAILABLE)
NGL_TARGET_LINK_LIBRARIES(ScmEditGuiPlugin
NGLLogger
ScmGuiPluginInterface
ScmDataPluginInterface
LtsSession
${Qt6_Widgets}
LtsWidgets
LtsUtilsGuiDds
svcScmCommon
svcExmClient
)
endif()
NGL_INSTALL_TARGET(ScmEditGuiPlugin)
@@ -1,358 +0,0 @@
#include "scm_dialog.h"
#include "ui_scm_dialog.h"
#include "scm_dialog_group.h"
#include "scm_dialog_service.h"
#include <LtsUtils/LtsUtilsCore/data_modification_enum.h>
#include <QtWidgets/QVBoxLayout>
namespace ServiceManagement
{
ServiceManagementDialog::ServiceManagementDialog(QWidget *parent)
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
, m_requestHelper(new LtsUtils::RequestHelper(this))
, m_ui(new Ui::ServiceManagementDialog)
, m_dtcExm(nullptr)
, m_dtc(nullptr)
, m_ftc(nullptr)
{
m_ui->setupUi(this);
m_ui->lbGroupsIndicator->hide();
m_ui->lbExercise->hide();
m_ui->lbServer->hide();
m_ui->cbServer->hide();
m_ui->cbExercise->hide();
setOnlineHelpFilename(QStringLiteral("Administrator-Service_Management"));
}
ServiceManagementDialog::~ServiceManagementDialog()
{
delete m_ui;
}
void ServiceManagementDialog::retranslate()
{
translate(m_ui, tr("Service Management"));
}
bool ServiceManagementDialog::init(const std::shared_ptr<ServiceManagement::Interface::Dtc> &dtc,
const std::shared_ptr<ServiceManagement::Interface::Ftc> &ftc,
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &dtcExm)
{
m_dtc = dtc;
m_ftc = ftc;
m_dtcExm = dtcExm;
connect(m_dtc.get(), &Interface::Dtc::groupInformationChanged,
this, &ServiceManagementDialog::slotGroupInformationChanged);
connect(m_dtc.get(), &Interface::Dtc::serviceInformationChanged,
this, &ServiceManagementDialog::slotServiceInformationChanged);
const QMap<qint32, ServiceManagement::GroupInformation> groupInfo = m_dtc->groupInformations();
if (groupInfo.isEmpty())
{
INFO_LOG(m_logger) << "initModel - no groups!";
return true;
}
m_ui->lbNoServices->hide();
INFO_LOG(m_logger) << "initModel - #group information: " << groupInfo.size();
QVector<int> servicesList;
for (const ServiceManagement::GroupInformation &gi : groupInfo)
{
const int server = gi.domainId();
const int exercise = gi.exercisePartitionId();
const int32_t replayPartitionId = gi.replayPartitionId();
const QString groupName = groupEnumToGroupName(gi.type());
long long timestamp = gi.timestamp();
servicesList.clear();
servicesList.reserve(gi.services().size());
for (auto service : gi.services())
servicesList.append(service);
addGroup(gi.type(), server, exercise, replayPartitionId, groupName, timestamp, servicesList);
}
auto cbSvc = [this](const ServiceManagement::ServiceInformation & svc)
{
addService(svc);
};
m_dtc->serviceInformations(cbSvc);
return true;
}
GroupWidget *ServiceManagementDialog::addGroup(const Core::ServiceGroupType &groupType, int server, int exercise, int32_t replayPartitionId,
const QString &groupName, long long timestamp, const QVector<int> &servicesList)
{
QString exName = QString::fromStdString(m_dtcExm.get()->exercise(exercise).name());
GroupWidget *group = new GroupWidget(groupType, server, exercise, replayPartitionId, exName, timestamp, servicesList);
QString groupObjectName = craftGroupName(server, exercise, groupName);
group->setObjectName(groupObjectName);
connect(group, &GroupWidget::signalRestartGroup, this, &ServiceManagementDialog::slotRestartGroup);
connect(group, &GroupWidget::signalStartGroup, this, &ServiceManagementDialog::slotStartGroup);
connect(group, &GroupWidget::signalStopGroup, this, &ServiceManagementDialog::slotStopGroup);
QVBoxLayout *l = qobject_cast<QVBoxLayout *>(m_ui->groupLayoutWidget->layout());
if (!l)
WARNING_LOG(m_logger) << "ServiceManagementDialog::addGroup: group layout failed, cannot add group";
else
l->addWidget(group, 0, Qt::AlignTop);
return group;
}
void ServiceManagementDialog::slotRestartService(int serviceID)
{
const RestartServiceRequest req(serviceID);
m_requestHelper->startSingleRequest([req, this]()
{
return m_ftc->restartServiceRequest(req, this);
});
}
static int s_requestId = 0;
void ServiceManagementDialog::slotRestartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId)
{
const GroupRequest req(groupType,
exercise,
server,
replayPartitionId,
++s_requestId,
{});
m_requestHelper->startSingleRequest([req, this]()
{
return m_ftc->restartGroupRequest(req, this);
});
}
void ServiceManagementDialog::slotStartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId)
{
const GroupRequest req(groupType,
exercise,
server,
replayPartitionId,
++s_requestId,
{});
m_requestHelper->startSingleRequest([req, this]()
{
return m_ftc->startGroupRequest(req, this);
});
}
void ServiceManagementDialog::slotStopGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId)
{
const GroupRequest req(groupType,
exercise,
server,
replayPartitionId,
++s_requestId,
{});
m_requestHelper->startSingleRequest([req, this]()
{
return m_ftc->stopGroupRequest(req, this);
});
}
void ServiceManagementDialog::slotGroupInformationChanged(ServiceManagement::GroupInformation info, DataModification mod)
{
int server = info.domainId();
int exercise = info.exercisePartitionId();
int32_t replayPartitionId = info.replayPartitionId();
QString groupName = groupEnumToGroupName(info.type());
long long timestamp = info.timestamp();
QString findGroupName = craftGroupName(server, exercise, groupName);
GroupWidget *gw = m_ui->groupLayoutWidget->findChild<GroupWidget *>(findGroupName);
if (!gw)
{
QVector<int> servicesList;
servicesList.reserve(info.services().size());
for (auto service : info.services())
servicesList << service;
m_ui->lbNoServices->hide();
addGroup(info.type(), server, exercise, replayPartitionId, groupName, timestamp, servicesList);
}
else
{
switch (mod)
{
case DataModification::eAdded:
case DataModification::eModified:
{
m_ui->lbNoServices->hide();
gw->setType(info.type());
gw->setServer(server);
gw->setExercise(exercise);
gw->setTimestamp(timestamp);
break;
}
case DataModification::eRemoved:
{
if (m_ui->groupLayoutWidget->findChildren<GroupWidget *>().isEmpty())
m_ui->lbNoServices->show();
delete gw;
break;
}
}
}
}
void ServiceManagementDialog::addService(const ServiceManagement::ServiceInformation &svc)
{
const int id = svc.id();
const long long pid = svc.pid();
const QString name(QString::fromStdString(svc.name()));
const Core::RunningState &state = svc.state();
const QString errorString(QString::fromStdString(svc.errorString()));
ServiceWidget *service = new ServiceWidget(id, pid, name, state, errorString);
service->setObjectName(QLatin1String("service.") + QString::number(id));
connect(service, &ServiceWidget::signalRestartService, this, &ServiceManagementDialog::slotRestartService);
const auto groupList = findChildren<GroupWidget *>();
for (GroupWidget *gw : groupList)
gw->addService(service);
}
void ServiceManagementDialog::slotServiceInformationChanged(ServiceManagement::ServiceInformation info, DataModification mod)
{
int32_t serviceId = info.id();
QString errorString = QString::fromStdString(info.errorString());
QString serviceName = QString::fromStdString(info.name());
long long pid = info.pid();
const Core::RunningState &state = info.state();
long long timestamp = info.timestamp();
QString findServiceName = QLatin1String("service.") + QString::number(serviceId);
const auto serviceList = findChildren<ServiceWidget *>(findServiceName);
if (serviceList.isEmpty() || mod == DataModification::eAdded)
{
addService(info);
}
for (ServiceWidget *serviceWidget : serviceList)
{
switch (mod)
{
case DataModification::eModified:
{
serviceWidget->setErrorString(errorString);
serviceWidget->setName(serviceName);
serviceWidget->setPid(pid);
serviceWidget->setState(state);
serviceWidget->setTimestamp(timestamp);
break;
}
case DataModification::eRemoved:
{
delete serviceWidget;
serviceWidget = nullptr;
break;
}
default:
{
break;
}
}
}
const auto groupList = findChildren<GroupWidget *>();
for (GroupWidget *groupWidget : groupList)
groupWidget->checkStatus();
}
}
@@ -1,94 +0,0 @@
#pragma once
#include "scm_dialog_group.h"
#include <ServiceManagement/scm_ftc.h>
#include <ServiceManagement/scm_dtc.h>
#include <ExerciseManagement/exm_dtc.h>
#include <ServiceManagement/logger.h>
#include <LtsWidgets/lts_dialog.h>
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
namespace Ui
{
class ServiceManagementDialog;
}
namespace ServiceManagement
{
class ServiceManagementDialog : public LtsWidgets::LtsDialog
, protected ServiceManagement::Interface::Ftc::RestartServiceReplyHandler
, protected ServiceManagement::Interface::Ftc::RestartGroupReplyHandler
, protected ServiceManagement::Interface::Ftc::StartGroupReplyHandler
, protected ServiceManagement::Interface::Ftc::StopGroupReplyHandler
{
Q_OBJECT
public:
explicit ServiceManagementDialog(QWidget *parent = nullptr);
~ServiceManagementDialog();
bool init(const std::shared_ptr<Interface::Dtc> &dtc,
const std::shared_ptr<Interface::Ftc> &ftc,
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &dtcExm);
virtual void onRestartServiceReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
virtual void onRestartGroupReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
virtual void onStartGroupReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
virtual void onStopGroupReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
static QString groupEnumToGroupName(const Core::ServiceGroupType &type)
{
QMap<QString, Core::ServiceGroupType_def::type> groupNameMapping;
groupNameMapping.insert(QLatin1String("Master"), Core::ServiceGroupType_def::Master);
groupNameMapping.insert(QLatin1String("Core"), Core::ServiceGroupType_def::Core);
groupNameMapping.insert(QLatin1String("ExercisePreparation"), Core::ServiceGroupType_def::ExercisePreparation);
groupNameMapping.insert(QLatin1String("ExerciseExecution"), Core::ServiceGroupType_def::ExerciseExecution);
groupNameMapping.insert(QLatin1String("ExercisePaused"), Core::ServiceGroupType_def::ExercisePaused);
groupNameMapping.insert(QLatin1String("ExerciseAfterActionReview"), Core::ServiceGroupType_def::ExerciseAfterActionReview);
groupNameMapping.insert(QLatin1String("Playback"), Core::ServiceGroupType_def::Playback);
return groupNameMapping.key(type.underlying());
}
private:
NGL::INGLLogger &m_logger;
void retranslate() override;
static QString craftBaseName(const QString &server, const QString &exercise) { return server + QLatin1Char('.') + exercise + QLatin1Char('.'); }
GroupWidget *addGroup(const Core::ServiceGroupType &groupType, int server, int exercise, int32_t replayPartitionId,
const QString &groupName, long long timestamp, const QVector<int> &servicesList);
void addService(const ServiceInformation &svc);
LtsUtils::RequestHelper *m_requestHelper;
public:
static QString craftGroupName(int server, int exercise, const QString &groupName) { return craftBaseName(QString::number(server), QString::number(exercise)) + groupName; }
static QString craftServiceName(int server, int exercise, const QString &groupName, int serviceId) { return craftGroupName(server, exercise, groupName) + QLatin1Char('.') + QString::number(serviceId); }
static QString craftWildcardedServiceName(int serviceId) { return craftBaseName(QLatin1String("*"), QLatin1String("*")) + QString::number(serviceId); }
Ui::ServiceManagementDialog *m_ui;
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_dtcExm;
std::shared_ptr<ServiceManagement::Interface::Dtc> m_dtc;
std::shared_ptr<ServiceManagement::Interface::Ftc> m_ftc;
private slots:
void slotRestartService(int serviceID);
void slotRestartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId);
void slotStartGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId);
void slotStopGroup(const Core::ServiceGroupType &groupType, int exercise, int server, int32_t replayPartitionId);
void slotGroupInformationChanged(ServiceManagement::GroupInformation, DataModification);
void slotServiceInformationChanged(ServiceManagement::ServiceInformation, DataModification);
};
}
@@ -1,95 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ServiceManagementDialog</class>
<widget class="QWidget" name="ServiceManagementDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>500</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Service Management</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="lbServer">
<property name="text">
<string>Server:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="cbServer">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="lbExercise">
<property name="text">
<string>Exercise:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cbExercise">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="lbNoServices">
<property name="text">
<string>There are no Services available to view.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbGroupsIndicator">
<property name="text">
<string>Groups of 'Server.Exercise':</string>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="groupLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>588</width>
<height>376</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>25</number>
</property>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -1,168 +0,0 @@
#include "scm_dialog.h"
#include "scm_dialog_group.h"
#include "ui_scm_dialog_group.h"
#include <QtCore/QDateTime>
namespace ServiceManagement
{
GroupWidget::GroupWidget(const Core::ServiceGroupType &groupType, int server, int exercise,
int32_t replayPartitionId,
const QString &groupName , long long timestamp,
const QVector<int> &neededServices, QWidget *parent)
: QWidget(parent)
, m_ui(new Ui::GroupWidget)
, m_status(ServiceWidget::UNKNOWN)
, m_server(server)
, m_exercise(exercise)
, m_groupName(groupName)
, m_replayPartitionId(replayPartitionId)
, m_neededServices(neededServices)
{
m_ui->setupUi(this);
connect(m_ui->pbRestart, &QToolButton::clicked, this, &GroupWidget::slotRestartGroup);
connect(m_ui->pbStart, &QToolButton::clicked, this, &GroupWidget::slotStartGroup);
connect(m_ui->pbStop, &QToolButton::clicked, this, &GroupWidget::slotStopGroup);
setType(groupType);
setServer(server);
setExercise(exercise);
setTimestamp(timestamp);
if (getStatus() != ServiceWidget::STOPPED)
setStatus(ServiceWidget::STARTED);
}
GroupWidget::~GroupWidget()
{
delete m_ui;
}
void GroupWidget::addService(ServiceWidget *service)
{
m_ui->lbNoServices->hide();
if (m_neededServices.contains(service->id()))
{
if (!findChild<ServiceWidget *>(service->objectName()))
{
m_ui->servicesLayout->addWidget(service);
checkStatus();
}
}
else
{
}
}
void GroupWidget::checkStatus()
{
m_status = ServiceWidget::UNKNOWN;
const QList<ServiceWidget *> serviceList = findChildren<ServiceWidget *>();
if (serviceList.isEmpty())
m_ui->lbNoServices->show();
for (const ServiceWidget *serviceWidget : serviceList)
{
if (serviceWidget->getStatus() != ServiceWidget::STARTED)
setStatus(ServiceWidget::STOPPED);
}
if (getStatus() != ServiceWidget::STOPPED)
setStatus(ServiceWidget::STARTED);
}
ServiceWidget::Status GroupWidget::getStatus() const
{
return m_status;
}
void GroupWidget::setStatus(ServiceWidget::Status status)
{
m_status = status;
QString newCss;
switch (m_status)
{
case ServiceWidget::STARTED:
newCss = QLatin1String("background-color: rgb(124, 189, 124);");
break;
case ServiceWidget::STOPPED:
newCss = QLatin1String("background-color: rgb(189, 106, 98);");
break;
case ServiceWidget::STARTING:
case ServiceWidget::STOPPING:
case ServiceWidget::UNKNOWN:
break;
}
m_ui->frStatus->setStyleSheet(newCss);
}
void GroupWidget::slotRestartGroup()
{
emit signalRestartGroup(m_groupType, m_exercise, m_server, m_replayPartitionId);
}
void GroupWidget::slotStartGroup()
{
emit signalStartGroup(m_groupType, m_exercise, m_server, m_replayPartitionId);
}
void GroupWidget::slotStopGroup()
{
emit signalStopGroup(m_groupType, m_exercise, m_server, m_replayPartitionId);
}
void GroupWidget::setType(Core::ServiceGroupType type)
{
m_groupType = type;
m_ui->lbGroupName->setText(QStringLiteral("<html><head/><body><p>%1<span style='font-weight:600;'> %2</span></p></body></html>")
.arg(tr("Services of %1").arg(ServiceManagement::ServiceManagementDialog::groupEnumToGroupName(type)), m_groupName));
}
void GroupWidget::setServer(int server)
{
m_server = server;
}
void GroupWidget::setExercise(int exercise)
{
m_exercise = exercise;
}
void GroupWidget::setTimestamp(long long timestamp)
{
if (timestamp < 1)
{
m_ui->lbTimestamp->setText(QString());
return;
}
m_ui->lbTimestamp->setText(QStringLiteral("<html><head/><body><p>%1:<br/>%2</p></body></html>")
.arg(tr("Last Heartbeat"), QDateTime::fromMSecsSinceEpoch(timestamp).toString()));
}
}
@@ -1,59 +0,0 @@
#pragma once
#include "scm_dialog_service.h"
#include <QtWidgets/QWidget>
#include <QtCore/QVector>
namespace Ui
{
class GroupWidget;
}
namespace ServiceManagement
{
class GroupWidget : public QWidget
{
Q_OBJECT
public:
GroupWidget(const Core::ServiceGroupType &groupType, int server, int exercise,
int32_t replayPartitionId,
const QString &groupName, long long timestamp,
const QVector<int> &neededServices, QWidget *parent = nullptr);
~GroupWidget();
void addService(ServiceWidget *service);
void setType(Core::ServiceGroupType type);
void setServer(int server);
void setExercise(int exercise);
void setTimestamp(long long timestamp);
ServiceWidget::Status getStatus() const;
void setStatus(ServiceWidget::Status status);
void checkStatus();
private:
Ui::GroupWidget *m_ui;
ServiceWidget::Status m_status;
Core::ServiceGroupType m_groupType;
int m_server;
int m_exercise;
QString m_groupName;
int32_t m_replayPartitionId;
QVector<int> m_neededServices;
private slots:
void slotRestartGroup();
void slotStartGroup();
void slotStopGroup();
signals:
void signalRestartGroup(const Core::ServiceGroupType &groupType, int, int, int32_t replayPartitionId);
void signalStartGroup(const Core::ServiceGroupType &groupType, int, int, const int32_t replayPartitionId);
void signalStopGroup(const Core::ServiceGroupType &groupType, int, int, const int32_t replayPartitionId);
};
}
@@ -1,222 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GroupWidget</class>
<widget class="QWidget" name="GroupWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>720</width>
<height>55</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>20</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QFrame" name="frStatus">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>10</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbGroupName">
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbTimestamp">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>250</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="pbRestart">
<property name="minimumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Restart this Group of Services (Restarts every Service inside this Group)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">R</string>
</property>
<property name="icon">
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
<normaloff>:/style/arrow_back.svg</normaloff>:/style/arrow_back.svg</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="pbStart">
<property name="minimumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Start this Group of Services (Starts Services inside this Group, that are currently stopped)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">S</string>
</property>
<property name="icon">
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
<normaloff>:/style/media-play-slower.svg</normaloff>:/style/media-play-slower.svg</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="pbStop">
<property name="minimumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Stop this Group of Services (Stops Services inside this Group, that are currently running / started)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">E</string>
</property>
<property name="icon">
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
<normaloff>:/style/application-exit.svg</normaloff>:/style/application-exit.svg</iconset>
</property>
</widget>
</item>
<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>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="servicesLayout">
<item>
<widget class="QLabel" name="lbNoServices">
<property name="text">
<string>No Services available in this Group.</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../../../Styles/Dark/resources/rme_dark_style.qrc"/>
</resources>
<connections/>
</ui>
@@ -1,134 +0,0 @@
#include "scm_dialog_service.h"
#include "ui_scm_dialog_service.h"
#include <QtCore/QDateTime>
namespace ServiceManagement
{
ServiceWidget::ServiceWidget(int32_t id, long long pid, const QString &name,
const Core::RunningState &state, const QString &errorString, QWidget *parent)
: QWidget(parent)
, m_ui(new Ui::ServiceWidget)
, m_status(ServiceWidget::UNKNOWN)
, m_id(id)
{
m_ui->setupUi(this);
connect(m_ui->pbRestart, &QToolButton::clicked, this, &ServiceWidget::slotRestartService);
setName(name);
setPid(pid);
setErrorString(errorString);
setState(state);
}
ServiceWidget::~ServiceWidget()
{
delete m_ui;
}
void ServiceWidget::setName(const QString &name)
{
m_ui->lbServiceName->setText(name);
}
void ServiceWidget::setPid(long long pid)
{
m_ui->lbPID->setText(QStringLiteral("<html><head/><body><p>%1:<br/>%2</p></body></html>")
.arg(tr("Process ID")).arg(pid));
}
void ServiceWidget::setTimestamp(long long timestamp)
{
if (timestamp < 1)
{
m_ui->lbTimestamp->setText(QString());
return;
}
m_ui->lbTimestamp->setText(QStringLiteral("<html><head/><body><p>%1:<br/>%2</p></body></html>")
.arg(tr("Last Heartbeat"), QDateTime::fromMSecsSinceEpoch(timestamp).toString()));
}
void ServiceWidget::setErrorString(const QString &errorString)
{
if (errorString.isEmpty())
{
m_ui->lbError->setText(QString());
return;
}
m_ui->lbError->setText(QStringLiteral("<html><head/><body><p><span style='color:#aa0000;'>%1:<br/>%2</span></p></body></html>").arg(tr("Error"), errorString));
}
void ServiceWidget::setState(Core::RunningState state)
{
auto status = ServiceWidget::UNKNOWN;
switch (state.underlying())
{
case Core::RunningState::inner_enum::Starting:
status = ServiceWidget::STARTING;
break;
case Core::RunningState::inner_enum::Running:
status = ServiceWidget::STARTED;
break;
case Core::RunningState::inner_enum::Stopping:
status = ServiceWidget::STOPPING;
break;
case Core::RunningState::inner_enum::StartingError:
case Core::RunningState::inner_enum::NotYetStarted:
case Core::RunningState::inner_enum::StoppedNormally:
case Core::RunningState::inner_enum::StoppedError:
status = ServiceWidget::STOPPED;
break;
}
setStatus(status);
}
void ServiceWidget::setStatus(const Status status)
{
m_status = status;
switch (m_status)
{
case ServiceWidget::STARTED:
m_ui->frStatus->setStyleSheet(greenStyleSheet());
break;
case ServiceWidget::STOPPED:
m_ui->frStatus->setStyleSheet(redStyleSheet());
break;
default:
m_ui->frStatus->setStyleSheet(orangeStyleSheet());
break;
}
}
ServiceWidget::Status ServiceWidget::getStatus() const
{
return m_status;
}
void ServiceWidget::slotRestartService()
{
emit signalRestartService(m_id);
}
}
@@ -1,59 +0,0 @@
#pragma once
#include <ServiceManagement/scm_dtc.h>
#include <QtWidgets/QWidget>
namespace Ui
{
class ServiceWidget;
}
namespace ServiceManagement
{
class ServiceWidget : public QWidget
{
Q_OBJECT
public:
enum Status
{
UNKNOWN = 0,
STARTING,
STARTED,
STOPPING,
STOPPED,
};
ServiceWidget(int32_t id, long long pid, const QString &name,
const Core::RunningState &state, const QString &errorString, QWidget *parent = nullptr);
~ServiceWidget();
void setPid(long long pid);
void setName(const QString &name);
void setTimestamp(long long timestamp);
void setState(Core::RunningState state);
void setErrorString(const QString &errorString);
void setStatus(const Status status);
Status getStatus() const;
int32_t id() const { return m_id; }
private:
Ui::ServiceWidget *m_ui;
Status m_status;
int32_t m_id;
static QString greenStyleSheet() { return QLatin1String("background-color: rgb(124, 189, 124);"); }
static QString orangeStyleSheet() { return QLatin1String("background-color: rgb(212, 190, 128);"); }
static QString redStyleSheet() { return QLatin1String("background-color: rgb(202, 122, 122);"); }
signals:
void signalRestartService(int id);
private slots:
void slotRestartService();
};
}
@@ -1,234 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ServiceWidget</class>
<widget class="QWidget" name="ServiceWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>767</width>
<height>50</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>20</number>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QFrame" name="frStatus">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>10</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>8</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="lbServiceName">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>250</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">Service Name</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="pbRestart">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>28</horstretch>
<verstretch>28</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Restart Service&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string notr="true">R</string>
</property>
<property name="icon">
<iconset resource="../../../Styles/Dark/resources/rme_dark_style.qrc">
<normaloff>:/style/arrow_back.svg</normaloff>:/style/arrow_back.svg</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbTimestamp">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>250</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbPID">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbError">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources>
<include location="../../../Styles/Dark/resources/rme_dark_style.qrc"/>
</resources>
<connections/>
</ui>
@@ -1,81 +0,0 @@
#include "scm_edit_gui_plugin.h"
#include "scm_dialog.h"
#include <LtsSession/lts_session.h>
#include <ServiceManagement/scm_operator_rights.h>
#include <ExerciseManagement/exm_data_plugin_interface.h>
namespace ServiceManagement
{
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.Scm.Edit"))
, m_dtcExm(nullptr)
, m_dtc(nullptr)
, m_ftc(nullptr)
{}
bool InterfaceImpl::fetchInterfaces()
{
if (!m_session->getDtc<DataInterface>(m_dtc))
return false;
if (!m_session->getFtc<DataInterface>(m_ftc))
return false;
if (!m_session->getDtc<ExerciseManagement::DataInterface>(m_dtcExm))
return false;
return true;
}
void InterfaceImpl::clearInterfaces()
{
m_ftc = nullptr;
m_dtc = nullptr;
}
QString InterfaceImpl::menuGroup() const
{
return tr("Services");
}
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
{
QVector<LtsWidgets::PluginData> ret;
LtsWidgets::PluginData plData;
plData.menuGroup = menuGroup();
plData.menuText = tr("Service Management");
plData.menuIcon = QIcon(QLatin1String("icon:service.svg"));
plData.identifier = QLatin1String("scmServiceEdit");
plData.operatorRight = OperatorRights::ServicesEdit;
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
plData.createWidgetFunc = [this](QWidget * parent)
{
m_dtc->enableGroupInformation();
m_dtc->enableServiceInformation();
m_ftc->enableRestartService();
m_ftc->enableStopGroup();
m_ftc->enableStartGroup();
m_ftc->enableRestartGroup();
return LtsWidgets::initDialog(new ServiceManagementDialog(parent),
m_dtc, m_ftc, m_dtcExm);
};
ret.append(plData);
return ret;
}
}
@@ -1,56 +0,0 @@
#pragma once
#include <QtCore/QObject>
#include <ServiceManagement/logger.h>
#include <ServiceManagement/scm_ftc.h>
#include <ServiceManagement/scm_dtc.h>
#include <ExerciseManagement/exm_dtc.h>
#include <ServiceManagement/scm_data_plugin_interface.h>
#include <PluginInterfaces/gui_plugin_interface.h>
namespace ServiceManagement
{
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
{
Q_PLUGIN_METADATA(IID "gui:3:scm")
Q_INTERFACES(GuiPluginBase::Plugin)
Q_OBJECT
public:
GuiPlugin() = default;
~GuiPlugin() = default;
QString pluginName() override { return QStringLiteral("ServiceManagement"); }
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
bool availableInPartition(IDL::PartitionType partition) const override
{
return (partition == IDL::PartitionType::Global);
}
};
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface
{
Q_OBJECT
public:
explicit InterfaceImpl(LtsSession::LtsSession *session);
QVector<LtsWidgets::PluginData> getActions() override;
bool fetchInterfaces() override;
void clearInterfaces() override;
QString menuGroup() const override;
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Global; }
private:
std::shared_ptr<ExerciseManagement::Interface::Dtc> m_dtcExm;
std::shared_ptr<ServiceManagement::Interface::Dtc> m_dtc;
std::shared_ptr<ServiceManagement::Interface::Ftc> m_ftc;
};
}
@@ -1,23 +0,0 @@
#pragma once
#include <PluginInterfaces/data_plugin_interface.h>
#include <ServiceManagement/scm_dtc.h>
#include <ServiceManagement/scm_ftc.h>
namespace ServiceManagement
{
class DataInterface : public DataPluginBase::Interface
{
public:
using DataPluginBase::Interface::Interface;
virtual std::shared_ptr<ServiceManagement::Interface::Dtc> getDtc() = 0;
virtual std::shared_ptr<ServiceManagement::Interface::Ftc> getFtc() = 0;
};
}
@@ -1,15 +0,0 @@
#pragma once
namespace ServiceManagement
{
class ForeignGuiInterface
{
public:
ForeignGuiInterface() = default;
virtual ~ForeignGuiInterface() = default;
};
}
@@ -1,17 +0,0 @@
#
# $Id$
# $HeadURL$
# $Author$
#
# Created by Mike Wille, SLTE, 2020-03-23
#
ADD_SUBDIRECTORY(Common)
ADD_SUBDIRECTORY(ThpManagement)
ADD_SUBDIRECTORY(ThpUsbManagement)
ADD_INTERFACE_LIBRARY(TpmGuiPluginInterface
${CMAKE_CURRENT_SOURCE_DIR}/tpm_gui_plugin_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/..
GuiPluginInterface
)
@@ -1,43 +0,0 @@
#
# $Id: CMakeLists.txt 51804 2020-07-31 04:47:28Z fritsche_h $
# $HeadURL: svn://slssvn/TDS/branches/product/iterations/21_03_salted_caramel/Lts/Plugins/TakeHomePackageManager/CMakeLists.txt $
# $Author: fritsche_h $
#
# Created by Mike Wille, SLTE, 2020-03-23
#
SET(src
logger.cpp
logger.h
tpm_exported_scripts_model.cpp
tpm_exported_scripts_model.h
tpm_process_dialog.cpp
tpm_process_dialog.h
)
QT5_WRAP_UI(src
tpm_process_dialog.ui
)
NGL_ADD_LIBRARY2(WS ThpCommon SHARED ${src})
NGL_TARGET_INCLUDE_DIRECTORIES(ThpCommon
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../ # export file
)
NGL_TARGET_LINK_LIBRARIES(ThpCommon
Qt6::Core
Qt6::Concurrent
NGLLogger
LtsSession
AsmDataPluginInterface
ExmDataPluginInterface
#nglcompression
#nglsettings
#ngltools
#LtsSessionData
#httq
)
NGL_INSTALL_TARGET(ThpCommon)
@@ -1,32 +0,0 @@
#include "logger.h"
#include <NGLLogger/NGLLoggerBootstrap.h>
namespace TakeHomePackageManager
{
LOGGER_T getLogger(const char *name)
{
static const char ns[] = "TPM.Common.";
std::string loggerName;
const size_t len = strlen(name);
loggerName.reserve(sizeof(ns) + len);
loggerName.append(ns, sizeof(ns) - 1);
loggerName.append(name, len);
try
{
return NGL::NGLLoggerBootstrap::getNGLRootLogger().
getNGLLogger(loggerName);
}
catch (const std::exception &ex)
{
fprintf(stderr, "Error retrieving logger: %s", ex.what());
abort();
}
}
}
@@ -1,17 +0,0 @@
#pragma once
#include <NGLLogger/INGLLogger.h>
namespace TakeHomePackageManager
{
typedef NGL::INGLLogger &LOGGER_T;
LOGGER_T getLogger(const char *name);
inline LOGGER_T getLogger(const QString &loggerName)
{
return getLogger(loggerName.toUtf8().constData());
}
}
@@ -1,602 +0,0 @@
#include "tpm_exported_scripts_model.h"
#include <utility>
#include <ngltools/ngltools_dtg.h>
#include <QtCore/QDateTime>
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QJsonArray>
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonObject>
namespace TakeHomePackageManager
{
ExportedScriptsModel::ExportedScriptsModel(QObject *parent)
: LtsWidgets::LtsAbstractTableModel<ExportedScriptInformation>(
{ tr("id"), tr("Exercise"), tr("Name"), tr("Created"), tr("Last downloaded"), tr("Location"), tr("Last uploaded"), tr("Server")}, parent)
{}
bool ExportedScriptsModel::init(const QString &rootDirectoryToScan)
{
std::shared_ptr<int> _(nullptr, [this](int *) { endResetModel(); });
m_rootDirectoryToScan = rootDirectoryToScan;
beginResetModel();
m_vecData.clear();
QVector <int> localExercises;
DEBUG_LOG(m_logger) << "ExportedScriptsModel::init rootDirectoryToScan=" << rootDirectoryToScan
;
{
DEBUG_LOG(m_logger) << "Get all local exercises rootDirectoryToScan=" << rootDirectoryToScan ;
QFile file(rootDirectoryToScan + QDir::separator() + QStringLiteral("exercises.json"));
if (!file.open(QFile::ReadOnly))
WARNING_LOG(m_logger) << "Cannot open " << file.fileName() << " for read/write: " << file.errorString();
const QJsonDocument doc(QJsonDocument::fromJson(file.readAll()));
const QJsonObject obj = doc.object();
const QJsonArray arr = obj[QStringLiteral("Exercises")].toArray();
localExercises.reserve(arr.size());
for (const auto &ele : arr)
localExercises.append(ele.toInt());
}
WARNING_LOG(m_logger) << "local exericses: " << localExercises.count();
for (const int exId : std::as_const(localExercises))
{
const QString baseDir = exercisePath(rootDirectoryToScan, exId);
QFile file(baseDir + QDir::separator() + QStringLiteral("data.json"));
if (!file.open(QIODevice::ReadOnly))
{
WARNING_LOG(m_logger) << "Cannot open " << file.fileName() << " for reading: " << file.errorString() << " - not critical";
return true;
}
const QJsonDocument doc(QJsonDocument::fromJson(file.readAll()));
const QJsonObject obj = doc.object();
const QJsonArray presentations = obj[QStringLiteral("presentations")].toArray();
DEBUG_LOG(m_logger) << "exercise: " << exId << ", presentations: " << presentations.size();
for (const QJsonValue &val : presentations)
{
ExportedScriptInformation esi = ExportedScriptInformation::fromJson(val);
DEBUG_LOG(m_logger) << "obj=" << QJsonDocument(obj).toJson(QJsonDocument::Compact);
const QJsonObject presentationObj = val.toObject();
DEBUG_LOG(m_logger) << "presentationObj=" << QJsonDocument(presentationObj).toJson(QJsonDocument::Compact);
if (obj.contains(QStringLiteral("exerciseId")))
{
esi.exerciseId = obj[QStringLiteral("exerciseId")].toInt();
esi.exerciseName = obj[QStringLiteral("exerciseName")].toString();
if (presentationObj.contains(QStringLiteral("name")) )
esi.scriptName = presentationObj[QStringLiteral("name")].toString();
if (presentationObj.contains(QStringLiteral("displayName")) )
esi.scriptName = presentationObj[QStringLiteral("displayName")].toString();
}
esi.local = true;
DEBUG_LOG(m_logger) << "push_back "
<< " exportTime=" << esi.exportTime
<< " scriptId=" << esi.scriptId
<< " scriptName=" << esi.scriptName
<< " exerciseId=" << esi.exerciseId
<< " exerciseName=" << esi.exerciseName
<< " local=" << esi.local;
esi.uploaded = ThpUnknownUploadState;
esi.rootDirectory = rootDirectoryToScan;
m_vecData.push_back(esi);
}
}
return true;
}
void ExportedScriptsModel::setServerContent(const QString &jsonArray)
{
if (jsonArray.isEmpty())
return;
QMap<int, QVector<int>> exerciseContentScriptIds;
QMap<int, QVector<int>> exerciseScriptIds;
DEBUG_LOG(m_logger) << "ExportedScriptsModel::setServerContent jsonArray =" << jsonArray;
QJsonParseError err;
const QJsonArray presentations = QJsonDocument::fromJson(jsonArray.toUtf8(), &err).array();
DEBUG_LOG(m_logger) << "presentations.size() =" << presentations.size();
if (err.error != QJsonParseError::NoError)
{
ERROR_LOG(m_logger) << "json array invalid at offset " << err.offset << ": " << err.errorString();
return;
}
for (const auto &data : std::as_const(m_vecData))
{
exerciseScriptIds[data.exerciseId].append(data.scriptId);
DEBUG_LOG(m_logger) << "exerciseId=" << data.exerciseId
<< " modelScriptIds.append: " << data.scriptId;
}
for (const QJsonValue &val : presentations)
{
const ExportedScriptInformation esi = ExportedScriptInformation::fromJson(val, false, ThpAlreadyUploaded);
exerciseContentScriptIds[esi.exerciseId].append(esi.scriptId);
}
for (int i = m_vecData.size() - 1; i >= 0; --i)
{
const auto &rowData = m_vecData[i];
const QVector<int> contentScriptIds = exerciseContentScriptIds.value(rowData.exerciseId);
DEBUG_LOG(m_logger) << "m_vecData.at(" << i << ").scriptId=" << rowData.scriptId
<< " exerciseId=" << rowData.exerciseId
<< " contentScriptIds.contains=" << contentScriptIds.contains(rowData.scriptId)
<< " rowData.local=" << rowData.local
<< " contentScriptIds.size()=" << contentScriptIds.size();
if (!contentScriptIds.contains(rowData.scriptId))
{
if (rowData.local == false)
{
DEBUG_LOG(m_logger) << "removeRow(" << i << ")"
<< " ScriptId=" << rowData.scriptId
<< " ExerciseId=" << rowData.exerciseId;
removeRow(i);
}
else
{
setUploadState(i, ThpUploadNotActive, 0, 0);
}
}
}
for (const QJsonValue &val : presentations)
{
ExportedScriptInformation esi = ExportedScriptInformation::fromJson(val, false, ThpAlreadyUploaded);
QVector<int> modelScriptIds = exerciseScriptIds.value(esi.exerciseId);
DEBUG_LOG(m_logger) << " exportTime=" << esi.exportTime
<< " scriptId=" << esi.scriptId
<< " exerciseId=" << esi.exerciseId
<< " exerciseName=" << esi.exerciseName
<< " scriptName=" << esi.scriptName
<< " fileSize=" << esi.fileSize
<< " modelScriptIds.size=" << modelScriptIds.size();
if (!modelScriptIds.contains(esi.scriptId))
{
DEBUG_LOG(m_logger) << "insertRow()";
insertRow(esi);
continue;
}
for (int i = 0; i < m_vecData.size(); i++)
{
const auto &rowData = m_vecData[i];
if (rowData.scriptId == esi.scriptId &&
rowData.exerciseId == esi.exerciseId)
{
DEBUG_LOG(m_logger) << "setUploadState i=" << i
<< " esi.scriptId=" << esi.scriptId
<< " esi.exerciseId=" << esi.exerciseId
<< " esi.fileSize=" << esi.fileSize
<< " esi.uploadTime=" << esi.uploadTime;
setUploadState(i, ThpAlreadyUploaded, esi.uploadTime, esi.fileSize);
break;
}
}
}
update();
return;
}
qint64 ExportedScriptsModel::downloadTime(const ExportedScriptInformation &val) const
{
if (!val.local)
return 0;
QString filename(QStringLiteral("%1/THP-Download/Exercise_%2/%3/index.html").arg(QDir::tempPath()).arg(val.exerciseId).arg(val.scriptId));
DEBUG_LOG(m_logger) << "downloadTime: filename " << filename;
QFileInfo fi(filename);
if (!fi.exists())
return 0;
return fi.lastModified().toMSecsSinceEpoch();
}
QVariant ExportedScriptsModel::data(const QModelIndex &index, int role) const
{
if (!indexIsValid(index))
return QVariant();
const ExportedScriptInformation &val = m_vecData[index.row()];
switch (role)
{
case Qt::FontRole:
{
if (!m_isOC
|| !val.local
|| index.column() != ColUploadedTime
|| val.uploadTime <= (downloadTime(val) + (10 * 1000) ))
break;
QFont font;
font.setBold(true);
return font;
}
case Qt::DisplayRole:
{
switch (index.column())
{
case ColId:
return val.scriptId;
case ColExercise:
return val.exerciseName;
case ColName:
return val.scriptName;
case ColCreated:
return QDateTime::fromMSecsSinceEpoch(val.exportTime);
case ColDownloaded:
{
qint64 dlTime = downloadTime(val);
if (dlTime == 0)
return QVariant();
return QDateTime::fromMSecsSinceEpoch(dlTime);
}
case ColUploadedTime:
return QDateTime::fromMSecsSinceEpoch(val.uploadTime);
case ColLocation:
return val.local ? tr("Local") : tr("Server");
case ColUploaded:
switch (val.uploaded)
{
case ThpConnectToHost:
return tr("Connect to host");
case ThpUploadActive:
return tr("Upload Active");
case ThpUploadError:
return tr("Upload Error");
case ThpUploadNotActive:
return tr("Not uploaded");
case ThpUnknownUploadState:
return tr("Unknown upload status");
case ThpAlreadyUploaded:
return tr("Already uploaded");
}
}
case Qt::UserRole:
{
return val.scriptId;
break;
}
break;
}
}
return QVariant();
}
bool ExportedScriptsModel::createDataJson(const QString &rootDirectory,
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc,
const std::shared_ptr<AssetManagement::Interface::Dtc> &asmDtc,
int exerciseId) const
{
const QString baseDir = exercisePath(rootDirectory, exerciseId);
if (!QDir().mkpath(baseDir))
{
ERROR_LOG(m_logger) << "Failed to create path " << baseDir;
return false;
}
QFile file(baseDir + QStringLiteral("data.json"));
DEBUG_LOG(m_logger) << "createDataJson=" << file.fileName();
if (!file.open(QFile::ReadWrite))
{
QString msg(tr("Could not open data file in script directory: %1").arg(file.errorString()));
ERROR_LOG(m_logger) << msg << " - " << file.fileName();
return false;
}
QJsonDocument doc(QJsonDocument::fromJson(file.readAll()));
QJsonObject obj = doc.object();
if (obj[QStringLiteral("exerciseId")].toInt() == exerciseId)
{
DEBUG_LOG(m_logger) << baseDir << " exists for exerciseId " << QString::number(exerciseId);
return true;
}
const ExerciseManagement::Exercise exercise = exmDtc->exercise(exerciseId);
const AssetManagement::TrainingArea ta = asmDtc->trainingArea(exercise.trainingAreaId());
obj[QStringLiteral("title")] = QString::fromStdString(exercise.name());
obj[QStringLiteral("exerciseId")] = exercise.id();
obj[QStringLiteral("exerciseName")] = QString::fromStdString(exercise.name());
obj[QStringLiteral("exerciseArea")] = QString::fromStdString(ta.name());
obj[QStringLiteral("cycleTime")] = QString(QDateTime::fromMSecsSinceEpoch(exercise.beginTime()).toString() +
QStringLiteral(" - ") + QDateTime::fromMSecsSinceEpoch(exercise.endTime()).toString());
obj[QStringLiteral("exerciseStart")] = exercise.beginTime();
obj[QStringLiteral("exerciseEnd")] = exercise.endTime();
obj[QStringLiteral("exercisingForces")] = QString::fromStdString(exercise.forces());
obj[QStringLiteral("exercisingPurpose")] = QString::fromStdString(exercise.description());
file.resize(0);
file.write(QJsonDocument(obj).toJson());
return true;
}
void ExportedScriptsModel::addDownloadData(const ExportedScriptInformation &esi)
{
{
DEBUG_LOG(m_logger) << "Add exercise to ExportRootPath";
if (!QDir(esi.rootDirectory).exists())
{
ERROR_LOG(m_logger) << "Cannot modify exercises.json as the info's root directory '"<<esi.rootDirectory<<"' does not exist!";
return;
}
QFile file(esi.rootDirectory + QDir::separator() + QStringLiteral("exercises.json"));
if (!file.open(QFile::ReadWrite))
{
WARNING_LOG(m_logger) << "Can not open " << file.fileName() << " for read/write: " << file.errorString();
return;
}
const QString key = QStringLiteral("Exercises");
QJsonDocument doc(QJsonDocument::fromJson(file.readAll()));
QJsonObject obj = doc.object();
QJsonArray arr = obj.value(key).toArray();
if (!arr.contains(esi.exerciseId))
{
DEBUG_LOG(m_logger) << "arr.append Exercise=" << esi.exerciseId;
arr.append(esi.exerciseId);
}
obj.insert(key, arr);
file.resize(0);
file.write(QJsonDocument(obj).toJson());
INFO_LOG(m_logger) << " file.write " << QJsonDocument(obj).toJson();
file.close();
}
const QString baseDir = exercisePath(esi.rootDirectory, esi.exerciseId);
if (!QDir().mkpath(baseDir))
{
ERROR_LOG(m_logger) << "Cannot create destination path " << baseDir;
return;
}
QFile file(baseDir + QDir::separator() + QStringLiteral("data.json"));
DEBUG_LOG(m_logger) << "File= " << file.fileName();
if (!file.open(QFile::ReadWrite))
{
WARNING_LOG(m_logger) << "Can not open " << file.fileName() << " for read/write: " << file.errorString();
return;
}
const QString keyArray = QStringLiteral("presentations");
const QJsonDocument doc(QJsonDocument::fromJson(file.readAll()));
QJsonObject obj = doc.object();
QJsonArray arr = obj.value(keyArray).toArray();
bool exported = false;
DEBUG_LOG(m_logger) << "arr.size=" << arr.size();
for (int i = 0; i < arr.size(); ++i)
{
auto arresi = ExportedScriptInformation::fromJson(arr.at(i));
if (arresi.scriptId == esi.scriptId &&
arresi.exerciseId == esi.exerciseId)
{
arresi.jsonPath = esi.jsonPath;
arr[i] = esi.toJson();
exported = true;
}
}
if (!exported)
{
DEBUG_LOG(m_logger) << "info scriptId=" << esi.scriptId
<< " Name=" << esi.scriptName
<< " Exercise=" << esi.exerciseName;
arr.append(esi.toJson());
}
obj.insert(keyArray, arr);
auto content = QJsonDocument(obj).toJson();
DEBUG_LOG(m_logger) << "content =" << content;
file.resize(0);
file.write(content);
file.close();
}
bool ExportedScriptsModel::setLocalState(const int row, const bool localHost)
{
ExportedScriptInformation data = getRowData(row);
data.local = localHost;
DEBUG_LOG(m_logger) << "setLocalState row=" << row
<< " scriptId=" << data.scriptId
<< " data.scriptName=" << data.scriptName
<< " Exercise=" << data.exerciseName;
bool result = setRowData(row, data);
if (result && localHost && m_rootDirectoryToScan.contains(QStringLiteral("Download")))
{
data.rootDirectory = m_rootDirectoryToScan;
setRowData(row, data);
addDownloadData(data);
}
return result;
}
bool ExportedScriptsModel::setUploadState(const int row,
const UploadState uploadState,
const qint64 uploadTime,
const qint64 fileSize)
{
ExportedScriptInformation data = getRowData(row);
data.uploaded = uploadState;
data.uploadTime = uploadTime;
data.fileSize = fileSize;
return setRowData(row, data);
}
bool ExportedScriptsModel::removeRow(int row)
{
ExportedScriptInformation data = getRowData(row);
if (!LtsWidgets::LtsAbstractTableModel<ExportedScriptInformation>::removeRow(row))
return false;
QString baseDir = exercisePath(data.rootDirectory, data.exerciseId);
QString filename = baseDir + QStringLiteral("data.json");
DEBUG_LOG(m_logger) << "filename= '" << filename << "'";
QFile file(baseDir + QStringLiteral("data.json"));
if (!file.open(QIODevice::ReadWrite))
{
DEBUG_LOG(m_logger) << "!file.open '" << filename << "'"
<< " no local scripts";
return true;
}
const QJsonDocument doc(QJsonDocument::fromJson(file.readAll()));
QJsonObject obj = doc.object();
const int exId = obj.value(QStringLiteral("exerciseId")).toInt();
QJsonArray arr;
for (const auto &esi : std::as_const(m_vecData))
{
if (esi.exerciseId == exId)
arr += esi.toJson();
}
obj[QStringLiteral("presentations")] = arr;
file.resize(0);
auto content = QJsonDocument(obj).toJson();
DEBUG_LOG(m_logger) << "content =" << content;
return file.write(QJsonDocument(obj).toJson());
}
QString ExportedScriptsModel::exercisePath(const QString &rootDirectory, const int exerciseId) const
{
QString path = QStringLiteral("%1/Exercise_%2/").arg(rootDirectory).arg(exerciseId);
#ifndef WIN32
path.prepend(QStringLiteral("/"));
#endif
return path;
}
QJsonValue ExportedScriptInformation::toJson() const
{
return QJsonObject({
{ QStringLiteral("displayName"), scriptName },
{ QStringLiteral("path"), jsonPath },
{ QStringLiteral("scriptId"), scriptId },
{ QStringLiteral("exportTime"), exportTime },
{ QStringLiteral("fileSize"), fileSize },
{ QStringLiteral("uploadTime"), uploadTime },
{ QStringLiteral("exerciseName"), exerciseName },
{ QStringLiteral("exerciseId"), exerciseId }
});
}
ExportedScriptInformation ExportedScriptInformation::fromJson(const QJsonValue &val,
const bool local,
const UploadState uploadState)
{
const QJsonObject obj = val.toObject();
ExportedScriptInformation esi;
esi.local = local;
esi.scriptName = obj[QStringLiteral("displayName")].toString();
if (esi.scriptName.isEmpty())
esi.scriptName = obj[QStringLiteral("name")].toString();
esi.jsonPath = obj[QStringLiteral("path")].toString();
esi.scriptId = obj[QStringLiteral("scriptId")].toInt();
esi.exportTime = qRound64(obj[QStringLiteral("exportTime")].toDouble());
esi.fileSize = obj[QStringLiteral("fileSize")].toInt();
esi.uploaded = uploadState;
esi.uploadTime = qRound64(obj[QStringLiteral("uploadTime")].toDouble());
esi.exerciseName = obj[QStringLiteral("exerciseName")].toString();
esi.exerciseId = obj[QStringLiteral("exerciseId")].toInt();
Q_ASSERT(esi.scriptId != -1);
Q_ASSERT(esi.exerciseId != -1);
if (esi.scriptId != -1 && esi.exerciseId != -1)
esi.valid = true;
return esi;
}
}
@@ -1,93 +0,0 @@
#pragma once
#include <logger.h>
#include <LtsWidgets/lts_abstract_table_model.h>
#include <ExerciseManagement/exm_data_plugin_interface.h>
#include <AssetManagement/asm_data_plugin_interface.h>
#include "thpcommon_export.h"
namespace TakeHomePackageManager
{
enum UploadState
{
ThpUnknownUploadState,
ThpUploadNotActive,
ThpConnectToHost,
ThpUploadActive,
ThpAlreadyUploaded,
ThpUploadError,
};
struct ExportedScriptInformation
{
bool valid { false };
QString exerciseName;
QString scriptName;
QString jsonPath;
QString rootDirectory;
qint64 exerciseId = -1;
qint64 exportTime = 0;
qint64 fileSize = 0;
bool local = true;
UploadState uploaded = ThpUnknownUploadState;
qint64 uploadTime = 0;
int scriptId = -1;
int id() const { return scriptId; }
QJsonValue toJson() const;
static ExportedScriptInformation fromJson(const QJsonValue &val,
const bool local = true,
const UploadState uploadStates = ThpUnknownUploadState);
};
class THPCOMMON_EXPORT ExportedScriptsModel : public LtsWidgets::LtsAbstractTableModel<ExportedScriptInformation>
{
Q_OBJECT
public:
enum Columns
{
ColId,
ColExercise,
ColName,
ColCreated,
ColDownloaded,
ColLocation,
ColUploadedTime,
ColUploaded,
};
explicit ExportedScriptsModel(QObject *parent = nullptr);
bool init(const QString &rootDirectoryToScan);
void setServerContent(const QString &jsonArray);
void setOC(bool isOC) { m_isOC = isOC; }
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool removeRow(int row) override;
bool setLocalState(const int row, const bool localHost);
bool setUploadState(const int row, const UploadState uploadState, const qint64 uploadTime, const qint64 fileSize);
bool createDataJson(const QString &rootDirectory, const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc,
const std::shared_ptr<AssetManagement::Interface::Dtc> &asmDtc,
int exerciseId) const;
void addDownloadData(const ExportedScriptInformation &esi);
private:
NGL::INGLLogger &m_logger;
QString exercisePath(const QString &rootDirectory, const int exerciseId) const;
qint64 downloadTime(const ExportedScriptInformation &val) const;
private:
bool m_isOC { false };
QString m_rootDirectoryToScan;
};
}
@@ -1,66 +0,0 @@
#include "tpm_process_dialog.h"
#include "ui_tpm_process_dialog.h"
namespace TakeHomePackageManager
{
ProcessOverlay::ProcessOverlay(QWidget *parent)
: QWidget(parent)
, m_ui(new Ui::ProcessOverlay)
{
m_ui->setupUi(this);
connect(m_ui->pbCancel, &QPushButton::clicked,
this, [this]()
{
m_ui->pbCancel->setEnabled(false);
emit signalCancel();
});
}
ProcessOverlay::~ProcessOverlay()
{
delete m_ui;
}
void ProcessOverlay::setCancelEnabled(bool enabled)
{
m_ui->pbCancel->setEnabled(enabled);
}
void ProcessOverlay::setStatus(const QString &text, qint64 totalFiles, qint64 curFile, qint64 totalSize, qint64 curPos, const QString &curName)
{
if (!text.isEmpty())
m_ui->lblStatus->setText(text);
if (!curName.isEmpty())
m_ui->lblFilename->setText(curName);
double progressBytes = (totalSize == 0) ? (double)0 : ((double)curPos / (double)totalSize);
double progressFiles = (((double)curFile - 1) / (double)totalFiles);
double progressTotal = progressFiles + (progressBytes / (double)totalFiles);
progressBytes = qRound(progressBytes * 100);
progressFiles = qRound(progressFiles * 100);
progressTotal = qRound(progressTotal * 100);
m_ui->pbarFiles->setValue(progressFiles);
m_ui->pbarBytes->setValue(progressBytes);
m_ui->pbarProgress->setValue(progressTotal);
QLocale l;
if (curFile == 0)
m_ui->lblFiles->setText(QStringLiteral(" - "));
else
m_ui->lblFiles->setText(QStringLiteral("%1 / %2").arg(l.toString(curFile)).arg(l.toString(totalFiles)));
if (curPos == 0)
m_ui->lblBytes->setText(QStringLiteral(" - "));
else
m_ui->lblBytes->setText(QStringLiteral("%1 / %2").arg(l.toString(curPos)).arg(l.toString(totalSize)));
}
}
@@ -1,32 +0,0 @@
#pragma once
#include "thpcommon_export.h"
#include <QtWidgets/QWidget>
namespace Ui
{
class ProcessOverlay;
}
namespace TakeHomePackageManager
{
class THPCOMMON_EXPORT ProcessOverlay : public QWidget
{
Q_OBJECT
public:
ProcessOverlay(QWidget *parent = nullptr);
~ProcessOverlay();
void setStatus(const QString &text = QString(), qint64 totalFiles = 1, qint64 curFile = 1, qint64 totalSize = 0, qint64 curPos = 0, const QString &curName = QString());
void setCancelEnabled(bool enabled = true);
signals:
void signalCancel();
private:
Ui::ProcessOverlay *m_ui;
bool m_decompressing { false };
};
}
@@ -1,174 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProcessOverlay</class>
<widget class="QWidget" name="ProcessOverlay">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>220</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>700</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="1">
<widget class="QLabel" name="lblBytes">
<property name="text">
<string notr="true"> - </string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Progress</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QProgressBar" name="pbarFiles">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="lblFiles">
<property name="text">
<string notr="true"> - </string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblStatus">
<property name="text">
<string notr="true">Preparing ...</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Files</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QProgressBar" name="pbarBytes">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="7" column="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="pbCancel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0" colspan="3">
<widget class="Line" name="line">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="lblFilename">
<property name="text">
<string notr="true"> - </string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Bytes</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<widget class="QProgressBar" name="pbarProgress">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Filename</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="Line" name="line_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -1,65 +0,0 @@
#
# $Id: CMakeLists.txt 51804 2020-07-31 04:47:28Z fritsche_h $
# $HeadURL: svn://slssvn/TDS/branches/product/iterations/21_03_salted_caramel/Lts/Plugins/TakeHomePackageManager/CMakeLists.txt $
# $Author: fritsche_h $
#
# Created by Gerlinde Rudolphus, NLE, 2019-03-25
#
#
# Common
#
# Make ${Qt6_Widgets} optional
if(QT6_GUI_AVAILABLE AND TARGET Qt6::Widgets)
set(Qt6_Widgets ${Qt6_Widgets})
else()
set(Qt6_Widgets "")
endif()
# Make ${Qt6_WebSockets} optional
if(QT6_GUI_AVAILABLE AND TARGET Qt6::WebSockets)
set(Qt6_WebSockets ${Qt6_WebSockets})
else()
set(Qt6_WebSockets "")
endif()
SET(thp_SRCS
tpm_gui_plugin.cpp
tpm_gui_plugin.h
tpm_exported_scripts_dialog.cpp
tpm_exported_scripts_dialog.h
logger.cpp
logger.h
)
QT5_WRAP_UI(thp_SRCS
tpm_exported_scripts_dialog.ui
)
#TODO: auto-remove "libTakeHomePackageManagerGuiPlugin.so" from lib as this lib replaces it
NGL_ADD_LIBRARY2(WS ThpManagementGuiPlugin MODULE ${thp_SRCS})
if(QT6_GUI_AVAILABLE)
NGL_TARGET_LINK_LIBRARIES(ThpManagementGuiPlugin
ThpCommon
TpmGuiPluginInterface
${Qt6_Widgets}
Qt6::Network
${Qt6_WebSockets}
NGLLogger
LtsWidgets
LtsSession
LtsDataView
nglcompression
nglsettings
ngltools
AsmDataPluginInterface
ExmDataPluginInterface
LtsSessionData
httq
)
endif()
NGL_INSTALL_TARGET(ThpManagementGuiPlugin)
@@ -1,32 +0,0 @@
#include "logger.h"
#include <NGLLogger/NGLLoggerBootstrap.h>
namespace TakeHomePackageManager
{
LOGGER_T getLogger(const char *name)
{
static const char ns[] = "TPM.";
std::string loggerName;
const size_t len = strlen(name);
loggerName.reserve(sizeof(ns) + len);
loggerName.append(ns, sizeof(ns) - 1);
loggerName.append(name, len);
try
{
return NGL::NGLLoggerBootstrap::getNGLRootLogger().
getNGLLogger(loggerName);
}
catch (const std::exception &ex)
{
fprintf(stderr, "Error retrieving logger: %s", ex.what());
abort();
}
}
}
@@ -1,17 +0,0 @@
#pragma once
#include <NGLLogger/INGLLogger.h>
namespace TakeHomePackageManager
{
typedef NGL::INGLLogger &LOGGER_T;
LOGGER_T getLogger(const char *name);
inline LOGGER_T getLogger(const QString &loggerName)
{
return getLogger(loggerName.toUtf8().constData());
}
}
@@ -1,207 +0,0 @@
#pragma once
#include "logger.h"
#include <Common/tpm_exported_scripts_model.h>
#include <LtsWidgets/lts_dialog.h>
#include <QtCore/QUrlQuery>
namespace Ui
{
class ExportedScriptsDialog;
}
namespace NGL
{
class Compress;
}
namespace LtsSession
{
class LtsSession;
}
class QTemporaryFile;
class QNetworkAccessManager;
class QNetworkReply;
class QNetworkRequest;
class QFileSystemWatcher;
namespace TakeHomePackageManager
{
class ProcessOverlay;
class HttpProcess : public QObject
{
Q_OBJECT
public:
HttpProcess(ExportedScriptInformation &&esi, QObject *parent);
virtual ~HttpProcess();
ProcessOverlay *process() const { return m_process; }
signals:
void signalReadyRead();
void signalSuccess();
void signalTimeout();
void signalCancel();
void signalError();
private slots:
void slotReadyRead();
void slotError();
void slotSuccess();
protected slots:
void stopTimeout();
void resetTimeout();
private:
NGL::INGLLogger &m_logger;
void doConnections(QNetworkReply *r);
protected:
QNetworkReply *post(const QString &path, QIODevice *data, const QUrlQuery &q = QUrlQuery(), const QString &contentType = QStringLiteral("application/octet-stream"));
QNetworkReply *get(const QString &path, const QUrlQuery &q = QUrlQuery());
QNetworkReply *deleteResource(const QString &path, const QUrlQuery &q = QUrlQuery());
ExportedScriptInformation m_esi;
bool m_isError { false };
ProcessOverlay *m_process;
bool m_wasCanceled { false };
bool m_isTimeout { false };
private:
static QNetworkRequest forgeRequest(const QString &path, const QUrlQuery &q, const QString &contentType = QString());
QNetworkAccessManager *m_nam;
QTimer *m_timeout;
};
class UploadProcess : public HttpProcess
{
Q_OBJECT
public:
UploadProcess(const QString &rootFolder, ExportedScriptInformation &&esi, QObject *parent);
signals:
private slots:
void compressionDone();
private:
void abortCompress();
QTemporaryFile *m_tempFile;
NGL::Compress *m_compress;
QString m_rootDir;
};
class DownloadProcess : public HttpProcess
{
Q_OBJECT
public:
DownloadProcess(const QString &rootFolder, int modelRowId, ExportedScriptInformation &&esi, QObject *parent);
int modelRowId() const { return m_modelRowId; }
private slots:
void downloadFinished();
signals:
void signalDone();
private:
QTemporaryFile *m_tempFile;
NGL::Compress *m_compress { nullptr };
int m_modelRowId { -1 };
QString m_rootFolder;
};
class RemoveProcess : public HttpProcess
{
Q_OBJECT
public:
RemoveProcess(int modelRowId, ExportedScriptInformation &&esi, QObject *parent);
int modelRowId() const { return m_modelRowId; }
signals:
void signalDone();
private:
int m_modelRowId { -1 };
};
class ExportedScriptsDialog : public LtsWidgets::LtsDialog
{
Q_OBJECT
public:
explicit ExportedScriptsDialog(QWidget *parent = nullptr);
~ExportedScriptsDialog();
void retranslate() override;
bool init(LtsSession::LtsSession *session);
static QString getContentFolder(const QString &rootFolder, int exerciseId);
private slots:
void uploadScript();
void downloadScript();
void removeScriptFromServer();
void removeScriptLocal();
void openScript();
void onSelectionChanged();
private:
enum class WsConnectionStatus
{
NotConnected,
Connecting,
Disconnected,
Error,
Connected,
};
void startUpload();
QString getContentFolder(int exerciseId) const;
QString getRootFolder() const;
bool initModel();
void setWsConnectionStatus(WsConnectionStatus status);
void setWsConnectionStatusLabel();
private:
ExportedScriptsModel *m_model;
Ui::ExportedScriptsDialog *m_ui;
LtsSession::LtsSession *m_session;
int m_exerciseId;
QFileSystemWatcher *m_fsWatcher;
QString m_lastServerContent;
WsConnectionStatus m_wsStatus { WsConnectionStatus::NotConnected };
};
}
@@ -1,77 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExportedScriptsDialog</class>
<widget class="QWidget" name="ExportedScriptsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>834</width>
<height>491</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>The following Scripts are already exported. You can remove them from your local hard disk or upload them to the server here.</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Server connection status:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblWsStatus">
<property name="text">
<string notr="true">-</string>
</property>
</widget>
</item>
<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>
</layout>
</item>
<item>
<widget class="LtsDataView::LtsDataView" name="ltsDataView">
<property name="showColumnCount" stdset="0">
<bool>false</bool>
</property>
<property name="toolButtonsVisible">
<bool>false</bool>
</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>
@@ -1,54 +0,0 @@
#include "tpm_gui_plugin.h"
#include "tpm_exported_scripts_dialog.h"
#include "logger.h"
namespace TakeHomePackageManager
{
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.Tpm"))
{}
bool InterfaceImpl::fetchInterfaces()
{
return true;
}
QString InterfaceImpl::menuGroup() const
{
return tr("Presentation");
}
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
{
QVector<LtsWidgets::PluginData> ret;
LtsWidgets::PluginData plData;
plData.menuGroup = menuGroup();
if (m_session->app() == LtsAppDescriptor::App::Scripts)
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
else
plData.exercisePart = LtsWidgets::ExercisePart::eAfterAction;
plData.identifier = QLatin1String("PresentationManagement.ScriptDialog.ManageExportedScripts");
plData.menuIcon = QIcon(QLatin1String("icon:export_documents.svg"));
plData.menuText = tr("Manage Exported Scripts");
plData.createWidgetFunc = [this](QWidget *)
{
return LtsWidgets::initDialog(new ExportedScriptsDialog(), m_session);
};
ret.append(plData);
return ret;
}
}
@@ -1,45 +0,0 @@
#pragma once
#include <OldTHP/tpm_gui_plugin_interface.h>
#include "logger.h"
#include <LtsSession/lts_session.h>
#include <PluginInterfaces/gui_plugin_interface.h>
namespace TakeHomePackageManager
{
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
{
Q_PLUGIN_METADATA(IID "gui:3:tpm.man")
Q_INTERFACES(GuiPluginBase::Plugin)
Q_OBJECT
public:
GuiPlugin() = default;
~GuiPlugin() = default;
QString pluginName() override { return QLatin1String("TakeHomePackageManager"); }
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, public ForeignTpmGuiInterface
{
Q_OBJECT
public:
explicit InterfaceImpl(LtsSession::LtsSession *session);
bool fetchInterfaces() override;
QString menuGroup() const override;
QVector<LtsWidgets::PluginData> getActions() override;
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Exercise; }
private:
};
}
@@ -1,61 +0,0 @@
#
# $Id: CMakeLists.txt 51804 2020-07-31 04:47:28Z fritsche_h $
# $HeadURL: svn://slssvn/TDS/branches/product/iterations/21_03_salted_caramel/Lts/Plugins/TakeHomePackageManager/CMakeLists.txt $
# $Author: fritsche_h $
#
# Created by Mike Wille, SLTE, 2020-03-23
#
# Make ${Qt6_Widgets} optional
if(QT6_GUI_AVAILABLE AND TARGET Qt6::Widgets)
set(Qt6_Widgets ${Qt6_Widgets})
else()
set(Qt6_Widgets "")
endif()
# Make ${Qt6_WebSockets} optional
if(QT6_GUI_AVAILABLE AND TARGET Qt6::WebSockets)
set(Qt6_WebSockets ${Qt6_WebSockets})
else()
set(Qt6_WebSockets "")
endif()
SET(src
tpm_usb_gui_plugin.cpp
tpm_usb_gui_plugin.h
tpm_usb_dialog.cpp
tpm_usb_dialog.h
logger.cpp
logger.h
)
QT5_WRAP_UI(src
tpm_usb_dialog.ui
)
NGL_ADD_LIBRARY2(WS ThpUsbManagementGuiPlugin MODULE ${src})
if(QT6_GUI_AVAILABLE)
NGL_TARGET_LINK_LIBRARIES(ThpUsbManagementGuiPlugin
ThpCommon
TpmGuiPluginInterface
${Qt6_Widgets}
Qt6::Network
${Qt6_WebSockets}
NGLLogger
LtsWidgets
LtsSession
LtsDataView
nglcompression
nglsettings
ngltools
LtsSessionData
# for creating data.json
AsmDataPluginInterface
ExmDataPluginInterface
)
endif()
NGL_INSTALL_TARGET(ThpUsbManagementGuiPlugin)
@@ -1,32 +0,0 @@
#include "logger.h"
#include <NGLLogger/NGLLoggerBootstrap.h>
namespace TakeHomePackageManager
{
LOGGER_T getLogger(const char *name)
{
static const char ns[] = "TPM.USB.";
std::string loggerName;
const size_t len = strlen(name);
loggerName.reserve(sizeof(ns) + len);
loggerName.append(ns, sizeof(ns) - 1);
loggerName.append(name, len);
try
{
return NGL::NGLLoggerBootstrap::getNGLRootLogger().
getNGLLogger(loggerName);
}
catch (const std::exception &ex)
{
fprintf(stderr, "Error retrieving logger: %s", ex.what());
abort();
}
}
}
@@ -1,17 +0,0 @@
#pragma once
#include <NGLLogger/INGLLogger.h>
namespace TakeHomePackageManager
{
typedef NGL::INGLLogger &LOGGER_T;
LOGGER_T getLogger(const char *name);
inline LOGGER_T getLogger(const QString &loggerName)
{
return getLogger(loggerName.toUtf8().constData());
}
}
@@ -1,131 +0,0 @@
#pragma once
#include "logger.h"
#include <LtsWidgets/lts_dialog.h>
#include <QFileInfoList>
namespace Ui
{
class USBDialog;
}
namespace LtsSession
{
class LtsSession;
}
namespace TakeHomePackageManager
{
class ExportedScriptsModel;
enum eLayerType
{
elevation,
map,
sceneObject,
scene
};
struct layerMappinEntry
{
eLayerType type;
QString description;
int maxScale;
int minScale;
QString name;
QString url;
public:
layerMappinEntry()
: type(eLayerType::map), description(QStringLiteral("NOTSET")), maxScale(125), minScale(-1), name(QStringLiteral("_name")), url(QStringLiteral("_url"))
{
}
layerMappinEntry(eLayerType _type, QString _description, int _maxScale, int _minScale, QString _name, QString _url)
: type(_type), description(_description), maxScale(_maxScale), minScale(_minScale), name(_name), url(_url)
{
}
};
class USBDialog : public LtsWidgets::LtsDialog
{
Q_OBJECT
public:
explicit USBDialog(LtsSession::LtsSession *session, QWidget *parent = nullptr);
~USBDialog();
void retranslate() override;
static QString getContentFolder(const QString &rootFolder, int exerciseId);
QString getContentFolder(const QString &rootFolder) const;
static QString exerciseDirectoryName(int exerciseId);
static QString getScriptFolder(const QString &rootFolder, int exerciseId, int scriptId);
signals:
void nextMap();
private slots:
void slotSelectionChanged();
void slotCopy();
void slotCopyMaps();
void slotCopyWinBin();
void slotCopyWinBinP2();
void slotCopyWinBinP3();
void slotRemove();
void slotRemoveMaps();
void slotChangePath();
void onNextMap();
void generateLayerMappingXML();
private:
NGL::INGLLogger &m_logger;
enum class What
{
ScriptWasDeletedFromExercise,
ExerciseDirectoryWasDeleted,
NewExerciseDirectoryWasCreated,
ScriptWasCopiedToExercise,
};
void adjustJsonFiles(What what);
void initModel();
void initUsbModel();
void scriptDeleted(int scriptId);
void scriptCopied(int scriptId);
QFileInfoList prepareFileInfoListForFolder(QString src, QFileInfoList fil);
QString getContentFolder(int exerciseId) const;
QString getContentFolder() const;
QString getRootFolder(bool forceDownloadDir = false) const;
QString exerciseDirectoryName() const;
QString getScriptFolder(const QString &rootFolder, int scriptId) const;
QString getScriptFolder(int scriptId) const;
ExportedScriptsModel *m_localThpModel;
ExportedScriptsModel *m_usbThpModel;
Ui::USBDialog *m_ui;
LtsSession::LtsSession *m_session;
int m_exerciseId;
int m_paths;
QMap<QString, QFileInfoList> m_files;
QString m_usbRoot;
int m_finished_mapCopys;
};
}
@@ -1,274 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>USBDialog</class>
<widget class="QWidget" name="USBDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1081</width>
<height>541</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QGroupBox" name="verticalGroupBox">
<property name="title">
<string>Local</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QSplitter" name="splitter_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="verticalLayoutWidget_3">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>THPs</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeView" name="tvLocal">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbCopy">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Copy selected THPs to USB</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="verticalLayoutWidget_4">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Maps</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tvLocalMaps">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Type</string>
</property>
</column>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Path</string>
</property>
</column>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbCopyMaps">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Copy selected Maps to USB</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="verticalGroupBox_2">
<property name="title">
<string>On USB</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Path:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblPath">
<property name="text">
<string>(none)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbCHange">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Change path</string>
</property>
</widget>
</item>
<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>
</layout>
</item>
<item>
<widget class="QSplitter" name="splitter_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>THPs</string>
</property>
</widget>
</item>
<item>
<widget class="QTableView" name="tvUSB">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbRemove">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove selected THPs from USB</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="verticalLayoutWidget_5">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Maps</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tvUSBMaps">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbRemoveMaps">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Remove selected Maps from USB</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -1,95 +0,0 @@
#include "tpm_usb_gui_plugin.h"
#include "tpm_usb_dialog.h"
#include "logger.h"
#include <QtCore/QDebug>
namespace TakeHomePackageManager
{
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("Plugin"))
{
}
bool InterfaceImpl::fetchInterfaces()
{
return true;
}
QString InterfaceImpl::menuGroup() const
{
return tr("Presentation");
}
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
{
QVector<LtsWidgets::PluginData> ret;
LtsWidgets::PluginData plData;
plData.menuGroup = menuGroup();
if (m_session->app() == LtsAppDescriptor::App::Scripts)
plData.exercisePart = LtsWidgets::ExercisePart::eSpecial;
else
plData.exercisePart = LtsWidgets::ExercisePart::eAfterAction;
plData.identifier = QLatin1String("THP.USB.Dialog");
plData.menuIcon = QIcon(QLatin1String("icon:export_documents.svg"));
plData.menuText = tr("USB Management");
plData.createWidgetFunc = [this](QWidget *)
{
return LtsWidgets::createThrowableDialog<USBDialog>(m_session);
};
ret.append(plData);
return ret;
}
}
@@ -1,45 +0,0 @@
#pragma once
#include <OldTHP/tpm_gui_plugin_interface.h>
#include "logger.h"
#include <LtsSession/lts_session.h>
#include <PluginInterfaces/gui_plugin_interface.h>
namespace TakeHomePackageManager
{
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
{
Q_PLUGIN_METADATA(IID "gui:3:tpm.usb")
Q_INTERFACES(GuiPluginBase::Plugin)
Q_OBJECT
public:
GuiPlugin() = default;
~GuiPlugin() = default;
QString pluginName() override { return QLatin1String("ThpUsbManager"); }
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, public ForeignTpmGuiInterface
{
Q_OBJECT
public:
explicit InterfaceImpl(LtsSession::LtsSession *session);
bool fetchInterfaces() override;
QString menuGroup() const override;
QVector<LtsWidgets::PluginData> getActions() override;
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Exercise; }
private:
};
}
@@ -1,19 +0,0 @@
#pragma once
#include <QtCore/QString>
namespace TakeHomePackageManager
{
class ForeignTpmGuiInterface
{
public:
ForeignTpmGuiInterface() = default;
virtual ~ForeignTpmGuiInterface() = default;
static QString pluginName() { return QStringLiteral("TpmGuiPlugin"); }
};
}
@@ -1,152 +0,0 @@
#
# $Id$
# $HeadURL$
# $Author$
#
# Created by Mike Wille, SLSE, 2017-02-10
#
# EventFilter
# Make ${Qt6_Widgets} optional
if(QT6_GUI_AVAILABLE AND TARGET Qt6::Widgets)
set(Qt6_Widgets ${Qt6_Widgets})
else()
set(Qt6_Widgets "")
endif()
# Make ${Qt6_WebSockets} optional
if(QT6_GUI_AVAILABLE AND TARGET Qt6::WebSockets)
set(Qt6_WebSockets ${Qt6_WebSockets})
else()
set(Qt6_WebSockets "")
endif()
SET(EventFilter_SRCS
EventFilter/AttributeEditingModeUI.h
EventFilter/AttributeEditingModeUI.cpp
EventFilter/AttributeSelectionModeUI.h
EventFilter/AttributeSelectionModeUI.cpp
EventFilter/FilterWindow.h
EventFilter/FilterWindow.cpp
EventFilter/FilterTableEntry.h
EventFilter/FilterTableEntry.cpp
EventFilter/FilterTableEntryAttribute.h
EventFilter/FilterTableEntryAttribute.cpp
EventFilter/interpreter/FilterWorker.h
EventFilter/interpreter/FilterWorker.cpp
EventFilter/widgets/AbstractAttributeWidget.cpp
EventFilter/widgets/ComboBox.cpp
EventFilter/widgets/TimeRangeWidget.cpp
EventFilter/widgets/AreaWidget.cpp
EventFilter/widgets/DefaultRangeWidget.cpp
EventFilter/widgets/CheckBoxWidget.cpp
EventFilter/widgets/RadiusWidget.cpp
EventFilter/interpreter/InfoWindow.h
EventFilter/interpreter/InfoWindow.cpp
EventFilter/interpreter/FilterEquationFunctions.cpp
EventFilter/interpreter/FilterValueInterpreter.cpp
EventFilter/widgets/AbstractAttributeWidget.h
EventFilter/widgets/ComboBox.h
EventFilter/widgets/TimeRangeWidget.h
EventFilter/widgets/AreaWidget.h
EventFilter/widgets/DefaultRangeWidget.h
EventFilter/widgets/CheckBoxWidget.h
EventFilter/widgets/RadiusWidget.h
EventFilter/interpreter/FilterEquationFunctions.h
EventFilter/interpreter/FilterValueInterpreter.h
detail_data.h
detail_data.cpp
excon_filter.h
excon_filter.cpp
logger.h
logger.cpp
)
SET(EventFilter_UICS
EventFilter/ui/FilterWindowUi.ui
)
# Timeline
SET(tln_view_gui_SRCS
attribute_value_lookup.cpp
attribute_value_lookup.h
tln_view_gui_plugin.cpp
tln_view_gui_plugin.h
tln_dialog.cpp
tln_dialog.h
tln_dialog_model.cpp
tln_dialog_model.h
tln_cache_dialog.cpp
tln_cache_dialog.h
tln_show_details.cpp
tln_show_details.h
tln_event_list.h
tln_event_list.cpp
tln_event_list_model.h
tln_event_list_model.cpp
tln_event_list_columns.h
tln_event_list_columns.cpp
tln_legend.h
tln_legend.cpp
${EventFilter_SRCS}
)
NGL_WRAP_UI(tln_view_gui_SRCS
tln_dialog.ui
tln_cache_dialog.ui
tln_show_details.ui
tln_event_list.ui
tln_event_list_columns.ui
tln_legend.ui
${EventFilter_UICS}
)
NGL_ADD_LIBRARY(WS TlnViewGuiPlugin MODULE ${tln_view_gui_SRCS})
if(QT6_GUI_AVAILABLE)
NGL_TARGET_LINK_LIBRARIES(TlnViewGuiPlugin
${Qt6_Widgets}
${Qt6_WebSockets}
LtsAppManager
LtsDataView
LtsTimelineClassic
LtsPrinting
LtsSession
LtsSessionData
LtsUtilsCore # data mod
LtsUtilsGuiDds
LtsUtilsSettings
LtsWidgets
NGLLogger
ngltools # dtg
AvmDataPluginInterface
ExmDataPluginInterface
IsmDataPluginInterface
MrkDataPluginInterface
OpmDataPluginInterface
PdmDataPluginInterface
PpmDataPluginInterface
FlmExplorerGuiPluginInterface
FltAesGuiPluginInterface # SitMap Filter
TlnDataPluginInterface
TlnViewGuiPluginInterface
MrkCommon # SitMap Filter Helper
)
endif()
NGL_INSTALL_TARGET(TlnViewGuiPlugin)
@@ -1,218 +0,0 @@
#include "AttributeEditingModeUI.h"
#include "../detail_data.h"
#include "widgets/TimeRangeWidget.h"
#include "widgets/DefaultRangeWidget.h"
#include "widgets/ComboBox.h"
#include "widgets/CheckBoxWidget.h"
#include "widgets/AreaWidget.h"
#include "widgets/RadiusWidget.h"
#include "logger.h"
#include <QtWidgets/QLabel>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QVBoxLayout>
namespace Timeline
{
AbstractAttributeWidget *EditingModeUI::createAttributeUIWidget(DetailData *detailData, const QString &attributeType,
int eventType, const QString &initialValue)
{
AbstractAttributeWidget *resultWidget = nullptr;
QString concreteAttributeType = detailData->attributeRedirectionLookup.getRedirection(attributeType);
int attributeUIType = detailData->attributeUITypeLookup.getUIType(concreteAttributeType);
if (attributeUIType == -1)
return nullptr;
const DetailData::AttributeParameterLookup::ParameterMap &pm = detailData->attributeParameterLookup.getParameterMap(concreteAttributeType);
switch (attributeUIType)
{
case DetailData::ATTRIBUTE_UI_TYPE_COMBO_BOX:
{
resultWidget = new ComboBox(detailData, concreteAttributeType, eventType, initialValue);
break;
}
case DetailData::ATTRIBUTE_UI_TYPE_DEFAULT_RANGE_WIDGET:
{
bool minb = false;
unsigned int min = pm.value(DetailData::UI_PARAM_TYPE_MIN).toUInt(&minb);
bool maxb = false;
unsigned int max = pm.value(DetailData::UI_PARAM_TYPE_MAX).toUInt(&maxb);
QString prefix = pm.value(DetailData::UI_PARAM_TYPE_PREFIX).toString();
QString suffix = pm.value(DetailData::UI_PARAM_TYPE_SUFFIX).toString();
if (!minb || !maxb)
{
WARNING_LOG(m_logger) << "createAttributeUIWidget: !minb (" << minb << ") || !maxb (" << maxb << ")";
break;
}
resultWidget = new DefaultRangeWidget(min, max, prefix, suffix, initialValue);
break;
}
case DetailData::ATTRIBUTE_UI_TYPE_RAD_RANGE_WIDGET:
{
bool n1k = false;
int n1 = pm.value(DetailData::UI_PARAM_TYPE_N1).toUInt(&n1k);
bool n2k = false;
int n2 = pm.value(DetailData::UI_PARAM_TYPE_N2).toUInt(&n2k);
bool o1k = false;
int o1 = pm.value(DetailData::UI_PARAM_TYPE_O1).toUInt(&o1k);
bool o2k = false;
int o2 = pm.value(DetailData::UI_PARAM_TYPE_O2).toUInt(&o2k);
bool rk = false;
int r = pm.value(DetailData::UI_PARAM_TYPE_RAD).toUInt(&rk);
if (n1k && n2k && o1k && o2k && rk)
{
resultWidget = new RadiusWidget(n1, n2, o1, o2, r);
break;
}
WARNING_LOG(m_logger) << "DetailData::ATTRIBUTE_UI_TYPE_RAD_RANGE_WIDGET: errorious values!";
break;
}
case DetailData::ATTRIBUTE_UI_TYPE_AREA_RANGE_WIDGET:
{
bool n1k = false;
int n1 = pm.value(DetailData::UI_PARAM_TYPE_N1).toUInt(&n1k);
bool n2k = false;
int n2 = pm.value(DetailData::UI_PARAM_TYPE_N2).toUInt(&n2k);
bool o1k = false;
int o1 = pm.value(DetailData::UI_PARAM_TYPE_O1).toUInt(&o1k);
bool o2k = false;
int o2 = pm.value(DetailData::UI_PARAM_TYPE_O2).toUInt(&o2k);
if (n1k && n2k && o1k && o2k)
{
resultWidget = new AreaWidget(n1, n2, o1, o2);
break;
}
WARNING_LOG(m_logger) << "DetailData::ATTRIBUTE_UI_TYPE_AREA_RANGE_WIDGET: errorious values!";
break;
}
case DetailData::ATTRIBUTE_UI_TYPE_CHECKBOX:
{
resultWidget = new CheckBoxWidget(detailData, concreteAttributeType, initialValue);
break;
}
case DetailData::ATTRIBUTE_UI_TYPE_TIME_RANGE_WIDGET:
{
TimeRangeWidget *trw = new TimeRangeWidget(detailData, initialValue);
detailData->createRetrieveCurrentTimeCallback(trw->m_edit1);
detailData->createRetrieveCurrentTimeCallback(trw->m_edit2);
resultWidget = trw;
break;
}
default:
{
WARNING_LOG(m_logger) << "createAttributeUIWidget: invalid attribute type #" << attributeUIType << "!";
break;
}
}
return resultWidget;
}
void EditingModeUI::addAttributeContainer(int eventType, const QString &initialValue)
{
AbstractAttributeWidget *attributeUIWidget = createAttributeUIWidget(m_detailData, attributeType, eventType, initialValue);
if (attributeUIWidget == nullptr)
{
DEBUG_LOG(m_logger) << "addAttributeContainer: !attributeUIWidget";
return;
}
connect(attributeUIWidget, &AbstractAttributeWidget::destroyed, this, &EditingModeUI::signalChanges);
connect(attributeUIWidget, &AbstractAttributeWidget::signalChanges, this, &EditingModeUI::signalChanges);
attributeValuesLayout->insertWidget(0, attributeUIWidget, 0, Qt::AlignTop);
attributeUIWidget->setFocus();
}
EditingModeUI::EditingModeUI(DetailData *detailData, const QString &attributeType, QWidget *parent) : QWidget(parent)
, attributeType(attributeType)
, m_detailData(detailData),
m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger()) {
QVBoxLayout *editingModeLayout = new QVBoxLayout;
QWidget *filterTextWidget = new QWidget;
QHBoxLayout *filterTextLayout = new QHBoxLayout;
filterTextWidget->setLayout(filterTextLayout);
pbDelete = new QPushButton(QStringLiteral("-"));
pbDelete->setToolTip(tr("Delete this attribute and all its values"));
pbDelete->setPalette(QPalette(QColor("red")));
pbDelete->setMaximumWidth(30);
lbFilterText = new QLabel;
filterTextLayout->addWidget(lbFilterText, 0, Qt::AlignLeft);
filterTextLayout->addWidget(pbDelete, 1, Qt::AlignLeft);
QWidget *attributeValuesWidget = new QWidget;
attributeValuesLayout = new QVBoxLayout();
attributeValuesWidget->setLayout(attributeValuesLayout);
pbAddAttributeContainer = new QPushButton(tr("Add Value"));
pbAddAttributeContainer->setPalette(QPalette(QColor("green")));
setLayout(editingModeLayout);
editingModeLayout->addWidget(filterTextWidget, 0, Qt::AlignTop);
QWidget *horizontalLineWidget = new QWidget;
horizontalLineWidget->setFixedHeight(2);
horizontalLineWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
horizontalLineWidget->setStyleSheet(QStringLiteral("background-color: #c0c0c0;"));
editingModeLayout->addWidget(horizontalLineWidget, 0, Qt::AlignTop);
editingModeLayout->addWidget(pbAddAttributeContainer, 0, Qt::AlignTop | Qt::AlignLeft);
editingModeLayout->addWidget(attributeValuesWidget, 0, Qt::AlignTop);
}
EditingModeUI::~EditingModeUI()
{
const auto children = findChildren<AbstractAttributeWidget*>();
for (auto child : children)
child->disconnect(this);
}
}
@@ -1,45 +0,0 @@
#pragma once
#include <NGLLogger/INGLLogger.h>
#include <QtWidgets/QWidget>
class QLabel;
class QPushButton;
class QVBoxLayout;
namespace Timeline
{
class DetailData;
class AbstractAttributeWidget;
class EditingModeUI : public QWidget
{
Q_OBJECT
public:
explicit EditingModeUI(DetailData *detailData, const QString &attributeType, QWidget *parent);
~EditingModeUI();
void addAttributeContainer(int eventType, const QString &initialValue = QString());
QLabel *lbFilterText;
QPushButton *pbDelete;
QVBoxLayout *attributeValuesLayout;
QPushButton *pbAddAttributeContainer;
private:
NGL::INGLLogger &m_logger;
Timeline::AbstractAttributeWidget *createAttributeUIWidget(DetailData *detailData, const QString &attributeType,
int eventType, const QString &initialValue);
signals:
void signalChanges();
private:
QString attributeType;
DetailData *m_detailData;
};
}
@@ -1,72 +0,0 @@
#include "../detail_data.h"
#include "AttributeSelectionModeUI.h"
#include "logger.h"
namespace Timeline
{
QComboBox *SelectionModeUI::createAttributesComboBox(int eventType)
{
QComboBox *cbAttributes = new QComboBox();
DetailData::AttributeEventLookup::AttributeList attributeList = m_detailData->attributeEventLookup.getEventsAttributeList(eventType);
for (auto i = attributeList.constBegin(); i != attributeList.constEnd(); ++i)
{
const QString &attributeKey = m_detailData->attributeRedirectionLookup.getRedirection(*i);
if (m_detailData->attributeInterpreterLookup.getInterpreterType(attributeKey) == DetailData::INTERPRETER_TYPE_NONE)
continue;
QString cbAttribute = m_detailData->attributeTypeLookup.getAttributeText(attributeKey);
if (cbAttribute.isEmpty())
{
WARNING_LOG(m_logger) << "SelectionModeUI::createAttributesComboBox: event type " << eventType << " has no attribute text for attribute " << attributeKey << " for attribute event lookup - not added";
}
else
{
cbAttributes->addItem(cbAttribute);
}
}
return cbAttributes;
}
SelectionModeUI::SelectionModeUI(DetailData *detailData, const int eventType) : eventType(eventType)
, m_detailData(detailData),
m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger()) {
selectionModeWidget = new QWidget();
selectionModeLayout = new QHBoxLayout();
lbFilterText = new QLabel(tr("Select attribute type to filter:"));
cbAttributeType = createAttributesComboBox(eventType);
pbAddEditingMode = new QPushButton(tr("OK"));
pbAddEditingMode->setToolTip(tr("Add this attribute and start adding values"));
pbAddEditingMode->setPalette(QPalette(QColor("green")));
pbAddEditingMode->setMaximumWidth(30);
pbDeleteFilter = new QPushButton(QStringLiteral("-"));
pbDeleteFilter->setPalette(QPalette(QColor("red")));
pbDeleteFilter->setToolTip(tr("Delete this attribute and all its values"));
pbDeleteFilter->setMaximumWidth(30);
selectionModeLayout->addWidget(lbFilterText, 0, Qt::AlignCenter);
selectionModeLayout->addWidget(cbAttributeType, 0, Qt::AlignTop);
selectionModeLayout->addWidget(pbAddEditingMode, 0, Qt::AlignTop);
selectionModeLayout->addWidget(pbDeleteFilter, 1, Qt::AlignTop);
selectionModeWidget->setLayout(selectionModeLayout);
}
}
@@ -1,53 +0,0 @@
#pragma once
#include <NGLLogger/INGLLogger.h>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QWidget>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QPushButton>
namespace Timeline
{
class DetailData;
class SelectionModeUI : public QObject
{
Q_OBJECT
private:
NGL::INGLLogger &m_logger;
SelectionModeUI &operator=(const SelectionModeUI &);
public:
QComboBox *createAttributesComboBox(int eventType);
explicit SelectionModeUI(DetailData *detailData, const int eventType);
~SelectionModeUI()
{
delete lbFilterText;
delete cbAttributeType;
delete pbAddEditingMode;
delete selectionModeLayout;
delete selectionModeWidget;
}
int eventType;
QWidget *selectionModeWidget;
QHBoxLayout *selectionModeLayout;
QLabel *lbFilterText;
QComboBox *cbAttributeType;
QPushButton *pbAddEditingMode;
QPushButton *pbDeleteFilter;
DetailData *m_detailData;
};
}
@@ -1,326 +0,0 @@
#include "FilterTableEntry.h"
#include "FilterTableEntryAttribute.h"
#include "interpreter/FilterWorker.h"
#include "../detail_data.h"
#include "logger.h"
#include <QtGui/QColor>
#include <QSizePolicy>
#include <QtCore/QJsonArray>
#include <QtCore/QDebug>
namespace Timeline
{
FilterTableEntry::FilterTableEntry(DetailData *detailData, const int &eventType, const bool &active, QWidget *parent) : QGroupBox(parent)
, m_eventType(eventType)
, m_mainLayout(new QVBoxLayout())
, m_topLayout(new QHBoxLayout())
, m_centerLayout(new QHBoxLayout())
, m_cbEventSelector(nullptr)
, m_pbDelete(new QPushButton(QStringLiteral("-")))
, m_pbFoundEvents(new QPushButton(tr("Show Events")))
, m_pbFilterActive(new QPushButton(tr("Active")))
, m_pbOK(new QPushButton(tr("OK")))
, m_lbSelectText(new QLabel(tr("Select event type to filter:")))
, m_detailData(detailData),
m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger()) {
m_cbEventSelector = getEventTypesComboBox();
m_pbDelete->setPalette(QPalette(QColor("red")));
m_pbDelete->setToolTip(tr("Delete this filter and all its attributes"));
m_pbFilterActive->setPalette(QPalette(QColor("orange")));
m_pbFoundEvents->setPalette(QPalette(QColor("orange")));
m_pbOK->setPalette(QPalette(QColor("green")));
m_pbOK->setToolTip(tr("Add this filter and start adding attributes (when needed)"));
connect(m_pbFilterActive, &QPushButton::clicked, this, &FilterTableEntry::signalChanges);
setLayout(m_mainLayout);
QWidget *topLayoutWidget = new QWidget(this);
topLayoutWidget->setLayout(m_topLayout);
m_mainLayout->addWidget(topLayoutWidget, 0, Qt::AlignTop);
m_topLayout->addWidget(m_lbSelectText, 0, Qt::AlignLeft);
m_topLayout->addWidget(m_cbEventSelector, 0, Qt::AlignLeft);
m_pbOK->setMinimumWidth(30);
m_pbOK->setMaximumWidth(30);
m_topLayout->addWidget(m_pbOK, 0, Qt::AlignLeft);
connect(m_pbOK, &QPushButton::clicked, this, &FilterTableEntry::slotSelectEventType);
connect(m_pbDelete, &QPushButton::clicked, this, &FilterTableEntry::deleteLater);
m_pbDelete->setMinimumWidth(30);
m_pbDelete->setMaximumWidth(30);
m_topLayout->addWidget(m_pbDelete, 1, Qt::AlignLeft);
QWidget *centerLayoutWidget = new QWidget(this);
centerLayoutWidget->setStyleSheet(topLayoutWidget->styleSheet());
centerLayoutWidget->setLayout(m_centerLayout);
m_mainLayout->addWidget(centerLayoutWidget, 0);
if (m_eventType > -1)
slotSelectEventType();
m_pbFoundEvents->setEnabled(active);
m_pbFilterActive->setCheckable(true);
m_pbFilterActive->setChecked(active);
m_pbFilterActive->setToolTip(m_pbFilterActive->isChecked() ? tr("Filter is active") : tr("Filter is inactive"));
}
FilterTableEntry::~FilterTableEntry()
{
const auto children = findChildren<FilterTableEntryAttribute *>();
for (auto child : children)
child->disconnect(this);
}
void FilterTableEntry::updateData()
{
for (int i = 0; i < m_centerLayout->count(); i++)
{
FilterTableEntryAttribute *ftec = dynamic_cast<FilterTableEntryAttribute *>(m_centerLayout->itemAt(i)->widget());
if (!ftec)
{
WARNING_LOG(m_logger) << "FilterTableEntry::filterText(): !ftec";
continue;
}
ftec->updateData(m_detailData);
}
}
QComboBox *FilterTableEntry::getEventTypesComboBox()
{
QComboBox *cbEventTypes = new QComboBox();
cbEventTypes->addItems(m_detailData->eventTypeLookup.getEventTexts());
cbEventTypes->model()->sort(0);
connect(cbEventTypes, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &FilterTableEntry::signalChanges);
return cbEventTypes;
}
const QJsonObject FilterTableEntry::filter(bool typeSafe) const
{
if (m_eventType == -1)
{
WARNING_LOG(m_logger) << "FilterTableEntry has no event type.";
return {};
}
if (!m_centerLayout->count())
{
}
QJsonObject result;
QString eventTypeString;
if (typeSafe)
eventTypeString = QString::number(m_eventType);
else
eventTypeString = m_detailData->eventTypeLookup.getEventText(m_eventType);
if (!eventTypeString.length())
return QJsonObject();
result[QStringLiteral("EventType")] = eventTypeString;
QJsonArray attributes;
for (int i = 0; i < m_centerLayout->count(); i++)
{
FilterTableEntryAttribute *ftec = dynamic_cast<FilterTableEntryAttribute *>(m_centerLayout->itemAt(i)->widget());
if (!ftec)
{
WARNING_LOG(m_logger) << "FilterTableEntry::filterText(): !ftec";
continue;
}
QJsonObject filterTile = ftec->filter(typeSafe);
if (filterTile.isEmpty())
continue;
attributes.append(filterTile);
}
result[QStringLiteral("Attributes")] = attributes;
result[QStringLiteral("Active")] = m_pbFilterActive->isChecked();
return result;
}
void FilterTableEntry::slotSelectEventType()
{
delete m_lbSelectText;
if (m_cbEventSelector)
{
if (m_eventType == -1)
{
m_eventType = m_detailData->eventTypeLookup.getEventType(m_cbEventSelector->currentText());
}
m_lbEventName = new QLabel(QString(tr("Filter by event type: <b>%1</b>")).arg(m_detailData->eventTypeLookup.getEventText(m_eventType)));
m_lbEventName->setMinimumWidth(m_cbEventSelector->width());
delete m_cbEventSelector;
m_cbEventSelector = nullptr;
m_topLayout->insertWidget(0, m_lbEventName);
}
if (m_eventType == -1)
{
WARNING_LOG(m_logger) << "slotSelectEventType: m_eventType == -1";
return;
}
delete m_pbOK;
QWidget *horizontalLineWidget = new QWidget();
horizontalLineWidget->setFixedHeight(2);
horizontalLineWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
horizontalLineWidget->setStyleSheet(QStringLiteral("background-color: #c0c0c0;"));
m_mainLayout->insertWidget(1, horizontalLineWidget, 0, Qt::AlignTop);
delete m_pbDelete;
m_pbDelete = new QPushButton(QStringLiteral("-"));
m_pbDelete->setToolTip(tr("Delete this filter and all its attributes"));
m_pbDelete->setPalette(QPalette(QColor("red")));
connect(m_pbDelete, &QPushButton::clicked, this, &FilterTableEntry::deleteLater);
m_pbDelete->setMinimumWidth(30);
m_pbDelete->setMaximumWidth(30);
m_topLayout->addWidget(m_pbDelete, 0, Qt::AlignLeft);
m_topLayout->addWidget(m_pbFilterActive, 0, Qt::AlignLeft);
connect(m_pbFilterActive, &QPushButton::clicked, this, &FilterTableEntry::slotFilterActiveClicked);
connect(m_pbFoundEvents, &QPushButton::clicked, this, &FilterTableEntry::slotShowEvents);
m_pbFoundEvents->setToolTip(tr("Show all events that fit to this filter"));
m_topLayout->addWidget(m_pbFoundEvents, 1, Qt::AlignLeft);
DetailData::AttributeEventLookup::AttributeList attributeList = m_detailData->attributeEventLookup.getEventsAttributeList(m_eventType);
QMutableListIterator<QString> it(attributeList);
while (it.hasNext())
{
const QString attributeType = it.next();
if (m_detailData->attributeInterpreterLookup.getInterpreterType(attributeType) == DetailData::INTERPRETER_TYPE_NONE)
it.remove();
}
if (attributeList.isEmpty())
return;
QPushButton *pbAddAttribute = new QPushButton(tr("Add Attribute"));
pbAddAttribute->setPalette(QPalette(QColor("green")));
connect(pbAddAttribute, &QPushButton::clicked, this, &FilterTableEntry::slotAddAttribute);
m_mainLayout->insertWidget(2, pbAddAttribute, 0, Qt::AlignLeft);
}
void FilterTableEntry::slotShowEvents()
{
QJsonArray a;
a.append(filter(true ));
emit signalShowEvents(a);
}
void FilterTableEntry::slotFilterActiveClicked()
{
if (m_pbFilterActive->isChecked())
{
m_pbFilterActive->setPalette(QPalette(QColor("orange")));
m_pbFilterActive->setToolTip(tr("Filter is active"));
m_pbFoundEvents->setPalette(QPalette(QColor("orange")));
m_pbFoundEvents->setEnabled(true);
}
else
{
m_pbFilterActive->setPalette(QPalette(QColor("grey")));
m_pbFilterActive->setToolTip(tr("Filter is inactive"));
m_pbFoundEvents->setPalette(QPalette(QColor("grey")));
m_pbFoundEvents->setEnabled(false);
}
}
void FilterTableEntry::slotAddAttribute()
{
addAttribute();
}
bool FilterTableEntry::hasAttributes() const
{
qWarning() << "hasAttributes? children: " << m_centerLayout->children().count();
return !!m_centerLayout->children().count();
}
FilterTableEntryAttribute *FilterTableEntry::addAttribute(const QString &attributeType)
{
FilterTableEntryAttribute *ftec = new FilterTableEntryAttribute(m_detailData, m_eventType, attributeType, this);
connect(ftec, &FilterTableEntryAttribute::signalChanges, this, &FilterTableEntry::signalChanges);
connect(ftec, &FilterTableEntryAttribute::destroyed, this, &FilterTableEntry::signalChanges);
m_centerLayout->insertWidget(0, ftec, 1, Qt::AlignLeft);
return ftec;
}
}
@@ -1,74 +0,0 @@
#pragma once
#include "FilterTableEntryAttribute.h"
#include <QtWidgets/QWidget>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QComboBox>
#include <QtGui/QPaintEvent>
#include <QtGui/QPainter>
#include <QtCore/QList>
#include <QtWidgets/QGroupBox>
namespace Timeline
{
class DetailData;
class FilterTableEntry : public QGroupBox
{
Q_OBJECT
public:
explicit FilterTableEntry(DetailData *detailData, const int &eventType = -1, const bool &active = true, QWidget *parent = nullptr);
~FilterTableEntry();
const QJsonObject filter(bool typeSafe = false) const;
FilterTableEntryAttribute *addAttribute(const QString &attributeType = QString());
bool hasAttributes() const;
void updateData();
private:
NGL::INGLLogger &m_logger;
QComboBox *getEventTypesComboBox();
int m_eventType;
QVBoxLayout *m_mainLayout{nullptr};
QHBoxLayout *m_topLayout{nullptr};
QHBoxLayout *m_centerLayout{nullptr};
QComboBox *m_cbEventSelector{nullptr};
QLabel *m_lbEventName{nullptr};
QPushButton *m_pbDelete{nullptr};
QPushButton *m_pbFoundEvents{nullptr};
QPushButton *m_pbFilterActive{nullptr};
QPushButton *m_pbOK{nullptr};
QLabel *m_lbSelectText{nullptr};
DetailData *m_detailData{nullptr};
signals:
void signalShowEvents(const QJsonArray &filter);
void signalChanges();
private slots:
void slotAddAttribute();
void slotFilterActiveClicked();
void slotSelectEventType();
void slotShowEvents();
public slots:
};
}
@@ -1,210 +0,0 @@
#include "interpreter/FilterWorker.h"
#include "FilterTableEntryAttribute.h"
#include "widgets/AbstractAttributeWidget.h"
#include "logger.h"
#include "../detail_data.h"
#include <QtWidgets/QVBoxLayout>
#include <QtCore/QJsonObject>
#include <QtCore/QJsonArray>
namespace Timeline
{
FilterTableEntryAttribute::FilterTableEntryAttribute(DetailData *detailData, int eventType, const QString &attributeType, QWidget *parent) : QGroupBox(parent)
, m_eventType(eventType)
, m_attributeType(attributeType)
, m_selectionModeUI(nullptr)
, m_editionModeUI(nullptr)
, m_attributesLayout(new QVBoxLayout())
, m_detailData(detailData),
m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger()) {
this->setTitle(QString());
setLayout(m_attributesLayout);
slotAddSelectionMode();
if (!attributeType.isEmpty())
{
m_selectionModeUI->cbAttributeType->setCurrentIndex(m_selectionModeUI->cbAttributeType->findData(QVariant::fromValue<QString>(attributeType)));
slotAddEditingMode(false);
}
}
FilterTableEntryAttribute::~FilterTableEntryAttribute()
{
delete m_editionModeUI;
}
void FilterTableEntryAttribute::updateData(DetailData *detailData)
{
if (!m_editionModeUI)
return;
for (int i = 0; i < m_editionModeUI->attributeValuesLayout->count(); i++)
{
AbstractAttributeWidget *aaw = dynamic_cast<AbstractAttributeWidget *>(m_editionModeUI->attributeValuesLayout->itemAt(i)->widget());
if (!aaw)
continue;
aaw->updateData(detailData);
connect(aaw, &AbstractAttributeWidget::deleteClicked, this, [this]()
{
emit attributeChanged(false);
});
}
}
const QJsonObject FilterTableEntryAttribute::filter(bool typeSafe) const
{
if (m_attributeType.isEmpty())
{
WARNING_LOG(m_logger) << "filterText: m_attributeType == -1";
return QJsonObject();
}
QString attributeTypeName;
if (typeSafe)
attributeTypeName = m_attributeType;
else
{
attributeTypeName = m_detailData->attributeTypeLookup.getAttributeText(m_attributeType);
}
if (attributeTypeName.isEmpty())
{
WARNING_LOG(m_logger) << "filterText: !attributeTypeName.length()";
return QJsonObject();
}
QJsonObject result;
result[QStringLiteral("AttributeType")] = attributeTypeName;
QJsonArray values;
if (m_editionModeUI)
{
for (int i = 0; i < m_editionModeUI->attributeValuesLayout->count(); i++)
{
AbstractAttributeWidget *aaw = dynamic_cast<AbstractAttributeWidget *>(m_editionModeUI->attributeValuesLayout->itemAt(i)->widget());
if (!aaw)
continue;
QString value = aaw->filterText(typeSafe);
if (value.isEmpty())
continue;
values.append(value);
}
}
result[QStringLiteral("AttributeValues")] = values;
return result;
}
void FilterTableEntryAttribute::slotAddSelectionMode()
{
m_selectionModeUI = new SelectionModeUI(m_detailData, m_eventType);
connect(m_selectionModeUI->pbAddEditingMode, &QPushButton::clicked, this, &FilterTableEntryAttribute::slotAddEditingMode);
connect(m_selectionModeUI->pbDeleteFilter, &QPushButton::clicked, this, &FilterTableEntryAttribute::slotDeleteAttributeContainer);
m_attributesLayout->addWidget(m_selectionModeUI->selectionModeWidget, 0, Qt::AlignTop);
}
void FilterTableEntryAttribute::slotAddEditingMode(bool createBlankContainer)
{
if (!m_selectionModeUI)
return;
QString attributeTypeString;
if (m_attributeType.isEmpty())
{
attributeTypeString = m_selectionModeUI->cbAttributeType->currentText();
m_attributeType = m_detailData->attributeTypeLookup.getAttributeType(attributeTypeString);
}
else
{
attributeTypeString = m_detailData->attributeTypeLookup.getAttributeText(m_attributeType);
}
delete m_selectionModeUI;
m_selectionModeUI = nullptr;
if (m_attributeType.isEmpty())
{
WARNING_LOG(m_logger) << "slotAddEditingMode: invalid attribute type string!";
return;
}
m_editionModeUI = new EditingModeUI(m_detailData, m_attributeType, nullptr);
connect(m_editionModeUI, &EditingModeUI::signalChanges, this, &FilterTableEntryAttribute::signalChanges);
connect(m_editionModeUI, &EditingModeUI::destroyed, this, &FilterTableEntryAttribute::signalChanges);
connect(m_editionModeUI->pbAddAttributeContainer, &QPushButton::clicked, this, &FilterTableEntryAttribute::slotAddAttributeContainer);
connect(m_editionModeUI->pbDelete, &QPushButton::clicked, this, &FilterTableEntryAttribute::slotDeleteAttributeContainer);
m_editionModeUI->lbFilterText->setText(tr("Filter by attribute type: <b>%1</b>").arg(attributeTypeString));
m_attributesLayout->addWidget(m_editionModeUI, 0, Qt::AlignTop);
if (createBlankContainer)
slotAddAttributeContainer();
}
void FilterTableEntryAttribute::slotDeleteAttributeContainer()
{
emit attributeChanged(false);
deleteLater();
}
void FilterTableEntryAttribute::slotAddAttributeContainer()
{
emit signalChanges();
emit attributeChanged(true);
if (m_editionModeUI != nullptr)
m_editionModeUI->addAttributeContainer(m_eventType);
}
}
@@ -1,52 +0,0 @@
#pragma once
#include "AttributeEditingModeUI.h"
#include "AttributeSelectionModeUI.h"
#include <QtWidgets/QGroupBox>
class QLabel;
class QVBoxLayout;
namespace Timeline
{
class DetailData;
class FilterTableEntryAttribute : public QGroupBox
{
Q_OBJECT
public:
explicit FilterTableEntryAttribute(DetailData *detailData, int eventType, const QString &attributeType, QWidget *parent = nullptr);
~FilterTableEntryAttribute();
const QJsonObject filter(bool typeSafe = false) const;
void updateData(DetailData *detailData);
int m_eventType;
QString m_attributeType;
SelectionModeUI *m_selectionModeUI;
EditingModeUI *m_editionModeUI;
QVBoxLayout *m_attributesLayout;
QLabel *m_lbSelectText;
DetailData *m_detailData;
signals:
void signalChanges();
void attributeChanged(const bool &hasAttribute);
private:
NGL::INGLLogger &m_logger;
private slots:
void slotAddAttributeContainer();
void slotDeleteAttributeContainer();
void slotAddSelectionMode();
void slotAddEditingMode(bool createBlankContainer = true);
};
}
@@ -1,317 +0,0 @@
#include "FilterWindow.h"
#include "ui_FilterWindowUi.h"
#include "FilterTableEntry.h"
#include "interpreter/FilterWorker.h"
#include "../detail_data.h"
#include "logger.h"
#include <FileManagement/flm_translation.h>
#include <QtWidgets/QMessageBox>
#include <QtCore/QJsonObject>
#include <QtCore/QJsonArray>
#include <QtCore/QJsonDocument>
#include <QJsonParseError>
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
#include <QScopeGuard>
#endif
#include <QtCore/QDebug>
namespace Timeline
{
FilterWindow::FilterWindow(DetailData *detailData,
const std::shared_ptr<FileManagement::ForeignGuiInterface> &flmIfc,
LtsSession::LtsSession *session,
QWidget *parent) : LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
, m_flmIfc(flmIfc)
, m_ui(new Ui::FilterWindow)
, updateTimer(new QTimer(this))
, m_detailData(detailData)
, m_session(session),
m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger()) {
m_ui->setupUi(this);
setMinimumSize(1500, 800);
m_buttonBox->getButton(LtsWidgets::DialogButton::Ok)->hide();
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add,
this, &FilterWindow::slotAddNewFilter);
m_buttonBox->connectButton(LtsWidgets::DialogButton::Show,
this, &FilterWindow::slotShowEvents);
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save,
this, &FilterWindow::slotSave);
m_buttonBox->connectButton(LtsWidgets::DialogButton::Load,
this, &FilterWindow::slotLoad);
connect(updateTimer, &QTimer::timeout, this, &FilterWindow::slotUpdate);
updateTimer->setInterval(5000);
updateTimer->start();
setOnlineHelpFilename(QStringLiteral("Timeline-Filter_Functions"));
}
FilterWindow::~FilterWindow()
{
const QList<FilterTableEntry*> lst = findChildren<FilterTableEntry*>();
for (FilterTableEntry *fte : lst)
fte->disconnect(this);
updateTimer->stop();
delete m_ui;
}
void FilterWindow::retranslate()
{
translate(m_ui, tr("Filters"));
m_buttonBox->getButton(LtsWidgets::DialogButton::Add)->setText(tr("Add Filter"));
m_buttonBox->getButton(LtsWidgets::DialogButton::Show)->setText(tr("Show Events"));
}
void FilterWindow::slotSave()
{
int fileId = m_flmIfc->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(),
filterToDoc(exportFilter()));
if (fileId > 0)
{
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
__unchange__();
}
else
ERROR_LOG(m_logger) << "Could not save file in library ";
}
void FilterWindow::slotUpdate()
{
for (int i = 0; i < m_ui->filterContainer->count(); i++)
{
FilterTableEntry *fte = qobject_cast<FilterTableEntry *>(m_ui->filterContainer->itemAt(i)->widget());
if (!fte)
continue;
fte->updateData();
}
}
FilterTableEntry *FilterWindow::addNewFilter(const int eventType, bool active)
{
FilterTableEntry *fte = new FilterTableEntry(m_detailData, eventType, active, this);
connect(fte, &FilterTableEntry::signalChanges, this, &FilterWindow::slotChangesMade);
connect(fte, &FilterTableEntry::destroyed, this, &FilterWindow::slotChangesMade);
connect(fte, &FilterTableEntry::signalShowEvents, this, &FilterWindow::signalShowEvents);
m_ui->filterContainer->addWidget(fte);
slotChangesMade();
return fte;
}
void FilterWindow::slotAddNewFilter()
{
addNewFilter();
}
const QJsonArray FilterWindow::exportFilter() const
{
if (!m_ui->filterContainer->count())
return QJsonArray();
QJsonArray result;
for (int i = 0; i < m_ui->filterContainer->count(); i++)
{
FilterTableEntry *fte = qobject_cast<FilterTableEntry *>(m_ui->filterContainer->itemAt(i)->widget());
if (!fte)
continue;
const QJsonObject filterTile = fte->filter(true );
if (filterTile.isEmpty())
continue;
result.append(filterTile);
}
qWarning() << "filter text:" << result;
return result;
}
const QByteArray FilterWindow::filterToDoc(const QJsonArray &flt)
{
QJsonObject obj;
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::TLNTimelineFilter);
obj[QStringLiteral("Filter")] = flt;
QJsonDocument doc(obj);
return doc.toJson(QJsonDocument::Compact);
}
bool FilterWindow::apply()
{
slotApplyFilter();
return true;
}
void FilterWindow::aboutToClose()
{
}
void FilterWindow::slotApplyFilter()
{
emit signalApplyFilter(exportFilter());
}
void FilterWindow::slotShowEvents()
{
emit signalShowEvents(exportFilter());
}
void FilterWindow::slotLoad()
{
QByteArray content;
int fileId = m_flmIfc->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(), FileManagement::toString(FileManagement::XmlType::TLNTimelineFilter));
if (fileId > 0)
{
int msgResult = QMessageBox::question(this,
tr("Load filter set"),
tr("Do you really want to discard current filter set to load the requested filter set?\n"
"\n"
"Yes, discard current filter set and load a filter set.\n"
"No, do not make any changes."),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
if (msgResult != QMessageBox::Yes)
return;
if (!m_flmIfc->isXmlType(content, FileManagement::toString(FileManagement::XmlType::TLNTimelineFilter)))
{
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
LtsWidgets::LtsMessageDialog::showMessage(this,
tr("Invalid xml file content"),
windowTitle(),
LtsWidgets::Behaviour::Modal,
LtsWidgets::Button::Yes,
texts);
}
else
{
const QJsonDocument doc(QJsonDocument::fromJson(content));
const QJsonObject obj(doc.object());
const QJsonArray tlnFilter(obj.value(QStringLiteral("Filter")).toArray());
loadFilters(tlnFilter);
slotChangesMade();
}
}
}
bool FilterWindow::loadFilters(const QJsonArray &filter)
{
setUnchangeable();
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
auto unchangableReset = qScopeGuard([this] { setUnchangeable(false); });
#else
std::shared_ptr<int> unchangeableReset(nullptr, [this](int *) { setUnchangeable(false); });
#endif
FilterWorker::GetModelFilterListResult result = FilterWorker::getModelFilterList(m_detailData, filter, true);
if (!FilterWorker::getInstance()->handleResultValues(result.resultValueList, this, true))
{
LtsWidgets::LtsMessageDialog::showMessage(this, tr("The selected filter set is invalid and cannot be loaded."), tr("Cannot load filter"));
return false;
}
while (m_ui->filterContainer->count())
{
delete m_ui->filterContainer->itemAt(0)->widget();
}
const ModelFilterList &modelFilterList = result.result;
int lastEventType = -1;
FilterTableEntry *lastFTW = nullptr;
QString lastAttributeType;
FilterTableEntryAttribute *lastFTEA = nullptr;
for (const FilterWorker::ModelFilter &mf : modelFilterList)
{
if (lastEventType != mf.eventType || lastEventType == -1 || !lastFTW)
{
lastEventType = mf.eventType;
lastFTW = addNewFilter(mf.eventType, mf.active);
}
if (mf.attributeType == QString())
continue;
if (lastAttributeType != mf.attributeType || lastAttributeType.isEmpty() || !lastFTEA)
{
lastAttributeType = mf.attributeType;
lastFTEA = lastFTW->addAttribute(mf.attributeType);
}
EditingModeUI *emui = lastFTEA->m_editionModeUI;
if (!emui)
continue;
emui->addAttributeContainer(mf.eventType, mf.attributeValue);
}
return true;
}
}
@@ -1,81 +0,0 @@
#pragma once
#include <LtsWidgets/lts_dialog.h>
#include <FileManagement/flm_explorer_gui_plugin_interface.h>
#include <NGLLogger/INGLLogger.h>
#include <LtsSession/lts_session.h>
#include <QtCore/QTimer>
#include <QtCore/QJsonArray>
namespace Ui
{
class FilterWindow;
}
namespace Timeline
{
class DetailData;
class FilterTableEntry;
class FilterWorker;
class FilterWindow : public LtsWidgets::LtsDialog
{
Q_OBJECT
public:
explicit FilterWindow(DetailData *detailData,
const std::shared_ptr<FileManagement::ForeignGuiInterface> &flmIfc,
LtsSession::LtsSession *session,
QWidget *parent = nullptr);
~FilterWindow();
FilterTableEntry *addNewFilter(const int eventType = -1, bool active = true);
void clearSavedFiltersList();
void updateData();
const QJsonArray exportFilter() const;
const QByteArray filterToDoc(const QJsonArray &flt);
bool loadFilters(const QJsonArray &filter);
private:
NGL::INGLLogger &m_logger;
void retranslate() override;
bool apply() override;
void aboutToClose() override;
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmIfc;
Ui::FilterWindow *m_ui;
QTimer *updateTimer;
DetailData *m_detailData;
LtsSession::LtsSession *m_session;
signals:
void signalConvertFilterText(const QString &);
void signalShowEvents(const QJsonArray &events);
void signalApplyFilter(const QJsonArray &filter);
void signalReloadSavedFiltersList();
void signalDeleteFilter(int);
void signalReplaceFilter(int);
void signalReplaceFilterNow(int, const QString &);
public slots:
void slotLoad();
void slotSave();
void slotUpdate();
void slotAddNewFilter();
private slots:
void slotApplyFilter();
void slotShowEvents();
};
}
@@ -1,291 +0,0 @@
#include "logger.h"
#include "FilterEquationFunctions.h"
#include "FilterValueInterpreter.h"
#include "../../detail_data.h"
#include <QtCore/QString>
#include <QtCore/QRect>
#include <QtCore/QVariant>
namespace Timeline
{
static bool inTime(DetailData *detailData, const QVariant &value, const QString &interpreterText)
{
NGL::INGLLogger &logger(getLogger("FilterEquationFunctions"));
bool ok = false;
unsigned int time = value.toUInt(&ok);
if (!ok)
{
WARNING_LOG(logger) << "inTime: value error!" << value.toString();
return false;
}
InterpreterResult ir = interpretValue(detailData, DetailData::INTERPRETER_TYPE_RANGE, interpreterText);
if (ir.resultType == InterpreterResult::InterpreterResultTypes::RESULT_SUCCESS && ir.resultList.count() == 2)
{
bool ok1 = false;
bool ok2 = false;
unsigned int t1 = ir.resultList.at(0).toUInt(&ok1);
unsigned int t2 = ir.resultList.at(1).toUInt(&ok2);
if (ok1 && ok2 && t1 <= time && t2 >= time)
{
return true;
}
}
return false;
}
static bool inArea(DetailData *detailData, const QVariant &value, const QString &interpreterText)
{
NGL::INGLLogger &logger(getLogger("FilterEquationFunctions"));
(void)detailData;
QStringList areaValuesList = value.toString().split(QLatin1Char('x'));
if (areaValuesList.count() != 2)
{
WARNING_LOG(logger) << "inArea: areaValuesList.count() != 2 (" << areaValuesList.count() << ")";
return false;
}
QStringList interpreterValuesList = interpreterText.split(QLatin1Char('x'));
if (interpreterValuesList.count() != 4)
{
WARNING_LOG(logger) << "inArea: interpreterValuesList.count() != 4 (" << interpreterValuesList.count() << ")";
return false;
}
bool nb = false;
int n = areaValuesList.at(0).toInt(&nb);
bool ob = false;
int o = areaValuesList.at(1).toInt(&ob);
bool n1b = false;
int n1 = interpreterValuesList.at(0).toInt(&n1b);
bool n2b = false;
int n2 = interpreterValuesList.at(1).toInt(&n2b);
bool o1b = false;
int o1 = interpreterValuesList.at(2).toInt(&o1b);
bool o2b = false;
int o2 = interpreterValuesList.at(3).toInt(&o2b);
if (!nb || !ob || !n1b || !n2b || !o1b || !o2b)
{
WARNING_LOG(logger) << "inArea: !nb || !ob || !n1b || !n2b || !o1b || !o2b";
return false;
}
QRect range;
range.adjust(o1, n1, o2, n2);
if (range.contains(o, n))
{
WARNING_LOG(logger) << "inArea: in area!";
return true;
}
WARNING_LOG(logger) << "inArea: not in area";
return false;
}
static bool inRad(DetailData *detailData, const QVariant &value, const QString &interpreterText)
{
NGL::INGLLogger &logger(getLogger("FilterEquationFunctions"));
(void)detailData;
QStringList radValuesList = value.toString().split(QLatin1Char('x'));
if (radValuesList.count() != 2)
{
WARNING_LOG(logger) << "inRad: radValuesList.count() != 2 (" << radValuesList.count() << ")";
return false;
}
QStringList interpreterValuesList = interpreterText.split(QLatin1Char('x'));
if (interpreterValuesList.count() != 3)
{
WARNING_LOG(logger) << "inArea: interpreterValuesList.count() != 3 (" << interpreterValuesList.count() << ")";
return false;
}
bool nb = false;
int n = radValuesList.at(0).toInt(&nb);
bool ob = false;
int o = radValuesList.at(1).toInt(&ob);
bool n1b = false;
int n1 = interpreterValuesList.at(0).toInt(&n1b);
bool o1b = false;
int o1 = interpreterValuesList.at(1).toInt(&o1b);
bool r1b = false;
int r1 = interpreterValuesList.at(2).toInt(&r1b);
if (!nb || !ob || !n1b || !o1b || !r1b)
{
WARNING_LOG(logger) << "inRad: !nb || !ob || !n1b || !o1b || !r1b";
return false;
}
QRect range;
range.adjust(o1 - r1, n1 - r1, o1 + r1, n1 + r1);
if (range.contains(o, n))
{
WARNING_LOG(logger) << "inRad: in radius!";
return true;
}
WARNING_LOG(logger) << "inRad: not in radius";
return false;
}
static bool isIntEqual(DetailData *detailData, const QVariant &value, const QString &interpreterText)
{
NGL::INGLLogger &logger(getLogger("FilterEquationFunctions"));
(void)detailData;
bool ok1 = false;
bool ok2 = false;
int i1 = value.toInt(&ok1);
int i2 = interpreterText.toInt(&ok2);
if (!ok1 || !ok2)
{
WARNING_LOG(logger) << "isIntEqual: STR to INT conversion error! ok1 (" << ok1 << ") ok2 (" << ok2 << ") value (" << value.toString() << ") intTxt (" << interpreterText << ")";
}
if (ok1 && ok2 && i1 == i2)
{
return true;
}
return false;
}
bool checkValue(DetailData *detailData, int attributeInterpreterType, const QVariant &value, const QString &interpreterText)
{
switch(attributeInterpreterType)
{
case DetailData::INTERPRETER_TYPE_TIME:
{
return inTime(detailData, value, interpreterText);
}
case DetailData::INTERPRETER_TYPE_AREA:
{
return inArea(detailData, value, interpreterText);
}
case DetailData::INTERPRETER_TYPE_RAD:
{
return inRad(detailData, value, interpreterText);
}
case DetailData::INTERPRETER_TYPE_STR_COMPARE:
{
if (value.toString() == interpreterText)
return true;
return false;
}
case DetailData::INTERPRETER_TYPE_ID_COMPARE:
{
bool tryIt = isIntEqual(detailData, value, interpreterText);
return tryIt;
}
default:
{
return false;
}
}
}
bool FilterEquationFunctions::checkValue(DetailData *detailData, const QString &attributeType, const QVariant &value, const QString &interpreterText)
{
int attributeInterpreterType = detailData->attributeInterpreterLookup.getInterpreterType(attributeType);
return checkValue(detailData, attributeInterpreterType, value, interpreterText);
}
}
@@ -1,20 +0,0 @@
#pragma once
class QVariant;
class QString;
namespace Timeline
{
class DetailData;
namespace FilterEquationFunctions
{
bool checkValue(DetailData *detailData, const QString &attributeType, const QVariant &value, const QString &interpreterText);
}
}
@@ -1,163 +0,0 @@
#include "FilterValueInterpreter.h"
#include "../../detail_data.h"
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QRect>
namespace Timeline
{
static InterpreterResult interpretAreaText(const QString &areaText)
{
QStringList areaList = areaText.split(QLatin1Char('x'));
if (areaList.count() != 4)
{
return InterpreterResult(InterpreterResult::InterpreterResultTypes::RESULT_AREATEXT_COUNT_NOT_FOUR);
}
bool ok1 = false;
bool ok2 = false;
bool ok3 = false;
bool ok4 = false;
int n1 = areaList.at(0).toInt(&ok1);
int n2 = areaList.at(1).toInt(&ok2);
int o1 = areaList.at(2).toInt(&ok3);
int o2 = areaList.at(3).toInt(&ok4);
if (!ok1)
{
return InterpreterResult(InterpreterResult::InterpreterResultTypes::RESULT_AREATEXT_CANNOT_INTERPRET_N1);
}
if (!ok2)
{
return InterpreterResult(InterpreterResult::InterpreterResultTypes::RESULT_AREATEXT_CANNOT_INTERPRET_N2);
}
if (!ok3)
{
return InterpreterResult(InterpreterResult::InterpreterResultTypes::RESULT_AREATEXT_CANNOT_INTERPRET_O1);
}
if (!ok4)
{
return InterpreterResult(InterpreterResult::InterpreterResultTypes::RESULT_AREATEXT_CANNOT_INTERPRET_O2);
}
InterpreterResult ir(InterpreterResult::InterpreterResultTypes::RESULT_SUCCESS);
ir.resultList.append(QRect(o1, n1, o2, n2));
return ir;
}
static InterpreterResult interpretToInt(const QString &text)
{
bool ok = false;
int result = text.toInt(&ok);
if (!ok)
{
return InterpreterResult(InterpreterResult::InterpreterResultTypes::RESULT_TOINT_CANNOT_INTERPRET_VALUE);
}
InterpreterResult ir(InterpreterResult::InterpreterResultTypes::RESULT_SUCCESS);
ir.resultList.append(result);
return ir;
}
static InterpreterResult interpretRangeText(const QString &rangeText)
{
QStringList rangeList = rangeText.split(QLatin1Char('-'));
if (rangeList.count() != 2)
{
return InterpreterResult(InterpreterResult::InterpreterResultTypes::RESULT_RANGETEXT_COUNT_NOT_TWO);
}
bool ok1 = false;
bool ok2 = false;
unsigned int t1 = rangeList.at(0).toUInt(&ok1);
unsigned int t2 = rangeList.at(1).toUInt(&ok2);
if (!ok1)
{
return InterpreterResult(InterpreterResult::InterpreterResultTypes::RESULT_RANGETEXT_CANNOT_INTERPRET_T1);
}
if (!ok2)
{
return InterpreterResult(InterpreterResult::InterpreterResultTypes::RESULT_RANGETEXT_CANNOT_INTERPRET_T2);
}
if (t1 > t2)
{
return InterpreterResult(InterpreterResult::InterpreterResultTypes::RESULT_RANGETEXT_BEGIN_GREATER_THAN_END);
}
InterpreterResult ir(InterpreterResult::InterpreterResultTypes::RESULT_SUCCESS);
ir.resultList.append(t1);
ir.resultList.append(t2);
return ir;
}
InterpreterResult interpretValue(DetailData *detailData, int attributeInterpreterType, const QString &value)
{
(void)detailData;
switch (attributeInterpreterType)
{
case DetailData::INTERPRETER_TYPE_ID_COMPARE:
{
return interpretToInt(value);
}
case DetailData::INTERPRETER_TYPE_RANGE:
{
return interpretRangeText(value);
}
case DetailData::INTERPRETER_TYPE_AREA:
{
return interpretAreaText(value);
}
case DetailData::INTERPRETER_TYPE_STR_COMPARE:
{
InterpreterResult ir(InterpreterResult::InterpreterResultTypes::RESULT_SUCCESS);
ir.resultList.append(value);
return ir;
}
default:
{
return InterpreterResult(InterpreterResult::InterpreterResultTypes::RESULT_ATTRIBUTE_HAS_NO_INTERPRETER);
}
}
}
InterpreterResult interpretValue(DetailData *detailData, const QString &attributeType, const QString &value)
{
int interpreterType = detailData->attributeInterpreterLookup.getInterpreterType(attributeType);
return interpretValue(detailData, interpreterType, value);
}
}
@@ -1,58 +0,0 @@
#pragma once
#include <QtCore/QString>
#include <QtCore/QVariant>
namespace Timeline
{
class DetailData;
class InterpreterResult
{
public:
enum class InterpreterResultTypes
{
RESULT_UNKNOWN,
RESULT_SUCCESS,
RESULT_ATTRIBUTE_HAS_NO_INTERPRETER,
RESULT_RANGETEXT_COUNT_NOT_TWO,
RESULT_RANGETEXT_BEGIN_GREATER_THAN_END,
RESULT_RANGETEXT_CANNOT_INTERPRET_T1,
RESULT_RANGETEXT_CANNOT_INTERPRET_T2,
RESULT_AREATEXT_COUNT_NOT_FOUR,
RESULT_AREATEXT_CANNOT_INTERPRET_N1,
RESULT_AREATEXT_CANNOT_INTERPRET_N2,
RESULT_AREATEXT_CANNOT_INTERPRET_O1,
RESULT_AREATEXT_CANNOT_INTERPRET_O2,
RESULT_TOINT_CANNOT_INTERPRET_VALUE
};
explicit InterpreterResult(const InterpreterResult::InterpreterResultTypes &res)
: resultType(res)
{
}
InterpreterResult()
: resultType(InterpreterResultTypes::RESULT_UNKNOWN)
{
}
InterpreterResultTypes resultType;
QList<QVariant> additionalInformation;
QList<QVariant> resultList;
};
InterpreterResult interpretValue(DetailData *detailData, int attributeInterpreterType, const QString &value);
InterpreterResult interpretValue(DetailData *detailData, const QString &attributeType, const QString &value);
}
@@ -1,313 +0,0 @@
#include "FilterWorker.h"
#include "InfoWindow.h"
#include "../../detail_data.h"
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtWidgets/QApplication>
#include <QtCore/QJsonArray>
#include <QtCore/QJsonObject>
#include <QtCore/QDebug>
namespace Timeline
{
FilterWorker* FilterWorker::s_instance = nullptr;
FilterWorker* FilterWorker::getInstance()
{
if (!s_instance)
{
s_instance = new FilterWorker();
}
return s_instance;
}
FilterWorker::~FilterWorker()
{
}
void FilterWorker::deleteInstance()
{
}
FilterWorker::FilterWorker()
{
#define addErrorHandler(x,y) { FilterWorker::ErrorHandler eh; eh.errorText = y; eh.errorParamCount = eh.errorText.split(QLatin1Char('%'), QString::SkipEmptyParts).count(); m_errorHandlerLookupMap.insert(x, eh); }(void)this
addErrorHandler(GetModelFilterListResult::ERR_ATTRIBUTE_BLOCK_NOT_CLOSED, tr("Attribute block not closed: \n\'%1'"));
addErrorHandler(GetModelFilterListResult::ERR_ATTRIBUTE_HAS_NO_VALUES, tr("Attribute '%1' has no values"));
addErrorHandler(GetModelFilterListResult::ERR_COLON_MISUSE, tr("Colon misuse: \n\'%1'"));
addErrorHandler(GetModelFilterListResult::ERR_EVENT_HAS_NOT_ATTRIBUTE, tr("Attribute type '%1' does not belong to event type '%2': \n'%3'"));
addErrorHandler(GetModelFilterListResult::ERR_NO_EVENT_NAME, tr("No event name given for filter '%1'"));
addErrorHandler(GetModelFilterListResult::ERR_UNKNOWN_ATTRIBUTE_TYPE_BY_STRING, tr("Attribute type for '%1' does not exist"));
addErrorHandler(GetModelFilterListResult::ERR_UNKNOWN_EVENT_TYPE, tr("Event type '%1' does not exist"));
addErrorHandler(GetModelFilterListResult::ERR_VALUE_NOT_FOUND, tr("The attribute value '%1' is not a value of attribute type '%2'"));
addErrorHandler(GetModelFilterListResult::ERR_NO_VALUE_GIVEN, tr("There are no values given inside the brackets: \n'%1'"));
addErrorHandler(GetModelFilterListResult::ERR_TOO_MUCH_BRACKETS, tr("Too much brackets: \n'%1'"));
}
FilterWorker::Result makeResult(const int resultValue, const QString& additionalInformation = QString())
{
FilterWorker::Result result;
result.resultValue = resultValue;
if (!additionalInformation.isEmpty())
{
result.additionalInformation.append(additionalInformation);
}
return result;
}
FilterWorker::Result makeResult(const int resultValue, const QStringList& additionalInformationList)
{
FilterWorker::Result result;
result.resultValue = resultValue;
result.additionalInformation.append(additionalInformationList);
return result;
}
FilterWorker::GetModelFilterListResult FilterWorker::getModelFilterList(DetailData *detailData, const QJsonArray &filter, bool fromTypeSafe)
{
GetModelFilterListResult result;
if (filter.isEmpty())
{
return result;
}
for (auto i1 = filter.constBegin(); i1 != filter.constEnd(); ++i1)
{
const QJsonObject &currentFilter = (*i1).toObject();
QString eventTypeString = currentFilter[QStringLiteral("EventType")].toString();
int eventType = -1;
if (fromTypeSafe)
{
bool ok = false;
eventType = eventTypeString.toInt(&ok);
if (!ok)
{
eventType = -1;
}
}
else
{
eventType = detailData->eventTypeLookup.getEventType(eventTypeString);
}
QString eventTypeName = detailData->eventTypeLookup.getEventText(eventType);
if (!eventTypeName.isEmpty())
eventTypeString = eventTypeName;
if (eventType == -1)
{
result.resultValueList.append(makeResult(GetModelFilterListResult::ResultValues::ERR_UNKNOWN_EVENT_TYPE,
eventTypeString));
continue;
}
bool active = currentFilter[QStringLiteral("Active")].toBool(false);
const QJsonArray &attributes = currentFilter[QStringLiteral("Attributes")].toArray();
if (attributes.isEmpty())
{
ModelFilter mf;
mf.eventType = eventType;
mf.attributeType = QString();
mf.active = active;
result.result.append(mf);
continue;
}
for (auto i2 = attributes.constBegin(); i2 != attributes.constEnd(); i2++)
{
const QJsonObject &attribute = (*i2).toObject();
QString attributeType = attribute[QStringLiteral("AttributeType")].toString();
if (!fromTypeSafe)
{
attributeType = detailData->attributeTypeLookup.getAttributeType(attributeType);
}
attributeType = detailData->attributeRedirectionLookup.getRedirection(attributeType);
if (attributeType.isEmpty())
{
result.resultValueList.append(makeResult(GetModelFilterListResult::ResultValues::ERR_UNKNOWN_ATTRIBUTE_TYPE_BY_STRING,
attributeType));
continue;
}
int interpreterType = detailData->attributeInterpreterLookup.getInterpreterType(attributeType);
if (interpreterType == DetailData::INTERPRETER_TYPE_NONE)
{
continue;
}
const QJsonArray &attributeValues = attribute[QStringLiteral("AttributeValues")].toArray();
for (auto i3 = attributeValues.constBegin(); i3 != attributeValues.constEnd(); ++i3)
{
QString attributeValueString = (*i3).toString();
ModelFilter mf;
mf.eventType = eventType;
mf.attributeType = attributeType;
mf.active = active;
mf.attributeValue = attributeValueString;
result.result.append(mf);
}
}
}
return result;
}
bool FilterWorker::handleResultValues(const QVector<Result> &resultList, QWidget* parentWidget, bool ignoreInfos)
{
bool errorOccured = false;
InfoWindowEntryList iwel;
for (int i = 0; i < resultList.count(); i++)
{
FilterWorker::Result result = resultList.at(i);
int resultValue = result.resultValue;
if (!errorOccured && (resultValue & GetModelFilterListResult::ERR) == GetModelFilterListResult::ERR)
{
errorOccured = true;
}
if (ignoreInfos && (resultValue & GetModelFilterListResult::INFO) == GetModelFilterListResult::INFO)
{
continue;
}
InfoWindowEntry iwe;
const ErrorHandler& eh = m_errorHandlerLookupMap.value(result.resultValue);
if (!eh.isValid())
{
iwe.text = tr("Unhandled error (%1)");
iwe.infoType = InfoWindowEntry::InfoTypes::Error;
iwel.append(iwe);
continue;
}
int additionalInformationCount = result.additionalInformation.count();
QString iweText = eh.errorText;
if (eh.errorParamCount)
{
for (int i2 = 0; i2 < eh.errorParamCount; i2++)
{
if (additionalInformationCount >= eh.errorParamCount)
{
iweText = iweText.arg(result.additionalInformation.at(i2));
}
else
{
iweText = iweText.arg(QStringLiteral("???"));
}
}
}
iwe.text = iweText;
iwel.append(iwe);
}
if (iwel.count())
{
InfoWindow* iw = new InfoWindow(iwel, parentWidget);
iw->show();
}
return !errorOccured;
}
}
@@ -1,113 +0,0 @@
#pragma once
#include <QtCore/QVector>
#include <QtCore/QString>
#include <QtWidgets/QWidget>
#include <QtCore/QMap>
namespace Timeline
{
class DetailData;
class FilterWorker : public QObject
{
Q_OBJECT
private:
FilterWorker();
~FilterWorker();
static FilterWorker* s_instance;
public:
static FilterWorker* getInstance();
static void deleteInstance();
struct ModelFilter
{
int eventType = -1;
QString attributeType;
bool active = false;
QString attributeValue;
};
struct Result
{
int resultValue = -1;
QStringList additionalInformation;
};
struct GetModelFilterListResult
{
enum ResultType
{
ERR = 0x80,
WARN = 0x40,
INFO = 0x20,
};
enum ResultValues
{
ERR_NO_EVENT_NAME = ERR | 0,
ERR_COLON_MISUSE = ERR | 1,
ERR_UNKNOWN_EVENT_TYPE = ERR | 2,
ERR_ATTRIBUTE_HAS_NO_VALUES = ERR | 3,
ERR_ATTRIBUTE_BLOCK_NOT_CLOSED = ERR | 4,
ERR_UNKNOWN_ATTRIBUTE_TYPE_BY_STRING = ERR | 5,
ERR_EVENT_HAS_NOT_ATTRIBUTE = ERR | 7,
ERR_VALUE_NOT_FOUND = ERR | 8,
ERR_NO_VALUE_GIVEN = ERR | 9,
ERR_TOO_MUCH_BRACKETS = ERR | 10,
};
QVector<Result> resultValueList;
QVector<ModelFilter> result;
};
static GetModelFilterListResult getModelFilterList(DetailData *detailData, const QJsonArray &filter, bool fromTypeSafe = false);
bool handleResultValues(const QVector<Result> &resultList, QWidget* parentWidget = nullptr, bool ignoreInfos = false);
private:
class ErrorHandler
{
public:
ErrorHandler(const QString& errorText = QString(), const int errorParamCount = 0)
: errorText(errorText)
, errorParamCount(errorParamCount)
{
}
bool isValid() const
{
if (errorText.isEmpty() && !errorParamCount)
return false;
return true;
}
QString errorText;
int errorParamCount;
};
using ErrorHandlerLookupMap = QMap<int, ErrorHandler>;
ErrorHandlerLookupMap m_errorHandlerLookupMap;
};
using ModelFilterList = QVector<FilterWorker::ModelFilter>;
}
@@ -1,128 +0,0 @@
#include "InfoWindow.h"
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QMessageBox>
namespace Timeline
{
InfoWindow::InfoWindow(const InfoWindowEntryList &infoWindowEntryList, QWidget* parent)
: QDialog(parent)
, infoWindowEntryList(infoWindowEntryList)
, mainLayout(new QVBoxLayout())
, pbPrev(new QPushButton(tr("< Previous")))
, lbIndicator(new QLabel())
, pbNext(new QPushButton(tr("Next >")))
, pbOK(new QPushButton(tr("OK")))
, teText(new QTextEdit(tr("Missing Message")))
, listPosition(-1)
{
if (!infoWindowEntryList.count())
{
return;
}
connect(pbPrev, &QPushButton::clicked, this, &InfoWindow::slotPrev);
connect(pbNext, &QPushButton::clicked, this, &InfoWindow::slotNext);
connect(pbOK , &QPushButton::clicked, this, &InfoWindow::deleteLater);
QHBoxLayout* topButtonsLayout = new QHBoxLayout();
pbPrev->setEnabled(false);
topButtonsLayout->addWidget(pbPrev);
topButtonsLayout->addWidget(lbIndicator);
topButtonsLayout->addWidget(pbNext);
pbNext->setEnabled(false);
QWidget* topButtonsWidget = new QWidget();
topButtonsWidget->setLayout(topButtonsLayout);
mainLayout->addWidget(topButtonsWidget);
mainLayout->addWidget(teText);
QHBoxLayout* bottomButtonsLayout = new QHBoxLayout();
bottomButtonsLayout->addWidget(pbOK);
QWidget* bottomButtonsWidget = new QWidget();
bottomButtonsWidget->setLayout(bottomButtonsLayout);
mainLayout->addWidget(bottomButtonsWidget);
slotNext();
this->setLayout(mainLayout);
}
void InfoWindow::checkNavigationButtons(int newPosition)
{
int listCount = infoWindowEntryList.count();
if (newPosition -1 >= 0)
{
pbPrev->setEnabled(true);
}
else
{
pbPrev->setEnabled(false);
}
if (newPosition +2 > listCount)
{
pbNext->setEnabled(false);
}
else
{
pbNext->setEnabled(true);
}
}
void InfoWindow::slotPrev()
{
int listCount = infoWindowEntryList.count();
int prevListPosition = listPosition - 1 ;
checkNavigationButtons(prevListPosition);
if (prevListPosition >= 0 && prevListPosition < listCount)
{
teText->setText(infoWindowEntryList.at(prevListPosition).text);
QString indicatorString = QStringLiteral("%1/%2");
lbIndicator->setText(indicatorString.arg(prevListPosition + 1 ).arg(listCount));
listPosition = prevListPosition;
}
}
void InfoWindow::slotNext()
{
int listCount = infoWindowEntryList.count();
int nextListPosition = listPosition + 1 ;
checkNavigationButtons(nextListPosition);
if (nextListPosition >= 0 && nextListPosition < listCount)
{
teText->setText(infoWindowEntryList.at(nextListPosition).text);
QString indicatorString = QStringLiteral("%1/%2");
lbIndicator->setText(indicatorString.arg(nextListPosition + 1 ).arg(listCount));
listPosition = nextListPosition;
}
}
}
@@ -1,61 +0,0 @@
#pragma once
#include <QtWidgets/QDialog>
#include <QtWidgets/QWidget>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QTextEdit>
#include <QtWidgets/QLabel>
namespace Timeline
{
struct InfoWindowEntry
{
enum class InfoTypes
{
Error,
Info,
Warning
};
QString title;
QString text;
InfoTypes infoType = InfoTypes::Info;
};
typedef QVector<InfoWindowEntry> InfoWindowEntryList;
class InfoWindow : public QDialog
{
Q_OBJECT
public:
InfoWindow(const InfoWindowEntryList &infoWindowEntryList, QWidget* parent = nullptr);
~InfoWindow() = default;
private:
InfoWindowEntryList infoWindowEntryList;
QVBoxLayout* mainLayout;
QPushButton* pbPrev;
QLabel* lbIndicator;
QPushButton* pbNext;
QPushButton* pbOK;
QTextEdit* teText;
int listPosition;
void checkNavigationButtons(int newPosition);
public slots:
void slotPrev();
void slotNext();
};
}
@@ -1,81 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FilterWindow</class>
<widget class="QWidget" name="FilterWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>628</width>
<height>393</height>
</rect>
</property>
<property name="windowTitle">
<string>Filter Table</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Closing this window will reset all filters for the timeline.</string>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaContent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>610</width>
<height>358</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="filterContainer"/>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -1,38 +0,0 @@
#include "AbstractAttributeWidget.h"
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QPushButton>
namespace Timeline
{
AbstractAttributeWidget::AbstractAttributeWidget(QWidget *parent)
: QWidget(parent)
, m_abstractMainLayout(new QHBoxLayout(this))
{
QPushButton *pbDelete(new QPushButton(QStringLiteral("-")));
pbDelete->setPalette(QPalette(QColor("red")));
pbDelete->setToolTip(tr("Delete this value"));
m_abstractMainLayout->addWidget(pbDelete);
connect(pbDelete, &QPushButton::clicked, this, &AbstractAttributeWidget::slotDelete);
}
void AbstractAttributeWidget::slotDelete()
{
emit deleteClicked();
deleteLater();
}
void AbstractAttributeWidget::addCustomWidget(QWidget* widget)
{
m_abstractMainLayout->insertWidget(0, widget, 1, Qt::AlignLeft);
}
}
@@ -1,36 +0,0 @@
#pragma once
#include <QtWidgets/QWidget>
class QHBoxLayout;
namespace Timeline
{
class DetailData;
class AbstractAttributeWidget : public QWidget
{
Q_OBJECT
public:
explicit AbstractAttributeWidget(QWidget *parent = nullptr);
virtual QString filterText(bool typeSafe = false) const = 0;
virtual void updateData(DetailData *detailData) = 0;
protected:
void addCustomWidget(QWidget* widget);
protected:
QHBoxLayout *m_abstractMainLayout;
private slots:
void slotDelete();
signals:
void signalChanges();
void deleteClicked();
};
}
@@ -1,71 +0,0 @@
#include "AreaWidget.h"
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QWidget>
namespace Timeline
{
AreaWidget::AreaWidget(int n1, int n2, int o1, int o2, QWidget *parent)
: AbstractAttributeWidget(parent)
, sbN1(new QSpinBox())
, sbN2(new QSpinBox())
, sbO1(new QSpinBox())
, sbO2(new QSpinBox())
{
connect(sbN1, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &AreaWidget::signalChanges);
connect(sbN2, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &AreaWidget::signalChanges);
connect(sbO1, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &AreaWidget::signalChanges);
connect(sbO2, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &AreaWidget::signalChanges);
QString sbNPrefix = tr("N ");
QString sbOPrefix = tr("O ");
sbN1->setPrefix(sbNPrefix);
sbN2->setPrefix(sbNPrefix);
sbO1->setPrefix(sbOPrefix);
sbO2->setPrefix(sbOPrefix);
sbN1->setRange(n1, n2);
sbN2->setRange(n1, n2);
sbO1->setRange(o1, o2);
sbO2->setRange(o1, o2);
sbN1->setValue(n1);
sbN2->setValue(n2);
sbO1->setValue(o1);
sbO2->setValue(o2);
QGridLayout* mainLayout = new QGridLayout();
mainLayout->addWidget(sbN1, 0, 1);
mainLayout->addWidget(sbN2, 2, 1);
mainLayout->addWidget(sbO1, 1, 0);
mainLayout->addWidget(sbO2, 1, 2);
QWidget* mainLayoutWidget = new QWidget();
mainLayoutWidget->setLayout(mainLayout);
this->addCustomWidget(mainLayoutWidget);
}
QString AreaWidget::filterText(bool typeSafe) const
{
Q_UNUSED(typeSafe);
return QStringLiteral("%1x%2x%3x%4").arg(sbN1->cleanText(), sbN2->cleanText(), sbO1->cleanText(), sbO2->cleanText());
}
void AreaWidget::updateData(DetailData *detailData)
{
Q_UNUSED(detailData);
}
}
@@ -1,30 +0,0 @@
#pragma once
#include "AbstractAttributeWidget.h"
class QSpinBox;
namespace Timeline
{
class AreaWidget : public AbstractAttributeWidget
{
Q_OBJECT
public:
explicit AreaWidget(int n1, int n2, int o1, int o2, QWidget *parent = nullptr);
QString filterText(bool typeSafe = false) const override;
void updateData(DetailData *detailData) override;
private:
QSpinBox* sbN1;
QSpinBox* sbN2;
QSpinBox* sbO1;
QSpinBox* sbO2;
};
}
@@ -1,67 +0,0 @@
#include "CheckBoxWidget.h"
#include "../../detail_data.h"
#include <QtWidgets/QCheckBox>
namespace Timeline
{
CheckBoxWidget::CheckBoxWidget(DetailData *detailData, const QString &attributeType, const QString &initialValue, QWidget* parent)
: AbstractAttributeWidget(parent)
, cbCheck(new QCheckBox(this))
{
connect(cbCheck, &QCheckBox::stateChanged, this, &CheckBoxWidget::signalChanges);
trueValue = detailData->attributeValueLookup.getValueStringFromValueId(attributeType, 1);
falseValue = detailData->attributeValueLookup.getValueStringFromValueId(attributeType, 0);
cbCheck->setText(trueValue);
addCustomWidget(cbCheck);
if (initialValue.isEmpty())
return;
cbCheck->setChecked(initialValue != QStringLiteral("0"));
}
void CheckBoxWidget::setText(const QString &text)
{
cbCheck->setText(text);
}
QString CheckBoxWidget::filterText(bool typeSafe) const
{
QString filterText;
if (cbCheck->isChecked())
{
if (typeSafe)
filterText += QStringLiteral("1");
else
filterText += trueValue;
}
else
{
if (typeSafe)
filterText += QStringLiteral("0");
else
filterText += falseValue;
}
return filterText;
}
void CheckBoxWidget::updateData(DetailData *)
{
}
}
@@ -1,31 +0,0 @@
#pragma once
#include "AbstractAttributeWidget.h"
#include "../../detail_data.h"
class QCheckBox;
namespace Timeline
{
class CheckBoxWidget : public AbstractAttributeWidget
{
Q_OBJECT
public:
explicit CheckBoxWidget(DetailData *detailData, const QString &attributeType, const QString &initialValue, QWidget *parent = nullptr);
QString filterText(bool typeSafe = false) const override;
void updateData(DetailData *) override;
void setText(const QString &text);
private:
QCheckBox* cbCheck;
QString trueValue;
QString falseValue;
};
}
@@ -1,100 +0,0 @@
#include "ComboBox.h"
#include "logger.h"
#include <QtWidgets/QComboBox>
namespace Timeline
{
ComboBox::ComboBox(DetailData *detailData, const QString &attributeType, int eventType, const QString &initialValue, QWidget* parent) : AbstractAttributeWidget(parent)
, m_cbValues(new QComboBox())
, m_eventType(eventType),
m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger()) {
connect(m_cbValues, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &ComboBox::signalChanges);
addCustomWidget(m_cbValues);
m_concreteAttributeType = detailData->attributeRedirectionLookup.getRedirection(attributeType);
updateData(detailData);
if (initialValue.isEmpty())
return;
bool k = false;
int initialValueKey = initialValue.toInt(&k);
if (initialValueKey < 0 || !k)
{
WARNING_LOG(m_logger) << "ComboBox::c_tor: initialValueKey < 0 (" << initialValueKey << ")" << "initialValue: " << initialValue;
return;
}
m_cbValues->setCurrentIndex(m_cbValues->findData(initialValueKey, Qt::UserRole));
}
void ComboBox::updateData(DetailData *detailData)
{
int lastSelectedKey = -1;
if (m_cbValues->currentIndex() > 0)
lastSelectedKey = m_cbValues->itemData(m_cbValues->currentIndex()).toInt();
QSignalBlocker blocker(m_cbValues);
m_cbValues->clear();
m_avm = detailData->m_attributeValueLookupDtc.getAttributeValueMap(m_eventType, m_concreteAttributeType);
if (m_avm.isEmpty())
m_avm = detailData->attributeValueLookup.getAttributeValueMap(m_concreteAttributeType);
for (auto i = m_avm.constBegin(); i != m_avm.constEnd(); ++i)
{
m_cbValues->addItem(i.value()
#ifdef DEBUG
+ " (" + QString::number(i.key()) + ")"
#endif
, i.key());
}
if (lastSelectedKey < 0)
{
m_cbValues->setCurrentIndex(0);
return;
}
m_cbValues->setCurrentIndex(m_cbValues->findData(lastSelectedKey, Qt::UserRole));
DEBUG_LOG(m_logger) << "ComboBox: no initial item index found for value id" << lastSelectedKey;
}
QString ComboBox::filterText(bool typeSafe) const
{
QString resultFilterText;
bool ok = false;
int key = m_cbValues->itemData(m_cbValues->currentIndex()).toInt(&ok);
if (!ok)
{
return resultFilterText;
}
if (typeSafe)
resultFilterText = QString::number(key);
else
resultFilterText = m_avm.value(key);
return resultFilterText;
}
}
@@ -1,35 +0,0 @@
#pragma once
#include "AbstractAttributeWidget.h"
#include "../../detail_data.h"
#include <NGLLogger/INGLLogger.h>
class QComboBox;
namespace Timeline
{
class ComboBox : public AbstractAttributeWidget
{
Q_OBJECT
public:
explicit ComboBox(DetailData *detailData, const QString &attributeType,
int eventType, const QString &initialValue, QWidget *parent = nullptr);
QString filterText(bool typeSafe = false) const override;
void updateData(DetailData *detailData) override;
private:
NGL::INGLLogger &m_logger;
QComboBox *m_cbValues;
int m_eventType;
QString m_concreteAttributeType;
AttributeValueMap m_avm;
};
}
@@ -1,91 +0,0 @@
#include "DefaultRangeWidget.h"
#include "logger.h"
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QLabel>
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QWidget>
namespace Timeline
{
DefaultRangeWidget::DefaultRangeWidget(unsigned int min, unsigned int max, const QString &prefix, const QString &suffix, const QString &initialValue, QWidget *parent) : AbstractAttributeWidget(parent)
, box1(new QSpinBox())
, box2(new QSpinBox()),
m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger()) {
connect(box1, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &DefaultRangeWidget::signalChanges);
connect(box2, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &DefaultRangeWidget::signalChanges);
box1->setRange(min, max);
box2->setRange(min, max);
box1->setPrefix(prefix);
box2->setPrefix(prefix);
box1->setSuffix(suffix);
box2->setSuffix(suffix);
box1->setValue(min);
box2->setValue(max);
QHBoxLayout* mainLayout = new QHBoxLayout();
mainLayout->addWidget(new QLabel(tr("between")));
mainLayout->addWidget(box1);
mainLayout->addWidget(new QLabel(tr("and")));
mainLayout->addWidget(box2);
QWidget* mainLayoutWidget = new QWidget();
mainLayoutWidget->setLayout(mainLayout);
this->addCustomWidget(mainLayoutWidget);
box1->setFocus();
if (initialValue.length())
{
QStringList valueList = initialValue.split(QLatin1Char('-'), QString::SkipEmptyParts);
if (valueList.count() != 2)
{
WARNING_LOG(m_logger) << "DefaultRangeWidget: invalid initial value '" << initialValue << "'";
return;
}
bool k1 = false;
bool k2 = false;
unsigned int val1 = valueList.at(0).toUInt(&k1);
unsigned int val2 = valueList.at(1).toUInt(&k2);
if (!k1 || !k2)
{
WARNING_LOG(m_logger) << "DefaultRangeWidget: initial value is not numeric '" << initialValue << "'";
return;
}
box1->setValue(val1);
box2->setValue(val2);
}
}
QString DefaultRangeWidget::filterText(bool typeSafe) const
{
Q_UNUSED(typeSafe);
return QStringLiteral("%1 - %2").arg(box1->value(), box2->value());
}
void DefaultRangeWidget::updateData(DetailData *detailData)
{
Q_UNUSED(detailData);
}
}
@@ -1,38 +0,0 @@
#pragma once
#include "AbstractAttributeWidget.h"
#include <NGLLogger/INGLLogger.h>
class QHBoxLayout;
class QSpinBox;
namespace Timeline
{
class DefaultRangeWidget : public AbstractAttributeWidget
{
Q_OBJECT
public:
explicit DefaultRangeWidget(unsigned int min,
unsigned int max,
const QString &prefix,
const QString &suffix,
const QString &initialValue = QString(),
QWidget *parent = nullptr);
QString filterText(bool typeSafe = false) const override;
void updateData(DetailData *detailData) override;
private:
NGL::INGLLogger &m_logger;
QSpinBox* box1;
QSpinBox* box2;
};
}
@@ -1,64 +0,0 @@
#include "RadiusWidget.h"
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QWidget>
namespace Timeline
{
RadiusWidget::RadiusWidget(int n1, int n2, int o1, int o2, int radius, QWidget *parent)
: AbstractAttributeWidget(parent)
, sbN(new QSpinBox(this))
, sbO(new QSpinBox(this))
, sbR(new QSpinBox(this))
{
Q_ASSERT(false);
QString sbNPrefix = tr("N ");
QString sbOPrefix = tr("O ");
QString sbRPrefix = tr("radius of ");
sbN->setPrefix(sbNPrefix);
sbO->setPrefix(sbOPrefix);
sbR->setPrefix(sbRPrefix);
sbN->setRange(n1, n2);
sbO->setRange(o1, o2);
sbR->setRange(0, 9999);
sbN->setValue(n1);
sbO->setValue(o1);
sbR->setValue(radius);
QGridLayout* mainLayout = new QGridLayout();
mainLayout->addWidget(sbN, 0, 0);
mainLayout->addWidget(sbR, 0, 1);
mainLayout->addWidget(sbO, 0, 2);
QWidget* mainLayoutWidget = new QWidget();
mainLayoutWidget->setLayout(mainLayout);
addCustomWidget(mainLayoutWidget);
}
QString RadiusWidget::filterText(bool typeSafe) const
{
Q_UNUSED(typeSafe);
return QStringLiteral("%1x%2x%3").arg(sbN->cleanText(), sbO->cleanText(), sbR->cleanText());
}
void RadiusWidget::updateData(DetailData *)
{
}
}
@@ -1,29 +0,0 @@
#pragma once
#include "AbstractAttributeWidget.h"
class QSpinBox;
namespace Timeline
{
class RadiusWidget : public AbstractAttributeWidget
{
Q_OBJECT
public:
explicit RadiusWidget(int n1, int n2, int o1, int o2, int radius, QWidget *parent = nullptr);
QString filterText(bool typeSafe = false) const override;
void updateData(DetailData *detailData) override;
private:
QSpinBox* sbN;
QSpinBox* sbO;
QSpinBox* sbR;
};
}
@@ -1,101 +0,0 @@
#include "logger.h"
#include "TimeRangeWidget.h"
#include "../../detail_data.h"
#include <LtsWidgets/lts_date_time_edit.h>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QLabel>
#include <QtCore/QDateTime>
namespace Timeline
{
TimeRangeWidget::TimeRangeWidget(DetailData *detailData, const QString &initialValue, QWidget *parent) : AbstractAttributeWidget(parent)
, m_edit1(new LtsWidgets::LtsDateTimeEdit(this))
, m_edit2(new LtsWidgets::LtsDateTimeEdit(this)),
m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger()) {
connect(m_edit1, &LtsWidgets::LtsDateTimeEdit::dateTimeChanged, this, &TimeRangeWidget::signalChanges);
connect(m_edit2, &LtsWidgets::LtsDateTimeEdit::dateTimeChanged, this, &TimeRangeWidget::signalChanges);
QHBoxLayout* mainLayout = new QHBoxLayout();
mainLayout->addWidget(new QLabel(tr("between")));
mainLayout->addWidget(m_edit1);
mainLayout->addWidget(new QLabel(tr("and")));
mainLayout->addWidget(m_edit2);
QWidget* mainLayoutWidget = new QWidget();
mainLayoutWidget->setLayout(mainLayout);
addCustomWidget(mainLayoutWidget);
m_edit1->setFocus();
updateData(detailData);
if (initialValue.isEmpty())
return;
const auto initialTimeRange(initialValue.splitRef(QLatin1Char('-'), QString::SkipEmptyParts));
if (initialTimeRange.count() != 2)
{
WARNING_LOG(m_logger) << "invalid initial time range value: " << initialValue;
return;
}
bool k = false;
qint64 time = initialTimeRange.at(0).toInt(&k);
time *= 1000;
if (!k)
WARNING_LOG(m_logger) << "invalid initial time range start value: " << initialTimeRange.at(0).toString();
else
m_edit1->setMsecsSinceEpoch(time);
time = initialTimeRange.at(1).toInt(&k);
time *= 1000;
if (!k)
WARNING_LOG(m_logger) << "invalid initial time range start value: " << initialTimeRange.at(1).toString();
else
m_edit2->setMsecsSinceEpoch(time);
}
QString TimeRangeWidget::filterText(bool typeSafe) const
{
(void)typeSafe;
QString filterText;
filterText += QString::number(m_edit1->msecsSinceEpoch() / 1000 );
filterText += QLatin1Char('-');
filterText += QString::number(m_edit2->msecsSinceEpoch() / 1000 );
return filterText;
}
void TimeRangeWidget::updateData(DetailData *detailData)
{
LtsSession::LtsSession *session = detailData->session();
m_edit1->setMsecsSinceEpoch(session->partitionTime() - 60 * 1000 );
m_edit2->setMsecsSinceEpoch(session->partitionTime());
}
}
Loaded 100 of 895 files, more files were not shown because too many files have changed in this diff. Show more