15#define QSQL_PREFETCH 255
25 const int oldBottomRow =
qMax(
bottom.row(), 0);
36 newBottom =
q->createIndex(
i,
bottom.column());
39 newBottom =
q->createIndex(-1,
bottom.column());
43 if (newBottom.
row() >= 0 && newBottom.
row() >
bottom.row()) {
178 return (!
parent.isValid() && !
d->atEnd);
210 if (!
d->nestedResetLevel)
219 if (!
d->nestedResetLevel)
228 if (!
d->nestedResetLevel)
237 if (!
d->nestedResetLevel)
246 if (!
d->nestedResetLevel)
255 if (!
d->nestedResetLevel)
264 if (!
d->nestedResetLevel)
273 if (!
d->nestedResetLevel)
282 if (!
d->nestedResetLevel)
284 ++
d->nestedResetLevel;
292 --
d->nestedResetLevel;
293 if (!
d->nestedResetLevel)
312 return index.isValid() ? 0 :
d->bottom.row() + 1;
320 return index.isValid() ? 0 :
d->rec.count();
341 if (!
d->rec.isGenerated(
item.column()))
344 if (dItem.
row() >
d->bottom.row())
347 if (!
d->query.seek(dItem.
row())) {
348 d->error =
d->query.lastError();
352 return d->query.value(dItem.
column());
368 if (role ==
Qt::DisplayRole &&
d->rec.count() > section &&
d->columnInQuery(section) != -1)
369 return d->rec.fieldName(section);
387#if QT_DEPRECATED_SINCE(6, 2)
421 bool columnsChanged = (newRec !=
d->rec);
423 if (
d->colOffsets.size() != newRec.
count() || columnsChanged)
424 d->initColOffsets(newRec.
count());
428 d->query = std::move(
query);
432 if (
d->query.isForwardOnly()) {
433 d->error =
QSqlError(
"Forward-only queries cannot be used in a data model"_L1,
439 if (!
d->query.isActive()) {
440 d->error =
d->query.lastError();
490 d->colOffsets.clear();
517 if (
d->headers.size() <= section)
518 d->headers.resize(
qMax(section + 1, 16));
519 d->headers[section][role] =
value;
576 for (
int i = 0;
i < rec.
count(); ++
i)
614 if (
count <= 0 ||
parent.isValid() || column < 0 || column >
d->rec.count())
623 if (
d->colOffsets.size() <
d->rec.count()) {
624 int nVal =
d->colOffsets.isEmpty() ? 0 :
d->colOffsets[
d->colOffsets.size() - 1];
625 d->colOffsets.append(nVal);
626 Q_ASSERT(
d->colOffsets.size() >=
d->rec.count());
628 for (
int i =
column + 1;
i <
d->colOffsets.size(); ++
i)
649 if (
count <= 0 ||
parent.isValid() || column < 0 || column >=
d->rec.count())
657 for (
i =
column;
i <
d->colOffsets.size(); ++
i)
679 int modelColumn =
d->columnInQuery(
item.column());
687#include "moc_qsqlquerymodel.cpp"
void endResetModel()
Completes a model reset operation.
virtual Q_INVOKABLE QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Returns the data for the given role and section in the header with the specified orientation.
void endRemoveRows()
Ends a row removal operation.
void beginRemoveColumns(const QModelIndex &parent, int first, int last)
Begins a column removal operation.
void headerDataChanged(Qt::Orientation orientation, int first, int last)
This signal is emitted whenever a header is changed.
void beginInsertColumns(const QModelIndex &parent, int first, int last)
Begins a column insertion operation.
void endInsertRows()
Ends a row insertion operation.
void beginResetModel()
Begins a model reset operation.
void endRemoveColumns()
Ends a column removal operation.
QModelIndex createIndex(int row, int column, const void *data=nullptr) const
Creates a model index for the given row and column with the internal pointer ptr.
void endInsertColumns()
Ends a column insertion operation.
void beginRemoveRows(const QModelIndex &parent, int first, int last)
Begins a row removal operation.
void beginInsertRows(const QModelIndex &parent, int first, int last)
Begins a row insertion operation.
QObject * parent() const
Returns a pointer to the parent object.
constexpr int row() const noexcept
Returns the row this model index refers to.
constexpr int column() const noexcept
Returns the column this model index refers to.
The QSqlDatabase class handles a connection to a database.
The QSqlError class provides SQL database error information.
The QSqlField class manipulates the fields in SQL database tables and views.
void setReadOnly(bool readOnly)
Sets the read only flag of the field's value to readOnly.
void setGenerated(bool gen)
Sets the generated state.
QVarLengthArray< int, 56 > colOffsets
void initColOffsets(int size)
int columnInQuery(int modelColumn) const
The QSqlQueryModel class provides a read-only data model for SQL result sets.
void beginInsertRows(const QModelIndex &parent, int first, int last)
virtual QModelIndex indexInQuery(const QModelIndex &item) const
Returns the index of the value in the database result set for the given item in the model.
QVariant data(const QModelIndex &item, int role=Qt::DisplayRole) const override
Returns the value for the specified item and role.
QSqlQueryModel(QObject *parent=nullptr)
Creates an empty QSqlQueryModel with the given parent.
void beginRemoveRows(const QModelIndex &parent, int first, int last)
int rowCount(const QModelIndex &parent=QModelIndex()) const override
const QSqlQuery & query(QT6_DECL_NEW_OVERLOAD) const
Returns a reference to the const QSqlQuery object associated with this model.
virtual void queryChange()
This virtual function is called whenever the query changes.
void setLastError(const QSqlError &error)
Protected function which allows derived classes to set the value of the last error that occurred on t...
bool canFetchMore(const QModelIndex &parent=QModelIndex()) const override
void setQuery(QSqlQuery &&query)
Resets the model and sets the data provider to be the given query.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns the header data for the given role in the section of the header with the specified orientatio...
virtual ~QSqlQueryModel()
Destroys the object and frees any allocated resources.
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole) override
Sets the caption for a horizontal header for the specified role to value.
void beginRemoveColumns(const QModelIndex &parent, int first, int last)
QHash< int, QByteArray > roleNames() const override
void fetchMore(const QModelIndex &parent=QModelIndex()) override
void beginInsertColumns(const QModelIndex &parent, int first, int last)
QSqlError lastError() const
Returns information about the last error that occurred on the database.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
\reimp
QSqlRecord record() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual void clear()
Clears the model and releases any acquired resource.
bool insertColumns(int column, int count, const QModelIndex &parent=QModelIndex()) override
Inserts count columns into the model at position column.
bool removeColumns(int column, int count, const QModelIndex &parent=QModelIndex()) override
Removes count columns from the model starting from position column.
The QSqlQuery class provides a means of executing and manipulating SQL statements.
The QSqlRecord class encapsulates a database record.
int count() const
Returns the number of fields in the record.
void setValue(int i, const QVariant &val)
Sets the value of the field at position index to val.
bool isGenerated(int i) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
\macro QT_RESTRICTED_CAST_FROM_ASCII
constexpr size_type size() const noexcept
void resize(qsizetype sz)
Combined button and popup list for selecting options.
static jboolean copy(JNIEnv *, jobject)
#define QByteArrayLiteral(str)
#define QT_IGNORE_DEPRECATIONS(statement)
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMax(const T &a, const T &b)
GLsizei const GLfloat * v
[13]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
#define QT6_IMPL_NEW_OVERLOAD
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent