Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

@@ -0,0 +1,104 @@
/**
* @RDE_HEADER@
* $Id$
* $HeadURL$
* $Author$
* Created by Philipp Last, NLSE, 2018-01-11
*/
#include "evl_comment_model.h"
#include <QDateTime>
#include <QColor>
#include <LtsSession/lts_session_manager.h>
#include <ngltools/ngltools_dtg.h>
namespace Evaluations
{
EvlCommentDataViewModel::EvlCommentDataViewModel(QObject *parent) : LtsAbstractTableModel(
{
tr("Id"),
tr("Timestamp"),
tr("Sender"),
tr("Is personal"),
tr("Comment"),
tr("Hierarchy")
},
parent)
{
}
QVariant EvlCommentDataViewModel::data(const QModelIndex &index, int role) const
{
if (!indexIsValid(index))
return QVariant();
if (role == Qt::BackgroundRole)
{
const CommentTuple &row = m_vecData.at(index.row());
if (row.m_receiver.size())
return QColor(188, 210, 238);
}
if (role == Qt::DisplayRole)
{
const CommentTuple &row = m_vecData.at(index.row());
switch (index.column())
{
case Id:
return index.row() + 1;
case Timestamp:
return QDateTime::fromMSecsSinceEpoch(row.m_timestamp.currentMSecsSinceEpoch());
case Sender:
return row.m_sender;
case IsPersonal:
return row.m_receiver.size() ? tr("Yes") : tr("No");
case Comment:
return row.m_text;
case Hierarchy:
return row.m_hierarchy;
default:
break;
}
}
return QVariant();
}
void EvlCommentDataViewProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
{
m_sourceModel = qobject_cast<EvlCommentDataViewModel*>(sourceModel);
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
}
bool EvlCommentDataViewProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
{
if (!m_sourceModel ||
source_left.column() != source_right.column() ||
!source_left.isValid() ||
!source_right.isValid())
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
switch (source_left.column())
{
case EvlCommentDataViewModel::Timestamp:
return dataLeft.m_timestamp.currentMSecsSinceEpoch() < dataRight.m_timestamp.currentMSecsSinceEpoch();
case EvlCommentDataViewModel::Id:
case EvlCommentDataViewModel::Sender:
case EvlCommentDataViewModel::IsPersonal:
case EvlCommentDataViewModel::Comment:
case EvlCommentDataViewModel::Hierarchy:
break;
}
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
}
}