kexi

KexiBLOBBuffer Class Reference

#include <kexiblobbuffer.h>

Inherits QObject.

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 loading (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:

  • Property editor's item for "image" property displays a preview of pixmap contents. Without buffering, it would be needed to load pixmap data again: what if the file it is loaded from is located remote and connection is slow? Memory would be also unnecessary doubled.
  • Undo/Redo framework requires to store previous property values. Having a reference defined by a single interger, memory can be handled more effectively.

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

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 ()
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...

Member Typedef Documentation

typedef long KexiBLOBBuffer::Id_t

long integer for unique identifying blobs

Todo:
Qt4: will be changed

Definition at line 85 of file kexiblobbuffer.h.


Member Function Documentation

KexiBLOBBuffer * KexiBLOBBuffer::self (  )  [static]

Access to KexiBLOBBuffer singleton.

Definition at line 365 of file kexiblobbuffer.cpp.

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.

Todo:
what about searching by filename only and then compare data?

Todo:
download the file if remote, then set fileName properly

Todo:
err msg

Todo:
err msg

stored

Definition at line 187 of file kexiblobbuffer.cpp.

KexiBLOBBuffer::Handle KexiBLOBBuffer::insertObject ( const QByteArray &  data,
const QString &  name,
const QString &  caption,
const QString &  mimeType,
KexiBLOBBuffer::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.

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

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

<

Todo:
OK? What about jpegs?

Definition at line 240 of file kexiblobbuffer.cpp.

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.

Todo:
err msg

Todo:
use PreparedStatement

Todo:
err msg

<

Todo:
folder id: fix Id_t for Qt4

Definition at line 259 of file kexiblobbuffer.cpp.

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.

stored

Definition at line 320 of file kexiblobbuffer.cpp.

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.

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

Takes an object for a item out of the buffer.

Definition at line 342 of file kexiblobbuffer.cpp.

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

Inserts an object for a given id into the buffer.

Definition at line 351 of file kexiblobbuffer.cpp.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys