kexi

roweditbuffer.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003 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_ROWEDITBUFFER_H
00021 #define KEXIDB_ROWEDITBUFFER_H
00022 
00023 #include <qmap.h>
00024 
00025 #include <kexidb/field.h>
00026 #include <kexidb/queryschema.h>
00027 
00028 namespace KexiDB {
00029 
00054 class KEXI_DB_EXPORT RowEditBuffer {
00055 public:
00056     typedef QMap<QString,QVariant> SimpleMap;
00057     typedef QMap<QueryColumnInfo*,QVariant> DBMap;
00058 
00059     RowEditBuffer(bool dbAwareBuffer);
00060     ~RowEditBuffer();
00061 
00062     inline bool isDBAware() const { return m_dbBuffer!=0; }
00063 
00064     void clear();
00065 
00066     bool isEmpty() const;
00067 
00068     inline void insert( QueryColumnInfo& fi, QVariant &val )
00069         { if (m_dbBuffer) m_dbBuffer->insert(&fi,val); }
00070 
00071     inline void insert( const QString& fname, QVariant &val ) 
00072         { if (m_simpleBuffer) m_simpleBuffer->insert(fname,val); }
00073 
00075     const QVariant* at( QueryColumnInfo& fi ) const;
00076     
00078     const QVariant* at( Field& f ) const;
00079     const QVariant* at( const QString& fname ) const;
00080 
00081     inline const SimpleMap simpleBuffer() { return *m_simpleBuffer; }
00082     inline const DBMap dbBuffer() { return *m_dbBuffer; }
00083 
00085     void debug();
00086 
00087 protected:
00088     SimpleMap *m_simpleBuffer;
00089     SimpleMap::ConstIterator *m_simpleBufferIt;
00090     DBMap *m_dbBuffer;
00091     DBMap::ConstIterator *m_dbBufferIt;
00092 };
00093 
00094 } //namespace KexiDB
00095 
00096 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys