80 lines
2.1 KiB
C++
Executable File
80 lines
2.1 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* List of topics of selected thp
|
|
* $Id: tpm_exported_scripts_model.h 53111 2021-03-22 08:21:29Z wille_m $
|
|
* $HeadURL: svn://slssvn/TDS/branches/product/iterations/21_03_salted_caramel/Lts/Plugins/TakeHomePackageManager/tpm_exported_scripts_model.h $
|
|
* $Author: wille_m $
|
|
*
|
|
* Created by Mike Wille, SLTE, 2024-02-09
|
|
*/
|
|
|
|
#include "tpm_topics_model.h"
|
|
|
|
#include <TopicEditorBase/topic_editor_utils.h>
|
|
|
|
#include <QJsonArray>
|
|
#include <QJsonDocument>
|
|
#include <QJsonObject>
|
|
|
|
|
|
namespace TakeHomePackageManager
|
|
{
|
|
TopicsModel::TopicsModel(QObject *parent)
|
|
: LtsWidgets::LtsAbstractTableModel<Topic>(
|
|
{ tr("id"), tr("Channel"), tr("Filter"), tr("Description"), tr("Type"), tr("Start [mm:ss]"), tr("Duration [mm:ss]")}, parent)
|
|
, m_logger(getLogger("TopicsModel"))
|
|
{}
|
|
|
|
|
|
void TopicsModel::addTopic(const Topic &topic)
|
|
{
|
|
insertRow(topic);
|
|
}
|
|
|
|
|
|
QVariant TopicsModel::data(const QModelIndex &index, int role) const
|
|
{
|
|
if (!indexIsValid(index))
|
|
return QVariant();
|
|
|
|
if (role == Qt::UserRole)
|
|
{
|
|
const auto &topic = m_vecData[index.row()];
|
|
return topic.id;
|
|
}
|
|
|
|
if (role != Qt::DisplayRole)
|
|
{
|
|
return {};
|
|
}
|
|
|
|
auto channelName = [](const int channel)
|
|
{
|
|
switch (channel)
|
|
{
|
|
case 1: return tr("Audio");
|
|
case 2: return tr("Replay");
|
|
case 3: return tr("Screen 1");
|
|
case 4: return tr("Screen 2");
|
|
default: { assert(false); return L("UNKNOWN"); }
|
|
}
|
|
};
|
|
|
|
const auto &topic = m_vecData[index.row()];
|
|
|
|
switch (index.column())
|
|
{
|
|
case ColId: return topic.id;
|
|
case ColChannel: return channelName(topic.channel);
|
|
case ColFilter: return (topic.filterSet ? QString::number(topic.filter) : L(" - "));
|
|
case ColDescription: return (topic.description.isEmpty() ? L(" - ") : topic.description);
|
|
case ColType: return TopicEditorBase::topicTypeTranslation((TopicEditorBase::TopicType)topic.type);
|
|
case ColStart: return QTime(0, 0).addSecs(topic.start).toString(L("mm:ss"));
|
|
case ColDuration: return QTime(0, 0).addSecs(topic.duration).toString(L("mm:ss"));
|
|
}
|
|
|
|
return {};
|
|
}
|
|
|
|
} // namespace TakeHomePackageManager
|