GPT first

This commit is contained in:
2025-02-02 01:07:48 +05:00
parent 18a6f4bb2c
commit 4e4e3d8a45
4 changed files with 63 additions and 0 deletions

14
CMakeLists.txt Normal file
View File

@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.14)
project(cpp-opds)
set(CMAKE_CXX_STANDARD 17)
find_package(Qt6 REQUIRED COMPONENTS Core Sql Network)
add_executable(cpp-opds
src/main.cpp
src/backend.cpp
)
target_include_directories(cpp-opds PRIVATE include)
target_link_libraries(cpp-opds Qt6::Core Qt6::Sql Qt6::Network)

18
include/backend.cpp Normal file
View File

@@ -0,0 +1,18 @@
#include "backend.h"
#include <QtCore/QDebug>
Backend::Backend(QObject *parent) : QObject(parent)
{
// Используем SQLite по умолчанию, для PostgreSQL потребуется изменить параметры подключения
db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("opds.db");
if (!db.open()) {
qDebug() << "Error: Unable to open database";
}
}
void Backend::start()
{
qDebug() << "Backend started.";
}

19
include/backend.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef BACKEND_H
#define BACKEND_H
#include <QObject>
#include <QtSql>
class Backend : public QObject
{
Q_OBJECT
public:
explicit Backend(QObject *parent = nullptr);
void start();
private:
QSqlDatabase db;
};
#endif // BACKEND_H

12
src/main.cpp Normal file
View File

@@ -0,0 +1,12 @@
#include <QCoreApplication>
#include "backend.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Backend backend;
backend.start();
return a.exec();
}