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/qstring.h> |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | |
15 | class Q_SQL_EXPORT QSqlIndex : public QSqlRecord |
16 | { |
17 | public: |
18 | explicit QSqlIndex(const QString &cursorName = QString(), const QString &name = QString()); |
19 | QSqlIndex(const QSqlIndex &other); |
20 | QSqlIndex(QSqlIndex &&other) noexcept = default; |
21 | ~QSqlIndex(); |
22 | QSqlIndex &operator=(const QSqlIndex &other); |
23 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QSqlIndex) |
24 | |
25 | void swap(QSqlIndex &other) noexcept { |
26 | QSqlRecord::swap(other); |
27 | cursor.swap(other&: other.cursor); |
28 | nm.swap(other&: other.nm); |
29 | sorts.swap(other&: other.sorts); |
30 | }; |
31 | |
32 | void setCursorName(const QString &cursorName); |
33 | inline QString cursorName() const { return cursor; } |
34 | void setName(const QString& name); |
35 | inline QString name() const { return nm; } |
36 | |
37 | void append(const QSqlField &field); |
38 | void append(const QSqlField &field, bool desc); |
39 | |
40 | bool isDescending(int i) const; |
41 | void setDescending(int i, bool desc); |
42 | |
43 | private: |
44 | QString createField(int i, const QString& prefix, bool verbose) const; |
45 | // ### Qt7: move to d-ptr |
46 | QString cursor; |
47 | QString nm; |
48 | QList<bool> sorts; |
49 | }; |
50 | |
51 | Q_DECLARE_SHARED(QSqlIndex) |
52 | |
53 | QT_END_NAMESPACE |
54 | |
55 | #endif // QSQLINDEX_H |
56 |