| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QSQLINDEX_H |
| 5 | #define QSQLINDEX_H |
| 6 | |
| 7 | #include <QtSql/qtsqlglobal.h> |
| 8 | #include <QtSql/qsqlrecord.h> |
| 9 | #include <QtCore/qlist.h> |
| 10 | #include <QtCore/qmetaobject.h> |
| 11 | #include <QtCore/qstring.h> |
| 12 | |
| 13 | // clazy:excludeall=qproperty-without-notify |
| 14 | QT_BEGIN_NAMESPACE |
| 15 | |
| 16 | |
| 17 | class Q_SQL_EXPORT QSqlIndex : public QSqlRecord |
| 18 | { |
| 19 | Q_GADGET |
| 20 | Q_PROPERTY(QString name READ name WRITE setName) |
| 21 | Q_PROPERTY(QString cursorName READ cursorName WRITE setCursorName) |
| 22 | |
| 23 | public: |
| 24 | explicit QSqlIndex(const QString &cursorName = QString(), const QString &name = QString()); |
| 25 | QSqlIndex(const QSqlIndex &other); |
| 26 | QSqlIndex(QSqlIndex &&other) noexcept = default; |
| 27 | ~QSqlIndex(); |
| 28 | QSqlIndex &operator=(const QSqlIndex &other); |
| 29 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QSqlIndex) |
| 30 | |
| 31 | void swap(QSqlIndex &other) noexcept { |
| 32 | QSqlRecord::swap(other); |
| 33 | cursor.swap(other&: other.cursor); |
| 34 | nm.swap(other&: other.nm); |
| 35 | sorts.swap(other&: other.sorts); |
| 36 | } |
| 37 | |
| 38 | void setCursorName(const QString &cursorName); |
| 39 | inline QString cursorName() const { return cursor; } |
| 40 | void setName(const QString& name); |
| 41 | inline QString name() const { return nm; } |
| 42 | |
| 43 | void append(const QSqlField &field); |
| 44 | void append(const QSqlField &field, bool desc); |
| 45 | |
| 46 | bool isDescending(int i) const; |
| 47 | void setDescending(int i, bool desc); |
| 48 | |
| 49 | private: |
| 50 | // ### Qt7: move to d-ptr |
| 51 | QString cursor; |
| 52 | QString nm; |
| 53 | QList<bool> sorts; |
| 54 | }; |
| 55 | |
| 56 | Q_DECLARE_SHARED(QSqlIndex) |
| 57 | |
| 58 | QT_END_NAMESPACE |
| 59 | |
| 60 | #endif // QSQLINDEX_H |
| 61 |
