Originally Posted by
wysota
No the UPDATE Query by submit all..
i found only ONE Way... connect the model an grab all data to construct a sqlquery..
is here no other way?
{
if (a.isValid() && b.isValid()) {
if (model->isDirty(a) && model->isDirty(b)) {
/* user mods data set new wath? */
const QString fieldnametouch
= FieldNameList.
at(a.
column());
const QString indexfieldname
= INDEXFIELD;
/* discovery on SHOW COLUMNS FROM table + make qstringlist FieldNameList */
DirtySQL = true;
if (INDEXFIELD.size() > 0) {
/* QModelIndex index field */
/* Prepare Dirty sqlupdate */
const QString pending
= QString("UPDATE %1 SET %2='%3' WHERE %4='%5' LIMIT 1") .arg(table)
.arg(fieldnametouch)
.arg(a.data().toString())
.arg(INDEXFIELD)
.arg(base.data(Qt::DisplayRole).toString());
/* append on a list wakeup on submit ... */
DirtyPendingQuery.append(pending);
qDebug() << "### Pendingsql one line " << pending;
qDebug() << "### WakeUpTable " << table << " fieldname active " << fieldnametouch << " - "
<< a.data().toString() << " - " << a.row()
<< "x" << a.column() << " on " << base.data(Qt::DisplayRole).toString();
}
}
}
}
connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(WakeUpTable(QModelIndex,QModelIndex)));
void Mysql_Table::WakeUpTable(const QModelIndex & a , const QModelIndex & b )
{
if (a.isValid() && b.isValid()) {
if (model->isDirty(a) && model->isDirty(b)) {
/* user mods data set new wath? */
const QString fieldnametouch = FieldNameList.at(a.column());
const QString indexfieldname = INDEXFIELD; /* discovery on SHOW COLUMNS FROM table + make qstringlist FieldNameList */
DirtySQL = true;
if (INDEXFIELD.size() > 0) {
/* QModelIndex index field */
QModelIndex base = a.sibling(a.row(),indexcolumn);
/* Prepare Dirty sqlupdate */
const QString pending = QString("UPDATE %1 SET %2='%3' WHERE %4='%5' LIMIT 1")
.arg(table)
.arg(fieldnametouch)
.arg(a.data().toString())
.arg(INDEXFIELD)
.arg(base.data(Qt::DisplayRole).toString());
/* append on a list wakeup on submit ... */
DirtyPendingQuery.append(pending);
qDebug() << "### Pendingsql one line " << pending;
qDebug() << "### WakeUpTable " << table << " fieldname active " << fieldnametouch << " - "
<< a.data().toString() << " - " << a.row()
<< "x" << a.column() << " on " << base.data(Qt::DisplayRole).toString();
}
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks