Revision d518fe54
Von Christian Ehringfeld vor mehr als 10 Jahren hinzugefügt
| EntityManager.pro | ||
|---|---|---|
|
src/schema/sqlitequerybuilder.h \
|
||
|
src/relation.h \
|
||
|
src/entityinstancefactory.h \
|
||
|
src/condition.h \
|
||
|
src/cache.h \
|
||
|
src/entityhelper.h \
|
||
|
src/logger.h
|
||
| ... | ... | |
|
src/schema/sqlitequerybuilder.cpp \
|
||
|
src/relation.cpp \
|
||
|
src/entityinstancefactory.cpp \
|
||
|
src/condition.cpp \
|
||
|
src/cache.cpp \
|
||
|
src/entityhelper.cpp \
|
||
|
src/logger.cpp
|
||
| samples/example/main.cpp | ||
|---|---|---|
|
e->create(groupPtr, true, true);
|
||
|
}
|
||
|
|
||
|
/** ---------------------------------
|
||
|
* FIND Pupil
|
||
|
* ---------------------------------
|
||
|
*/
|
||
|
QSharedPointer<Entity> pupilFindPtr = e->findById(22, QString("Pupil*"));
|
||
|
QSharedPointer<Pupil> pupilPtr = pupilFindPtr.objectCast<Pupil>();
|
||
|
qDebug() << "Pupil:" << pupilPtr->toString();
|
||
|
qDebug() << "GroupSize:" << pupilPtr->getGroups().size();
|
||
|
|
||
|
|
||
|
/** ---------------------------------
|
||
|
* FIND Group
|
||
|
* ---------------------------------
|
||
| ... | ... | |
|
qDebug() << "FoundMainTeacherGroupSize:" <<
|
||
|
foundMainTeacher->getMaintainedGroups().size();
|
||
|
|
||
|
qDebug() << "-----------------------------";
|
||
|
QSharedPointer<Pupil> foundPupil = e->findById<Pupil *>
|
||
|
(13).objectCast<Pupil>();
|
||
|
qDebug() << "FoundPupil:" << foundPupil->toString();
|
||
|
qDebug() << "FoundPupilGroupSize:" <<
|
||
|
foundPupil->getGroups().size();
|
||
|
|
||
|
qDebug() << "-----------------------------";
|
||
|
|
||
|
qDebug() << "Duration:" << t.elapsed();
|
||
| samples/example/models/group.cpp | ||
|---|---|---|
|
|
||
|
const QHash<QString, CuteEntityManager::Relation> Group::getRelations() const {
|
||
|
auto hash = QHash<QString, CuteEntityManager::Relation>();
|
||
|
hash.insert("pupils", CuteEntityManager::Relation("pupils",
|
||
|
RelationType::MANY_TO_MANY));
|
||
|
hash.insert("persons", CuteEntityManager::Relation("persons",
|
||
|
RelationType::MANY_TO_MANY));
|
||
|
hash.insert("pupils", CuteEntityManager::Relation("pupils",
|
||
|
RelationType::MANY_TO_MANY, QString("groups")));
|
||
|
hash.insert("mainTeacher", CuteEntityManager::Relation("mainTeacher",
|
||
|
RelationType::MANY_TO_ONE));
|
||
|
return hash;
|
||
| samples/example/models/pupil.cpp | ||
|---|---|---|
|
const QHash<QString, Relation> Pupil::getRelations() const {
|
||
|
auto hash = Person::getRelations();
|
||
|
hash.insert("groups", CuteEntityManager::Relation("groups",
|
||
|
RelationType::MANY_TO_MANY,
|
||
|
QString("pupils")));
|
||
|
RelationType::MANY_TO_MANY));
|
||
|
return hash;
|
||
|
}
|
||
| src/condition.cpp | ||
|---|---|---|
|
/*
|
||
|
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
|
||
|
*
|
||
|
* This program is free software; you can redistribute it and/or modify it
|
||
|
* under the terms of the GNU Lesser General Public License as published by
|
||
|
* the Free Software Foundation.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful, but
|
||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||
|
* for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Lesser General Public License
|
||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
#include "condition.h"
|
||
|
using namespace CuteEntityManager;
|
||
|
Condition::Condition() {
|
||
|
|
||
|
}
|
||
|
|
||
| src/condition.h | ||
|---|---|---|
|
/*
|
||
|
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
|
||
|
*
|
||
|
* This program is free software; you can redistribute it and/or modify it
|
||
|
* under the terms of the GNU Lesser General Public License as published by
|
||
|
* the Free Software Foundation.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful, but
|
||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||
|
* for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Lesser General Public License
|
||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
#ifndef CONDITION_H
|
||
|
#define CONDITION_H
|
||
|
|
||
|
namespace CuteEntityManager {
|
||
|
class Condition {
|
||
|
public:
|
||
|
Condition();
|
||
|
};
|
||
|
}
|
||
|
|
||
|
#endif // CONDITION_H
|
||
| src/querybuilder.cpp | ||
|---|---|---|
|
bool ignoreID, const QString &primaryKey) const {
|
||
|
QHash<QString, QVariant>::const_iterator i = h.constBegin();
|
||
|
while (i != h.constEnd()) {
|
||
|
if (!ignoreID || (ignoreID && !(i.key() == primaryKey))) {
|
||
|
if ((!ignoreID || (ignoreID && !(i.key() == primaryKey))) && !i.value().isNull()) {
|
||
|
this->bindValue(i.key(), i.value(), q);
|
||
|
}
|
||
|
++i;
|
||
| ... | ... | |
|
if (!m.isEmpty()) {
|
||
|
QHash<QString, QVariant>::const_iterator i = m.constBegin();
|
||
|
while (i != m.constEnd()) {
|
||
|
if (!ignoreID || (ignoreID && !(i.key() == primaryKey))) {
|
||
|
if ((!ignoreID || (ignoreID && !(i.key() == primaryKey))) && !i.value().isNull()) {
|
||
|
if (!(rc == "")) {
|
||
|
rc += " " + conjunction + " ";
|
||
|
}
|
||
Auch abrufbar als: Unified diff
update