Files
qt-migration-legatus/qt5-before/dlbo/Lts/Tools/SqlBrowser/AddModel.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

153 lines
2.9 KiB
C++

#include "AddModel.h"
#include <QDebug>
void AddModel::setHeaderList(const HeaderList& headerList)
{
m_headerList = headerList;
beginResetModel();
endResetModel();
}
const HeaderList& AddModel::getHeaderList() const
{
return m_headerList;
}
bool AddModel::removeRow(int row, const QModelIndex &parent)
{
//qWarning() << "removeRow";
(void)parent;
if (row >= m_dataList.count())
{
//qWarning() << "removeRows false";
return false;
}
beginRemoveRows(parent, row, row);
m_dataList.removeAt(row);
endRemoveRows();
return true;
}
void AddModel::clear()
{
beginResetModel();
m_dataList.clear();
endResetModel();
}
QVariant AddModel::data(const QModelIndex &index, int role) const
{
switch (role)
{
case Qt::EditRole:
case Qt::DisplayRole:
{
if (index.row() >= m_dataList.count())
{
return QVariant(); // probably the new line was not added yet (use setData the first time to create it)
}
return m_dataList.at(index.row()).at(index.column());
}
}
return QVariant();
}
bool AddModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (role != Qt::EditRole)
{
return false;
}
if (index.row() >= m_dataList.count()) // no row in dataList?
{
Data newData; // create new row
int headerListCount = m_headerList.count();
newData.reserve(headerListCount);
for (int i = 0; i < headerListCount; i++) // preadd empty columns
{
newData.append(QString());
}
m_dataList.append(newData); // finally add new line to dataList
}
Data data = m_dataList.at(index.row()); // get old row
data.replace(index.column(), value.toString()); // replace column in row
m_dataList.replace(index.row(), data); // finally replace row in dataList
beginResetModel();
endResetModel(); // tell the model to show the new empty line
return true;
}
QVariant::Type AddModel::getColumnType(const int column) const
{
if (column < 0 || column >= m_headerList.size())
return QVariant::Invalid;
return m_headerList.at(column).second;
}
QVariant AddModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation != Qt::Horizontal)
return QVariant();
switch (role)
{
case Qt::DisplayRole:
{
return m_headerList.at(section).first;
}
}
return QVariant();
}
int AddModel::rowCount(const QModelIndex &) const
{
return m_dataList.count() + 1 /* empty row for new data */; // yes, if the user wants to add more than 1 line!
}
int AddModel::columnCount(const QModelIndex &) const
{
return m_headerList.count();
}
Qt::ItemFlags AddModel::flags(const QModelIndex &) const
{
return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;
}
void AddModel::setTablename(const QString& tableName)
{
m_tableName = tableName;
}
const QString& AddModel::getTableName() const
{
return m_tableName;
}