Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Topic Editor for the Snapshot Topic in the Script Editor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Iuliana Ojog, SLSE, 2017-10-07
|
||||
*/
|
||||
|
||||
#include "topic_editor.h"
|
||||
#include "ui_topic_editor.h"
|
||||
|
||||
#include <LtsScriptTimeline/track_entry.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <Plugins/MarkerManagement/Gui/MarkerEdit/snapshot_dialog_model.h>
|
||||
#include <Services/MarkerManagement/mrk.hpp>
|
||||
#include <TopicEditorBase/topic_previewer.h>
|
||||
|
||||
#include <QModelIndex>
|
||||
#include <QModelIndexList>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
|
||||
namespace MarkerManagement
|
||||
{
|
||||
|
||||
SnapshotTopicEditor::SnapshotTopicEditor(SnapshotDialogModel *snapshotModel, QSortFilterProxyModel *proxyModel, QWidget *parent)
|
||||
: TopicEditorBase::TopicEditor(parent)
|
||||
, m_snapshotModel(snapshotModel)
|
||||
, m_proxyModel(proxyModel)
|
||||
, m_snapshotId(0)
|
||||
, m_ui(new Ui::SnapshotTopicEditor)
|
||||
, m_logger(getLogger("SnapshotTopicEditor"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
init(m_ui->widget);
|
||||
|
||||
if (snapshotModel != nullptr) // mrk plugin available
|
||||
{
|
||||
snapshotModel->setParent(this); // model was created without parent!
|
||||
proxyModel->setParent(this);
|
||||
|
||||
proxyModel->setSourceModel(snapshotModel);
|
||||
m_ui->snapshotsDataView->setModel(proxyModel);
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->snapshotsDataView->hideColumn(SnapshotDialogModel::ColFileId);
|
||||
#endif
|
||||
connect(m_ui->snapshotsDataView, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &SnapshotTopicEditor::onSnapshotSelected);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->snapshotsDataView->hide(); // no markers, no view
|
||||
}
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_Snapshot_Topic"));
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Import, tr("Refetch Snapshot"));
|
||||
m_buttonBox->setToolTip(LtsWidgets::DialogButton::Import, tr("If the selected snapshot was modified after it was used in this topic, then click this button to reload the snapshot to its most recent version for this topic."));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Import, this, &SnapshotTopicEditor::slotChangesMade /* we actually don't reload the snapshot, apply() does this :) */);
|
||||
}
|
||||
|
||||
SnapshotTopicEditor::~SnapshotTopicEditor()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// PRIVATE
|
||||
|
||||
void SnapshotTopicEditor::updateInternalData()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION;
|
||||
|
||||
m_ui->snapshotsDataView->selectionModel()->clear();
|
||||
m_snapshotId = m_topicData.properties.value(QStringLiteral("snapshotId")).toInt(0/*invalid*/);
|
||||
|
||||
if (m_snapshotId > 0) // there is a snapshot id saved (not a new topic)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "snapshotId = " << m_snapshotId;
|
||||
QModelIndex idx = m_snapshotModel->findIndexForId(m_snapshotId);
|
||||
|
||||
if (idx.isValid()) // the snapshot is still available on the system, tell its name and select it in the view
|
||||
{
|
||||
m_ui->snapshotsDataView->selectRow(m_proxyModel->mapFromSource(idx));
|
||||
const MarkerManagement::Snapshot snapshot = m_snapshotModel->getRowData(idx.row());
|
||||
DEBUG_LOG(m_logger) << "SnapShot Selected " << snapshot.id() ;
|
||||
m_snapshotId = snapshot.id();
|
||||
m_ui->lblName->setText(QString::fromStdString(snapshot.name()));
|
||||
}
|
||||
else // the snapshot does not exist anymore, but that's okay because all relevant data is saved
|
||||
{
|
||||
QString name = m_topicData.properties.value(QStringLiteral("snapshotName")).toString();
|
||||
if (name.isEmpty())
|
||||
name = QStringLiteral("<font color='red'>%1</font>").arg(tr("unknown"));
|
||||
m_ui->lblName->setText(QStringLiteral("%1 <font color='red'>(%2)</font>").arg(name, tr("Snapshot not available anymore!")));
|
||||
}
|
||||
}
|
||||
else // there is not a snapshot id saved, that means that this is a new topic
|
||||
{
|
||||
m_ui->lblName->setText(QStringLiteral("<font color='red'>%1</font>").arg(tr("Please select a valid snapshot")));
|
||||
}
|
||||
}
|
||||
|
||||
void SnapshotTopicEditor::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Snapshot Topic Editor"));
|
||||
m_uiRequirements->clear();
|
||||
m_uiRequirements->addRequirement(
|
||||
{ m_ui->lblNamePre, [this]() { return (m_snapshotId > 0); }, tr("Invalid or no snapshot selected") }
|
||||
);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// PRIVATE SLOTS
|
||||
|
||||
void SnapshotTopicEditor::onSnapshotSelected()
|
||||
{
|
||||
const QModelIndex idx =m_ui->snapshotsDataView->currentIndex();
|
||||
const MarkerManagement::Snapshot snapshot = m_snapshotModel->getRowData(idx.row());
|
||||
if (snapshot.id() <= 0)
|
||||
return;
|
||||
|
||||
m_snapshotId = snapshot.id();
|
||||
DEBUG_LOG(m_logger) << "new snapshot id = " << m_snapshotId;
|
||||
m_ui->lblName->setText(QString::fromStdString(snapshot.name()));
|
||||
slotChangesMade();
|
||||
}
|
||||
|
||||
|
||||
bool SnapshotTopicEditor::apply2()
|
||||
{
|
||||
//const QModelIndex idx = m_ui->snapshotsDataView->currentIndex();
|
||||
const QModelIndexList &idxList = m_ui->snapshotsDataView->selectionModel()->selectedRows(); // WARNING: do not use to get data! use getRowData instead!
|
||||
if (idxList.count() != 1)
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(this, tr("Invalid or no snapshot selected"));
|
||||
return false;
|
||||
}
|
||||
|
||||
const MarkerManagement::Snapshot snapshot = m_snapshotModel->getRowData(m_ui->snapshotsDataView->currentIndex().row());
|
||||
if (snapshot.id() <= 0)
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(this, tr("Invalid or no snapshot selected"));
|
||||
return false;
|
||||
}
|
||||
|
||||
setTopicDataProperty(QStringLiteral("snapshotName"), QString::fromStdString(snapshot.name()));
|
||||
setTopicDataProperty(QStringLiteral("snapshotId"), m_snapshotId);
|
||||
setTopicDataProperty(QStringLiteral("planOverlay"), QString::fromStdString(snapshot.planOverlay()));
|
||||
setTopicDataProperty(QStringLiteral("snapshotFilter"), QString::fromStdString(snapshot.filter()));
|
||||
setTopicDataProperty(QStringLiteral("timeStamp"), double(snapshot.timeStamp())); // QJsonValue's toInt is too small for int64
|
||||
setTopicDataProperty(QStringLiteral("mapSettings"), QString::fromStdString(snapshot.mapSettings()));
|
||||
setTopicDataProperty(QStringLiteral("fileContentId"), snapshot.fileContentId());
|
||||
setDescription(m_ui->widget->description().isEmpty() ? QString::fromStdString(snapshot.name()) : m_ui->widget->description());
|
||||
if (topicPreviewWidget()->description().isEmpty())
|
||||
topicPreviewWidget()->setDescription(QString::fromStdString(snapshot.name()));
|
||||
m_ui->widget->previewer()->setTopicData(m_topicData);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace MarkerManagement
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Topic Editor for the Snapshot Topic in the Script Editor
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Iuliana Ojog, SLSE, 2017-10-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <MarkerManagement/logger.h>
|
||||
#include <Services/MarkerManagement/mrk.hpp>
|
||||
#include <TopicEditorBase/topic_editor_base.h>
|
||||
|
||||
|
||||
class QSortFilterProxyModel;
|
||||
|
||||
namespace Ui { class SnapshotTopicEditor; }
|
||||
|
||||
|
||||
namespace MarkerManagement
|
||||
{
|
||||
|
||||
class SnapshotDialogModel;
|
||||
|
||||
|
||||
class SnapshotTopicEditor : public TopicEditorBase::TopicEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SnapshotTopicEditor(
|
||||
SnapshotDialogModel *snapshotModel, QSortFilterProxyModel *proxyModel, QWidget *parent = nullptr
|
||||
);
|
||||
~SnapshotTopicEditor();
|
||||
|
||||
private:
|
||||
void updateInternalData() override final;
|
||||
void retranslate() override final;
|
||||
|
||||
private slots:
|
||||
void onSnapshotSelected();
|
||||
|
||||
bool apply2() override final;
|
||||
|
||||
private:
|
||||
SnapshotDialogModel *m_snapshotModel{nullptr};
|
||||
QSortFilterProxyModel *m_proxyModel{nullptr};
|
||||
int m_snapshotId{0};
|
||||
|
||||
Ui::SnapshotTopicEditor *m_ui{nullptr};
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
} // namespace MarkerManagement
|
||||
@@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SnapshotTopicEditor</class>
|
||||
<widget class="QWidget" name="SnapshotTopicEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>868</width>
|
||||
<height>388</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Script Editor</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lblName">
|
||||
<property name="text">
|
||||
<string notr="true">unknown</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="TopicEditorBase::TopicPreviewWidget" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblNamePre">
|
||||
<property name="text">
|
||||
<string>Selected Snapshot:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="lbxAvailableSnapshots">
|
||||
<property name="text">
|
||||
<string>Available Snapshots:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<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>
|
||||
<item row="1" column="2" rowspan="2">
|
||||
<widget class="LtsDataView::LtsDataView" name="snapshotsDataView">
|
||||
<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>
|
||||
<customwidget>
|
||||
<class>TopicEditorBase::TopicPreviewWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>TopicEditorBase/topic_preview_widget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in new issue
Block a user