SOURCES += main.cpp \
database.cpp \
- controller.cpp
+ controller.cpp \
+ logging.cpp
RESOURCES += qml.qrc
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
+# Disable all qDebug output in release builds
+#CONFIG(release):DEFINES += QT_NO_DEBUG_OUTPUT
+
# 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.
HEADERS += \
database.h \
- controller.h
+ controller.h \
+ logging.h
-DISTFILES += style.astylrc
+DISTFILES += style.astylrc \
+ logrules.ini
+#DEFINES += QT_LOGGING_CONF="logrules.ini"
if (component.isReady() ) {
QObject* dialog = component.create();
- QQmlEngine::setObjectOwnership (dialog, QQmlEngine::CppOwnership);
+ QQmlEngine::setObjectOwnership (dialog, QQmlEngine::JavaScriptOwnership);
QObject::connect (dialog, SIGNAL (addHuman (QVariant, QVariant, QVariant) ),
db, SLOT (addHuman (QVariant, QVariant, QVariant) ) );
if (component.isReady() ) {
QObject* dialog = component.create();
- QQmlEngine::setObjectOwnership (dialog, QQmlEngine::CppOwnership);
+ QQmlEngine::setObjectOwnership (dialog, QQmlEngine::JavaScriptOwnership);
QObject::connect (dialog, SIGNAL (addService (QVariant, QVariant, QVariant) ),
db, SLOT (addService (QVariant, QVariant, QVariant) ) );
} else {
#include "database.h"
#include <QtSql/QSqlQuery>
-#include <QDebug>
#include <QDate>
+#include "logging.h"
DataBase::DataBase (QObject* parent) : QObject (parent)
{
if (!db.open() ) {
//do stuff
}
- qDebug() << initDB();
+
+ qCDebug (dbase) << initDB();
}
void DataBase::addHuman (const QVariant& name, const QVariant& firstname,
const QVariant& birthday)
{
- qDebug() << "addHuman slot called with: " << name << ", " << firstname << ", " << birthday;
+ qCDebug (dbase) << "addHuman slot called with: " << name << ", " << firstname << ", " << birthday;
QSqlQuery q;
- if (!q.prepare (this->sqlAddHuman) ) qDebug() << "error while preparing: " << q.lastError();
+ if (!q.prepare (this->sqlAddHuman) ) qCDebug (dbase) << "error while preparing: " << q.lastError();
q.addBindValue (name.toString() );
q.addBindValue (firstname.toString() );
q.addBindValue (birthday.toDate() );
- if (!q.exec() ) qDebug() << "error: " << q.lastError();
+ if (!q.exec() ) qCDebug (dbase) << "error: " << q.lastError();
}
void DataBase::addService (const QVariant& name, const QVariant& url,
const QVariant& description)
{
- qDebug() << "addService slot called with: " << name << ", " << url << ", " << description;
+ qCDebug (dbase) << "addService slot called with: " << name << ", " << url << ", " << description;
QSqlQuery q;
- if (!q.prepare (this->sqlAddService) ) qDebug() << "error while preparing: " << q.lastError();
+ if (!q.prepare (this->sqlAddService) ) qCDebug (dbase) << "error while preparing: " << q.lastError();
q.addBindValue (name.toString() );
q.addBindValue (url.toUrl() );
q.addBindValue (description.toString() );
- if (!q.exec() ) qDebug() << "error: " << q.lastError();
+ if (!q.exec() ) qCDebug (dbase) << "error: " << q.lastError();
}
void DataBase::addUser (const QVariant& humanID, const QVariant& serviceID,
QSqlQuery q;
if (!tables.contains ("human", Qt::CaseSensitivity::CaseInsensitive) ) {
if (!q.exec (this->sqlCreateHumanTable) ) return q.lastError();
- } else qDebug() << "table human already created";
+ } else qCDebug (dbase) << "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";
+ } else qCDebug (dbase) << "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";
+ } else qCDebug (dbase) << "table user already created";
return QSqlError();
}