Extension of QSqlTableModel class and used throughout the application.
More...
#include <Database.h>
List of all members.
Detailed Description
Extension of QSqlTableModel class and used throughout the application.
Constructor & Destructor Documentation
Member Function Documentation
void SqlTableModel::queryChange |
( |
|
) |
[virtual] |
{
if (primaryKey().isEmpty() && !rowIdentifierField().isEmpty()) {
QSqlIndex index = primaryKey();
for(int i = 0; i < record().count(); i++)
if (record().field(i).name() == rowIdentifierField())
index.append(record().field(i));
if (!index.isEmpty()) qDebug() << "PK set to rowIdentifierField: " << index << " for table " << tableName();
setPrimaryKey(index);
}
if (primaryKey().isEmpty()) {
QSqlIndex index = primaryKey();
for(int i = 0; i < record().count(); i++)
if (record().field(i).name().contains(QRegExp("_id|_nr")))
index.append(record().field(i));
if (!index.isEmpty()) qDebug() << "PK set to " << index << " for table " << tableName();
setPrimaryKey(index);
}
if (primaryKey().isEmpty()) {
QSqlIndex index = primaryKey();
for(int i = 0; i < record().count(); i++)
index.append(record().field(i));
if (!index.isEmpty()) qDebug() << "PK set to all fields for table " << tableName();
setPrimaryKey(index);
}
if (primaryKey().isEmpty())
qWarning() << "No primary key set for table " << tableName() << ". This might cause problems.";
qDebug() << "Emitting queryChanged for table " << tableName();
emit queryChanged();
}
void SqlTableModel::queryChanged |
( |
|
) |
[signal] |
void SqlTableModel::setTable |
( |
const QString & |
table |
) |
|
The documentation for this class was generated from the following files: