Files
qt-migration-legatus/qt5-before/dlbo/Lts/Common/LtsTimelineClassic/AbstractTimelineModel.cpp
T
torstenandCopilot 7173785915 Qt6 Migration: Complete migration with DDS/RTI support and build validation
Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list

Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF

Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
  - Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
  - Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)

Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified

Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-15 18:20:26 +00:00

293 lines
7.2 KiB
C++

/**
* @RDE_HEADER@
* MVC model
* $Id$
* $HeadURL$
* $Author$
* Created by Mike Wille, SLSE, 2014-10-01
*/
#include "AbstractTimelineModel.h"
#include <NGLLogger/NGLLoggerBootstrap.h>
namespace LtsTimelineClassic
{
AbstractTimelineModel::AbstractTimelineModel(QObject *parent)
: QAbstractItemModel(parent)
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("Timeline.AbstractTimelineModel"))
, m_highestPositionedItem(0)
, m_lowestPositionedItem(0)
, m_getEventListsRecursive(true) // get events from actuators and all their children
, m_rootItem(new Item(QLatin1String("#mwille/r00t/")))
, m_markersItem(new Item(tr("Markers"), QStringLiteral("Markers")))
{
/*/
*
* Filter Text syntax see zwmstl_exconFilter.cpp
*
/*/
m_rootItem->addItem(m_markersItem); // reparented
}
AbstractTimelineModel::~AbstractTimelineModel()
{
delete m_rootItem;
}
void AbstractTimelineModel::retranslate()
{
m_markersItem->setName(tr("Markers"));
}
void AbstractTimelineModel::invalidateTimeline()
{
const LtsTimelineClassic::ItemList il = m_rootItem->getFullItemList(true);
for (auto i = il.constBegin(); i != il.constEnd(); ++i)
{
LtsTimelineClassic::Item *item = *i;
if (item != nullptr)
item->setEventListChanged();
}
}
//void AbstractTimelineModel::invalidateItemForEvent(int uniqueId)
//{
// const LtsTimelineClassic::ItemList il = m_rootItem->getFullItemList(true);
// for (auto i = il.constBegin(); i != il.constEnd(); ++i)
// {
// LtsTimelineClassic::Item *item = *i;
// if (item != nullptr && item->getIdentifier() != QStringLiteral("Markers"))
// {
// const LtsTimelineClassic::EventList el = item->getFullEventList(true, true);
// for (LtsTimelineClassic::Event *event : el)
// {
// if (event->uniqueId() == uniqueId)
// {
// item->setEventListChanged();
// return;
// }
// }
// }
// }
// ERROR_LOG(m_logger) << "unable to invalidate an item - event not found!";
//}
Event *AbstractTimelineModel::getEvent(int uniqueId) // NOTE: ignores markers
{
const LtsTimelineClassic::ItemList il = m_rootItem->getFullItemList(true);
for (auto i = il.constBegin(); i != il.constEnd(); ++i)
{
LtsTimelineClassic::Item *item = *i;
if (item != nullptr && item->getIdentifier() != QStringLiteral("Markers"))
{
const LtsTimelineClassic::EventList el = item->getFullEventList(true, true);
for (LtsTimelineClassic::Event *event : el)
{
if (event->uniqueId() == uniqueId)
return event;
}
}
}
return nullptr;
}
void AbstractTimelineModel::addEvent(Event *event) // FIXME: to const ref ! give ownership...
{
QStringList actuatorPath = event->getActuator();
// actuatorPath => path/to/event ==> event
Item *currentItem = m_rootItem; // set first item to the root item
QModelIndex currentIndex = QModelIndex();
for (const QString &curPath : qAsConst(actuatorPath)) // look for paths in actuatorPath
{
Item *oldItem = currentItem; // to see wether an item has been found or has to be created!!!
const ItemList *itemList = currentItem->getChildren();
if (itemList != nullptr)
{
for (int row = 0; row < itemList->count(); row++) // look for items with the name equal to the path name
{
Item *childItem = itemList->at(row);
if (childItem->getName() == curPath)
{
currentIndex = index(row, 0, currentIndex);
currentItem = childItem;
break;
}
}
}
if (oldItem == currentItem) // path not found, it (item) has to be created - DO NOT FILL WITH EVENT YET, it is possible that there are paths left!
{
beginInsertRows(currentIndex, currentItem->childCount(), currentItem->childCount());
Item *newItem = new Item(curPath);
currentItem->addItem(newItem);
endInsertRows();
currentIndex = index(currentItem->childCount() - 1, 0, currentIndex); // TODO: not needed?
currentItem = newItem; // we are now on the new item to work with it
}
}
currentItem->addEvent(event);
}
Item *AbstractTimelineModel::getRootItem()
{
return m_rootItem;
}
Item *AbstractTimelineModel::itemFromIndex(const QModelIndex &idx) const
{
if (!idx.isValid())
return m_rootItem;
return static_cast<Item *>(idx.internalPointer());
}
QVariant AbstractTimelineModel::data(const QModelIndex &index, int role) const
{
if (role != Qt::DisplayRole || !index.isValid())
return QVariant();
Item *item = itemFromIndex(index);
if (!item)
return QVariant();
// if (m_listMode)
// getFullEventList
// ....
// else
if (index.column() == 1) // event row = delegate row
{
PassiveEventContainer *pevcon = item->getPevcon(); // set new event list for pevcon in case that new events were appended
return QVariant::fromValue(pevcon);
}
// actuators column (0)
QString name(item->getName());
if (name.isEmpty())
name = tr("[unknown]");
return QVariant(name);
}
Qt::ItemFlags AbstractTimelineModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return {};
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
}
QVariant AbstractTimelineModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
// if (m_listMode)
switch (section)
{
case 0: return QString(tr("Actuator") + QStringLiteral("\r\n"));
case 1: return QString(tr("Events") + QStringLiteral("\r\n"));
}
// else switch (section)
// {
// case 1: return QString(tr("Event Type") + QStringLiteral("\r\n"));
// case 2: return QString(tr("Start time") + QStringLiteral("\r\n"));
// case 3: return QString(tr("End time") + QStringLiteral("\r\n"));
// }
}
return QVariant();
}
QModelIndex AbstractTimelineModel::index(int row, int column, const QModelIndex &parent) const
{
if (!hasIndex(row, column, parent))
return QModelIndex();
Item *item = itemFromIndex(parent);
Item *child = item ? item->child(row) : nullptr;
if (child)
{
//qWarning() << "new Index: row = " << row << "column = " << column << "parent = " << &parent;
return createIndex(row, column, child);
}
return QModelIndex();
}
QModelIndex AbstractTimelineModel::parent(const QModelIndex &index) const
{
if (!index.isValid())
return QModelIndex();
Item *item = itemFromIndex(index);
Item *parent = item ? item->getParent() : nullptr;
if (parent == m_rootItem || parent == nullptr)
return QModelIndex();
int idx = parent->indexOfParent();
if (idx == -1)
return QModelIndex();
return createIndex(idx, 0, parent);
}
int AbstractTimelineModel::rowCount(const QModelIndex &parent) const
{
if (!parent.isValid())
{
int r = m_rootItem->visibleChildCount();
//qWarning() << m_rootItem->getName() << "rowCount" << r;
return r;
}
Item *item = itemFromIndex(parent);
if (item)
{
int r = item->visibleChildCount();
//qWarning() << item->getName() << "rowCount" << r;
return r;
}
return 0;
}
int AbstractTimelineModel::columnCount(const QModelIndex &) const
{
return 2; // Actuator + Events
}
} // namespace LtsTimelineClassic