Files
qt-migration-legatus/qt5-before/dlbo/Lts/Viewer/LtsDataView/search_model.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

157 lines
4.1 KiB
C++

/**
* @RDE_HEADER@
* Search Model for TableViews (has the ability to give the user a row for searching data)
* $Id$
* $HeadURL$
* $Author$
* Created by Mike Wille, SLSE, 2016-03-14
*/
#include "search_model.h"
#include <QFont>
#include <QGuiApplication>
#include <QIcon>
#include <QPalette>
#include <LtsWidgets/lts_column_filter_proxy_model.h>
namespace LtsDataView
{
SearchModel::SearchModel(QObject *parent)
: QAbstractItemModel(parent)
, m_searchIcon(QIcon(QStringLiteral("icon:show.svg")))
{
}
int SearchModel::columnCount(const QModelIndex &parent) const
{
if (parent.isValid()) return 0;
if (!m_sourceModel) return 0;
// no parent here - the given model index has nothing to do with the source model
return m_sourceModel->columnCount(QModelIndex());
}
int SearchModel::rowCount(const QModelIndex &parent) const
{
if (parent.isValid()) return 0;
if (!m_sourceModel) return 0;
return 1; // the search row
}
QVariant SearchModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
switch (role)
{
case Qt::DisplayRole: // Text
return m_displayData.value(index.column());
case Qt::EditRole: // Editor Text
return m_columnFilters.value(index.column());
case Qt::TextColorRole: // Text-Color
if (!m_columnFilters.contains(index.column()))
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::ButtonText);
break;
case Qt::DecorationRole:
return m_hideDecorationColumns.contains(index.column()) ? QVariant() : m_searchIcon;
case Qt::BackgroundRole:
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase);
case LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole:
return m_comboBoxData.value(index.column());
default:
break;
}
return QVariant();
}
QVariant SearchModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::FontRole)
{
QFont boldFont;
boldFont.setBold(true);
return boldFont;
}
return m_sourceModel ? m_sourceModel->headerData(section, orientation, role) : QVariant();
}
bool SearchModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (!m_sourceModel || !index.isValid())
return false;
if (role == Qt::EditRole) // add / replace column filter when edited and in search row (row 0)
{
if (value.isNull())
m_columnFilters.remove(index.column());
else
m_columnFilters[index.column()] = value;
emit stringFilterForColumnChanged(value.toString(), index.column());
emit signalFilterChanged(); // must be called at last
emit dataChanged(index, index, {role});
return true; // done! (report a change, so that text keeps showing on search row)
}
if (role == Qt::DisplayRole)
{
if (value.isNull())
m_displayData.remove(index.column());
else
m_displayData[index.column()] = value;
emit dataChanged(index, index, {role});
return true;
}
if (role == LtsWidgets::LtsColumnFilterProxyModel::ComboboxFilterRole)
{
if (value.isNull())
m_comboBoxData.remove(index.column());
else
m_comboBoxData[index.column()] = value;
emit dataFilterForColumnChanged(value, index.column());
emit signalFilterChanged(); // must be called at last
emit dataChanged(index, index, {role});
return true;
}
if (role == Qt::DecorationRole)
{
if (value.isNull())
m_hideDecorationColumns.remove(index.column());
else
m_hideDecorationColumns.insert(index.column());
emit dataChanged(index, index, {role});
}
return false;
}
void SearchModel::setSourceModel(QAbstractItemModel* sourceModel)
{
m_sourceModel = sourceModel;
m_columnFilters.clear();
emit dataChanged(QModelIndex(), QModelIndex()); // update view
}
Qt::ItemFlags SearchModel::flags(const QModelIndex &index) const
{
Q_UNUSED(index);
return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;
}
QModelIndex SearchModel::index(int row, int column, const QModelIndex &parent) const
{
if (parent.isValid())
return QModelIndex();
return createIndex(row, column);
}
} // namespace LtsDataView