revert
This commit is contained in:
parent
4e0731f50d
commit
7871092a81
62
src/query.h
62
src/query.h
|
|
@ -259,10 +259,6 @@ Q_OUTOFLINE_TEMPLATE RowList<T> Query<T>::toList(int count)
|
||||||
int n = -1;
|
int n = -1;
|
||||||
|
|
||||||
while (p) {
|
while (p) {
|
||||||
// Q_ASSERT(p != lastP);
|
|
||||||
// if (p == lastP)
|
|
||||||
// qFatal("NULL Loop detected");
|
|
||||||
|
|
||||||
++n;
|
++n;
|
||||||
n = n % levels.count();
|
n = n % levels.count();
|
||||||
if (checked[n])
|
if (checked[n])
|
||||||
|
|
@ -272,14 +268,14 @@ Q_OUTOFLINE_TEMPLATE RowList<T> Query<T>::toList(int count)
|
||||||
// check if key value is changed
|
// check if key value is changed
|
||||||
if (data.lastKeyValue == q.value(data.keyFiledname)) {
|
if (data.lastKeyValue == q.value(data.keyFiledname)) {
|
||||||
--p;
|
--p;
|
||||||
// qDebug() << "key os not changed for" << data.keyFiledname;
|
qDebug() << "key os not changed for" << data.keyFiledname;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if master if current table has processed
|
// check if master if current table has processed
|
||||||
foreach (int m, data.masters)
|
foreach (int m, data.masters)
|
||||||
if (!checked[m]) {
|
if (!checked[m]) {
|
||||||
// qDebug() << "row is checked";
|
qDebug() << "row is checked";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -289,34 +285,30 @@ Q_OUTOFLINE_TEMPLATE RowList<T> Query<T>::toList(int count)
|
||||||
|
|
||||||
//create table row
|
//create table row
|
||||||
Table *table;
|
Table *table;
|
||||||
Row<Table> tablePointer;
|
Row<T> tablePointer;
|
||||||
const QMetaObject *childMetaObject;
|
|
||||||
if (data.table->className() == d->className) {
|
if (data.table->className() == d->className) {
|
||||||
table = new T;
|
table = new T();
|
||||||
childMetaObject = &T::staticMetaObject;
|
|
||||||
// table = Nut::create<T>();
|
|
||||||
#ifdef NUT_SHARED_POINTER
|
#ifdef NUT_SHARED_POINTER
|
||||||
tablePointer.reset(table);
|
tablePointer = QSharedPointer<T>(qobject_cast<T*>(table));
|
||||||
returnList.append(qSharedPointerCast<T>(tablePointer));
|
returnList.append(tablePointer);
|
||||||
#else
|
|
||||||
returnList.append(qobject_cast<T>(table1));
|
|
||||||
#endif
|
|
||||||
d->tableSet->add(tablePointer);
|
d->tableSet->add(tablePointer);
|
||||||
// table->setParentTableSet(d->tableSet);
|
#else
|
||||||
|
returnList.append(dynamic_cast<T*>(table));
|
||||||
|
#endif
|
||||||
|
table->setParentTableSet(d->tableSet);
|
||||||
} else {
|
} else {
|
||||||
childMetaObject = QMetaType::metaObjectForType(data.table->typeId());
|
const QMetaObject *childMetaObject
|
||||||
|
= QMetaType::metaObjectForType(data.table->typeId());
|
||||||
table = qobject_cast<Table *>(childMetaObject->newInstance());
|
table = qobject_cast<Table *>(childMetaObject->newInstance());
|
||||||
if (!table)
|
if (!table)
|
||||||
qFatal("Could not create instance of %s",
|
qFatal("Could not create instance of %s",
|
||||||
qPrintable(data.table->name()));
|
qPrintable(data.table->name()));
|
||||||
|
|
||||||
tablePointer.reset(table);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<FieldModel*> childFields = data.table->fields();
|
QList<FieldModel*> childFields = data.table->fields();
|
||||||
foreach (FieldModel *field, childFields)
|
foreach (FieldModel *field, childFields)
|
||||||
tablePointer->setProperty(field->name.toLatin1().data(),
|
table->setProperty(field->name.toLatin1().data(),
|
||||||
d->database->sqlGenertor()->unescapeValue(
|
d->database->sqlGenertor()->unescapeValue(
|
||||||
field->type,
|
field->type,
|
||||||
q.value(data.table->name() + "." + field->name)));
|
q.value(data.table->name() + "." + field->name)));
|
||||||
|
|
@ -326,36 +318,32 @@ Q_OUTOFLINE_TEMPLATE RowList<T> Query<T>::toList(int count)
|
||||||
#ifdef NUT_SHARED_POINTER
|
#ifdef NUT_SHARED_POINTER
|
||||||
QString mName = QString("set%1").arg(levels[master].lastRow->metaObject()->className());
|
QString mName = QString("set%1").arg(levels[master].lastRow->metaObject()->className());
|
||||||
QString type = QString("Nut::Row<%1>").arg(levels[master].lastRow->metaObject()->className());
|
QString type = QString("Nut::Row<%1>").arg(levels[master].lastRow->metaObject()->className());
|
||||||
for (int i = 0; i < table->metaObject()->methodCount(); ++i) {
|
|
||||||
QMetaMethod m = table->metaObject()->method(i);
|
|
||||||
qDebug() << m.name();
|
|
||||||
}
|
|
||||||
bool ok = table->metaObject()->invokeMethod(table,
|
bool ok = table->metaObject()->invokeMethod(table,
|
||||||
mName.toLocal8Bit().data(),
|
mName.toLocal8Bit().data(),
|
||||||
QGenericArgument(type.toLatin1().data(), levels[master].lastRow));
|
QGenericArgument(type.toLatin1().data(), levels[master].lastRow));
|
||||||
#else
|
#else
|
||||||
bool ok = table->setProperty(data.masterFields[i].toLocal8Bit().data(),
|
bool ok = table->setProperty(data.masterFields[i].toLocal8Bit().data(),
|
||||||
QVariant::fromValue(levels[master].lastRow));
|
QVariant::fromValue(levels[master].lastRow));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!ok)
|
if (!ok)
|
||||||
qWarning("Unable to set property %s::%s",
|
qWarning("Unable to set property %s::%s",
|
||||||
tablePointer->metaObject()->className(), data.masterFields[i].toLocal8Bit().data());
|
table->metaObject()->className(), data.masterFields[i].toLocal8Bit().data());
|
||||||
|
|
||||||
auto tableset = levels[master].lastRow->childTableSet(
|
auto tableset = levels[master].lastRow->childTableSet(
|
||||||
data.table->className());
|
data.table->className());
|
||||||
// table->setParentTableSet(tableset);
|
table->setParentTableSet(tableset);
|
||||||
//#ifdef NUT_SHARED_POINTER
|
#ifdef NUT_SHARED_POINTER
|
||||||
tableset->add(tablePointer);
|
tableset->add(qSharedPointerCast<Table>(tablePointer));
|
||||||
//#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
tablePointer->setStatus(Table::FeatchedFromDB);
|
table->setStatus(Table::FeatchedFromDB);
|
||||||
tablePointer->setParent(this);
|
table->setParent(this);
|
||||||
tablePointer->clear();
|
table->clear();
|
||||||
|
|
||||||
//set last created row
|
//set last created row
|
||||||
data.lastRow = table;///*QSharedPointer<Table>*/(table.data());
|
data.lastRow = /*QSharedPointer<Table>*/(table);
|
||||||
} //while
|
} //while
|
||||||
} // while
|
} // while
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue