1// qsqltablemodel.sip generated by MetaSIP
2//
3// This file is part of the QtSql Python extension module.
4//
5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com>
6//
7// This file is part of PyQt5.
8//
9// This file may be used under the terms of the GNU General Public License
10// version 3.0 as published by the Free Software Foundation and appearing in
11// the file LICENSE included in the packaging of this file.  Please review the
12// following information to ensure the GNU General Public License version 3.0
13// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
14//
15// If you do not wish to use this file under the terms of the GPL version 3.0
16// then you may purchase a commercial license.  For more information contact
17// info@riverbankcomputing.com.
18//
19// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21
22
23class QSqlTableModel : QSqlQueryModel
24{
25%TypeHeaderCode
26#include <qsqltablemodel.h>
27%End
28
29public:
30    enum EditStrategy
31    {
32        OnFieldChange,
33        OnRowChange,
34        OnManualSubmit,
35    };
36
37    QSqlTableModel(QObject *parent /TransferThis/ = 0, QSqlDatabase db = QSqlDatabase());
38    virtual ~QSqlTableModel();
39    virtual bool select();
40    virtual void setTable(const QString &tableName);
41    QString tableName() const;
42    virtual Qt::ItemFlags flags(const QModelIndex &index) const;
43    virtual QVariant data(const QModelIndex &idx, int role = Qt::ItemDataRole::DisplayRole) const;
44    virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::ItemDataRole::EditRole);
45    virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::ItemDataRole::DisplayRole) const;
46    bool isDirty(const QModelIndex &index) const;
47    bool isDirty() const;
48    virtual void clear();
49    virtual void setEditStrategy(QSqlTableModel::EditStrategy strategy);
50    QSqlTableModel::EditStrategy editStrategy() const;
51    QSqlIndex primaryKey() const;
52    QSqlDatabase database() const;
53    int fieldIndex(const QString &fieldName) const;
54    virtual void sort(int column, Qt::SortOrder order);
55    virtual void setSort(int column, Qt::SortOrder order);
56    QString filter() const;
57    virtual void setFilter(const QString &filter);
58    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
59    virtual bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex());
60    virtual bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
61    virtual bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
62    bool insertRecord(int row, const QSqlRecord &record);
63    bool setRecord(int row, const QSqlRecord &record);
64    virtual void revertRow(int row);
65
66public slots:
67    virtual bool submit();
68    virtual void revert();
69    bool submitAll();
70    void revertAll();
71
72signals:
73    void primeInsert(int row, QSqlRecord &record);
74    void beforeInsert(QSqlRecord &record);
75    void beforeUpdate(int row, QSqlRecord &record);
76    void beforeDelete(int row);
77
78protected:
79    virtual bool updateRowInTable(int row, const QSqlRecord &values);
80    virtual bool insertRowIntoTable(const QSqlRecord &values);
81    virtual bool deleteRowFromTable(int row);
82    virtual QString orderByClause() const;
83    virtual QString selectStatement() const;
84    void setPrimaryKey(const QSqlIndex &key);
85    void setQuery(const QSqlQuery &query);
86    virtual QModelIndex indexInQuery(const QModelIndex &item) const;
87
88public:
89    virtual bool selectRow(int row);
90    QSqlRecord record() const;
91    QSqlRecord record(int row) const;
92
93protected:
94%If (Qt_5_1_0 -)
95    QSqlRecord primaryValues(int row) const;
96%End
97};
98