KDb

KDbQueryColumnInfo.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2003-2018 Jarosław Staniek <staniek@kde.org>
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
27KDbQueryColumnInfo::KDbQueryColumnInfo(KDbField *f, const QString& alias, bool visible,
28 KDbQueryColumnInfo *foreignColumn)
29 : d(new Private(f, alias, visible, foreignColumn))
30{
31}
32
33KDbQueryColumnInfo::~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
118QDebug 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}
Provides database connection, allowing queries and data modification.
Meta-data for a field.
Definition KDbField.h:72
KDbTableSchema * table()
Definition KDbField.cpp:585
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.
QString captionOrAliasOrName() const
const KDbQuerySchema * querySchema() const
Returns query schema for this column.
void setField(KDbField *field)
Sets the field.
KDbConnection * connection()
Returns connection for this column.
KDbQueryColumnInfo * foreignColumn()
void setIndexForVisibleLookupValue(int index)
void setVisible(bool set)
Sets the visible flag.
QString aliasOrName() const
int indexForVisibleLookupValue() const
KDbQuerySchema provides information about database query.
QDebug & nospace()
QDebug & space()
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.