Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f53f7740

Von Christian Ehringfeld vor mehr als 9 Jahren hinzugefügt

  • ID f53f7740d0d97a2b88d970bd042b352fe9623f21
  • Vorgänger d568923d
  • Nachfolger b02f465a

example update

Unterschiede anzeigen:

example/main.cpp
*/
int main(int argc, char *argv[]) {
CuteEntityManager::EntityManager *e = new CuteEntityManager::EntityManager("QSQLITE",QDir::currentPath() + "/db.sqlite");
QSharedPointer<Artikel> a = QSharedPointer<Artikel>(new Artikel(20.0,"Müsli"));
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);
e->create(ep);
// 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();
// }
// 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();
g->setTeacher(new Person("Test","Test12345"));
g->setTeacherP(QSharedPointer<Person>(new Person("Max","Mustermann")));
for (int var = 0; var < g->metaObject()->propertyCount(); ++var) {
qDebug() << "Name:" << g->metaObject()->property(var).name();
qDebug() << "Name:" << g->metaObject()->property(var).name();
// qDebug() << "Type:" << g->metaObject()->property(var).typeName();
auto p = g->metaObject()->property(var).read(g);
// qDebug() << "Value:" << p;
// qDebug() << p.canConvert<CuteEntityManager::Entity*>();
// qDebug() << qvariant_cast<CuteEntityManager::Entity*>(p);
//p.type().canConvert(1);
QSharedPointer<Person> p = QSharedPointer<Person>(new Person("Max", "Mustermann", Person::MALE, "", "", "",
QDate::currentDate()));
auto pptr = p.dynamicCast<CuteEntityManager::Entity>();
e->createTable(pptr);
e->create(pptr);
// 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();
// }
// }
}
QSharedPointer<Group> grp = QSharedPointer<Group>(new Group());
e->createTable(grp.dynamicCast<CuteEntityManager::Entity>());
grp.data()->setTeacher(new Person("Test", "Test12345"));
grp.data()->setTeacherP(QSharedPointer<Person>(new Person("Max", "Mustermann")));
return 0;
}
example/models/artikel.cpp
*/
#include "artikel.h"
//QHash<QString, QString> Artikel::getProperties(DatabaseType type) {
// QHash<QString, QString> h = QHash<QString, QString>();
// h.insert("id",this->idColumnSQL());
// h.insert("preis","DOUBLE");
// h.insert("name","TEXT");
// return h;
//}
//PersistenceType Artikel::getPersistenceType() {
// return OpenTeacherTool::LOCAL;
//}
//QHash<QString, Entity*> *Artikel::getRelations() {
// return this->relations;
//}
//QHash<QString, QVariant> *Artikel::getAttributeValues() {
// this->attributeValues->insert("id",this->id);
// this->attributeValues->insert("name",this->name);
// this->attributeValues->insert("preis",this->preis);
// return this->attributeValues;
//}
//void Artikel::setAttributes(QHash<QString, QVariant> h) {
// this->id = h.value("id").toInt();
// this->name = h.value("name").toString();
// this->preis = h.value("preis").toDouble();
//}
double Artikel::getPreis() const {
return preis;
}
example/models/artikel.h
public:
~Artikel();
// QHash<QString, QString> getProperties(DatabaseType type);
// PersistenceType getPersistenceType();
// QHash<QString,Entity*>* getRelations();
// QHash<QString, QVariant>* getAttributeValues();
// void setAttributes(QHash<QString, QVariant> h);
explicit Artikel(QObject *parent = 0);
Artikel(double preis, QString name);
double getPreis() const;
example/models/group.cpp
qDebug() << "set!!!";
persons = value;
}
QSharedPointer<Person> Group::getTeacherP() const
{
QSharedPointer<Person> Group::getTeacherP() const {
return teacherP;
}
void Group::setTeacherP(const QSharedPointer<Person> &value)
{
void Group::setTeacherP(const QSharedPointer<Person> &value) {
teacherP = value;
}
Person *Group::getTeacher() const
{
Person *Group::getTeacher() const {
return teacher;
}
void Group::setTeacher(Person *value)
{
void Group::setTeacher(Person *value) {
teacher = value;
}
QSharedPointer<Artikel> Group::getArtikel() const
{
QSharedPointer<Artikel> Group::getArtikel() const {
return artikel;
}
void Group::setArtikel(const QSharedPointer<Artikel> &value)
{
void Group::setArtikel(const QSharedPointer<Artikel> &value) {
artikel = value;
}
void Group::personChangedSlot() {
qDebug() << "changed!";
}
QHash<QString, CuteEntityManager::Relation> Group::getRelations()
{
QHash<QString, CuteEntityManager::Relation> Group::getRelations() {
QHash<QString, CuteEntityManager::Relation> h = QHash<QString, CuteEntityManager::Relation>();
CuteEntityManager::Relation r = CuteEntityManager::Relation("artikel",CuteEntityManager::MANY_TO_ONE);
CuteEntityManager::Relation r = CuteEntityManager::Relation("artikel", CuteEntityManager::MANY_TO_ONE);
h.insert("artikel", r);
return h;
}

Auch abrufbar als: Unified diff