Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:22:30

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 // Qt-Security score:significant reason:default
0004 
0005 #ifndef QSQLQUERYMODEL_H
0006 #define QSQLQUERYMODEL_H
0007 
0008 #include <QtSql/qtsqlglobal.h>
0009 #include <QtCore/qabstractitemmodel.h>
0010 #include <QtSql/qsqldatabase.h>
0011 
0012 QT_REQUIRE_CONFIG(sqlmodel);
0013 
0014 QT_BEGIN_NAMESPACE
0015 
0016 class QSqlQueryModelPrivate;
0017 class QSqlError;
0018 class QSqlRecord;
0019 class QSqlQuery;
0020 
0021 class Q_SQL_EXPORT QSqlQueryModel: public QAbstractTableModel
0022 {
0023     Q_OBJECT
0024     Q_DECLARE_PRIVATE(QSqlQueryModel)
0025 
0026 public:
0027     explicit QSqlQueryModel(QObject *parent = nullptr);
0028     virtual ~QSqlQueryModel();
0029 
0030     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0031     int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0032     QSqlRecord record(int row) const;
0033     QSqlRecord record() const;
0034 
0035     QVariant data(const QModelIndex &item, int role = Qt::DisplayRole) const override;
0036     QVariant headerData(int section, Qt::Orientation orientation,
0037                         int role = Qt::DisplayRole) const override;
0038     bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
0039                        int role = Qt::EditRole) override;
0040 
0041     bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;
0042     bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override;
0043 
0044 #if QT_REMOVAL_QT7_DEPRECATED_SINCE(6, 2)
0045     QT_DEPRECATED_VERSION_X_6_2("QSqlQuery is not meant to be copied. Pass it by move instead.")
0046     void setQuery(const QSqlQuery &query);
0047 #endif
0048     void setQuery(QSqlQuery &&query);
0049     void setQuery(const QString &query, const QSqlDatabase &db = QSqlDatabase());
0050     void refresh();
0051 #if QT_SQL_REMOVED_SINCE(6, 5)
0052     QSqlQuery query() const;
0053 #endif
0054     const QSqlQuery &query(QT6_DECL_NEW_OVERLOAD) const;
0055 
0056     virtual void clear();
0057 
0058     QSqlError lastError() const;
0059 
0060     void fetchMore(const QModelIndex &parent = QModelIndex()) override;
0061     bool canFetchMore(const QModelIndex &parent = QModelIndex()) const override;
0062 
0063     QHash<int, QByteArray> roleNames() const override;
0064 
0065 protected:
0066     void beginInsertRows(const QModelIndex &parent, int first, int last);
0067     void endInsertRows();
0068 
0069     void beginRemoveRows(const QModelIndex &parent, int first, int last);
0070     void endRemoveRows();
0071 
0072     void beginInsertColumns(const QModelIndex &parent, int first, int last);
0073     void endInsertColumns();
0074 
0075     void beginRemoveColumns(const QModelIndex &parent, int first, int last);
0076     void endRemoveColumns();
0077 
0078     void beginResetModel();
0079     void endResetModel();
0080     virtual void queryChange();
0081 
0082     virtual QModelIndex indexInQuery(const QModelIndex &item) const;
0083     void setLastError(const QSqlError &error);
0084     QSqlQueryModel(QSqlQueryModelPrivate &dd, QObject *parent = nullptr);
0085 };
0086 
0087 QT_END_NAMESPACE
0088 
0089 #endif // QSQLQUERYMODEL_H