KDb

KDbQueryColumnInfo.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 2003-2018 JarosÅ‚aw Staniek <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
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
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18 */
19 
20 #include "KDbQueryColumnInfo.h"
21 #include "KDbQuerySchema_p.h"
22 #include "KDbTableSchema.h"
23 #include "KDbField.h"
24 #include "KDbField_p.h"
25 #include "kdb_debug.h"
26 
27 KDbQueryColumnInfo::KDbQueryColumnInfo(KDbField *f, const QString& alias, bool visible,
28  KDbQueryColumnInfo *foreignColumn)
29  : d(new Private(f, alias, visible, foreignColumn))
30 {
31 }
32 
33 KDbQueryColumnInfo::~KDbQueryColumnInfo()
34 {
35  delete d;
36 }
37 
39 {
40  return d->field;
41 }
42 
44 {
45  return d->field;
46 }
47 
49 {
50  d->field = field;
51 }
52 
54 {
55  return d->alias;
56 }
57 
59 {
60  d->alias = alias;
61 }
62 
64 {
65  return d->alias.isEmpty() ? d->field->name() : d->alias;
66 }
67 
69 {
70  return d->field->caption().isEmpty() ? aliasOrName() : d->field->caption();
71 }
72 
74 {
75  return d->visible;
76 }
77 
79 {
80  d->visible = set;
81 }
82 
84 {
85  return d->indexForVisibleLookupValue;
86 }
87 
89 {
90  d->indexForVisibleLookupValue = index;
91 }
92 
94 {
95  return d->foreignColumn;
96 }
97 
99 {
100  return d->foreignColumn;
101 }
102 
104 {
105  return d->querySchema;
106 }
107 
109 {
110  return d->connection;
111 }
112 
114 {
115  return d->connection;
116 }
117 
118 QDebug operator<<(QDebug dbg, const KDbQueryColumnInfo& info)
119 {
120  QString fieldName;
121  if (info.field()->name().isEmpty()) {
122  fieldName = QLatin1String("<NONAME>");
123  } else {
124  fieldName = info.field()->name();
125  }
126  dbg.nospace()
127  << (info.field()->table() ? (info.field()->table()->name() + QLatin1Char('.')) : QString())
128  + fieldName;
129  debug(dbg, *info.field(), KDbFieldDebugNoOptions);
130  dbg.nospace()
131  << qPrintable(info.alias().isEmpty() ? QString() : (QLatin1String(" AS ") + info.alias()))
132  << qPrintable(QLatin1String(info.isVisible() ? nullptr : " [INVISIBLE]"));
133  return dbg.space();
134 }
int indexForVisibleLookupValue() const
void setVisible(bool set)
Sets the visible flag.
KDbTableSchema * table()
Definition: KDbField.cpp:585
QDebug & nospace()
QString name
QDebug & space()
QDataStream & operator<<(QDataStream &out, const KDateTime &dateTime)
QString aliasOrName() const
void setIndexForVisibleLookupValue(int index)
bool isEmpty() const const
const KDbQuerySchema * querySchema() const
Returns query schema for this column.
void setField(KDbField *field)
Sets the field.
QString captionOrAliasOrName() const
KDbQuerySchema provides information about database query.
Meta-data for a field.
Definition: KDbField.h:71
KDbConnection * connection()
Returns connection for this column.
Provides database connection, allowing queries and data modification.
Definition: KDbConnection.h:51
QString name() const
Definition: KDbField.cpp:256
Helper class that assigns additional information for the column in a query.
void setAlias(const QString &alias)
Sets the alias.
KDbQueryColumnInfo * foreignColumn()
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jun 25 2022 06:21:33 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.