--- /dev/null
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.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*
+
+# 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
+
--- /dev/null
+import QtQuick 2.7
+import QtQuick.Controls 2.0
+import QtQuick.Layouts 1.0
+
+ApplicationWindow {
+ id: root
+ //width: 200
+ //height: 200
+ Text{
+ id: lblname
+ anchors.left: parent.left
+ anchors.verticalCenter: name.verticalCenter
+ text:qsTr("Name: ")
+ }
+
+ TextField {
+ id: name
+ anchors.left: lblname.right
+ anchors.top: parent.top
+ placeholderText: qsTr("Karl-Heinz")
+ }
+
+}
--- /dev/null
+QT += qml quick sql
+
+CONFIG += c++11
+
+SOURCES += main.cpp \
+ database.cpp
+
+RESOURCES += qml.qrc
+
+# Additional import path used to resolve QML modules in Qt Creator's code model
+QML_IMPORT_PATH =
+
+# Additional import path used to resolve QML modules just for Qt Quick Designer
+QML_DESIGNER_IMPORT_PATH =
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which as been marked deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+
+HEADERS += \
+ database.h
--- /dev/null
+#include "database.h"
+#include <QtSql/QSqlQuery>
+#include <QDebug>
+
+DataBase::DataBase(QObject *parent) : QObject(parent)
+{
+ db = QSqlDatabase::addDatabase("QSQLITE");
+ db.setDatabaseName("usersheets.db");
+ if (!db.open()) {
+ //do stuff
+ }
+ qDebug() << initDB();
+
+}
+
+DataBase::~DataBase()
+{
+
+}
+
+QVariant DataBase::addHuman(const QString& name, const QString& firstname, const QDate& birthday)
+{
+ QSqlQuery q;
+
+}
+
+QVariant DataBase::addService(const QString& name, const QUrl& url, const QString& description)
+{
+
+}
+
+QVariant DataBase::addUser(const QVariant& humanID, const QVariant& serviceID, const QString& username, const QString& password)
+{
+
+}
+
+QSqlError DataBase::initDB()
+{
+ QStringList tables = db.tables();
+ QSqlQuery q;
+ if (!tables.contains("human", Qt::CaseSensitivity::CaseInsensitive)){ if (!q.exec(this->sqlCreateHumanTable)) return q.lastError();}
+ else qDebug() << "table human already created";
+ if (!tables.contains("service", Qt::CaseSensitivity::CaseInsensitive)){ if (!q.exec(this->sqlCreateServiceTable)) return q.lastError();}
+ else qDebug() << "table service already created";
+ if (!tables.contains("user", Qt::CaseSensitivity::CaseInsensitive)){ if (!q.exec(this->sqlCreateUserTable)) return q.lastError();}
+ else qDebug() << "table user already created";
+
+ return QSqlError();
+}
--- /dev/null
+#ifndef DATABASE_H
+#define DATABASE_H
+#include <QObject>
+#include <QtSql/QSqlDatabase>
+#include <QtSql/QSqlError>
+#include <QVariant>
+#include <QString>
+#include <QUrl>
+
+class DataBase : public QObject
+{
+ Q_OBJECT
+public:
+ explicit DataBase(QObject *parent = 0);
+ virtual ~DataBase();
+
+signals:
+
+public slots:
+ QVariant addHuman(const QString& name, const QString& firstname, const QDate& birthday);
+ QVariant addService(const QString& name, const QUrl& url, const QString& description);
+ QVariant addUser(const QVariant& humanID, const QVariant& serviceID, const QString& username, const QString& password);
+
+
+private:
+ QSqlError initDB();
+
+ QSqlDatabase db;
+ QLatin1String sqlCreateHumanTable = QLatin1String("create table human(id integer primary key, name varchar, firstname varchar, birthday date)");
+ QLatin1String sqlCreateServiceTable = QLatin1String("create table service(id integer primary key, name varchar, url varchar, desription varchar)");
+ QLatin1String sqlCreateUserTable = QLatin1String(
+ "create table user(id integer primary key, humanid integer not null, serviceid integer not null, username varchar, password varchar,"
+ "foreign key(humanid) references human(id),"
+ "foreign key(serviceid) references service(id))");
+};
+
+#endif // DATABASE_H
--- /dev/null
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include "database.h"
+
+int main(int argc, char *argv[])
+{
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QGuiApplication app(argc, argv);
+
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QLatin1String("qrc:/main.qml")));
+ DataBase db;
+
+
+ return app.exec();
+}
--- /dev/null
+import QtQuick 2.7
+import QtQuick.Controls 2.0
+import QtQuick.Layouts 1.0
+
+ApplicationWindow {
+ id: root
+ visible: true
+ width: 640
+ height: 480
+ title: qsTr("Hello World")
+
+ Button {
+ id: btnaddhuman
+ anchors.centerIn: parent
+ visible: true
+ text: "Add Human"
+ onClicked: {
+ var addHumanDialog = Qt.createComponent("AddHuman.qml")
+ var window = addHumanDialog.createObject(root)
+ window.show();
+ }
+ }
+}
--- /dev/null
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>qtquickcontrols2.conf</file>
+ <file>AddHuman.qml</file>
+ </qresource>
+</RCC>
--- /dev/null
+; This file can be edited to change the style of the application
+; See Styling Qt Quick Controls 2 in the documentation for details:
+; http://doc.qt.io/qt-5/qtquickcontrols2-styles.html
+
+[Controls]
+Style=Default
+
+[Universal]
+Theme=Light
+;Accent=Steel
+
+[Material]
+Theme=Light
+;Accent=BlueGrey
+;Primary=BlueGray