Kexi API Documentation (2.0 alpha)

KexiDB::RowEditBuffer Class Reference

#include <roweditbuffer.h>

List of all members.


Detailed Description

provides data for single edited database row KexiDB::RowEditBuffer provides data for single edited row, needed to perform update at the database backend. Its advantage over pasing e.g. KexiDB::FieldList object is that EditBuffer contains only changed values.

EditBuffer offers two modes: db-aware and not-db-aware. Db-aware buffer addresses a field using references to QueryColumnInfo object, while not-db-aware buffer addresses a field using its name.

Example usage of not-db-aware buffer: QuerySchema *query = ..... EditBuffer buf; buf.insert("name", "Joe"); buf.insert("surname", "Black"); buf.at("name"); //returns "Joe" buf.at("surname"); //returns "Black" buf.at(query->field("surname")); //returns "Black" too // Now you can use buf to add or edit records using // KexiDB::Connection::updateRow(), KexiDB::Connection::insertRow()

Example usage of db-aware buffer: QuerySchema *query = ..... QueryColumnInfo *ci1 = ....... //e.g. can be obtained from QueryScehma::fieldsExpanded() QueryColumnInfo *ci2 = ....... EditBuffer buf; buf.insert(*ci1, "Joe"); buf.insert(*ci2, "Black"); buf.at(*ci1); //returns "Joe" buf.at(*ci2); //returns "Black" // Now you can use buf to add or edit records using // KexiDB::Connection::updateRow(), KexiDB::Connection::insertRow()

You can use QMap::clear() to clear buffer contents, QMap::isEmpty() to see if buffer is empty. For more, see QMap documentation.

Notes: added fields should come from the same (common) QuerySchema object. However, this isn't checked at QValue& EditBuffer::operator[]( const Field& f ) level.

Definition at line 74 of file roweditbuffer.h.

Public Types

typedef QMap< QString, QVariant > SimpleMap
typedef QMap< QueryColumnInfo *,
QVariant > 
DBMap

Public Member Functions

 RowEditBuffer (bool dbAwareBuffer)
 ~RowEditBuffer ()
bool isDBAware () const
void clear ()
bool isEmpty () const
void insert (QueryColumnInfo &ci, QVariant &val)
 Inserts value val for db-aware buffer's column ci.
void insert (const QString &fname, QVariant &val)
 Inserts value val for not-db-aware buffer's column fname.
const QVariant * at (QueryColumnInfo &ci, bool useDefaultValueIfPossible=true) const
const QVariant * at (Field &f) const
 Useful only for not-db-aware buffer.
const QVariant * at (const QString &fname) const
 Useful only for not-db-aware buffer.
bool hasDefaultValueAt (QueryColumnInfo &ci) const
 Useful only for db-aware buffer:.
const SimpleMap simpleBuffer ()
const DBMap dbBuffer ()
void debug ()
 For debugging purposes.

Protected Attributes

SimpleMapm_simpleBuffer
SimpleMap::ConstIterator * m_simpleBufferIt
DBMapm_dbBuffer
DBMap::Iterator * m_dbBufferIt
QMap< QueryColumnInfo *, bool > * m_defaultValuesDbBuffer
QMap< QueryColumnInfo *, bool
>::ConstIterator * 
m_defaultValuesDbBufferIt


Member Typedef Documentation

typedef QMap<QueryColumnInfo*,QVariant> KexiDB::RowEditBuffer::DBMap
 

Definition at line 77 of file roweditbuffer.h.

typedef QMap<QString,QVariant> KexiDB::RowEditBuffer::SimpleMap
 

Definition at line 76 of file roweditbuffer.h.


Constructor & Destructor Documentation

RowEditBuffer::RowEditBuffer bool  dbAwareBuffer  ) 
 

Definition at line 28 of file roweditbuffer.cpp.

RowEditBuffer::~RowEditBuffer  ) 
 

Definition at line 38 of file roweditbuffer.cpp.

References m_dbBuffer, m_dbBufferIt, m_defaultValuesDbBuffer, m_simpleBuffer, and m_simpleBufferIt.


Member Function Documentation

const QVariant * RowEditBuffer::at const QString fname  )  const
 

Useful only for not-db-aware buffer.

Returns:
value for field fname

Definition at line 83 of file roweditbuffer.cpp.

References KexiDBWarn, m_simpleBuffer, and m_simpleBufferIt.

const QVariant * RowEditBuffer::at Field f  )  const
 

Useful only for not-db-aware buffer.

