kexi

lookupfieldschema.h
1/* This file is part of the KDE project
2 Copyright (C) 2006-2007 Jaroslaw Staniek <js@iidea.pl>
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#ifndef KEXIDB_LOOKUPFIELDSCHEMA_H
21#define KEXIDB_LOOKUPFIELDSCHEMA_H
22
23#include <tqvaluelist.h>
24#include <tqstringlist.h>
25
26class TQDomElement;
27class TQDomDocument;
28class TQVariant;
29
30namespace KexiDB {
31
33#define KEXIDB_LOOKUP_FIELD_DEFAULT_HEADERS_VISIBLE false
34
36#define KEXIDB_LOOKUP_FIELD_DEFAULT_LIST_ROWS 8
37
39#define KEXIDB_LOOKUP_FIELD_MAX_LIST_ROWS 100
40
42#define KEXIDB_LOOKUP_FIELD_DEFAULT_LIMIT_TO_LIST true
43
45#define KEXIDB_LOOKUP_FIELD_DEFAULT_DISPLAY_WIDGET KexiDB::LookupFieldSchema::ComboBox
46
47
49
55class KEXI_DB_EXPORT LookupFieldSchema
56{
57 public:
58
60 class KEXI_DB_EXPORT RowSource {
61 public:
71
72 RowSource();
73 ~RowSource();
74
78 Type type() const { return m_type; }
79
81 void setType(Type type) { m_type = type; }
82
84 TQString typeName() const;
85
89 void setTypeByName( const TQString& typeName );
90
95 TQString name() const { return m_name; }
96
98 void setName(const TQString& name);
99
101 TQStringList values() const;
102
105 void setValues(const TQStringList& values);
106
108 TQString debugString() const;
109
111 void debug() const;
112 private:
113 Type m_type;
114 TQString m_name;
115 TQStringList *m_values;
116 };
117
119
121
123 RowSource& rowSource() { return m_rowSource; }
124
126 void setRowSource(const RowSource& rowSource) { m_rowSource = rowSource; }
127
131 int boundColumn() const { return m_boundColumn; }
132
134 void setBoundColumn(int column) { m_boundColumn = column>=0 ? column : -1; }
135
139 TQValueList<uint> visibleColumns() const { return m_visibleColumns; }
140
143 void setVisibleColumns(const TQValueList<uint>& list) { m_visibleColumns = list; }
144
149 inline int visibleColumn(uint fieldsCount) const {
150 if (m_visibleColumns.count()==1)
151 return (m_visibleColumns.first() < fieldsCount)
152 ? (int)m_visibleColumns.first() : -1;
153 if (m_visibleColumns.isEmpty())
154 return -1;
155 return fieldsCount - 1;
156 }
157
160 const TQValueList<int> columnWidths() const { return m_columnWidths; }
161
163 void setColumnWidths(const TQValueList<int>& widths) { m_columnWidths = widths; }
164
167 bool columnHeadersVisible() const { return m_columnHeadersVisible; }
168
170 void setColumnHeadersVisible(bool set) { m_columnHeadersVisible = set; }
171
175 uint maximumListRows() const { return m_maximumListRows; }
176
181 void setMaximumListRows(uint rows);
182
185 bool limitToList() const { return m_limitToList; }
186
188 void setLimitToList(bool set) { m_limitToList = set; }
189
192 ComboBox = 0,
193 ListBox = 1
194 };
195
199 DisplayWidget displayWidget() const { return m_displayWidget; }
200
202 void setDisplayWidget(DisplayWidget widget) { m_displayWidget = widget; }
203
205 TQString debugString() const;
206
208 void debug() const;
209
213 static LookupFieldSchema* loadFromDom(const TQDomElement& lookupEl);
214
216 static void saveToDom(LookupFieldSchema& lookupSchema, TQDomDocument& doc, TQDomElement& parentEl);
217
220 static bool setProperty(
221 LookupFieldSchema& lookup, const TQCString& propertyName, const TQVariant& value );
222
223 protected:
224 RowSource m_rowSource;
225 int m_boundColumn;
226 TQValueList<uint> m_visibleColumns;
227 TQValueList<int> m_columnWidths;
228 uint m_maximumListRows;
229 DisplayWidget m_displayWidget;
230 bool m_columnHeadersVisible : 1;
231 bool m_limitToList : 1;
232};
233
234} //namespace KexiDB
235
236#endif
Row source information that can be specified for the lookup field schema.
@ Table
table as lookup row source
@ ValueList
a fixed list of values as lookup row source
@ Query
named query as lookup row source
@ SQLStatement
anonymous query as lookup row source
Provides information about lookup field's setup.
void setDisplayWidget(DisplayWidget widget)
void setVisibleColumns(const TQValueList< uint > &list)
DisplayWidget displayWidget() const
void setRowSource(const RowSource &rowSource)
void setColumnWidths(const TQValueList< int > &widths)
int visibleColumn(uint fieldsCount) const
DisplayWidget
used in displayWidget()
void setColumnHeadersVisible(bool set)
const TQValueList< int > columnWidths() const
TQValueList< uint > visibleColumns() const
High-level database connectivity library with database backend drivers.
KEXI_DB_EXPORT void debug(const QuerySchemaParameterList &list)
Shows debug information for list.