Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+81
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SituationReplayManagement - Replay Partition Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-19
|
||||
*/
|
||||
#include "replay_dialog_model.h"
|
||||
|
||||
namespace SituationReplayManagement
|
||||
{
|
||||
ReplayPartitionDialogModel::ReplayPartitionDialogModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<Core::ReplayPartition>({tr("Id"),
|
||||
tr("Name"),
|
||||
tr("Exercise"),
|
||||
tr("Workstation"),
|
||||
tr("Connection")},
|
||||
parent)
|
||||
, m_partitionid(-1)
|
||||
, m_dtc(nullptr)
|
||||
, m_logger(getLogger("ReplayPartitionDialogModel"))
|
||||
{}
|
||||
|
||||
ReplayPartitionDialogModel::~ReplayPartitionDialogModel()
|
||||
{}
|
||||
|
||||
bool ReplayPartitionDialogModel::initModel(int partitionId,
|
||||
const std::shared_ptr<Core::Interface::Dtc> &dtc)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_partitionid = partitionId;
|
||||
|
||||
connect(m_dtc.get(), &Core::Interface::Dtc::replayPartitionChanged,
|
||||
this, &ReplayPartitionDialogModel::onDataChanged);
|
||||
m_dtc->replayPartitions([this](const Core::ReplayPartition &partition) { insertRow(partition); });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QVariant ReplayPartitionDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const Core::ReplayPartition &partition = m_vecData.at(index.row());
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return partition.id();
|
||||
case Name:
|
||||
return QString::fromStdString(partition.name());
|
||||
case Exercise:
|
||||
return partition.exerciseId(); // TODO: get name from pdm
|
||||
case WorkstationId:
|
||||
return partition.workstationId();
|
||||
case ConnectionString:
|
||||
{
|
||||
if (partition.tcpConnectionUrl().size() == 0)
|
||||
return QString::number(partition.domainId());
|
||||
return QString(QString::fromUtf8(partition.tcpConnectionUrl().c_str()) +
|
||||
QStringLiteral(" - ") +
|
||||
QString::number(partition.domainId()));
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
bool ReplayPartitionDialogModel::removeRows(int row, int count, const QModelIndex &parent)
|
||||
{
|
||||
//#warning PATRIC!!
|
||||
// int partitionId = m_vecData.at(r).id();
|
||||
// int workstationId = m_vecData.at(r).workstationId();
|
||||
// // TODO: make async / wait dialog
|
||||
// m_ftc->replayPartitionRemoveRequest(ReplayPartitionRemoveRequest(partitionId, workstationId), this);
|
||||
return LtsAbstractTableModel::removeRows(row, count, parent);
|
||||
}
|
||||
} // namespace SituationReplayManagement
|
||||
Reference in new issue
Block a user