Revision f682a8cb
Von Christian Ehringfeld vor mehr als 9 Jahren hinzugefügt
samples/example/models/address.cpp | ||
---|---|---|
const QHash<QString, CuteEntityManager::Relation> Address::getRelations()
|
||
const {
|
||
auto hash = Entity::getRelations();
|
||
// hash.insert("persons", CuteEntityManager::Relation("persons",
|
||
// RelationType::MANY_TO_MANY,
|
||
// QString("addresses")));
|
||
hash.insert("persons", CuteEntityManager::Relation("persons",
|
||
RelationType::MANY_TO_MANY,
|
||
QString("addresses")));
|
||
hash.insert("pupils", CuteEntityManager::Relation("pupils",
|
||
RelationType::MANY_TO_MANY,
|
||
QString("addresses")));
|
samples/example/models/contact.cpp | ||
---|---|---|
const QHash<QString, CuteEntityManager::Relation> Contact::getRelations()
|
||
const {
|
||
auto hash = Entity::getRelations();
|
||
// hash.insert("persons", CuteEntityManager::Relation("persons",
|
||
// RelationType::MANY_TO_MANY,
|
||
// QString("contacts")));
|
||
hash.insert("persons", CuteEntityManager::Relation("persons",
|
||
RelationType::MANY_TO_MANY,
|
||
QString("contacts")));
|
||
hash.insert("pupils", CuteEntityManager::Relation("pupils",
|
||
RelationType::MANY_TO_MANY,
|
||
QString("contacts")));
|
samples/example/models/person.cpp | ||
---|---|---|
hash.insert("maintainedGroups", CuteEntityManager::Relation("maintainedGroups",
|
||
RelationType::ONE_TO_MANY,
|
||
QString("mainTeacher")));
|
||
// hash.insert("contacts", CuteEntityManager::Relation("contacts",
|
||
// RelationType::MANY_TO_MANY));
|
||
// hash.insert("addresses", CuteEntityManager::Relation("addresses",
|
||
// RelationType::MANY_TO_MANY));
|
||
hash.insert("contacts", CuteEntityManager::Relation("contacts",
|
||
RelationType::MANY_TO_MANY));
|
||
hash.insert("addresses", CuteEntityManager::Relation("addresses",
|
||
RelationType::MANY_TO_MANY));
|
||
return hash;
|
||
}
|
||
|
samples/example/models/person.h | ||
---|---|---|
Q_PROPERTY(QList<QSharedPointer<Group>> groups READ getGroups WRITE setGroups)
|
||
Q_PROPERTY(QList<QSharedPointer<Group>> maintainedGroups READ
|
||
getMaintainedGroups WRITE setMaintainedGroups)
|
||
// Q_PROPERTY(QList<QSharedPointer<Contact>> contacts READ getContacts WRITE
|
||
// setContacts)
|
||
// Q_PROPERTY(QList<QSharedPointer<Address>> addresses READ
|
||
// getAddresses WRITE setAddresses)
|
||
Q_PROPERTY(QList<QSharedPointer<Contact>> contacts READ getContacts WRITE
|
||
setContacts)
|
||
Q_PROPERTY(QList<QSharedPointer<Address>> addresses READ
|
||
getAddresses WRITE setAddresses)
|
||
|
||
public:
|
||
enum class Gender {MALE, FEMALE, UNKNOWNGENDER};
|
src/logger.cpp | ||
---|---|---|
qDebug() << errorMsg;
|
||
stream << errorMsg;
|
||
}
|
||
if(logQuery) {
|
||
if(logQuery || !errorMsg.isEmpty()) {
|
||
const QString query = this->generateLogMsg(q);
|
||
if(!query.isEmpty()) {
|
||
qDebug() << query;
|
||
stream << query;
|
||
}
|
||
}
|
||
stream << "\n";
|
||
stream.flush();
|
||
log.close();
|
||
}
|
||
... | ... | |
}
|
||
}
|
||
|
||
QString Logger::generateLogMsg(const QSqlQuery &q) const {
|
||
QString Logger::generateLogMsg(const QSqlQuery &q, bool withValues) const {
|
||
QString r = "<" + q.executedQuery() + ">";
|
||
if(withValues) {
|
||
QMap<QString, QVariant> m = q.boundValues();
|
||
QMap<QString,QVariant>::iterator i;
|
||
if(!m.isEmpty()) {
|
||
... | ... | |
r += "{" + i.key() + ":" + i.value().toString() + "}";
|
||
}
|
||
}
|
||
}
|
||
return r;
|
||
}
|
||
|
||
... | ... | |
|
||
QString Logger::generateLogMsg(const QSqlError &e) const {
|
||
if(e.isValid()) {
|
||
return "UTC:" + QDateTime::currentDateTime().toString("yyyy-MM-dd|hh:MM:ss") + "|" + e.driverText() + "|" + e.databaseText().toLatin1() + "\n";
|
||
return "ErrorUTC:" + QDateTime::currentDateTime().toString("yyyy-MM-dd|hh:MM:ss") + "|" + e.driverText() + "|" + e.databaseText().toLatin1();
|
||
} else {
|
||
return "";
|
||
}
|
src/logger.h | ||
---|---|---|
|
||
protected:
|
||
QString generateLogMsg(const QSqlError &e) const;
|
||
QString generateLogMsg(const QSqlQuery &q) const;
|
||
QString generateLogMsg(const QSqlQuery &q, bool withValues=true) const;
|
||
|
||
private:
|
||
QString path;
|
Auch abrufbar als: Unified diff
example and logger update