#include "controller.h"
#include <QDebug>
#include <QQuickWindow>
+#include <QQmlProperty>
#include "humandatamodel.h"
Controller::Controller (DataBase* d, QObject* parent) :
QObject::connect (qmlRoot, SIGNAL (openAddService() ),
this, SLOT (openAddService() ) );
QObject* humanslist = qmlRoot->findChild<QObject*> ("humanslist");
+ QVariant model = QQmlProperty::read (humanslist, "model");
- QObject::connect (db, SIGNAL (humanChanged() ), humanslist, SLOT (dataChanged() ) );
+ QObject::connect (db, SIGNAL (humanChanged() ), humanslist, SLOT (forceLayout () ) );
}
void Controller::openAddHuman()
{
QQmlComponent component (engine, QUrl (QStringLiteral ("qrc:/addhuman.qml") ), QQmlComponent::PreferSynchronous,
- engine->rootObjects().first() );
+ qmlRoot );
if (component.isReady() ) {
QObject* dialog = component.create();
void Controller::openAddService()
{
QQmlComponent component (engine, QUrl (QStringLiteral ("qrc:/addservice.qml") ), QQmlComponent::PreferSynchronous,
- engine->rootObjects().first() );
+ qmlRoot );
if (component.isReady() ) {
QObject* dialog = component.create();
}
return data;
}
+
+bool HumanDataModel::setData (const QModelIndex& index, const QVariant& value, int role)
+{
+ QSqlQueryModel::setData(index, value,role);
+ emit dataChanged(index, index);
+ return true;
+}
+
+Qt::ItemFlags HumanDataModel::flags(const QModelIndex& index) const
+{
+
+}
#include <QHash>
#include "logging.h"
-
+// Use QSqlTableModel for human and service tables and QSqlRelationalTableModel for user
class HumanDataModel : public QSqlQueryModel
{
public:
QHash<int, QByteArray> roleNames() const;
QVariant data (const QModelIndex& model, int role) const;
+ bool setData (const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
+ Qt::ItemFlags flags (const QModelIndex& index) const;
};
#endif // HUMANDATAMODEL_H
}
}
+ Button {
+ id: btnaddservice
+// anchors.left: btnaddhuman.right
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+ text: qsTr("Add Service")
+ onClicked: openAddService()
+ }
+
Button {
id: btnaddhuman
- anchors.left: parent.left
anchors.bottom: parent.bottom
+ anchors.right: btnaddservice.left
visible: true
text: qsTr("Add Human")
onClicked: openAddHuman()
}
- Button {
- id: btnaddservice
- anchors.left: btnaddhuman.right
- anchors.bottom: parent.bottom
- text: qsTr("Add Service")
- onClicked: openAddService()
- }
+
}