Herunterladen als
root/example/main.cpp @ 1e213c09
81c23b56 | Christian Ehringfeld | #include <QCoreApplication>
|
|
#include <typeinfo>
|
|||
#include <QDir>
|
|||
#include <QDebug>
|
|||
9d05e414 | Christian Ehringfeld | #include "models/artikel.h"
|
|
#include "models/person.h"
|
|||
#include <typeinfo>
|
|||
#include <QMetaMethod>
|
|||
#include <QMetaProperty>
|
|||
#include "models/group.h"
|
|||
#include "entity.h"
|
|||
9c2f773f | Christian Ehringfeld | #include "entitymanager.h"
|
|
9d05e414 | Christian Ehringfeld | #include <QGenericReturnArgument>
|
|
81c23b56 | Christian Ehringfeld | /**
|
|
* create,remove und merge funktionieren
|
|||
*/
|
|||
9d05e414 | Christian Ehringfeld | int main(int argc, char *argv[]) {
|
|
9c2f773f | Christian Ehringfeld | CuteEntityManager::EntityManager *e = new CuteEntityManager::EntityManager("QSQLITE",QDir::currentPath() + "/db.sqlite");
|
|
QSharedPointer<Artikel> a = QSharedPointer<Artikel>(new Artikel(20.0,"Müsli"));
|
|||
auto ep = a.dynamicCast<CuteEntityManager::Entity>();
|
|||
qDebug() << e;
|
|||
qDebug() << "Tabelle artikel erstellt:" << e->createTable(ep);
|
|||
9d05e414 | Christian Ehringfeld | // OpenTeacherTool::Artikel *b= new OpenTeacherTool::Artikel(30,"Peter123");
|
|
// OpenTeacherTool::Entity *entity = b->getEntity();
|
|||
// qDebug() << "findByAttributes:" << e->findByAttributes(entity,true);
|
|||
// qDebug() << "create:" << e->create(entity);
|
|||
// qDebug() << "findAll:" << e->findAll(entity->getTablename());
|
|||
// entity->setAttributes(e->findByAttributes(entity,true).at(0));
|
|||
// qDebug() << "AttributeValues, Artikel:" << *b->getAttributeValues();
|
|||
// b->setName("Peter");
|
|||
// b->setPreis(20);
|
|||
// e->remove(entity);
|
|||
// qDebug() << "TypID:" << typeid(entity).name();
|
|||
// qDebug() << entity->getId();
|
|||
// qDebug() << "merge:" << e->merge(entity);
|
|||
// delete entity;
|
|||
// Artikel *a = new Artikel(10.0,"pew");
|
|||
// a->setId(100);
|
|||
// qDebug() << a->getTablename();
|
|||
// for (int var = 0; var < a->metaObject()->methodCount(); ++var) {
|
|||
// qDebug() << a->metaObject()->method(var).name();
|
|||
// }
|
|||
81c23b56 | Christian Ehringfeld | ||
9d05e414 | Christian Ehringfeld | // Person *b = new Person();
|
|
// b->setId(110);
|
|||
// qDebug() << b->getTablename();
|
|||
// for (int var = 0; var < b->metaObject()->propertyCount(); ++var) {
|
|||
// qDebug() << b->metaObject()->property(var).name();
|
|||
// qDebug() << b->metaObject()->property(var).read(b);
|
|||
// }
|
|||
Group *g = new Group();
|
|||
586bb527 | Christian Ehringfeld | g->setTeacher(new Person("Test","Test12345"));
|
|
g->setTeacherP(QSharedPointer<Person>(new Person("Max","Mustermann")));
|
|||
9d05e414 | Christian Ehringfeld | for (int var = 0; var < g->metaObject()->propertyCount(); ++var) {
|
|
qDebug() << "Name:" << g->metaObject()->property(var).name();
|
|||
a47954c0 | Christian Ehringfeld | qDebug() << "Name:" << g->metaObject()->property(var).name();
|
|
// qDebug() << "Type:" << g->metaObject()->property(var).typeName();
|
|||
9d05e414 | Christian Ehringfeld | auto p = g->metaObject()->property(var).read(g);
|
|
a47954c0 | Christian Ehringfeld | // qDebug() << "Value:" << p;
|
|
// qDebug() << p.canConvert<CuteEntityManager::Entity*>();
|
|||
// qDebug() << qvariant_cast<CuteEntityManager::Entity*>(p);
|
|||
586bb527 | Christian Ehringfeld | //p.type().canConvert(1);
|
|
// if (QString(p.typeName()).contains("QList")) {
|
|||
// auto n = static_cast<QList<CuteEntityManager::Entity *>*>(p.data());
|
|||
// qDebug() << "Size:" << n->size();
|
|||
// for (int var = 0; var < n->size(); ++var) {
|
|||
// CuteEntityManager::Entity *entity = n->at(var);
|
|||
// qDebug() << entity->toString();
|
|||
// }
|
|||
// }
|
|||
9d05e414 | Christian Ehringfeld | }
|
|
81c23b56 | Christian Ehringfeld | return 0;
|
|
}
|