From 4fbe63701fff6cd7b1e617ad076ed23aa630591a Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 9 Mar 2025 10:13:52 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D0=BE=D0=B5=20=D0=BD=D0=B0?= =?UTF-8?q?=D1=87=D0=B0=D0=BB=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 108 +++++++++++++++++++++++++++++++------------- CMakeLists.txt | 58 ------------------------ cpp-opds.qbs | 13 ++++++ include/backend.cpp | 25 ---------- include/backend.h | 21 --------- main.cpp | 19 ++++++++ src/author.hpp | 13 ------ src/book.hpp | 22 --------- src/database.cpp | 13 ------ src/database.h | 0 src/main.cpp | 12 ----- 11 files changed, 108 insertions(+), 196 deletions(-) delete mode 100644 CMakeLists.txt create mode 100644 cpp-opds.qbs delete mode 100644 include/backend.cpp delete mode 100644 include/backend.h create mode 100644 main.cpp delete mode 100644 src/author.hpp delete mode 100644 src/book.hpp delete mode 100644 src/database.cpp delete mode 100644 src/database.h delete mode 100644 src/main.cpp diff --git a/.gitignore b/.gitignore index f797cc7..aa3808c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,38 +1,82 @@ -# user ignore -build -opds.db +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- -# ---> C++ -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo +*~ +*.autosave +*.a +*.core +*.moc *.o *.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries +*.orig +*.rej *.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl *.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash +# qtcreator generated files +*.pro.user* +*.qbs.user* +CMakeLists.txt.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + +# Directories with generated files +.moc/ +.obj/ +.pch/ +.rcc/ +.uic/ +/build*/ diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 40afeae..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,58 +0,0 @@ -cmake_minimum_required(VERSION 3.16) -project(cpp-opds) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(ODB_INCLUDE_DIRS /usr/include) -set(ODB_LIBRARY_DIRS /usr/lib/x86_64-linux-gnu) - -include_directories(${ODB_INCLUDE_DIRS}) -link_directories(${ODB_LIBRARY_DIRS}) - -find_package(Qt6 REQUIRED COMPONENTS Core Sql Network) -# find_package(ODB REQUIRED) -# find_package(SQLite3 REQUIRED) - -find_library(ODB_LIBRARIES NAMES odb HINTS ${ODB_LIBRARY_DIRS}) -find_library(ODB_SQLITE_LIBRARIES NAMES odb-sqlite HINTS ${ODB_LIBRARY_DIRS}) - - -set(CMAKE_AUTOMOC ON) # <-- Включаем автоматическую генерацию MOC-файлов - -# include_directories(${ODB_INCLUDE_DIRS} ${SQLite3_INCLUDE_DIRS}) -# link_directories(${ODB_LIBRARY_DIRS} ${SQLite3_LIBRARY_DIRS}) - -# add_executable(cpp-opds -# src/main.cpp -# include/backend.cpp -# ) - -set(SOURCE_FILES - src/main.cpp - # src/database.cpp - # src/book.cpp - # src/author.hpp -) - -set(ODB_SOURCES - src/book - src/author -) - -# Генерация ODB файлов -foreach(file ${ODB_SOURCES}) - add_custom_command( - OUTPUT ${file}.odb.cpp ${file}.odb.hpp - COMMAND odb --generate-query --generate-schema --database sqlite ${file}.hpp - DEPENDS ${file}.hpp - COMMENT "Running ODB on ${file}.hpp" - ) - list(APPEND SOURCE_FILES ${file}.odb.cpp) -endforeach() - -add_executable(cpp-opds ${SOURCE_FILES}) - -target_include_directories(cpp-opds PRIVATE include) -# target_link_libraries(cpp-opds Qt6::Core Qt6::Sql Qt6::Network ${ODB_LIBRARIES} ${SQLite3_LIBRARIES}) -target_link_libraries(cpp-opds Qt6::Core Qt6::Sql Qt6::Network ${ODB_LIBRARIES} ${ODB_SQLITE_LIBRARIES}) diff --git a/cpp-opds.qbs b/cpp-opds.qbs new file mode 100644 index 0000000..4e93c3a --- /dev/null +++ b/cpp-opds.qbs @@ -0,0 +1,13 @@ +QtApplication { + cpp.defines: [ + // You can make your code fail to compile if it uses deprecated APIs. + // In order to do so, uncomment the following line. + //"QT_DISABLE_DEPRECATED_BEFORE=0x060000" // disables all the APIs deprecated before Qt 6.0.0 + ] + + consoleApplication: true + install: true + files: [ + "main.cpp", + ] +} diff --git a/include/backend.cpp b/include/backend.cpp deleted file mode 100644 index c59b0b3..0000000 --- a/include/backend.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "backend.h" -#include - -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"; - } -} - -Backend::~Backend() -{ - qDebug() << "Backend stoped."; -} - -void Backend::start() -{ - qDebug() << "Backend started."; -} diff --git a/include/backend.h b/include/backend.h deleted file mode 100644 index dc4a187..0000000 --- a/include/backend.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef BACKEND_H -#define BACKEND_H - -#include -#include - -class Backend : public QObject -{ - Q_OBJECT - -public: - explicit Backend(QObject* parent = nullptr); - ~Backend() override; - - void start(); - -private: - QSqlDatabase db; -}; - -#endif // BACKEND_H diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..3994cd4 --- /dev/null +++ b/main.cpp @@ -0,0 +1,19 @@ +#include + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + // Set up code that uses the Qt event loop here. + // Call a.quit() or a.exit() to quit the application. + // A not very useful example would be including + // #include + // near the top of the file and calling + // QTimer::singleShot(5000, &a, &QCoreApplication::quit); + // which quits the application after 5 seconds. + + // If you do not need a running Qt event loop, remove the call + // to a.exec() or use the Non-Qt Plain C++ Application template. + + return a.exec(); +} diff --git a/src/author.hpp b/src/author.hpp deleted file mode 100644 index 69d1ce2..0000000 --- a/src/author.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma db object -class Author { -public: - Author() = default; - Author(const std::string& name) : name(name) {} - - const std::string& getName() const { return name; } - -private: - #pragma db id auto - int id; - std::string name; -}; \ No newline at end of file diff --git a/src/book.hpp b/src/book.hpp deleted file mode 100644 index f6b5c2b..0000000 --- a/src/book.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#pragma db object -class Book { -public: - Book() = default; - Book(const std::string& title, const std::string& author, const std::string& filePath, - int fileSize, const std::string& format); - - const std::string& getTitle() const { return title; } - const std::string& getAuthor() const { return author; } - const std::string& getFilePath() const { return filePath; } - int getFileSize() const { return fileSize; } - const std::string& getFormat() const { return format; } - -private: - #pragma db id auto - int id; - std::string title; - std::string author; - std::string filePath; - int fileSize; - std::string format; -}; \ No newline at end of file diff --git a/src/database.cpp b/src/database.cpp deleted file mode 100644 index 4bbec8c..0000000 --- a/src/database.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "database.h" -#include -#include -#include "book-odb.hxx" -#include "author-odb.hxx" - -std::unique_ptr initializeDatabase(const std::string& dbPath) { - auto db = std::make_unique(dbPath, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE); - odb::transaction t(db->begin()); - odb::schema_catalog::create_schema(*db); - t.commit(); - return db; -} \ No newline at end of file diff --git a/src/database.h b/src/database.h deleted file mode 100644 index e69de29..0000000 diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index f3b64db..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include "backend.h" - -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - - Backend backend; - backend.start(); - - return a.exec(); -}