Changeset View
Changeset View
Standalone View
Standalone View
src/KDbQueryColumnInfo.cpp
1 | /* This file is part of the KDE project | 1 | /* This file is part of the KDE project | ||
---|---|---|---|---|---|
2 | Copyright (C) 2003-2016 Jarosław Staniek <staniek@kde.org> | 2 | Copyright (C) 2003-2018 Jarosław Staniek <staniek@kde.org> | ||
3 | 3 | | |||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public | ||
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. | ||
8 | 8 | | |||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Library General Public License for more details. | 12 | Library General Public License for more details. | ||
13 | 13 | | |||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | * Boston, MA 02110-1301, USA. | 17 | * Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "KDbQueryColumnInfo.h" | 20 | #include "KDbQueryColumnInfo.h" | ||
21 | #include "KDbQuerySchema_p.h" | ||||
21 | #include "KDbTableSchema.h" | 22 | #include "KDbTableSchema.h" | ||
22 | #include "KDbField.h" | 23 | #include "KDbField.h" | ||
23 | #include "KDbField_p.h" | 24 | #include "KDbField_p.h" | ||
24 | #include "kdb_debug.h" | 25 | #include "kdb_debug.h" | ||
25 | 26 | | |||
26 | //! @internal | | |||
27 | class Q_DECL_HIDDEN KDbQueryColumnInfo::Private | | |||
28 | { | | |||
29 | public: | | |||
30 | Private(KDbField *f, const QString& a, bool v, KDbQueryColumnInfo *foreign) | | |||
31 | : field(f) | | |||
32 | , alias(a) | | |||
33 | , visible(v) | | |||
34 | , indexForVisibleLookupValue(-1) | | |||
35 | , foreignColumn(foreign) | | |||
36 | { | | |||
37 | } | | |||
38 | | ||||
39 | KDbField *field; | | |||
40 | QString alias; | | |||
41 | | ||||
42 | //! @c true if this column is visible to the user (and its data is fetched by the engine) | | |||
43 | bool visible; | | |||
44 | | ||||
45 | /*! Index of column with visible lookup value within the 'fields expanded' vector. | | |||
46 | @see KDbQueryColumnInfo::indexForVisibleLookupValue() */ | | |||
47 | int indexForVisibleLookupValue; | | |||
48 | | ||||
49 | //! Non-nullptr if this column is a visible column for @a foreignColumn | | |||
50 | KDbQueryColumnInfo *foreignColumn; | | |||
51 | }; | | |||
52 | | ||||
53 | KDbQueryColumnInfo::KDbQueryColumnInfo(KDbField *f, const QString& alias, bool visible, | 27 | KDbQueryColumnInfo::KDbQueryColumnInfo(KDbField *f, const QString& alias, bool visible, | ||
54 | KDbQueryColumnInfo *foreignColumn) | 28 | KDbQueryColumnInfo *foreignColumn) | ||
55 | : d(new Private(f, alias, visible, foreignColumn)) | 29 | : d(new Private(f, alias, visible, foreignColumn)) | ||
56 | { | 30 | { | ||
57 | } | 31 | } | ||
58 | 32 | | |||
59 | KDbQueryColumnInfo::~KDbQueryColumnInfo() | 33 | KDbQueryColumnInfo::~KDbQueryColumnInfo() | ||
60 | { | 34 | { | ||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 94 | { | |||
121 | return d->foreignColumn; | 95 | return d->foreignColumn; | ||
122 | } | 96 | } | ||
123 | 97 | | |||
124 | const KDbQueryColumnInfo *KDbQueryColumnInfo::foreignColumn() const | 98 | const KDbQueryColumnInfo *KDbQueryColumnInfo::foreignColumn() const | ||
125 | { | 99 | { | ||
126 | return d->foreignColumn; | 100 | return d->foreignColumn; | ||
127 | } | 101 | } | ||
128 | 102 | | |||
103 | const KDbQuerySchema* KDbQueryColumnInfo::querySchema() const | ||||
104 | { | ||||
105 | return d->querySchema; | ||||
106 | } | ||||
107 | | ||||
108 | KDbConnection* KDbQueryColumnInfo::connection() | ||||
109 | { | ||||
110 | return d->connection; | ||||
111 | } | ||||
112 | | ||||
113 | const KDbConnection* KDbQueryColumnInfo::connection() const | ||||
114 | { | ||||
115 | return d->connection; | ||||
116 | } | ||||
117 | | ||||
129 | QDebug operator<<(QDebug dbg, const KDbQueryColumnInfo& info) | 118 | QDebug operator<<(QDebug dbg, const KDbQueryColumnInfo& info) | ||
130 | { | 119 | { | ||
131 | QString fieldName; | 120 | QString fieldName; | ||
132 | if (info.field()->name().isEmpty()) { | 121 | if (info.field()->name().isEmpty()) { | ||
133 | fieldName = QLatin1String("<NONAME>"); | 122 | fieldName = QLatin1String("<NONAME>"); | ||
134 | } else { | 123 | } else { | ||
135 | fieldName = info.field()->name(); | 124 | fieldName = info.field()->name(); | ||
136 | } | 125 | } | ||
Show All 9 Lines |