Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 90dfeb49

Von Christian Ehringfeld vor mehr als 8 Jahren hinzugefügt

  • ID 90dfeb497c4650fcd46fe2dff35d18be9cb8d6e6
  • Vorgänger a902ed57
  • Nachfolger 4ce3b0c1

enum fix

Unterschiede anzeigen:

src/entityinstancefactory.cpp
QMetaProperty prop = metaprops.value(iterator.key());
if (prop.isWritable()) {
if (prop.isEnumType()) {
prop.write(e, prop.enumerator().key(iterator.value().toInt()));
prop.write(e, prop.enumerator().valueToKey(iterator.value().toInt()));
} else {
prop.write(e, iterator.value());
}
tests/em/tst_querybuilder.cpp
CuteEntityManager::EntityInstanceFactory::registerClass<Person>();
CuteEntityManager::EntityInstanceFactory::registerClass<Employee>();
CuteEntityManager::EntityInstanceFactory::registerClass<WorkerGroup>();
this->e = new CuteEntityManager::EntityManager("QSQLITE", ":memory:", "", "", "", "",
this->e = new CuteEntityManager::EntityManager("QSQLITE",
QDir::currentPath() + "/db.sqlite", "", "", "", "",
true, "foreign_keys = ON", false);
QStringList inits = QStringList() << "Person" << "Group" << "Employee" << "WorkerGroup";
QVERIFY2(this->e->startup("queryBuilderTest", inits), "Failure");
......
QCOMPARE(groupList.at(0)->getPersons().size(), 3);
}
void QuerybuilderTest::testEnum() {
auto qb = e->getQueryBuilder();
Query q = Query();
QVariant var;
var.setValue<Person::Gender>(Person::Gender::FEMALE);
q.appendWhere(q.equal(qb, "gender", var.toInt()));
QList<QSharedPointer<Person>> females = e->find<Person>(q, false);
QCOMPARE(females.size(), 4);
QCOMPARE(females.first()->getGender(), Person::Gender::FEMALE);
}
void QuerybuilderTest::testRefresh() {
e->clearCache();
auto persons = e->findAll<Person>(false);
tests/em/tst_querybuilder.h
void testQueryBuilderSingleAttributeOr();
void testQueryBuilderManyToOneRelationAttribute();
void testQueryBuilderManyToManyRelationAttribute();
void testEnum();
void testRefresh();
private:
tests/models.h
getMaintainedGroups WRITE setMaintainedGroups)
public:
enum class Gender {MALE, FEMALE, UNKNOWNGENDER};
enum class Gender {MALE=109, FEMALE=102, UNKNOWNGENDER=0};
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
Q_ENUM(Gender)
#else

Auch abrufbar als: Unified diff