f31522130f
Build system (5 gaps hardened): - COOKBOOK_OFFLINE defaults to true (fork-mode) - normalize_patch handles diff -ruN format - New 'repo validate-patches' command (25/25 relibc patches) - 14 patched Qt/Wayland/display recipes added to protected list - relibc archive regenerated with current patch chain Boot fixes (fixable): - Full ISO EFI partition: 16 MiB → 1 MiB (matches mini, BIOS hardcoded 2 MiB offset) - D-Bus system bus: absolute /usr/bin/dbus-daemon path (was skipped) - redbear-sessiond: absolute /usr/bin/redbear-sessiond path (was skipped) - daemon framework: silenced spurious INIT_NOTIFY warnings for oneshot_async services (P0-daemon-silence-init-notify.patch) - udev-shim: demoted INIT_NOTIFY warning to INFO (expected for oneshot_async) - relibc: comprehensive named semaphores (sem_open/close/unlink) replacing upstream todo!() stubs - greeterd: Wayland socket timeout 15s → 30s (compositor DRM wait) - greeter-ui: built and linked (header guard unification, sem_compat stubs removed) - mc: un-ignored in both configs, fixed glib/libiconv/pcre2 transitive deps - greeter config: removed stale keymapd dependency from display/greeter services - prefix toolchain: relibc headers synced, _RELIBC_STDLIB_H guard unified Unfixable (diagnosed, upstream): - i2c-hidd: abort on no-I2C-hardware (QEMU) — process::exit → relibc abort - kded6/greeter-ui: page fault 0x8 — Qt library null deref - Thread panics fd != -1 — Rust std library on Redox - DHCP timeout / eth0 MAC — QEMU user-mode networking - hwrngd/thermald — no hardware RNG/thermal in VM - live preload allocation — BIOS memory fragmentation, continues on demand
131 lines
3.7 KiB
C++
131 lines
3.7 KiB
C++
// Copyright (C) 2016 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
|
|
#include "connectionwidget.h"
|
|
|
|
#include <QAction>
|
|
#include <QHeaderView>
|
|
#include <QSqlDatabase>
|
|
#include <QTreeWidget>
|
|
#include <QVBoxLayout>
|
|
|
|
ConnectionWidget::ConnectionWidget(QWidget *parent)
|
|
: QWidget(parent)
|
|
, tree(new QTreeWidget(this))
|
|
{
|
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
|
layout->setContentsMargins({});
|
|
tree->setHeaderLabels(QStringList(tr("Database")));
|
|
tree->header()->setStretchLastSection(true);
|
|
QAction *refreshAction = new QAction(tr("Refresh"), tree);
|
|
metaDataAction = new QAction(tr("Show Schema"), tree);
|
|
connect(refreshAction, &QAction::triggered, this, &ConnectionWidget::refresh);
|
|
connect(metaDataAction, &QAction::triggered, this, &ConnectionWidget::showMetaData);
|
|
tree->addAction(refreshAction);
|
|
tree->addAction(metaDataAction);
|
|
tree->setContextMenuPolicy(Qt::ActionsContextMenu);
|
|
|
|
layout->addWidget(tree);
|
|
|
|
connect(tree, &QTreeWidget::itemActivated,
|
|
this, &ConnectionWidget::onItemActivated);
|
|
connect(tree, &QTreeWidget::currentItemChanged,
|
|
this, &ConnectionWidget::onCurrentItemChanged);
|
|
}
|
|
|
|
ConnectionWidget::~ConnectionWidget()
|
|
= default;
|
|
|
|
void ConnectionWidget::refresh()
|
|
{
|
|
const auto qDBCaption = [](const QSqlDatabase &db)
|
|
{
|
|
QString nm = db.driverName() + QLatin1Char(':');
|
|
if (!db.userName().isEmpty())
|
|
nm += db.userName() + QLatin1Char('@');
|
|
nm += db.databaseName();
|
|
return nm;
|
|
};
|
|
|
|
tree->clear();
|
|
const QStringList connectionNames = QSqlDatabase::connectionNames();
|
|
|
|
bool gotActiveDb = false;
|
|
for (const auto &connectionName : connectionNames) {
|
|
QTreeWidgetItem *root = new QTreeWidgetItem(tree);
|
|
QSqlDatabase db = QSqlDatabase::database(connectionName, false);
|
|
root->setText(0, qDBCaption(db));
|
|
if (connectionName == activeDb) {
|
|
gotActiveDb = true;
|
|
setActive(root);
|
|
}
|
|
if (db.isOpen()) {
|
|
QStringList tables = db.tables();
|
|
for (int t = 0; t < tables.count(); ++t) {
|
|
QTreeWidgetItem *table = new QTreeWidgetItem(root);
|
|
table->setText(0, tables.at(t));
|
|
}
|
|
}
|
|
}
|
|
if (!gotActiveDb) {
|
|
activeDb = connectionNames.value(0);
|
|
setActive(tree->topLevelItem(0));
|
|
}
|
|
|
|
tree->doItemsLayout(); // HACK
|
|
}
|
|
|
|
QSqlDatabase ConnectionWidget::currentDatabase() const
|
|
{
|
|
return QSqlDatabase::database(activeDb);
|
|
}
|
|
|
|
void ConnectionWidget::setActive(QTreeWidgetItem *item)
|
|
{
|
|
const auto qSetBold = [](QTreeWidgetItem *item, bool bold)
|
|
{
|
|
QFont font = item->font(0);
|
|
font.setBold(bold);
|
|
item->setFont(0, font);
|
|
};
|
|
|
|
for (int i = 0; i < tree->topLevelItemCount(); ++i) {
|
|
if (tree->topLevelItem(i)->font(0).bold())
|
|
qSetBold(tree->topLevelItem(i), false);
|
|
}
|
|
|
|
if (!item)
|
|
return;
|
|
|
|
qSetBold(item, true);
|
|
activeDb = QSqlDatabase::connectionNames().value(tree->indexOfTopLevelItem(item));
|
|
}
|
|
|
|
void ConnectionWidget::onItemActivated(QTreeWidgetItem *item)
|
|
{
|
|
if (!item)
|
|
return;
|
|
|
|
if (!item->parent()) {
|
|
setActive(item);
|
|
} else {
|
|
setActive(item->parent());
|
|
emit tableActivated(item->text(0));
|
|
}
|
|
}
|
|
|
|
void ConnectionWidget::showMetaData()
|
|
{
|
|
QTreeWidgetItem *cItem = tree->currentItem();
|
|
if (!cItem || !cItem->parent())
|
|
return;
|
|
setActive(cItem->parent());
|
|
emit metaDataRequested(cItem->text(0));
|
|
}
|
|
|
|
void ConnectionWidget::onCurrentItemChanged(QTreeWidgetItem *current)
|
|
{
|
|
metaDataAction->setEnabled(current && current->parent());
|
|
}
|
|
|