- Copied complete Lts/Tools directory from qt5-before to qt6-after - Updated 32 CMakeLists.txt files (Qt5:: → Qt6::) - Tools subdirectory already included in parent Lts/CMakeLists.txt - All 72 tool submodules now present in qt6-migrated-legatus - Includes: Adler, ArAssets, ConfigX, DBAdministration, DBUpdate, DdsView, InfrastructureManagement, and 67 more tools - C++17 standard (RTI 7.7.0 compatibility maintained) - Tests deferred until final validation phase Migration progress: ✅ Lts/Application (68 files) ✅ Lts/DDS (verified Qt6-ready) ✅ Lts/Plugins (60 submodules, verified) ✅ Lts/Projects (5 submodules, verified) ✅ Lts/Proxies (13 submodules, verified) ✅ Lts/Services (47 submodules, verified) ✅ Lts/Tools (72 submodules, copied + CMake updated) ✅ Lts/Viewer (LtsFileDialog, LtsReportDisplay, SituationMap) 🟡 TetraIF (partial) 🟡 Z (partial: nglwidgets, QtSingleApplication, qsql_informix, WMS_Interface)
153 lines
2.9 KiB
C++
Executable File
153 lines
2.9 KiB
C++
Executable File
#include "AddModel.h"
|
|
|
|
#include <QtCore/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;
|
|
}
|