124 bool m_dictInitialized;
163 return m_dictInitialized;
171 if (
model ==
nullptr)
189 record.field(displayColumn).value();
191 m_dictInitialized =
true;
197 m_dictInitialized =
false;
209 return (
rel.
isValid() && m_parent !=
nullptr);
399 d->relations.value(
index.column()).isValid()) {
401 if (!
relation.isDictionaryInitialized())
414 return relation.dictionary[
v.toString()];
442 &&
d->relations.value(
index.column()).isValid()) {
444 if (!
relation.isDictionaryInitialized())
475 if (
d->relations.size() <=
column)
476 d->relations.resize(
column + 1);
489 return d->relations.value(
column).rel;
493 const QString &fieldName)
const
511 if (
d->relations.isEmpty())
517 for (
int i = 0;
i <
d->baseRec.count(); ++
i) {
527 for (
int i = 0;
i < rec.
count(); ++
i) {
535 name =
d->baseRec.fieldName(
i);
538 fieldList.append(
name);
544 for (
int i = 0;
i <
d->baseRec.count(); ++
i) {
552 if (fieldNames.
value(fieldList[
i]) > 1) {
563 displayTableField =
SqlrTm::as(displayTableField, alias);
564 --fieldNames[fieldList[
i]];
607 if (column < 0 || column >=
d->relations.size())
635 d->relations.clear();
661 d->joinMode = joinMode;
679 d->baseRec =
d->db.record(
table);
688 for (
int i = 0;
i <
values.count(); ++
i) {
691 bool gen =
values.isGenerated(
i);
707 d->translateFieldNames(rec);
720 d->translateFieldNames(rec);
748 if (
parent.isValid() || column < 0 || column + count >
d->rec.count())
753 if (
d->relations.size() >
column)
761#include "moc_qsqlrelationaltablemodel.cpp"
QObject * parent() const
Returns a pointer to the parent object.
static constexpr QChar fromLatin1(char c) noexcept
Converts the Latin-1 character c to its equivalent QChar.
T value(const Key &key) const noexcept
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
qsizetype size() const noexcept
T value(qsizetype i) const
The QSqlDatabase class handles a connection to a database.
QSqlDriver * driver() const
Returns the database driver used to access the database connection.
QSqlRecord record(const QString &tablename) const
Returns a QSqlRecord populated with the names of all the fields in the table (or view) called tablena...
virtual QString stripDelimiters(const QString &identifier, IdentifierType type) const
Returns the identifier with the leading and trailing delimiters removed, identifier can either be a t...
virtual bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const
Returns whether identifier is escaped according to the database rules.
static const QLatin1StringView et()
static const QLatin1StringView orderBy()
static const QLatin1StringView asc()
static const QLatin1StringView comma()
static const QLatin1StringView as()
static const QLatin1StringView leftJoin()
static const QLatin1StringView desc()
static const QLatin1StringView select()
static const QLatin1StringView on()
static const QString paren(const QString &s)
static const QString concat(const QString &a, const QString &b)
static const QLatin1StringView from()
static const QLatin1StringView where()
static const QLatin1StringView eq()
The QSqlRecord class encapsulates a database record.
QSqlField field(int i) const
Returns the field at position index.
int count() const
Returns the number of fields in the record.
QString fieldName(int i) const
Returns the name of the field at position index.
int indexOf(const QString &name) const
Returns the position of the field called name within the record, or -1 if it cannot be found.
QString tableName() const
Returns the name of the table to which a foreign key refers.
bool isValid() const noexcept
Returns true if the QSqlRelation object is valid; otherwise returns false.
QString indexColumn() const
Returns the index column from table tableName() to which a foreign key refers.
QString displayColumn() const
Returns the column from table tableName() that should be presented to the user instead of a foreign k...
QList< QRelation > relations
QSqlRelationalTableModelPrivate()
void clearCache() override
int nameToIndex(const QString &name) const override
QString fullyQualifiedFieldName(const QString &tableName, const QString &fieldName) const
void translateFieldNames(QSqlRecord &values) const
QSqlRelationalTableModel::JoinMode joinMode
void revertCachedRow(int row) override
static const QString relTablePrefix(int i)
The QSqlRelationalTableModel class provides an editable data model for a single database table,...
virtual void setRelation(int column, const QSqlRelation &relation)
Lets the specified column be a foreign index specified by relation.
QSqlRelation relation(int column) const
Returns the relation for the column column, or an invalid relation if no relation is set.
JoinMode
\value InnerJoin - Inner join mode, return rows when there is at least one match in both tables.
QVariant data(const QModelIndex &item, int role=Qt::DisplayRole) const override
\reimp
QString selectStatement() const override
\reimp
bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex()) override
\reimp
void clear() override
\reimp
QString orderByClause() const override
\reimp
bool updateRowInTable(int row, const QSqlRecord &values) override
\reimp
void setTable(const QString &tableName) override
\reimp
void revertRow(int row) override
\reimp
virtual QSqlTableModel * relationModel(int column) const
Returns a QSqlTableModel object for accessing the table for which column is a foreign key,...
bool setData(const QModelIndex &item, const QVariant &value, int role=Qt::EditRole) override
Sets the data for the role in the item with the specified index to the value given.
void setJoinMode(QSqlRelationalTableModel::JoinMode joinMode)
Sets the SQL joinMode to show or hide rows with NULL foreign keys.
bool select() override
\reimp
bool insertRowIntoTable(const QSqlRecord &values) override
\reimp
virtual ~QSqlRelationalTableModel()
Destroys the object and frees any allocated resources.
QSqlRelationalTableModel(QObject *parent=nullptr, const QSqlDatabase &db=QSqlDatabase())
Creates an empty QSqlRelationalTableModel and sets the parent to parent and the database connection t...
virtual int nameToIndex(const QString &name) const
virtual void clearCache()
virtual void revertCachedRow(int row)
QString strippedFieldName(const QString &name) const
The QSqlTableModel class provides an editable data model for a single database table.
virtual QString orderByClause() const
Returns an SQL {ORDER BY} clause based on the currently set sort order.
bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex()) override
Removes count columns from the parent model, starting at index column.
QVariant data(const QModelIndex &idx, int role=Qt::DisplayRole) const override
\reimp
QSqlRecord record() const
This is an overloaded function.
QString filter() const
Returns the currently set filter.
virtual bool updateRowInTable(int row, const QSqlRecord &values)
Updates the given row in the currently active database table with the specified values.
virtual bool insertRowIntoTable(const QSqlRecord &values)
Inserts the values values into the currently active database table.
void clear() override
\reimp
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Sets the data for the item index for the role role to value.
QString tableName() const
Returns the name of the currently selected table.
virtual void setTable(const QString &tableName)
Sets the database table on which the model operates to tableName.
virtual QString selectStatement() const
Returns the SQL SELECT statement used internally to populate the model.
virtual bool select()
Populates the model with data from the table that was set via setTable(), using the specified filter ...
QSqlDatabase database() const
Returns the model's database connection.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
\reimp
virtual void revertRow(int row)
Reverts all changes for the specified row.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void truncate(qsizetype pos)
Truncates the string at the given position index.
qsizetype size() const
Returns the number of characters in this string.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
QString section(QChar sep, qsizetype start, qsizetype end=-1, SectionFlags flags=SectionDefault) const
This function returns a section of the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & prepend(QChar c)
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLsizei GLsizei GLint * values
[15]
GLsizei const GLfloat * v
[13]
GLenum GLenum GLsizei count
GLenum GLenum GLsizei void GLsizei void * column
GLenum GLenum GLsizei void * row
GLenum GLenum GLsizei void * table
QRelatedTableModel * model
void init(QSqlRelationalTableModel *parent, const QSqlRelation &relation)
void populateDictionary()
QHash< QString, QVariant > dictionary
bool isDictionaryInitialized()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent