summaryrefslogtreecommitdiffstats
path: root/src/sql/kernel/qsqlfield.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/sql/kernel/qsqlfield.h')
-rw-r--r--src/sql/kernel/qsqlfield.h99
1 files changed, 51 insertions, 48 deletions
diff --git a/src/sql/kernel/qsqlfield.h b/src/sql/kernel/qsqlfield.h
index 892420d26e..451f70f3b6 100644
--- a/src/sql/kernel/qsqlfield.h
+++ b/src/sql/kernel/qsqlfield.h
@@ -1,46 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSql module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QSQLFIELD_H
#define QSQLFIELD_H
#include <QtSql/qtsqlglobal.h>
+#include <QtCore/qshareddata.h>
#include <QtCore/qvariant.h>
#include <QtCore/qstring.h>
@@ -48,22 +13,38 @@ QT_BEGIN_NAMESPACE
class QSqlFieldPrivate;
+QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QSqlFieldPrivate, Q_SQL_EXPORT)
class Q_SQL_EXPORT QSqlField
{
+ Q_GADGET
public:
enum RequiredStatus { Unknown = -1, Optional = 0, Required = 1 };
- explicit QSqlField(const QString& fieldName = QString(),
- QVariant::Type type = {});
- QSqlField(const QString &fieldName, QVariant::Type type,
- const QString &tableName);
+ Q_PROPERTY(QVariant value READ value WRITE setValue)
+ Q_PROPERTY(QVariant defaultValue READ defaultValue WRITE setDefaultValue)
+ Q_PROPERTY(QString name READ name WRITE setName)
+ Q_PROPERTY(QString tableName READ tableName WRITE setTableName)
+ Q_PROPERTY(QMetaType metaType READ metaType WRITE setMetaType)
+ Q_PROPERTY(RequiredStatus requiredStatus READ requiredStatus WRITE setRequiredStatus)
+ Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
+ Q_PROPERTY(bool generated READ isGenerated WRITE setGenerated)
+ Q_PROPERTY(bool autoValue READ isAutoValue WRITE setAutoValue)
+ Q_PROPERTY(int length READ length WRITE setLength)
+ Q_PROPERTY(int precision READ precision WRITE setPrecision)
+
+ explicit QSqlField(const QString& fieldName = QString(), QMetaType type = QMetaType(), const QString &tableName = QString());
QSqlField(const QSqlField& other);
QSqlField& operator=(const QSqlField& other);
+ QSqlField(QSqlField &&other) noexcept = default;
+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QSqlField)
+ ~QSqlField();
+
+ void swap(QSqlField &other) noexcept { val.swap(other.val); d.swap(other.d); }
+
bool operator==(const QSqlField& other) const;
inline bool operator!=(const QSqlField &other) const { return !operator==(other); }
- ~QSqlField();
void setValue(const QVariant& value);
inline QVariant value() const
@@ -76,17 +57,31 @@ public:
void setReadOnly(bool readOnly);
bool isReadOnly() const;
void clear();
- QVariant::Type type() const;
bool isAutoValue() const;
- void setType(QVariant::Type type);
+ QMetaType metaType() const;
+ void setMetaType(QMetaType type);
+
+#if QT_DEPRECATED_SINCE(6, 0)
+ QT_WARNING_PUSH
+ QT_WARNING_DISABLE_DEPRECATED
+ QT_DEPRECATED_VERSION_X_6_0("Use the constructor using a QMetaType instead")
+ QSqlField(const QString& fieldName, QVariant::Type type, const QString &tableName = QString())
+ : QSqlField(fieldName, QMetaType(type), tableName)
+ {}
+ QT_DEPRECATED_VERSION_X_6_0("Use metaType() instead")
+ QVariant::Type type() const { return QVariant::Type(metaType().id()); };
+ QT_DEPRECATED_VERSION_X_6_0("Use setMetaType() instead")
+ void setType(QVariant::Type type) { setMetaType(QMetaType(int(type))); }
+ QT_WARNING_POP
+#endif
+
void setRequiredStatus(RequiredStatus status);
inline void setRequired(bool required)
{ setRequiredStatus(required ? Required : Optional); }
void setLength(int fieldLength);
void setPrecision(int precision);
void setDefaultValue(const QVariant &value);
- void setSqlType(int type);
void setGenerated(bool gen);
void setAutoValue(bool autoVal);
@@ -94,16 +89,24 @@ public:
int length() const;
int precision() const;
QVariant defaultValue() const;
- int typeID() const;
bool isGenerated() const;
bool isValid() const;
+#if QT_DEPRECATED_SINCE(6, 8)
+ QT_DEPRECATED_VERSION_X_6_8("This internal value is no longer used.")
+ void setSqlType(int type);
+ QT_DEPRECATED_VERSION_X_6_8("This internal value is no longer used.")
+ int typeID() const;
+#endif
private:
void detach();
+ // ### Qt7: move to private class
QVariant val;
- QSqlFieldPrivate* d;
+ QExplicitlySharedDataPointer<QSqlFieldPrivate> d;
};
+Q_DECLARE_SHARED(QSqlField)
+
#ifndef QT_NO_DEBUG_STREAM
Q_SQL_EXPORT QDebug operator<<(QDebug, const QSqlField &);
#endif