KDb

KDbLookupFieldSchema.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 2006-2016 JarosÅ‚aw Staniek <[email protected]>
3 
4  This program 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 program 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 program; see the file COPYING. 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 "KDbLookupFieldSchema.h"
21 #include "KDb.h"
22 #include "kdb_debug.h"
23 
24 #include <QDomElement>
25 #include <QVariant>
26 #include <QStringList>
27 #include <QHash>
28 
29 #include <vector>
30 
31 //! @internal
32 class Q_DECL_HIDDEN KDbLookupFieldSchemaRecordSource::Private
33 {
34 public:
35  Private()
37  }
38  Private(const Private &other) {
39  copy(other);
40  }
41 #define KDbLookupFieldSchemaRecordSourcePrivateArgs(o) std::tie(o.type, o.name, o.values)
42  void copy(const Private &other) {
43  KDbLookupFieldSchemaRecordSourcePrivateArgs((*this))
44  = KDbLookupFieldSchemaRecordSourcePrivateArgs(other);
45  }
46  bool operator==(const KDbLookupFieldSchemaRecordSource::Private &other) const {
47  return KDbLookupFieldSchemaRecordSourcePrivateArgs((*this))
48  == KDbLookupFieldSchemaRecordSourcePrivateArgs(other);
49  }
50 
52  QString name;
54 };
55 
56 //! @internal
57 class Q_DECL_HIDDEN KDbLookupFieldSchema::Private
58 {
59 public:
60  Private()
61  : boundColumn(-1)
62  , maxVisibleRecords(KDB_LOOKUP_FIELD_DEFAULT_MAX_VISIBLE_RECORDS)
63  , displayWidget(KDB_LOOKUP_FIELD_DEFAULT_DISPLAY_WIDGET)
64  , columnHeadersVisible(KDB_LOOKUP_FIELD_DEFAULT_HEADERS_VISIBLE)
65  , limitToList(KDB_LOOKUP_FIELD_DEFAULT_LIMIT_TO_LIST) {
66  }
67  Private(const Private &other) {
68  copy(other);
69  }
70 #define KDbLookupFieldSchemaPrivateArgs(o) std::tie(o.recordSource, o.boundColumn, o.visibleColumns, \
71  o.columnWidths, o.maxVisibleRecords, o.displayWidget, \
72  o.columnHeadersVisible, o.limitToList)
73  void copy(const Private &other) {
74  KDbLookupFieldSchemaPrivateArgs((*this)) = KDbLookupFieldSchemaPrivateArgs(other);
75  }
76  bool operator==(const KDbLookupFieldSchema::Private &other) const {
77  return KDbLookupFieldSchemaPrivateArgs((*this)) == KDbLookupFieldSchemaPrivateArgs(other);
78  }
79 
81  int boundColumn;
82  QList<int> visibleColumns;
83  QList<int> columnWidths;
84  int maxVisibleRecords;
85  DisplayWidget displayWidget;
86  bool columnHeadersVisible;
87  bool limitToList;
88 };
89 
90 //! Cache
91 class LookupFieldSchemaStatic
92 {
93 public:
94  LookupFieldSchemaStatic()
95  : typeNames({
96  QString(), // no type
97  QLatin1String("table"),
98  QLatin1String("query"),
99  QLatin1String("sql"),
100  QLatin1String("valuelist"),
101  QLatin1String("fieldlist")})
102  {
103  typesForNames.insert(QLatin1String("table"), KDbLookupFieldSchemaRecordSource::Type::Table);
104  typesForNames.insert(QLatin1String("query"), KDbLookupFieldSchemaRecordSource::Type::Query);
106  typesForNames.insert(QLatin1String("valuelist"), KDbLookupFieldSchemaRecordSource::Type::ValueList);
107  typesForNames.insert(QLatin1String("fieldlist"), KDbLookupFieldSchemaRecordSource::Type::KDbFieldList);
108  }
109  const std::vector<QString> typeNames;
111 private:
112  Q_DISABLE_COPY(LookupFieldSchemaStatic)
113 };
114 
115 Q_GLOBAL_STATIC(LookupFieldSchemaStatic, KDb_lookupFieldSchemaStatic)
116 
117 //----------------------------
118 
119 KDbLookupFieldSchemaRecordSource::KDbLookupFieldSchemaRecordSource()
120  : d(new Private)
121 {
122 }
123 
124 KDbLookupFieldSchemaRecordSource::KDbLookupFieldSchemaRecordSource(const KDbLookupFieldSchemaRecordSource& other)
125  : d(new Private(*other.d))
126 {
127 }
128 
129 KDbLookupFieldSchemaRecordSource::~KDbLookupFieldSchemaRecordSource()
130 {
131  delete d;
132 }
133 
135 {
136  return d->type;
137 }
138 
140 {
141  d->type = type;
142 }
143 
145 {
146  return d->name;
147 }
148 
150 {
151  d->name = name;
152  d->values.clear();
153 }
154 
156 {
157  Q_ASSERT(size_t(d->type) < KDb_lookupFieldSchemaStatic->typeNames.size());
158  return KDb_lookupFieldSchemaStatic->typeNames[static_cast<int>(d->type)];
159 }
160 
162 {
163  setType(KDb_lookupFieldSchemaStatic->typesForNames.value(typeName, Type::None));
164 }
165 
167 {
168  return d->values;
169 }
170 
172 {
173  d->name.clear();
174  d->values = values;
175 }
176 
178 {
179  if (this != &other) {
180  *d = *other.d;
181  }
182  return *this;
183 }
184 
186 {
187  return *d == *other.d;
188 }
189 
191 {
192  dbg.nospace() << "LookupFieldSchemaRecordSource TYPE:";
193  dbg.space() << source.typeName();
194  dbg.space() << "NAME:";
195  dbg.space() << source.name();
196  dbg.space() << "VALUES:";
197  dbg.space() << source.values().join(QLatin1String("|")) << '\n';
198  return dbg.nospace();
199 }
200 
201 //----------------------------
202 
203 KDbLookupFieldSchema::KDbLookupFieldSchema()
204  : d(new Private)
205 {
206 }
207 
208 KDbLookupFieldSchema::KDbLookupFieldSchema(const KDbLookupFieldSchema &schema)
209 : d(new Private(*schema.d))
210 {
211 }
212 
213 KDbLookupFieldSchema::~KDbLookupFieldSchema()
214 {
215  delete d;
216 }
217 
218 static bool setBoundColumn(KDbLookupFieldSchema *lookup, const QVariant &val)
219 {
220  if (val.isNull()) {
221  lookup->setBoundColumn(-1);
222  }
223  else {
224  bool ok;
225  const int ival = val.toInt(&ok);
226  if (!ok)
227  return false;
228  lookup->setBoundColumn(ival);
229  }
230  return true;
231 }
232 
233 static bool setVisibleColumns(KDbLookupFieldSchema *lookup, const QVariant &val)
234 {
235  QList<QVariant> variantList;
236  if (val.canConvert(QVariant::Int)) {
237  //! @todo Remove this case: it's for backward compatibility with Kexi's 1.1.2 table designer GUI
238  //! supporting only single lookup column.
239  variantList.append(val);
240  }
241  else {
242  variantList = val.toList();
243  }
244  QList<int> visibleColumns;
245  foreach(const QVariant& variant, variantList) {
246  bool ok;
247  const int ival = variant.toInt(&ok);
248  if (!ok) {
249  return false;
250  }
251  visibleColumns.append(ival);
252  }
253  lookup->setVisibleColumns(visibleColumns);
254  return true;
255 }
256 
257 static bool setColumnWidths(KDbLookupFieldSchema *lookup, const QVariant &val)
258 {
259  QList<int> widths;
260  foreach(const QVariant& variant, val.toList()) {
261  bool ok;
262  const int ival = variant.toInt(&ok);
263  if (!ok)
264  return false;
265  widths.append(ival);
266  }
267  lookup->setColumnWidths(widths);
268  return true;
269 }
270 
271 static bool setDisplayWidget(KDbLookupFieldSchema *lookup, const QVariant &val)
272 {
273  bool ok;
274  const uint ival = val.toUInt(&ok);
275  if (!ok || ival > static_cast<uint>(KDbLookupFieldSchema::DisplayWidget::ListBox)) {
276  return false;
277  }
278  lookup->setDisplayWidget(static_cast<KDbLookupFieldSchema::DisplayWidget>(ival));
279  return true;
280 }
281 
283 {
284  return d->recordSource;
285 }
286 
288 {
289  d->recordSource = recordSource;
290 }
291 
293 {
294  if (count == 0)
295  d->maxVisibleRecords = KDB_LOOKUP_FIELD_DEFAULT_MAX_VISIBLE_RECORDS;
296  else if (count > KDB_LOOKUP_FIELD_LIMIT_MAX_VISIBLE_RECORDS)
297  d->maxVisibleRecords = KDB_LOOKUP_FIELD_LIMIT_MAX_VISIBLE_RECORDS;
298  else
299  d->maxVisibleRecords = count;
300 }
301 
302 QDebug operator<<(QDebug dbg, const KDbLookupFieldSchema& lookup)
303 {
304  dbg.nospace() << "LookupFieldSchema(";
305  dbg.space() << lookup.recordSource();
306  dbg.space() << "boundColumn:";
307  dbg.space() << lookup.boundColumn();
308  dbg.space() << "visibleColumns:";
309 
310  bool first = true;
311  foreach(int visibleColumn, lookup.visibleColumns()) {
312  if (first) {
313  first = false;
314  dbg.nospace();
315  }
316  else
317  dbg.nospace() << ';';
318  dbg.nospace() << visibleColumn;
319  }
320  dbg.space() << "maxVisibleRecords:";
321  dbg.space() << lookup.maxVisibleRecords();
322  dbg.space() << "displayWidget:";
324  ? "ComboBox"
325  : "ListBox");
326  dbg.space() << "columnHeadersVisible:";
327  dbg.space() << lookup.columnHeadersVisible();
328  dbg.space() << "limitToList:";
329  dbg.space() << lookup.limitToList();
330  dbg.space() << "columnWidths:";
331 
332  first = true;
333  const QList<int> columnWidths(lookup.columnWidths());
334  for (int width : columnWidths) {
335  if (first)
336  first = false;
337  else
338  dbg.nospace() << ';';
339  dbg.space() << width;
340  }
341  dbg.nospace() << ')';
342  return dbg.space();
343 }
344 
345 /* static */
347 {
348  KDbLookupFieldSchema *lookupFieldSchema = new KDbLookupFieldSchema();
350  for (QDomNode node = lookupEl.firstChild(); !node.isNull(); node = node.nextSibling()) {
351  QDomElement el = node.toElement();
352  const QByteArray name(el.tagName().toLatin1());
353  if (name == "row-source") {
354  /*<row-source>
355  empty
356  | <type>table|query|sql|valuelist|fieldlist</type> #required because there can be
357  #table and query with the same name
358  #"fieldlist" (basically a list of
359  #column names of a table/query,
360  #"Field List" as in MSA)
361  <name>string</name> #table/query name, etc. or KDbSQL SELECT QUERY
362  <values><value>...</value> #for "valuelist" type
363  <value>...</value>
364  </values>
365  </row-source> */
366  for (el = el.firstChild().toElement(); !el.isNull(); el = el.nextSibling().toElement()) {
367  const QByteArray childName(el.tagName().toLatin1());
368  if (childName == "type") {
370  }
371  else if (childName == "name") {
372  recordSource.setName(el.text());
373 //! @todo handle fieldlist (retrieve from external table or so?), use KDbLookupFieldSchemaRecordSource::setValues()
374  }
375  }
376  } else if (name == "bound-column") {
377  /* <bound-column>
378  <number>number</number> #in later implementation there can be more columns
379  </bound-column> */
380  bool ok;
381  const QVariant val = KDb::loadPropertyValueFromDom(el.firstChild(), &ok);
382  if (!ok || !::setBoundColumn(lookupFieldSchema, val)) {
383  delete lookupFieldSchema;
384  return nullptr;
385  }
386  } else if (name == "visible-column") {
387  /* <visible-column> #a column that has to be visible in the combo box
388  <number>number 1</number>
389  <number>number 2</number>
390  [..]
391  </visible-column> */
392  QVariantList list;
393  for (QDomNode childNode = el.firstChild(); !childNode.isNull();
394  childNode = childNode.nextSibling())
395  {
396  bool ok;
397  const QVariant val = KDb::loadPropertyValueFromDom(childNode, &ok);
398  if (!ok) {
399  delete lookupFieldSchema;
400  return nullptr;
401  }
402  list.append(val);
403  }
404  if (!::setVisibleColumns(lookupFieldSchema, list)) {
405  delete lookupFieldSchema;
406  return nullptr;
407  }
408  } else if (name == "column-widths") {
409  /* <column-widths> #column widths, -1 means 'default'
410  <number>int</number>
411  ...
412  <number>int</number>
413  </column-widths> */
414  QVariantList columnWidths;
415  for (el = el.firstChild().toElement(); !el.isNull(); el = el.nextSibling().toElement()) {
416  bool ok;
418  if (!ok) {
419  delete lookupFieldSchema;
420  return nullptr;
421  }
422  columnWidths.append(val);
423  }
424  if (!::setColumnWidths(lookupFieldSchema, columnWidths)) {
425  delete lookupFieldSchema;
426  return nullptr;
427  }
428  } else if (name == "show-column-headers") {
429  /* <show-column-headers>
430  <bool>true/false</bool>
431  </show-column-headers> */
432  bool ok;
433  const QVariant val = KDb::loadPropertyValueFromDom(el.firstChild(), &ok);
434  if (!ok) {
435  delete lookupFieldSchema;
436  return nullptr;
437  }
438  if (val.type() == QVariant::Bool)
439  lookupFieldSchema->setColumnHeadersVisible(val.toBool());
440  } else if (name == "list-rows") {
441  /* <list-rows>
442  <number>1..100</number>
443  </list-rows> */
444  bool ok;
445  const QVariant val = KDb::loadPropertyValueFromDom(el.firstChild(), &ok);
446  if (!ok) {
447  delete lookupFieldSchema;
448  return nullptr;
449  }
450  if (val.type() == QVariant::Int)
451  lookupFieldSchema->setMaxVisibleRecords(val.toInt());
452  } else if (name == "limit-to-list") {
453  /* <limit-to-list>
454  <bool>true/false</bool>
455  </limit-to-list> */
456  bool ok;
457  const QVariant val = KDb::loadPropertyValueFromDom(el.firstChild(), &ok);
458  if (!ok) {
459  delete lookupFieldSchema;
460  return nullptr;
461  }
462  if (val.type() == QVariant::Bool)
463  lookupFieldSchema->setLimitToList(val.toBool());
464  }
465  else if (name == "display-widget") {
466  const QByteArray displayWidgetName(el.text().toLatin1());
467  if (displayWidgetName == "combobox") {
469  }
470  else if (displayWidgetName == "listbox") {
472  }
473  }
474  }
475  lookupFieldSchema->setRecordSource(recordSource);
476  return lookupFieldSchema;
477 }
478 
480 {
481  if (!doc || !parentEl) {
482  return;
483  }
484  QDomElement lookupColumnEl, recordSourceEl, recordSourceTypeEl, nameEl;
485  if (!recordSource().name().isEmpty()) {
486  lookupColumnEl = doc->createElement(QLatin1String("lookup-column"));
487  parentEl->appendChild(lookupColumnEl);
488 
489  recordSourceEl = doc->createElement(QLatin1String("row-source"));
490  lookupColumnEl.appendChild(recordSourceEl);
491 
492  recordSourceTypeEl = doc->createElement(QLatin1String("type"));
493  recordSourceEl.appendChild(recordSourceTypeEl);
494  recordSourceTypeEl.appendChild(doc->createTextNode(recordSource().typeName())); //can be empty
495 
496  nameEl = doc->createElement(QLatin1String("name"));
497  recordSourceEl.appendChild(nameEl);
498  nameEl.appendChild(doc->createTextNode(recordSource().name()));
499  }
500 
502  if (!values.isEmpty()) {
503  QDomElement valuesEl(doc->createElement(QLatin1String("values")));
504  recordSourceEl.appendChild(valuesEl);
505  for (QStringList::ConstIterator it = values.constBegin(); it != values.constEnd(); ++it) {
506  QDomElement valueEl(doc->createElement(QLatin1String("value")));
507  valuesEl.appendChild(valueEl);
508  valueEl.appendChild(doc->createTextNode(*it));
509  }
510  }
511 
512  if (boundColumn() >= 0) {
513  KDb::saveNumberElementToDom(doc, &lookupColumnEl,
514  QLatin1String("bound-column"), boundColumn());
515  }
516 
518  if (!visibleColumns.isEmpty()) {
519  QDomElement visibleColumnEl(doc->createElement(QLatin1String("visible-column")));
520  lookupColumnEl.appendChild(visibleColumnEl);
521  foreach(int visibleColumn, visibleColumns) {
522  QDomElement numberEl(doc->createElement(QLatin1String("number")));
523  visibleColumnEl.appendChild(numberEl);
525  }
526  }
527 
528  const QList<int> columnWidths(this->columnWidths());
529  if (!columnWidths.isEmpty()) {
530  QDomElement columnWidthsEl(doc->createElement(QLatin1String("column-widths")));
531  lookupColumnEl.appendChild(columnWidthsEl);
532  foreach(int columnWidth, columnWidths) {
533  QDomElement columnWidthEl(doc->createElement(QLatin1String("number")));
534  columnWidthsEl.appendChild(columnWidthEl);
535  columnWidthEl.appendChild(doc->createTextNode(QString::number(columnWidth)));
536  }
537  }
538 
539  if (columnHeadersVisible() != KDB_LOOKUP_FIELD_DEFAULT_HEADERS_VISIBLE)
540  KDb::saveBooleanElementToDom(doc, &lookupColumnEl,
541  QLatin1String("show-column-headers"),
543  if (maxVisibleRecords() != KDB_LOOKUP_FIELD_DEFAULT_MAX_VISIBLE_RECORDS)
544  KDb::saveNumberElementToDom(doc, &lookupColumnEl,
545  QLatin1String("list-rows"),
547  if (limitToList() != KDB_LOOKUP_FIELD_DEFAULT_LIMIT_TO_LIST)
548  KDb::saveBooleanElementToDom(doc, &lookupColumnEl,
549  QLatin1String("limit-to-list"),
550  limitToList());
551 
552  if (displayWidget() != KDB_LOOKUP_FIELD_DEFAULT_DISPLAY_WIDGET) {
553  QDomElement displayWidgetEl(doc->createElement(QLatin1String("display-widget")));
554  lookupColumnEl.appendChild(displayWidgetEl);
555  displayWidgetEl.appendChild(
556  doc->createTextNode(
557  QLatin1String((displayWidget() == DisplayWidget::ListBox) ? "listbox" : "combobox")));
558  }
559 }
560 
562 {
563  values->clear();
564  KDb::getProperties(this, values);
565 }
566 
567 bool KDbLookupFieldSchema::setProperty(const QByteArray& propertyName, const QVariant& value)
568 {
569  bool ok;
570  if ( "rowSource" == propertyName
571  || "rowSourceType" == propertyName
572  || "rowSourceValues" == propertyName)
573  {
575  if ("rowSource" == propertyName)
576  recordSource.setName(value.toString());
577  else if ("rowSourceType" == propertyName)
579  else if ("rowSourceValues" == propertyName) {
581  } else {
582  kdbCritical() << "impl. error: unsupported property" << propertyName;
583  }
584  this->setRecordSource(recordSource);
585  }
586  else if ("boundColumn" == propertyName) {
587  if (!::setBoundColumn(this, value)) {
588  return false;
589  }
590  }
591  else if ("visibleColumn" == propertyName) {
592  if (!::setVisibleColumns(this, value)) {
593  return false;
594  }
595  } else if ("columnWidths" == propertyName) {
596  if (!::setColumnWidths(this, value)) {
597  return false;
598  }
599  } else if ("showColumnHeaders" == propertyName) {
601  } else if ("listRows" == propertyName) {
602  const int ival = value.toInt(&ok);
603  if (!ok)
604  return false;
605  setMaxVisibleRecords(ival);
606  } else if ("limitToList" == propertyName) {
607  setLimitToList(value.toBool());
608  } else if ("displayWidget" == propertyName) {
609  if (!::setDisplayWidget(this, value)) {
610  return false;
611  }
612  }
613  return true;
614 }
615 
617 {
620  bool ok;
621  bool updateRecordSource = false;
622  if ((it = values.find("rowSource")) != values.constEnd()) {
623  recordSource.setName(it.value().toString());
624  updateRecordSource = true;
625  }
626  if ((it = values.find("rowSourceType")) != values.constEnd()) {
627  recordSource.setTypeByName(it.value().toString());
628  updateRecordSource = true;
629  }
630  if ((it = values.find("rowSourceValues")) != values.constEnd()) {
631  if (!it.value().isNull()) {
632  recordSource.setValues(it.value().toStringList());
633  updateRecordSource = true;
634  }
635  }
636  if (updateRecordSource) {
638  }
639  if ((it = values.find("boundColumn")) != values.constEnd()) {
640  if (!::setBoundColumn(this, it.value())) {
641  return false;
642  }
643  }
644  if ((it = values.find("visibleColumn")) != values.constEnd()) {
645  if (!::setVisibleColumns(this, it.value())) {
646  return false;
647  }
648  }
649  if ((it = values.find("columnWidths")) != values.constEnd()) {
650  if (!::setColumnWidths(this, it.value())) {
651  return false;
652  }
653  }
654  if ((it = values.find("showColumnHeaders")) != values.constEnd()) {
655  setColumnHeadersVisible(it.value().toBool());
656  }
657  if ((it = values.find("listRows")) != values.constEnd()) {
658  int ival = it.value().toInt(&ok);
659  if (!ok)
660  return false;
661  setMaxVisibleRecords(ival);
662  }
663  if ((it = values.find("limitToList")) != values.constEnd()) {
664  setLimitToList(it.value().toBool());
665  }
666  if ((it = values.find("displayWidget")) != values.constEnd()) {
667  if (!::setDisplayWidget(this, it.value())) {
668  return false;
669  }
670  }
671  return true;
672 }
673 
674 
676 {
677  return d->boundColumn;
678 }
679 
681 {
682  d->boundColumn = column >= 0 ? column : -1;
683 }
684 
686 {
687  return d->visibleColumns;
688 }
689 
691 {
692  d->visibleColumns = list;
693 }
694 
696 {
697  if (index >= d->visibleColumns.count()) {
698  return -1;
699  }
700  return index;
701 }
702 
704 {
705  return d->columnWidths;
706 }
707 
709 {
710  d->columnWidths = widths;
711 }
712 
714 {
715  return d->columnHeadersVisible;
716 }
717 
719 {
720  d->columnHeadersVisible = set;
721 }
722 
724 {
725  return d->maxVisibleRecords;
726 }
727 
729 {
730  return d->limitToList;
731 }
732 
734 {
735  d->limitToList = set;
736 }
737 
739 {
740  return d->displayWidget;
741 }
742 
744 {
745  d->displayWidget = widget;
746 }
747 
749 {
750  if (this != &other) {
751  *d = *other.d;
752  }
753  return *this;
754 }
755 
757 {
758  return *d == *other.d;
759 }
void append(const T &value)
bool isNull() const const
void setMaxVisibleRecords(int count)
KDB_EXPORT QVariant loadPropertyValueFromDom(const QDomNode &node, bool *ok)
Definition: KDb.cpp:1123
void saveToDom(QDomDocument *doc, QDomElement *parentEl)
QString text() const const
QDomNode firstChild() const const
KDB_EXPORT void getProperties(const KDbLookupFieldSchema *lookup, QMap< QByteArray, QVariant > *values)
Definition: KDb.cpp:758
QDomElement toElement() const const
Provides information about lookup field's setup.
void setDisplayWidget(DisplayWidget widget)
QString number(int n, int base)
void setRecordSource(const KDbLookupFieldSchemaRecordSource &recordSource)
int visibleColumn(int index) const
KDbLookupFieldSchemaRecordSource & operator=(const KDbLookupFieldSchemaRecordSource &other)
Assigns other to this record source and returns a reference to this record source.
@ ValueList
a fixed list of values as lookup record source
@ KDbFieldList
a list of column names from a table/query will be displayed
QString tagName() const const
void setValues(const QStringList &values)
Type type(const QSqlDatabase &db)
KDB_EXPORT QDomElement saveNumberElementToDom(QDomDocument *doc, QDomElement *parentEl, const QString &elementName, int value)
Definition: KDb.cpp:1169
const T value(const Key &key, const T &defaultValue) const const
bool isNull() const const
QDebug & nospace()
QDomText createTextNode(const QString &value)
@ Query
named query as lookup record source
void setColumnHeadersVisible(bool set)
QDebug & space()
QDataStream & operator<<(QDataStream &out, const KDateTime &dateTime)
QByteArray toLatin1() const const
bool operator==(const KDbLookupFieldSchemaRecordSource &other) const
KDB_EXPORT QDomElement saveBooleanElementToDom(QDomDocument *doc, QDomElement *parentEl, const QString &elementName, bool value)
Definition: KDb.cpp:1183
@ ComboBox
(the default) combobox widget should be displayed in forms for this lookup field
bool setProperties(const QMap< QByteArray, QVariant > &values)
QDomElement createElement(const QString &tagName)
KDbLookupFieldSchema & operator=(const KDbLookupFieldSchema &other)
Assigns other to this lookup schema and returns a reference to this lookup schema.
@ ListBox
listbox widget should be displayed in forms for this lookup field
DisplayWidget
used in displayWidget()
void setTypeByName(const QString &typeName)
Q_GLOBAL_STATIC(Internal::StaticControl, s_instance) class ControlPrivate
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
Record source information that can be specified for the lookup field schema.
QVariant::Type type() const const
bool setProperty(const QByteArray &propertyName, const QVariant &value)
DisplayWidget displayWidget() const
@ Table
table as lookup record source
KDbLookupFieldSchemaRecordSource recordSource() const
uint toUInt(bool *ok) const const
int toInt(bool *ok) const const
QList< int > columnWidths() const
bool isEmpty() const const
bool operator==(const KDbLookupFieldSchema &other) const
QString join(const QString &separator) const const
bool toBool() const const
bool canConvert(int targetTypeId) const const
typedef ConstIterator
QList< int > visibleColumns() const
QDomNode appendChild(const QDomNode &newChild)
@ SQLStatement
anonymous query as lookup record source
static KDbLookupFieldSchema * loadFromDom(const QDomElement &lookupEl)
void setBoundColumn(int column)
QString name(StandardShortcut id)
void getProperties(QMap< QByteArray, QVariant > *values) const
QList< QVariant > toList() const const
QDomNode nextSibling() const const
void setVisibleColumns(const QList< int > &list)
QStringList toStringList() const const
QVector< V > values(const QMultiHash< K, V > &c)
void setColumnWidths(const QList< int > &widths)
const QList< QKeySequence > & copy()
QString toString() const const
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.