kexi
lookupfieldschema.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KEXIDB_LOOKUPFIELDSCHEMA_H
00021 #define KEXIDB_LOOKUPFIELDSCHEMA_H
00022
00023 #include <qvaluelist.h>
00024 #include <qstringlist.h>
00025
00026 class QDomElement;
00027 class QDomDocument;
00028 class QVariant;
00029
00030 namespace KexiDB {
00031
00033 #define KEXIDB_LOOKUP_FIELD_DEFAULT_HEADERS_VISIBLE false
00034
00036 #define KEXIDB_LOOKUP_FIELD_DEFAULT_LIST_ROWS 8
00037
00039 #define KEXIDB_LOOKUP_FIELD_MAX_LIST_ROWS 100
00040
00042 #define KEXIDB_LOOKUP_FIELD_DEFAULT_LIMIT_TO_LIST true
00043
00045 #define KEXIDB_LOOKUP_FIELD_DEFAULT_DISPLAY_WIDGET KexiDB::LookupFieldSchema::ComboBox
00046
00047
00049
00055 class KEXI_DB_EXPORT LookupFieldSchema
00056 {
00057 public:
00058
00060 class KEXI_DB_EXPORT RowSource {
00061 public:
00063 enum Type {
00064 NoType,
00065 Table,
00066 Query,
00067 SQLStatement,
00068 ValueList,
00069 FieldList
00070 };
00071
00072 RowSource();
00073 ~RowSource();
00074
00078 Type type() const { return m_type; }
00079
00081 void setType(Type type) { m_type = type; }
00082
00084 QString typeName() const;
00085
00089 void setTypeByName( const QString& typeName );
00090
00095 QString name() const { return m_name; }
00096
00098 void setName(const QString& name);
00099
00101 QStringList values() const;
00102
00105 void setValues(const QStringList& values);
00106
00108 QString debugString() const;
00109
00111 void debug() const;
00112 private:
00113 Type m_type;
00114 QString m_name;
00115 QStringList *m_values;
00116 };
00117
00118 LookupFieldSchema();
00119
00120 ~LookupFieldSchema();
00121
00123 RowSource& rowSource() { return m_rowSource; }
00124
00126 void setRowSource(const RowSource& rowSource) { m_rowSource = rowSource; }
00127
00130
00131 int boundColumn() const { return m_boundColumn; }
00132
00134 void setBoundColumn(int column) { m_boundColumn = column>=0 ? column : -1; }
00135
00139 QValueList<uint> visibleColumns() const { return m_visibleColumns; }
00140
00143 void setVisibleColumns(const QValueList<uint>& list) { m_visibleColumns = list; }
00144
00149 inline int visibleColumn(uint fieldsCount) const {
00150 if (m_visibleColumns.count()==1)
00151 return (m_visibleColumns.first() < fieldsCount)
00152 ? (int)m_visibleColumns.first() : -1;
00153 if (m_visibleColumns.isEmpty())
00154 return -1;
00155 return fieldsCount - 1;
00156 }
00157
00160 const QValueList<int> columnWidths() const { return m_columnWidths; }
00161
00163 void setColumnWidths(const QValueList<int>& widths) { m_columnWidths = widths; }
00164
00167 bool columnHeadersVisible() const { return m_columnHeadersVisible; }
00168
00170 void setColumnHeadersVisible(bool set) { m_columnHeadersVisible = set; }
00171
00175 uint maximumListRows() const { return m_maximumListRows; }
00176
00181 void setMaximumListRows(uint rows);
00182
00185 bool limitToList() const { return m_limitToList; }
00186
00188 void setLimitToList(bool set) { m_limitToList = set; }
00189
00191 enum DisplayWidget {
00192 ComboBox = 0,
00193 ListBox = 1
00194 };
00195
00199 DisplayWidget displayWidget() const { return m_displayWidget; }
00200
00202 void setDisplayWidget(DisplayWidget widget) { m_displayWidget = widget; }
00203
00205 QString debugString() const;
00206
00208 void debug() const;
00209
00213 static LookupFieldSchema* loadFromDom(const QDomElement& lookupEl);
00214
00216 static void saveToDom(LookupFieldSchema& lookupSchema, QDomDocument& doc, QDomElement& parentEl);
00217
00220 static bool setProperty(
00221 LookupFieldSchema& lookup, const QCString& propertyName, const QVariant& value );
00222
00223 protected:
00224 RowSource m_rowSource;
00225 int m_boundColumn;
00226 QValueList<uint> m_visibleColumns;
00227 QValueList<int> m_columnWidths;
00228 uint m_maximumListRows;
00229 DisplayWidget m_displayWidget;
00230 bool m_columnHeadersVisible : 1;
00231 bool m_limitToList : 1;
00232 };
00233
00234 }
00235
00236 #endif
|