Returns:
value for field f

Definition at line 71 of file roweditbuffer.cpp.

References KexiDBWarn, m_simpleBuffer, and m_simpleBufferIt.

const QVariant * RowEditBuffer::at QueryColumnInfo ci,
bool  useDefaultValueIfPossible = true
const
 

Useful only for db-aware buffer.

Returns:
value for column ci If there is no value assigned for the buffer, this method tries to remember and return default value obtained from ci if useDefaultValueIfPossible is true. Note that if the column is declared as unique (especially: primary key), default value will not be used.

Definition at line 47 of file roweditbuffer.cpp.

References hasDefaultValueAt(), KexiDB::isDefaultValueAllowed(), KexiDBWarn, m_dbBuffer, m_dbBufferIt, and m_defaultValuesDbBuffer.

void RowEditBuffer::clear  ) 
 

Definition at line 95 of file roweditbuffer.cpp.

References m_dbBuffer, m_defaultValuesDbBuffer, and m_simpleBuffer.

Referenced by KexiTableViewData::clearRowEditBuffer(), and KexiTableViewData::saveRow().

const DBMap KexiDB::RowEditBuffer::dbBuffer  )  [inline]
 

Definition at line 120 of file roweditbuffer.h.

Referenced by KexiDB::Connection::insertRow(), and KexiDB::Connection::updateRow().

void RowEditBuffer::debug  ) 
 

For debugging purposes.

Definition at line 113 of file roweditbuffer.cpp.

References hasDefaultValueAt(), isDBAware(), KexiDBDbg, and m_dbBuffer.

bool KexiDB::RowEditBuffer::hasDefaultValueAt QueryColumnInfo ci  )  const [inline]
 

Useful only for db-aware buffer:.

Returns:
true if the value available as at( ci ) is obtained from column's default value

Definition at line 115 of file roweditbuffer.h.

Referenced by at(), and debug().

void KexiDB::RowEditBuffer::insert const QString fname,
QVariant &  val
[inline]
 

Inserts value val for not-db-aware buffer's column fname.

Definition at line 97 of file roweditbuffer.h.

void KexiDB::RowEditBuffer::insert QueryColumnInfo ci,
QVariant &  val
[inline]
 

Inserts value val for db-aware buffer's column ci.

Definition at line 89 of file roweditbuffer.h.

Referenced by KexiTableViewData::updateRowEditBufferRef().

bool KexiDB::RowEditBuffer::isDBAware  )  const [inline]
 

Definition at line 82 of file roweditbuffer.h.

Referenced by debug(), and KexiTableViewData::updateRowEditBufferRef().

bool RowEditBuffer::isEmpty  )  const
 

Definition at line 104 of file roweditbuffer.cpp.

References m_dbBuffer.

const SimpleMap KexiDB::RowEditBuffer::simpleBuffer  )  [inline]
 

Definition at line 119 of file roweditbuffer.h.

Referenced by KexiTableViewData::saveRow().


Member Data Documentation

DBMap* KexiDB::RowEditBuffer::m_dbBuffer [protected]
 

Definition at line 128 of file roweditbuffer.h.

Referenced by at(), clear(), debug(), isEmpty(), and ~RowEditBuffer().

DBMap::Iterator* KexiDB::RowEditBuffer::m_dbBufferIt [protected]
 

Definition at line 129 of file roweditbuffer.h.

Referenced by at(), and ~RowEditBuffer().

QMap<QueryColumnInfo*,bool>* KexiDB::RowEditBuffer::m_defaultValuesDbBuffer [protected]
 

Definition at line 130 of file roweditbuffer.h.

Referenced by at(), clear(), and ~RowEditBuffer().

QMap<QueryColumnInfo*,bool>::ConstIterator* KexiDB::RowEditBuffer::m_defaultValuesDbBufferIt [protected]
 

Definition at line 131 of file roweditbuffer.h.

SimpleMap* KexiDB::RowEditBuffer::m_simpleBuffer [protected]
 

Definition at line 126 of file roweditbuffer.h.

Referenced by at(), clear(), and ~RowEditBuffer().

SimpleMap::ConstIterator* KexiDB::RowEditBuffer::m_simpleBufferIt [protected]
 

Definition at line 127 of file roweditbuffer.h.

Referenced by at(), and ~RowEditBuffer().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for Kexi 2.0 alpha.
Documentation copyright © 2002-2007 the Kexi Team.
Generated on Tue Apr 1 20:50:48 2008 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003