Build script changes: - Add --group6/--no-group6 argument support to new_docker_build.sh - Add GROUP6_TARGETS array with 11 LTS tools - Add BUILD_GROUP6 environment variable export - Add GROUP6 build invocation in run_build_group function Test infrastructure: - Create CTest test files for all 11 Group 6 tools - Add exclusion filters in tests/CMakeLists.txt for conditional builds - Tests follow gtest pattern: CompilationStub, Qt6ApiCompatibility, BasicFunctionality Qt6 migration bug fixes: - DBAdministration: Fix m_id → id member access (3 files) - DBAdministration: Add missing QFile include in showLogFile.cpp - DBUpdate: Add CMAKE_AUTOUIC_SEARCH_PATHS for ui/ directory - DBUpdate: Fix m_id → id, m_description → description (3 files) Build validation: - DBAdministration, DBOperatorSettingsRemover, DBUpdate build successfully - Remaining tools blocked by pre-existing Group 3 (ExerciseManagement) errors - Policy checks passed Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
166 lines
3.9 KiB
C++
Executable File
166 lines
3.9 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* PresentationManangement - Script Overview Dialog Model
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*
|
|
* Created by Mike Wille, SLSE, 2017-03-15
|
|
*/
|
|
|
|
#include "local_databases_model.h"
|
|
|
|
#include <ngltools/ngltools_dtg.h>
|
|
#include <ngldb/nsqlquery.h>
|
|
|
|
#include <QtCore/QDateTime>
|
|
#include <QPalette>
|
|
|
|
namespace DBAdministration
|
|
{
|
|
|
|
LocalDatabasesModel::LocalDatabasesModel(QObject *parent)
|
|
: QAbstractTableModel(parent)
|
|
, m_logger(getLogger("LocalDatabasesModel"))
|
|
{}
|
|
|
|
|
|
LocalDatabasesModel::~LocalDatabasesModel()
|
|
{}
|
|
|
|
|
|
bool LocalDatabasesModel::initModel(const QSqlDatabase &db)
|
|
{
|
|
beginResetModel();
|
|
m_vecData.clear();
|
|
endResetModel();
|
|
|
|
NSqlQuery q(db);
|
|
|
|
QString stmt = QStringLiteral("SELECT id, name, db_name, begin_time, end_time FROM local_databases");
|
|
|
|
if (!q.exec(stmt))
|
|
return false;
|
|
|
|
while (q.next())
|
|
{
|
|
LocalExercise e;
|
|
e.id = q.value(0).toInt();
|
|
e.name = q.value(1).toString();
|
|
e.dbName = q.value(2).toString();
|
|
e.startTime = q.value(3).toLongLong();
|
|
e.endTime = q.value(4).toLongLong();
|
|
insertRow(e);
|
|
}
|
|
|
|
INFO_LOG(m_logger) << "initModel - #exercises: " << m_vecData.size();
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
QVariant LocalDatabasesModel::data(const QModelIndex &index, int role) const
|
|
{
|
|
if (role != Qt::DisplayRole || !index.isValid() || index.row() >= m_vecData.size())
|
|
return QVariant();
|
|
|
|
const LocalExercise &e = m_vecData.at(index.row());
|
|
|
|
switch (index.column())
|
|
{
|
|
case Id:
|
|
return e.id;
|
|
case Name:
|
|
return QString(e.name);
|
|
case DbName:
|
|
return QString(e.dbName);
|
|
case StartTime:
|
|
return DTG::toStringMSec(e.startTime);
|
|
case EndTime:
|
|
return DTG::toStringMSec(e.endTime);
|
|
}
|
|
|
|
return QVariant();
|
|
}
|
|
|
|
int LocalDatabasesModel::rowCount(const QModelIndex &parent) const
|
|
{
|
|
return parent.isValid() ? 0 : m_vecData.size();
|
|
}
|
|
|
|
int LocalDatabasesModel::columnCount(const QModelIndex &parent) const
|
|
{
|
|
return parent.isValid() ? 0 : EndTime + 1;
|
|
}
|
|
|
|
QVariant LocalDatabasesModel::headerData(int section, Qt::Orientation orientation, int role) const
|
|
{
|
|
if (orientation == Qt::Horizontal
|
|
&& role == Qt::DisplayRole)
|
|
{
|
|
Columns col = static_cast<Columns>(section);
|
|
switch (col)
|
|
{
|
|
case Id:
|
|
return tr("Id");
|
|
case Name:
|
|
return tr("Name");
|
|
case DbName:
|
|
return tr("Database Name");
|
|
case StartTime:
|
|
return tr("Start Time");
|
|
case EndTime:
|
|
return tr("End Time");
|
|
}
|
|
}
|
|
return QAbstractTableModel::headerData(section, orientation, role);
|
|
}
|
|
|
|
LocalExercise LocalDatabasesModel::getRowData(int row) const
|
|
{
|
|
if (row < 0 || row >= m_vecData.size())
|
|
return LocalExercise();
|
|
return m_vecData.at(row);
|
|
}
|
|
|
|
bool LocalDatabasesModel::insertRow(const LocalExercise &item)
|
|
{
|
|
beginInsertRows(QModelIndex(), m_vecData.size(), m_vecData.size());
|
|
m_vecData.append(item);
|
|
endInsertRows();
|
|
return true;
|
|
}
|
|
|
|
void LocalDatabasesProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
|
{
|
|
m_sourceModel = qobject_cast<LocalDatabasesModel*>(sourceModel);
|
|
QSortFilterProxyModel::setSourceModel(sourceModel);
|
|
}
|
|
|
|
bool LocalDatabasesProxyModel::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 QSortFilterProxyModel::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 LocalDatabasesModel::StartTime:
|
|
return dataLeft.startTime < dataRight.startTime;
|
|
case LocalDatabasesModel::EndTime:
|
|
return dataLeft.endTime < dataRight.endTime;
|
|
case LocalDatabasesModel::Id:
|
|
case LocalDatabasesModel::Name:
|
|
case LocalDatabasesModel::DbName:
|
|
|
|
break;
|
|
}
|
|
return QSortFilterProxyModel::lessThan(source_left, source_right);
|
|
}
|
|
|
|
|
|
} // namespace DBAdministration
|