kexi

fieldlist.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003-2005 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_FIELDLIST_H
00021 #define KEXIDB_FIELDLIST_H
00022 
00023 #include <qvaluelist.h>
00024 #include <qdict.h>
00025 #include <qstring.h>
00026 
00027 #include <kexidb/field.h>
00028 #include <kexidb/driver.h>
00029 
00030 namespace KexiDB {
00031 
00032 class Connection;
00033 
00037 class KEXI_DB_EXPORT FieldList
00038 {
00039     public:
00046         FieldList(bool owner = false);
00047 
00049         FieldList(const FieldList& fl);
00050 
00053         virtual ~FieldList();
00054         
00056         inline uint fieldCount() const { return m_fields.count(); }
00057 
00059         FieldList& addField(Field *field);
00060 
00065         virtual FieldList& insertField(uint index, Field *field);
00066         
00071         virtual void removeField(KexiDB::Field *field);
00072 
00074         inline Field* field(uint id) { return (id < m_fields.count()) ? m_fields.at(id) : 0; }
00075         
00077         virtual Field* field(const QString& name);
00078 
00080         inline bool hasField(const Field* field) { return m_fields.findRef(field)!=-1; }
00081 
00084         inline int indexOf(const Field* field) { return m_fields.findRef(field); }
00085 
00087         QStringList names() const;
00088         
00089         Field::ListIterator fieldsIterator() const { return Field::ListIterator(m_fields); }
00090 
00091         inline Field::List* fields() { return &m_fields; }
00092 
00094         Field::List* autoIncrementFields();
00095 
00097         inline bool isOwner() const { return m_fields.autoDelete(); }
00098 
00100         virtual void clear();
00101 
00103         virtual QString debugString();
00104         
00106         void debug();
00107 
00115         FieldList* subList(const QString& n1, const QString& n2 = QString::null, 
00116             const QString& n3 = QString::null, const QString& n4 = QString::null,
00117             const QString& n5 = QString::null, const QString& n6 = QString::null,
00118             const QString& n7 = QString::null, const QString& n8 = QString::null,
00119             const QString& n9 = QString::null, const QString& n10 = QString::null,
00120             const QString& n11 = QString::null, const QString& n12 = QString::null,
00121             const QString& n13 = QString::null, const QString& n14 = QString::null,
00122             const QString& n15 = QString::null, const QString& n16 = QString::null,
00123             const QString& n17 = QString::null, const QString& n18 = QString::null
00124         );
00125 
00127         FieldList* subList(const QStringList& list);
00128     
00135         QString sqlFieldsList(Driver *driver);
00136 
00138         static QString sqlFieldsList(Field::List* list, Driver *driver);
00139 
00142         void renameField(const QString& oldName, const QString& newName);
00143 
00146         void renameField(KexiDB::Field *field, const QString& newName);
00147 
00148     protected:
00149         Field::List m_fields;
00150         QDict<Field> m_fields_by_name; 
00151         Field::List *m_autoinc_fields;
00152     
00153     private:
00155         QString m_sqlFields;
00156 };
00157 
00158 } //namespace KexiDB
00159 
00160 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys