GPT first
This commit is contained in:
14
CMakeLists.txt
Normal file
14
CMakeLists.txt
Normal 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
18
include/backend.cpp
Normal 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
19
include/backend.h
Normal 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
12
src/main.cpp
Normal 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();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user