25#include "KDbTableViewColumn.h"
27#include "KDbConnection.h"
28#include "KDbConnectionOptions.h"
31#include "KDbQuerySchema.h"
32#include "KDbRecordEditBuffer.h"
33#include "KDbTableViewData.h"
34#include "KDbValidator.h"
44 , relatedData(nullptr)
47 , visibleLookupColumnInfo(nullptr)
51 , relatedDataEditable(false)
52 , headerTextVisible(true)
57 KDbTableViewData* data;
59 QString captionAliasOrName;
63 KDbValidator* validator;
65 KDbTableViewData* relatedData;
66 int relatedDataPKeyID;
71 KDbQueryColumnInfo* columnInfo;
74 KDbQueryColumnInfo* visibleLookupColumnInfo;
81 bool relatedDataEditable;
82 bool headerTextVisible;
92 d->fieldOwned = isOwned == FieldIsOwned::Yes;
97 KDbField::Constraints cconst,
98 KDbField::Options options,
99 int maxLength,
int precision,
105 name, ctype, cconst, options, maxLength, precision, defaultValue, caption, description);
107 d->isDBAware =
false;
108 d->fieldOwned =
true;
109 d->captionAliasOrName = d->field->captionOrName();
118 KDbField::NoConstraints,
122 caption, description);
124 d->isDBAware =
false;
125 d->fieldOwned =
true;
126 d->captionAliasOrName = d->field->captionOrName();
135 Q_ASSERT(aColumnInfo);
136 d->field = aColumnInfo->
field();
137 d->columnInfo = aColumnInfo;
138 d->visibleLookupColumnInfo = aVisibleLookupColumnInfo;
140 d->fieldOwned =
false;
143 if (!d->columnInfo->field()->caption().isEmpty()) {
144 d->captionAliasOrName = d->columnInfo->field()->caption();
147 d->captionAliasOrName = d->columnInfo->alias();
149 if (d->captionAliasOrName.isEmpty())
150 d->captionAliasOrName = d->columnInfo->field()->name();
157 const bool columnFromMasterTable = query.masterTable() == d->columnInfo->field()->table();
158 d->readOnly = !columnFromMasterTable;
168 d->isDBAware =
false;
171KDbTableViewColumn::~KDbTableViewColumn()
176 delete d->relatedData;
183 if (!d->validator->parent())
199 delete d->relatedData;
200 d->relatedData =
nullptr;
210 d->relatedDataPKeyID = id;
211 d->relatedData = data;
219 return d->readOnly || (d->data && d->data->isReadOnly());
229 return d->columnInfo ? d->columnInfo->isVisible() : d->visible;
234 bool changed = d->visible != v;
235 if (d->columnInfo && d->columnInfo->isVisible() != v) {
236 d->columnInfo->setVisible(v);
240 if (changed && d->data) {
241 d->data->columnVisibilityChanged(*
this);
257 d->headerTextVisible = visible;
262 return d->headerTextVisible;
267 return d->captionAliasOrName;
277 return d->relatedData;
282 return d->relatedData;
297 d->relatedDataEditable = set;
302 return d->relatedDataEditable;
307 return d->columnInfo;
312 return d->columnInfo;
317 return d->visibleLookupColumnInfo;
322 return d->visibleLookupColumnInfo;
331bool KDbTableViewColumn::acceptsFirstChar(
const QChar &ch)
const
335 KDbField *visibleField = d->visibleLookupColumnInfo
336 ? d->visibleLookupColumnInfo->
field() : d->field;
352 case KDbField::DateTime:
354 return ch >= QLatin1Char(
'0') && ch <= QLatin1Char(
'9');
372 dbg.
nospace() <<
"TableViewColumn(";
373 dbg.
space() <<
"columnInfo:";
377 dbg.
space() <<
"<NONE>";
380 dbg.
space() <<
"visibleLookupColumnInfo:";
384 dbg.
space() <<
"<NONE>";
386 dbg.
space() <<
"data: KDbTableViewData(";
387 const KDbTableViewData *data = column.d->data;
389 dbg.
space() <<
"count:" << data->count() <<
")";
391 dbg.
space() <<
"<NONE>)";
393 dbg.
space() <<
"relatedData: KDbTableViewData(";
394 const KDbTableViewData *
relatedData = column.d->relatedData;
398 dbg.
space() <<
"<NONE>)";
404 dbg.
space() <<
"<NONE>";
406 dbg.
space() <<
"fieldOwned:" << column.d->fieldOwned;
407 dbg.
space() <<
"validator:";
409 dbg.
space() <<
"<YES>";
411 dbg.
space() <<
"<NO>";
414 dbg.
space() <<
"fieldOwned:" << column.d->fieldOwned;
bool isNumericType() const
QString captionOrName() const
bool isFPNumericType() const
bool isUnsigned() const
if the type has the unsigned attribute
bool isPrimaryKey() const
Helper class that assigns additional information for the column in a query.
KDbQuerySchema provides information about database query.
Definition of a single column for table view.
KDbTableViewData * relatedData()
void setIcon(const QIcon &icon)
KDbValidator * validator() const
bool isRelatedDataEditable() const
friend KDB_EXPORT QDebug operator<<(QDebug, const KDbTableViewColumn &)
Sends information about column column to debug output dbg.
bool isVisible() const
Column visibility. By default column is visible.
void setReadOnly(bool ro)
forces readOnly flag to be set to ro
KDbQueryColumnInfo * visibleLookupColumnInfo()
void setHeaderTextVisible(bool visible)
void setVisible(bool v)
Changes column visibility.
KDbTableViewColumn(KDbField *f, FieldIsOwned isOwned=FieldIsOwned::No)
bool isHeaderTextVisible() const
QString captionAliasOrName() const
void setValidator(KDbValidator *v)
void setRelatedDataEditable(bool set)
KDbQueryColumnInfo * columnInfo()
void setRelatedData(KDbTableViewData *data)
void setData(KDbTableViewData *data)
used by KDbTableViewData::addColumn()
QList< KDbTableViewColumn * > * columns()
A validator extending QValidator with offline-checking for value's validity.
QString name() const const