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
71 lines
2.5 KiB
C++
71 lines
2.5 KiB
C++
// Copyright (C) 2021 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
|
|
#include "sqleventdatabase.h"
|
|
|
|
#include <QDebug>
|
|
#include <QFileInfo>
|
|
#include <QSqlError>
|
|
#include <QSqlQuery>
|
|
|
|
SqlEventDatabase::SqlEventDatabase()
|
|
{
|
|
createConnection();
|
|
}
|
|
|
|
QList<Event> SqlEventDatabase::eventsForDate(QDate date)
|
|
{
|
|
const QString queryStr = QString::fromLatin1("SELECT * FROM Event WHERE '%1' >= startDate AND '%1' <= endDate").arg(date.toString("yyyy-MM-dd"));
|
|
QSqlQuery query(queryStr);
|
|
if (!query.exec()) {
|
|
qWarning() << "SQL query failed";
|
|
return {};
|
|
}
|
|
|
|
QList<Event> events;
|
|
while (query.next()) {
|
|
Event event;
|
|
event.name = query.value("name").toString();
|
|
|
|
QDateTime startDate;
|
|
startDate.setDate(query.value("startDate").toDate());
|
|
startDate.setTime(QTime(0, 0).addSecs(query.value("startTime").toInt()));
|
|
event.startDate = startDate;
|
|
|
|
QDateTime endDate;
|
|
endDate.setDate(query.value("endDate").toDate());
|
|
endDate.setTime(QTime(0, 0).addSecs(query.value("endTime").toInt()));
|
|
event.endDate = endDate;
|
|
|
|
events.append(event);
|
|
}
|
|
return events;
|
|
}
|
|
|
|
/*
|
|
Defines a helper function to open a connection to an
|
|
in-memory SQLITE database and to create a table.
|
|
*/
|
|
void SqlEventDatabase::createConnection()
|
|
{
|
|
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
|
|
db.setDatabaseName(":memory:");
|
|
if (!db.open()) {
|
|
qFatal("Cannot open database");
|
|
return;
|
|
}
|
|
|
|
QSqlQuery query;
|
|
const QString year = QDate::currentDate().toString("yyyy");
|
|
const QString month = QDate::currentDate().toString("MM");
|
|
// Keep the example up-to-date by making the events fall in the current year and month.
|
|
// We store the time as seconds because it's easier to query.
|
|
query.exec("create table Event (name TEXT, startDate DATE, startTime INT, endDate DATE, endTime INT)");
|
|
query.exec(QString::fromLatin1("insert into Event values('Grocery shopping', '%1-%2-01', 36000, '%1-%2-01', 39600)").arg(year, month));
|
|
query.exec(QString::fromLatin1("insert into Event values('Ice skating', '%1-%2-01', 57600, '%1-%2-01', 61200)").arg(year, month));
|
|
query.exec(QString::fromLatin1("insert into Event values('Doctor''s appointment', '%1-%2-15', 57600, '%1-%2-15', 63000)").arg(year, month));
|
|
query.exec(QString::fromLatin1("insert into Event values('Conference', '%1-%2-24', 32400, '%1-%2-28', 61200)").arg(year, month));
|
|
|
|
return;
|
|
}
|