Source Code (Use browser search to find items of interest.)
Class Index
kdelibs'ImageSource (./kdelibs/khtml/misc/loader.cpp:124)
class ImageSource : public QDataSource
{
public:
ImageSource(QByteArray buf);
~ImageSource();
/**
* Overload QDataSource::readyToSend() and returns the number
* of bytes ready to send if not eof instead of returning -1.
*/
int readyToSend();
/*!
Reads and sends a block of data.
*/
void sendTo(QDataSink*, int count);
/*!
KHTMLImageSource's is rewindable.
*/
bool rewindable() const;
/*!
Enables rewinding. No special action is taken.
*/
void enableRewind(bool on);
/*
Calls reset() on the QIODevice.
*/
void rewind();
/**
* Sets the EOF state.
*/
void setEOF( bool state );
private:
QByteArray buffer;
bool rew;
int pos;
bool eof;
};
};
/*!
This Class defines the DataSource for incremental loading of images.
*/
ImageSource::ImageSource(QByteArray buf)
{
buffer = buf;
rew = false;
pos = 0;
eof = false;
}
/*!
Destroys the QIODeviceSource, deleting the QIODevice from which it was
constructed.
*/
ImageSource::~ImageSource() {}
/**
* Overload QDataSource::readyToSend() and returns the number
* of bytes ready to send if not eof instead of returning -1.
*/
int ImageSource::readyToSend()
{
int n = buffer.size() - pos;
if ( !n && !eof )
return n;
return n ? n : -1;
}
/*!
ImageSource's is rewindable.
*/
bool ImageSource::rewindable() const
{
return TRUE;
}
/*!
Enables rewinding. No special action is taken.
*/
void ImageSource::enableRewind(bool on)
{
rew = on;
}
/*
Calls reset() on the QIODevice.
*/
void ImageSource::rewind()
{
pos = 0;
if (!rew) {
QDataSource::rewind();
} else
ready();
}
/*!
Reads and sends a block of data.
*/
void ImageSource::sendTo(QDataSink* sink, int n)
{
sink->receive((const uchar*)&buffer.at(pos), n);
pos += n;
}
/**
* Sets the EOF state.
*/
void ImageSource::setEOF( bool state )
{
eof = state;
}
// -------------------------------------------------------------------------------------
kdelibs'ImageSource::setEOF() (./kdelibs/khtml/misc/loader.cpp:243)
void ImageSource::setEOF( bool state )
{
eof = state;
}
// -------------------------------------------------------------------------------------