Kexi API Documentation (2.0 alpha)

KexiBLOBBuffer Class Reference

#include <kexiblobbuffer.h>

List of all members.


Detailed Description

Application-wide buffer for local BLOB data like pixmaps.

For now only pixmaps are supported

Todo:
support any KPart-compatible objects and more...
Use this class by acessing to its singleton: KexiBLOBBuffer::self().

This class is used for buffering BLOB data, to avoid duplicating object's data in memory and a need for loding (decoding) the same object many times. The data is always local, what means database storage is not employed here.

Each BLOB instance is identified by an unsigned integer number (Id_t type), uniquely generated on BLOB loading. Each BLOB can have assigned source url it has been loaded from (the url can be empty though, e.g. for data coming from clipboard).

References to KexiBLOBBuffer are counted, so when last reference is lost, data is freed and the integer identifier is no longer pointing any valid data. KexiBLOBBuffer::Handle is value-based class that describes handle based in an identifier. Objects of this class are obtained e.g. from insertPixmap() method.

There are two kinds of identifiers:

KexiBLOBBuffer is also useful for two more reasons:

Example use cases: A large pixmap file "abc.jpg" is loaded as QByteArray once and buffered: integer identifier is returned. Then, multiple image widgets are using "abc.jpg" for displaying. Duplicating an image widget means only duplicating it's properties like position and BLOB's id: BLOB itself (data of "abc.jpg")is not duplicated. Creating a new image widget and assiging the same "abc.jpg" pixmap, means only referencing KexiBLOBBuffer using the same identifier.

Definition at line 80 of file kexiblobbuffer.h.

Public Types

typedef long Id_t

Public Member Functions

 KexiBLOBBuffer ()
 ~KexiBLOBBuffer ()
Handle insertPixmap (const KURL &url)
Handle insertObject (const QByteArray &data, const QString &name, const QString &caption, const QString &mimeType, Id_t identifier=0)
Handle insertPixmap (const QPixmap &pixmap)
Handle objectForId (Id_t id, bool stored)
Handle objectForId (Id_t id)

Static Public Member Functions

static KexiBLOBBufferself ()
 Access to KexiBLOBBuffer singleton.
static void setConnection (KexiDB::Connection *conn)

Protected Member Functions

void removeItem (Id_t id, bool stored)
void takeItem (Item *item)
void insertItem (Item *item)

Friends

class Handle

Classes

class  Handle
 Object handle used by KexiBLOBBuffer. More...
class  Item


Member Typedef Documentation

typedef long KexiBLOBBuffer::Id_t
 

Todo:
Qt4: will be changed

Definition at line 85 of file kexiblobbuffer.h.


Constructor & Destructor Documentation

KexiBLOBBuffer::KexiBLOBBuffer  ) 
 

Definition at line 173 of file kexiblobbuffer.cpp.

Referenced by self().

KexiBLOBBuffer::~KexiBLOBBuffer  ) 
 

Definition at line 182 of file kexiblobbuffer.cpp.


Member Function Documentation

void KexiBLOBBuffer::insertItem Item *  item  )  [protected]
 

Inserts an object for a given id into the buffer.

Definition at line 351 of file kexiblobbuffer.cpp.

Referenced by insertObject(), insertPixmap(), and objectForId().

KexiBLOBBuffer::Handle KexiBLOBBuffer::insertObject const QByteArray &  data,
const QString name,
const QString caption,
const QString mimeType,
Id_t  identifier = 0
 

Inserts a new BLOB data.

Parameters:
data The data for BLOB object.
name The name for the object, usually a file name or empty
caption The more friendly than name, can be based on file name or empty or defined by a user (this case is not yet used)
mimeType The mimeType for the object for easier and mor accurate decoding.
identifier Object's identifier. If positive, the "stored" flag for the data will be set to true with identifer, otherwise (the default) the BLOB data will have "stored" flag set to false, and a new temporary identifier will be assigned.

Definition at line 226 of file kexiblobbuffer.cpp.

References Handle, and insertItem().

KexiBLOBBuffer::Handle KexiBLOBBuffer::insertPixmap const QPixmap &  pixmap  ) 
 

Inserts a new pixmap available in memory, e.g. coming from clipboard.

Definition at line 240 of file kexiblobbuffer.cpp.

References Handle, and insertItem().

KexiBLOBBuffer::Handle KexiBLOBBuffer::insertPixmap const KURL &  url  ) 
 

Inserts a new pixmap loaded from a file at url. If the same file has already been loaded before, it can be found in cache and returned instantly. It is assumed that the BLOB is unstored, because it is loaded from external source, so stored() will be equal to false for returned handle.

Returns:
handle to the pixmap data or a null handle if such pixmap could not be loaded.

Definition at line 187 of file kexiblobbuffer.cpp.

References Handle, insertItem(), and kexipluginswarn.

KexiBLOBBuffer::Handle KexiBLOBBuffer::objectForId Id_t  id  ) 
 

Returns:
an object for a given id. First, unstored object is checked, then unstored, if stored was not found.

Definition at line 320 of file kexiblobbuffer.cpp.

References objectForId().

KexiBLOBBuffer::Handle KexiBLOBBuffer::objectForId Id_t  id,
bool  stored
 

Returns:
an object for a given id. If stored is true, stored BLOBs buffer is browsed, otherwise unstored (in memory) BLOBs buffer is browsed. If no object is cached for this id, null handle is returned.

Definition at line 259 of file kexiblobbuffer.cpp.

References KexiDB::QuerySchema::addField(), KexiDB::QuerySchema::addToWhereExpression(), KexiDB::FieldList::field(), Handle, insertItem(), and tristate::toString().

Referenced by objectForId(), and KexiFormView::storeData().

void KexiBLOBBuffer::removeItem Id_t  id,
bool  stored
[protected]
 

Removes an object for a given id. If stored is true, stored BLOB is removed, otherwise unstored (in memory) BLOB is removed.

Definition at line 328 of file kexiblobbuffer.cpp.

KexiBLOBBuffer * KexiBLOBBuffer::self  )  [static]
 

Access to KexiBLOBBuffer singleton.

Definition at line 365 of file kexiblobbuffer.cpp.

References KexiBLOBBuffer(), and m_bufferDeleter.

Referenced by KexiImagePropertyEdit::drawViewer(), KexiDBImageBox::handleInsertFromFileAction(), KexiDBImageBox::handlePasteAction(), KexiImagePropertyEdit::selectPixmap(), setConnection(), KexiDBImageBox::setPixmapId(), KexiDBImageBox::setStoredPixmapId(), KexiBLOBBuffer::Handle::setStoredWidthID(), KexiImagePropertyEdit::setValue(), KexiFormView::storeData(), and KexiBLOBBuffer::Handle::~Handle().

void KexiBLOBBuffer::setConnection KexiDB::Connection conn  )  [static]
 

Definition at line 360 of file kexiblobbuffer.cpp.

References self().

Referenced by KexiProject::createConnection().

void KexiBLOBBuffer::takeItem Item *  item  )  [protected]
 

Takes an object for a item out of the buffer.

Definition at line 342 of file kexiblobbuffer.cpp.


Friends And Related Function Documentation

friend class Handle [friend]
 

Definition at line 220 of file kexiblobbuffer.h.

Referenced by insertObject(), insertPixmap(), and objectForId().


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:49:44 2008 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003