From 43f5e1b22c99c698cd768d96c6e99744b97e13f0 Mon Sep 17 00:00:00 2001 From: Kevin Whitaker Date: Tue, 2 Jun 2020 15:45:39 -0400 Subject: [PATCH] Start adding data structure. --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 11 +++++- src/db/sqlcar.cpp | 18 ++++++++++ src/db/sqlcar.h | 32 +++++++++++++++++ src/db/sqlservicerecord.cpp | 18 ++++++++++ src/db/sqlservicerecord.h | 32 +++++++++++++++++ src/main.cpp | 70 +++++++++++++++++++++++++++++++++++++ 7 files changed, 181 insertions(+), 2 deletions(-) create mode 100644 src/db/sqlcar.cpp create mode 100644 src/db/sqlcar.h create mode 100644 src/db/sqlservicerecord.cpp create mode 100644 src/db/sqlservicerecord.h create mode 100644 src/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b8bf33d..0b9519b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ include(KDECompilerSettings NO_POLICY_SCOPE) ################# Find dependencies ################# -find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Svg QuickControls2) +find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Sql QuickControls2) find_package(KF5Kirigami2 ${KF5_MIN_VERSION} REQUIRED) find_package(KF5CoreAddons ${KF5_MIN_VERSION} REQUIRED) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8d1c8b6..91d8ab0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1 +1,10 @@ - +set(vehiclevoyage_SRCS + db/sqlcar.cpp + db/sqlservicerecord.cpp + main.cpp + ) + +qt5_add_resources(RESOURCES resources.qrc) +add_executable(vehiclevoyage ${vehiclevoyage_SRCS} ${RESOURCES}) +target_link_libraries(vehiclevoyage Qt5::Core Qt5::Qml Qt5::Quick Qt5::Sql KF5::CoreAddons) +install(TARGETS vehiclevoyage ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/src/db/sqlcar.cpp b/src/db/sqlcar.cpp new file mode 100644 index 0000000..e502ea6 --- /dev/null +++ b/src/db/sqlcar.cpp @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "sqlcar.h" diff --git a/src/db/sqlcar.h b/src/db/sqlcar.h new file mode 100644 index 0000000..2bb39fb --- /dev/null +++ b/src/db/sqlcar.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SQLCAR_H +#define SQLCAR_H + +#include + +/** + * @todo write docs + */ +class SqlCar : public QSqlQueryModel +{ + Q_OBJECT + +}; + +#endif // SQLCAR_H diff --git a/src/db/sqlservicerecord.cpp b/src/db/sqlservicerecord.cpp new file mode 100644 index 0000000..341051c --- /dev/null +++ b/src/db/sqlservicerecord.cpp @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2020 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "sqlservicerecord.h" diff --git a/src/db/sqlservicerecord.h b/src/db/sqlservicerecord.h new file mode 100644 index 0000000..62e6adb --- /dev/null +++ b/src/db/sqlservicerecord.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef SQLSERVICERECORD_H +#define SQLSERVICERECORD_H + +#include + +/** + * @todo write docs + */ +class SqlServiceRecord : public QSqlQueryModel +{ + Q_OBJECT + +}; + +#endif // SQLSERVICERECORD_H diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..882d288 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,70 @@ +/* + * Vehicle Voyage + * Copyright (C) 2020 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +Q_DECL_EXPORT int main(int argc, char *argv[]) +{ + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QGuiApplication app(argc, argv); + + KAboutData aboutData("org.eyecreate.vehiclevoyage", "Vehicle Voyage", "1.0", "Track vehicle service history.",KAboutLicense::GPL_V3);//TODO:i18n + aboutData.setProductName("vehiclevoyage"); + aboutData.addAuthor("Kevin Whitaker",QString(),"eyecreate@eyecreate.org","https://www.eyecreate.org"); + aboutData.setDesktopFileName("org.eyecreate.vehiclevoyage"); + + QCoreApplication::setOrganizationName("eyecreate"); + QCoreApplication::setOrganizationDomain("eyecreate.org"); + QCoreApplication::setApplicationName(aboutData.productName()); + QCoreApplication::setApplicationVersion(aboutData.version()); + app.setWindowIcon(QIcon::fromTheme("org.eyecreate.vehiclevoyage")); + + QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); + db.setDatabaseName(QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("servicerecords.sqlite")); + if(!QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).exists()) + { + QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); + } + if(!QFile(db.databaseName()).exists()) + { + QFile(db.databaseName()).open(QIODevice::ReadWrite); + } + if(!db.open()) + { + //Bad db, exit now. + printf("%s",db.lastError().text().toLatin1().data()); + return -2; + } + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:///main.qml"))); + + if (engine.rootObjects().isEmpty()) { + return -1; + } + + return app.exec(); +} -- GitLab