pass QSqlDatabase by const &
Change-Id: I326c09ab9313098470cb657571f67755fd7810c7 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
e164d61ca8
commit
3026c0630d
@ -258,7 +258,7 @@ QSqlQuery::QSqlQuery(const QSqlQuery& other)
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
static void qInit(QSqlQuery *q, const QString& query, QSqlDatabase db)
|
||||
static void qInit(QSqlQuery *q, const QString& query, const QSqlDatabase &db)
|
||||
{
|
||||
QSqlDatabase database = db;
|
||||
if (!database.isValid())
|
||||
@ -278,7 +278,7 @@ static void qInit(QSqlQuery *q, const QString& query, QSqlDatabase db)
|
||||
|
||||
\sa QSqlDatabase
|
||||
*/
|
||||
QSqlQuery::QSqlQuery(const QString& query, QSqlDatabase db)
|
||||
QSqlQuery::QSqlQuery(const QString& query, const QSqlDatabase &db)
|
||||
{
|
||||
d = QSqlQueryPrivate::shared_null();
|
||||
qInit(this, query, db);
|
||||
@ -291,7 +291,7 @@ QSqlQuery::QSqlQuery(const QString& query, QSqlDatabase db)
|
||||
\sa QSqlDatabase
|
||||
*/
|
||||
|
||||
QSqlQuery::QSqlQuery(QSqlDatabase db)
|
||||
QSqlQuery::QSqlQuery(const QSqlDatabase &db)
|
||||
{
|
||||
d = QSqlQueryPrivate::shared_null();
|
||||
qInit(this, QString(), db);
|
||||
|
@ -59,8 +59,8 @@ class Q_SQL_EXPORT QSqlQuery
|
||||
{
|
||||
public:
|
||||
explicit QSqlQuery(QSqlResult *r);
|
||||
explicit QSqlQuery(const QString& query = QString(), QSqlDatabase db = QSqlDatabase());
|
||||
explicit QSqlQuery(QSqlDatabase db);
|
||||
explicit QSqlQuery(const QString& query = QString(), const QSqlDatabase &db = QSqlDatabase());
|
||||
explicit QSqlQuery(const QSqlDatabase &db);
|
||||
QSqlQuery(const QSqlQuery& other);
|
||||
QSqlQuery& operator=(const QSqlQuery& other);
|
||||
~QSqlQuery();
|
||||
|
@ -161,7 +161,7 @@ struct QRelation
|
||||
class QRelatedTableModel : public QSqlTableModel
|
||||
{
|
||||
public:
|
||||
QRelatedTableModel(QRelation *rel, QObject *parent = 0, QSqlDatabase db = QSqlDatabase());
|
||||
QRelatedTableModel(QRelation *rel, QObject *parent = 0, const QSqlDatabase &db = QSqlDatabase());
|
||||
bool select() override;
|
||||
private:
|
||||
bool firstSelect;
|
||||
@ -245,7 +245,7 @@ bool QRelation::isValid()
|
||||
|
||||
|
||||
|
||||
QRelatedTableModel::QRelatedTableModel(QRelation *rel, QObject *parent, QSqlDatabase db) :
|
||||
QRelatedTableModel::QRelatedTableModel(QRelation *rel, QObject *parent, const QSqlDatabase &db) :
|
||||
QSqlTableModel(parent, db), firstSelect(true), relation(rel)
|
||||
{
|
||||
}
|
||||
@ -410,7 +410,7 @@ void QSqlRelationalTableModelPrivate::clearCache()
|
||||
and the database connection to \a db. If \a db is not valid, the
|
||||
default database connection will be used.
|
||||
*/
|
||||
QSqlRelationalTableModel::QSqlRelationalTableModel(QObject *parent, QSqlDatabase db)
|
||||
QSqlRelationalTableModel::QSqlRelationalTableModel(QObject *parent, const QSqlDatabase &db)
|
||||
: QSqlTableModel(*new QSqlRelationalTableModelPrivate, parent, db)
|
||||
{
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
};
|
||||
|
||||
explicit QSqlRelationalTableModel(QObject *parent = nullptr,
|
||||
QSqlDatabase db = QSqlDatabase());
|
||||
const QSqlDatabase &db = QSqlDatabase());
|
||||
virtual ~QSqlRelationalTableModel();
|
||||
|
||||
QVariant data(const QModelIndex &item, int role = Qt::DisplayRole) const override;
|
||||
|
@ -291,7 +291,7 @@ bool QSqlTableModelPrivate::exec(const QString &stmt, bool prepStatement,
|
||||
|
||||
The default edit strategy is \l OnRowChange.
|
||||
*/
|
||||
QSqlTableModel::QSqlTableModel(QObject *parent, QSqlDatabase db)
|
||||
QSqlTableModel::QSqlTableModel(QObject *parent, const QSqlDatabase &db)
|
||||
: QSqlQueryModel(*new QSqlTableModelPrivate, parent)
|
||||
{
|
||||
Q_D(QSqlTableModel);
|
||||
@ -300,7 +300,7 @@ QSqlTableModel::QSqlTableModel(QObject *parent, QSqlDatabase db)
|
||||
|
||||
/*! \internal
|
||||
*/
|
||||
QSqlTableModel::QSqlTableModel(QSqlTableModelPrivate &dd, QObject *parent, QSqlDatabase db)
|
||||
QSqlTableModel::QSqlTableModel(QSqlTableModelPrivate &dd, QObject *parent, const QSqlDatabase &db)
|
||||
: QSqlQueryModel(dd, parent)
|
||||
{
|
||||
Q_D(QSqlTableModel);
|
||||
|
@ -62,7 +62,7 @@ class Q_SQL_EXPORT QSqlTableModel: public QSqlQueryModel
|
||||
public:
|
||||
enum EditStrategy {OnFieldChange, OnRowChange, OnManualSubmit};
|
||||
|
||||
explicit QSqlTableModel(QObject *parent = nullptr, QSqlDatabase db = QSqlDatabase());
|
||||
explicit QSqlTableModel(QObject *parent = nullptr, const QSqlDatabase &db = QSqlDatabase());
|
||||
virtual ~QSqlTableModel();
|
||||
|
||||
virtual void setTable(const QString &tableName);
|
||||
@ -127,7 +127,7 @@ Q_SIGNALS:
|
||||
void beforeDelete(int row);
|
||||
|
||||
protected:
|
||||
QSqlTableModel(QSqlTableModelPrivate &dd, QObject *parent = nullptr, QSqlDatabase db = QSqlDatabase());
|
||||
QSqlTableModel(QSqlTableModelPrivate &dd, QObject *parent = nullptr, const QSqlDatabase &db = QSqlDatabase());
|
||||
|
||||
virtual bool updateRowInTable(int row, const QSqlRecord &values);
|
||||
virtual bool insertRowIntoTable(const QSqlRecord &values);
|
||||
|
Loading…
Reference in New Issue
Block a user