Start adding data structure.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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})
|
||||
|
||||
18
src/db/sqlcar.cpp
Normal file
18
src/db/sqlcar.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2020 <Kevin Whitaker> <eyecreate@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "sqlcar.h"
|
||||
32
src/db/sqlcar.h
Normal file
32
src/db/sqlcar.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2020 <Kevin Whitaker> <eyecreate@eyecreate.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SQLCAR_H
|
||||
#define SQLCAR_H
|
||||
|
||||
#include <QSqlQueryModel>
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
*/
|
||||
class SqlCar : public QSqlQueryModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
};
|
||||
|
||||
#endif // SQLCAR_H
|
||||
18
src/db/sqlservicerecord.cpp
Normal file
18
src/db/sqlservicerecord.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2020 <Kevin Whitaker> <eyecreate@eyecreate.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "sqlservicerecord.h"
|
||||
32
src/db/sqlservicerecord.h
Normal file
32
src/db/sqlservicerecord.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2020 <Kevin Whitaker> <eyecreate@eyecreate.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SQLSERVICERECORD_H
|
||||
#define SQLSERVICERECORD_H
|
||||
|
||||
#include <QSqlQueryModel>
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
*/
|
||||
class SqlServiceRecord : public QSqlQueryModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
};
|
||||
|
||||
#endif // SQLSERVICERECORD_H
|
||||
70
src/main.cpp
Normal file
70
src/main.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Vehicle Voyage
|
||||
* Copyright (C) 2020 <Kevin Whitaker> <eyecreate@eyecreate.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <KAboutData>
|
||||
#include <QIcon>
|
||||
#include <QStandardPaths>
|
||||
#include <QDir>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlError>
|
||||
#include <QDebug>
|
||||
|
||||
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();
|
||||
}
|
||||
Reference in New Issue
Block a user