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>
159 lines
3.7 KiB
C++
Executable File
159 lines
3.7 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* PresentationManangement - Script Overview Dialog Model
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*
|
|
* Created by Mike Wille, SLSE, 2017-03-15
|
|
*/
|
|
|
|
#include "server_databases_model.h"
|
|
|
|
#include <ngltools/ngltools_dtg.h>
|
|
#include <ngldb/nsqlquery.h>
|
|
|
|
#include <QtCore/QDateTime>
|
|
#include <QPalette>
|
|
|
|
namespace DBAdministration
|
|
{
|
|
|
|
ServerDatabasesModel::ServerDatabasesModel(QObject *parent)
|
|
: QAbstractTableModel(parent)
|
|
, m_logger(getLogger("ServerDatabasesModel"))
|
|
{}
|
|
|
|
|
|
ServerDatabasesModel::~ServerDatabasesModel()
|
|
{}
|
|
|
|
|
|
bool ServerDatabasesModel::initModel(const QSqlDatabase &db)
|
|
{
|
|
beginResetModel();
|
|
m_vecData.clear();
|
|
endResetModel();
|
|
|
|
NSqlQuery q(db);
|
|
|
|
QString stmt = QStringLiteral("SELECT id, name, begin_time, end_time FROM exm.exercise");
|
|
|
|
if (!q.exec(stmt))
|
|
return false;
|
|
|
|
while (q.next())
|
|
{
|
|
Exercise e;
|
|
e.id = q.value(0).toInt();
|
|
e.name = q.value(1).toString();
|
|
e.startTime = q.value(2).toLongLong();
|
|
e.endTime = q.value(3).toLongLong();
|
|
insertRow(e);
|
|
}
|
|
|
|
INFO_LOG(m_logger) << "initModel - #exercises: " << m_vecData.size();
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
QVariant ServerDatabasesModel::data(const QModelIndex &index, int role) const
|
|
{
|
|
if (role != Qt::DisplayRole || !index.isValid() || index.row() >= m_vecData.size())
|
|
return QVariant();
|
|
|
|
const Exercise &e = m_vecData.at(index.row());
|
|
|
|
switch (index.column())
|
|
{
|
|
case Id:
|
|
return e.id;
|
|
case Name:
|
|
return QString(e.name);
|
|
case StartTime:
|
|
return DTG::toStringMSec(e.startTime);
|
|
case EndTime:
|
|
return DTG::toStringMSec(e.endTime);
|
|
}
|
|
|
|
return QVariant();
|
|
}
|
|
|
|
int ServerDatabasesModel::rowCount(const QModelIndex &parent) const
|
|
{
|
|
return parent.isValid() ? 0 : m_vecData.size();
|
|
}
|
|
|
|
int ServerDatabasesModel::columnCount(const QModelIndex &parent) const
|
|
{
|
|
return parent.isValid() ? 0 : EndTime + 1;
|
|
}
|
|
|
|
QVariant ServerDatabasesModel::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 StartTime:
|
|
return tr("Start Time");
|
|
case EndTime:
|
|
return tr("End Time");
|
|
}
|
|
}
|
|
return QAbstractTableModel::headerData(section, orientation, role);
|
|
}
|
|
|
|
Exercise ServerDatabasesModel::getRowData(int row) const
|
|
{
|
|
if (row < 0 || row >= m_vecData.size())
|
|
return Exercise();
|
|
return m_vecData.at(row);
|
|
}
|
|
|
|
bool ServerDatabasesModel::insertRow(const Exercise &item)
|
|
{
|
|
beginInsertRows(QModelIndex(), m_vecData.size(), m_vecData.size());
|
|
m_vecData.append(item);
|
|
endInsertRows();
|
|
return true;
|
|
}
|
|
|
|
void ServerDatabasesProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
|
{
|
|
m_sourceModel = qobject_cast<ServerDatabasesModel*>(sourceModel);
|
|
QSortFilterProxyModel::setSourceModel(sourceModel);
|
|
}
|
|
|
|
bool ServerDatabasesProxyModel::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 ServerDatabasesModel::StartTime:
|
|
return dataLeft.startTime < dataRight.startTime;
|
|
case ServerDatabasesModel::EndTime:
|
|
return dataLeft.endTime < dataRight.endTime;
|
|
case ServerDatabasesModel::Id:
|
|
case ServerDatabasesModel::Name:
|
|
break;
|
|
}
|
|
return QSortFilterProxyModel::lessThan(source_left, source_right);
|
|
}
|
|
|
|
|
|
} // namespace DBAdministration
|