kexi

lookupfieldschema.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2006 Jaroslaw Staniek <js@iidea.pl>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
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 
00029 namespace KexiDB {
00030 
00032 #define KEXIDB_LOOKUP_FIELD_DEFAULT_HEADERS_VISIBLE false
00033 
00035 #define KEXIDB_LOOKUP_FIELD_DEFAULT_LIST_ROWS 8
00036 
00038 #define KEXIDB_LOOKUP_FIELD_MAX_LIST_ROWS 100
00039 
00041 #define KEXIDB_LOOKUP_FIELD_DEFAULT_LIMIT_TO_LIST true
00042 
00044 #define KEXIDB_LOOKUP_FIELD_DEFAULT_DISPLAY_WIDGET KexiDB::LookupFieldSchema::ComboBox
00045 
00046 
00048 
00054 class KEXI_DB_EXPORT LookupFieldSchema
00055 {
00056     public:
00057 
00059         class KEXI_DB_EXPORT RowSource {
00060             public:
00062                 enum Type {
00063                     NoType,         
00064                     Table,        
00065                     Query,        
00066                     SQLStatement, 
00067                     ValueList,    
00068                     FieldList     
00069                 };
00070 
00071                 RowSource();
00072                 ~RowSource();
00073 
00077                 Type type() const { return m_type; }
00078 
00080                 void setType(Type type) { m_type = type; }
00081 
00083                 QString typeName() const;
00084 
00088                 void setTypeByName( const QString& typeName );
00089 
00094                 QString name() const { return m_name; }
00095 
00097                 void setName(const QString& name);
00098 
00100                 QStringList values() const;
00101 
00104                 void setValues(const QStringList& values);
00105 
00107                 QString debugString() const;
00108 
00110                 void debug() const;
00111             private:
00112                 Type m_type;
00113                 QString m_name;
00114                 QStringList *m_values;
00115         };
00116 
00117         LookupFieldSchema();
00118 
00119         ~LookupFieldSchema();
00120 
00122         RowSource& rowSource() { return m_rowSource; }
00123 
00125         void setRowSource(const RowSource& rowSource) { m_rowSource = rowSource; }
00126 
00129 
00130         int boundColumn() const { return m_boundColumn; }
00131 
00133         void setBoundColumn(int column) { m_boundColumn = column>=0 ? column : -1; }
00134 
00138 
00139         int visibleColumn() const { return m_visibleColumn; }
00140 
00142         void setVisibleColumn(int column) { m_visibleColumn = column>=0 ? column : -1; }
00143 
00146         const QValueList<int> columnWidths() const { return m_columnWidths; }
00147 
00149         void setColumnWidths(const QValueList<int>& widths) { m_columnWidths = widths; }
00150 
00153         bool columnHeadersVisible() const { return m_columnHeadersVisible; }
00154 
00156         void setColumnHeadersVisible(bool set) { m_columnHeadersVisible = set; }
00157 
00161         uint maximumListRows() const { return m_maximumListRows; }
00162 
00167         void setMaximumListRows(uint rows);
00168 
00171         bool limitToList() const { return m_limitToList; }
00172 
00174         void setLimitToList(bool set) { m_limitToList = set; }
00175 
00177         enum DisplayWidget {
00178             ComboBox, 
00179             ListBox   
00180         };
00181 
00185         DisplayWidget displayWidget() const { return m_displayWidget; }
00186 
00188         void setDisplayWidget(DisplayWidget widget) { m_displayWidget = widget; }
00189 
00191         QString debugString() const;
00192 
00194         void debug() const;
00195 
00199         static LookupFieldSchema* loadFromDom(const QDomElement& lookupEl);
00200 
00202         static void saveToDom(LookupFieldSchema& lookupSchema, QDomDocument& doc, QDomElement& parentEl);
00203 
00204     protected:
00205         RowSource m_rowSource;
00206         int m_boundColumn, m_visibleColumn;
00207         QValueList<int> m_columnWidths;
00208         uint m_maximumListRows;
00209         DisplayWidget m_displayWidget;
00210         bool m_columnHeadersVisible : 1;
00211         bool m_limitToList : 1;
00212 };
00213 
00214 } //namespace KexiDB
00215 
00216 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys