diff --git a/CMakeLists.txt b/CMakeLists.txt index b8bf33d6cec9e0ab8378d718c19b7f9a43fa459f..0b9519bf70646ae1786a43610b7854d8fec7df48 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 8d1c8b69c3fce7bea45c73efd06983e3c419a92f..91d8ab0abdd619e9bfc5cde159feebffc5fab095 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 0000000000000000000000000000000000000000..e502ea62c1f1de86650bb9b0f6d565ab405ebab0 --- /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 0000000000000000000000000000000000000000..2bb39fb802e9f237e9b2c786b7fe2f26b32bbf73 --- /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 0000000000000000000000000000000000000000..341051c9c2567c4a20975ce764aec3f0de8201ff --- /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 0000000000000000000000000000000000000000..62e6adbd1a2e0739b258d3b73b580fac44948d46 --- /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 0000000000000000000000000000000000000000..882d288bf5d84ce3458f96e746204f0bb0f024dd --- /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(); +}