kexi

kexidbcursor.h

00001 /***************************************************************************
00002  * kexidbcursor.h
00003  * This file is part of the KDE project
00004  * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this program; see the file COPYING.  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 KROSS_KEXIDB_KEXIDBCURSOR_H
00021 #define KROSS_KEXIDB_KEXIDBCURSOR_H
00022 
00023 #include <qstring.h>
00024 
00025 #include <api/object.h>
00026 #include <api/variant.h>
00027 #include <api/list.h>
00028 #include <api/class.h>
00029 
00030 #include <kexidb/cursor.h>
00031 #include <kexidb/roweditbuffer.h>
00032 
00033 namespace Kross { namespace KexiDB {
00034 
00035     // Forward declaration.
00036     class KexiDBConnection;
00037 
00085     class KexiDBCursor : public Kross::Api::Class<KexiDBCursor>
00086     {
00087         public:
00088             KexiDBCursor(::KexiDB::Cursor* cursor);
00089             virtual ~KexiDBCursor();
00090             virtual const QString getClassName() const;
00091 
00092         private:
00093 
00095             bool open();
00097             bool isOpened();
00099             bool reopen();
00101             bool close();
00102 
00104             bool moveFirst();
00106             bool moveLast();
00108             bool movePrev();
00110             bool moveNext();
00111 
00113             bool bof();
00115             bool eof();
00116 
00120             Q_LLONG at();
00122             uint fieldCount();
00124             QVariant value(uint index);
00127             bool setValue(uint index, QVariant value);
00128 
00132             bool save();
00133 
00134         private:
00135             ::KexiDB::Cursor* m_cursor;
00136 
00137             class Record {
00138                 public:
00139                     ::KexiDB::RowData rowdata;
00140                     ::KexiDB::RowEditBuffer* buffer;
00141                     Record(::KexiDB::Cursor* cursor)
00142                         : buffer( new ::KexiDB::RowEditBuffer(true) )
00143                     {
00144                         cursor->storeCurrentRow(rowdata);
00145                     }
00146                     ~Record()
00147                     {
00148                         delete buffer;
00149                     }
00150             };
00151             QMap<Q_LLONG, Record*> m_modifiedrecords;
00152 
00153             void clearBuffers();
00154     };
00155 
00156 }}
00157 
00158 #endif
00159 
KDE Home | KDE Accessibility Home | Description of Access Keys