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

252 lines
6.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "ui_BrowserWndUi.h"
#include "BrowserWnd.h"
#include "LoginWnd.h"
#include "Query.h"
#include "DataModel.h"
#include "QueryThread.h"
#include <QDebug>
#include <QGraphicsDropShadowEffect>
#include <QListWidgetItem>
#include <QMessageBox>
#include <QRegExp>
#include <QShortcut>
#include <QThread>
BrowserWnd::BrowserWnd()
: QWidget(nullptr)
, m_loginWnd(new LoginWnd(this))
, m_waitWnd(new WaitWnd(this))
, m_ui(new Ui::BrowserWnd)
, m_queryWorker(new QueryWorker())
, m_queryThread(new QThread())
{
//setVersionView();
qRegisterMetaType<LoginData>("LoginData");
if (!test())
exit(1);
new QShortcut(QKeySequence(QStringLiteral("Ctrl+Q")), this, SLOT(close()));
connect(this, &BrowserWnd::signalConnect, m_queryWorker, &QueryWorker::slotConnectIt);
connect(m_queryWorker, &QueryWorker::signalConnectResult, this, &BrowserWnd::slotConnectResult);
connect(this, &BrowserWnd::signalGetTableList, m_queryWorker, &QueryWorker::slotGetTableList);
connect(m_queryWorker, &QueryWorker::signalNewTableList, this, &BrowserWnd::slotNewTableList);
m_queryWorker->moveToThread(m_queryThread);
m_queryThread->start();
}
BrowserWnd::~BrowserWnd()
{
endThread();
delete m_ui;
delete m_waitWnd;
delete m_loginWnd;
}
void BrowserWnd::slotAddNewQuery()
{
addNewQuery();
}
void BrowserWnd::slotConnectResult(const QString &result)
{
if (result.isEmpty()) // connection success!
{
// everything okay, logged in, go!
m_ui->setupUi(this);
// showing Host / DB name in window title
this->setWindowTitle(QStringLiteral("RDE SQL Browser on Database: ") + m_loginWnd->getLoginData().database);
m_ui->splitter->setStretchFactor(0, 0); // not stretch for table list
m_ui->splitter->setStretchFactor(1, 1); // stretch the query widget
this->show();
addNewQuery();
refreshTableList();
connect(m_ui->leFilter, &QLineEdit::textChanged, this, &BrowserWnd::slotFilterTableList);
connect(m_ui->lwTables, &QListWidget::itemDoubleClicked, this, &BrowserWnd::slotFilterTableItemChanged);
connect(m_ui->twQueries, &QTabWidget::tabCloseRequested, this, &BrowserWnd::slotTabCloseRequested);
connect(m_ui->pbNewQuery, &QPushButton::clicked, this, &BrowserWnd::slotAddNewQuery);
connect(m_ui->pushButton, &QPushButton::clicked, qApp, &QApplication::quit);
connect(m_ui->pushButton_2, &QPushButton::clicked, this, &BrowserWnd::slotHeart);
}
else // failed with message
{
QMessageBox::critical(this,
tr("Connection Error"),
tr("Cannot connect to specified server."
"\nError:"
"\n'%1'").arg(result));
}
m_waitWnd->hide();
}
void BrowserWnd::slotFilterTableList(const QString &)
{
refreshTableList();
}
void BrowserWnd::addNewQuery(const QString &tableName) // tableName only set when query from double clicking table list
{
Query *query = new Query(m_queryWorker);
connect(query, &Query::signalShowWait, this, &BrowserWnd::slotShowWait);
connect(query, &Query::signalHideWait, this, &BrowserWnd::slotHideWait);
int tabIndex = -1;
if (tableName.length()) // there is a tablename
{
query->setTable(tableName);
tabIndex = m_ui->twQueries->addTab(query, tableName);
}
else // no tablename
tabIndex = m_ui->twQueries->addTab(query, QStringLiteral("Query %1").arg(m_newQueryCounter++));
m_ui->twQueries->setCurrentIndex(tabIndex);
}
//#warning TODO: reimpl
//void BrowserWnd::slotSelectQueryStatus(int percent)
//{
// m_waitWnd->setStatus(percent);
//}
void BrowserWnd::endThread()
{
if (!m_queryThread)
return;
m_queryWorker->dy();
m_queryThread->quit();
m_queryThread->wait();
delete m_queryThread;
m_queryThread = nullptr;
delete m_queryWorker;
m_queryWorker = nullptr;
}
void BrowserWnd::refreshTableList()
{
m_ui->lwTables->clear();
m_waitWnd->wait(QStringLiteral("Refreshing Table List .."));
emit signalGetTableList();
}
void BrowserWnd::slotNewTableList(QStringList tables)
{
if (!m_ui->leFilter->text().isEmpty()) // filter when there is a filter
{
QRegExp regExp(m_ui->leFilter->text(), Qt::CaseInsensitive, QRegExp::Wildcard);
tables = tables.filter(regExp);
}
m_ui->lwTables->addItems(tables);
m_waitWnd->hide();
}
void BrowserWnd::startConnect()
{
//m_loginWnd->setDefaultLoginData(presetManager. defaultLoginData);
if (!m_loginWnd->exec()) // false = user reject
{
QCoreApplication::quit();
return;
}
m_waitWnd->wait(tr("Connecting .."));
emit signalConnect(m_loginWnd->getLoginData());
}
bool BrowserWnd::test()
{
if (QSqlDatabase::drivers().isEmpty() ||
QSqlDatabase::drivers().indexOf(QLatin1String("QSQLITE")) == -1)
{
QMessageBox::critical(this,
tr("Missing Qt PostgreSQL driver"),
tr("There is no QPSQL driver."
"\nDid you install the package 'libQt5Sql5-postgresql'?"));
return false;
}
return true;
}
void BrowserWnd::slotFilterTableItemChanged(QListWidgetItem *item)
{
QString tableName = item->text();
addNewQuery(tableName);
}
void BrowserWnd::slotTabCloseRequested(int index)
{
Query *q = qobject_cast<Query *>(m_ui->twQueries->widget(index));
m_ui->twQueries->removeTab(index);
if (!q)
QMessageBox::critical(this, QStringLiteral("Query Failed"), QStringLiteral("Woops..?!!"));
delete q; // It´s safe to delete nullptr;
}
void BrowserWnd::slotShowWait(const QString &msg)
{
m_waitWnd->wait(msg);
}
void BrowserWnd::slotHideWait()
{
m_waitWnd->hide();
}
void BrowserWnd::slotHeart()
{
QWidget *w = new QWidget;
w->setAttribute(Qt::WA_DeleteOnClose); // delete when closed
QVBoxLayout *b = new QVBoxLayout;
QLabel *l = new QLabel(QStringLiteral("<html><body>Geschmiedet mit %1 , ohne Kostenträger, für das Team.<br>Diese Software wurde in meiner Freizeit entwickelt, bitte habt Verständnis für Bugs und Geduld für Fixes. Danke! - Euer Mike Wille, SLSE 2016, 17</body></html>").arg(QChar(0x2764)));
QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect;
shadow->setOffset(0, 0);
shadow->setBlurRadius(22);
shadow->setColor(QColor("blue"));
l->setGraphicsEffect(shadow);
b->addWidget(l);
w->setLayout(b);
w->show();
}