summaryrefslogtreecommitdiffstats
path: root/src/gvcore/imageloader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gvcore/imageloader.cpp')
-rw-r--r--src/gvcore/imageloader.cpp206
1 files changed, 103 insertions, 103 deletions
diff --git a/src/gvcore/imageloader.cpp b/src/gvcore/imageloader.cpp
index 8cbc442..c14de6e 100644
--- a/src/gvcore/imageloader.cpp
+++ b/src/gvcore/imageloader.cpp
@@ -1,7 +1,7 @@
// vim: set tabstop=4 shiftwidth=4 noexpandtab
/*
Gwenview - A simple image viewer for KDE
-Copyright 2000-2004 Aurélien Gâteau
+Copyright 2000-2004 Aur�lien G�teau
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -23,9 +23,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <assert.h>
-// Qt
-#include <qtimer.h>
-#include <qwmatrix.h>
+// TQt
+#include <tqtimer.h>
+#include <tqwmatrix.h>
// KDE
#include <kapplication.h>
@@ -64,59 +64,59 @@ const int IMAGE_UPDATE_INTERVAL=100;
#define LOG2(x) ;
#endif
-static QMap< KURL, ImageLoader* > sLoaders;
+static TQMap< KURL, ImageLoader* > sLoaders;
//---------------------------------------------------------------------
//
// CancellableBuffer
-// This class acts like QBuffer, but will simulates a truncated file if the
+// This class acts like TQBuffer, but will simulates a truncated file if the
// TSThread which was passed to its constructor has been asked for cancellation
//
//---------------------------------------------------------------------
-class CancellableBuffer : public QBuffer {
+class CancellableBuffer : public TQBuffer {
public:
- CancellableBuffer(QByteArray buffer, TSThread* thread)
- : QBuffer(buffer), mThread(thread) {}
+ CancellableBuffer(TQByteArray buffer, TSThread* thread)
+ : TQBuffer(buffer), mThread(thread) {}
bool atEnd() const {
if (mThread->testCancel()) {
LOG("cancel detected");
return true;
}
- return QBuffer::atEnd();
+ return TQBuffer::atEnd();
}
- Q_LONG readBlock(char * data, Q_ULONG maxlen) {
+ TQ_LONG readBlock(char * data, TQ_ULONG maxlen) {
if (mThread->testCancel()) {
LOG("cancel detected");
return 0;
}
- return QBuffer::readBlock(data, maxlen);
+ return TQBuffer::readBlock(data, maxlen);
}
- Q_LONG readLine(char * data, Q_ULONG maxlen) {
+ TQ_LONG readLine(char * data, TQ_ULONG maxlen) {
if (mThread->testCancel()) {
LOG("cancel detected");
return 0;
}
- return QBuffer::readLine(data, maxlen);
+ return TQBuffer::readLine(data, maxlen);
}
- QByteArray readAll() {
+ TQByteArray readAll() {
if (mThread->testCancel()) {
LOG("cancel detected");
- return QByteArray();
+ return TQByteArray();
}
- return QBuffer::readAll();
+ return TQBuffer::readAll();
}
int getch() {
if (mThread->testCancel()) {
LOG("cancel detected");
- setStatus(IO_ReadError);
+ setqStatus(IO_ReadError);
return -1;
}
- return QBuffer::getch();
+ return TQBuffer::getch();
}
private:
@@ -130,17 +130,17 @@ private:
//
//---------------------------------------------------------------------
void DecoderThread::run() {
- QMutexLocker locker(&mMutex);
+ TQMutexLocker locker(&mMutex);
LOG("");
// This block makes sure imageIO won't access the image after the signal
// has been posted
{
- QImageIO imageIO;
+ TQImageIO imageIO;
CancellableBuffer buffer(mRawData, this);
buffer.open(IO_ReadOnly);
- imageIO.setIODevice(&buffer);
+ imageIO.setIODevice(TQT_TQIODEVICE(&buffer));
bool ok=imageIO.read();
if (testCancel()) {
LOG("cancelled");
@@ -149,7 +149,7 @@ void DecoderThread::run() {
if (!ok) {
LOG("failed");
- postSignal( this, SIGNAL(failed()) );
+ postSignal( this, TQT_SIGNAL(failed()) );
return;
}
@@ -158,20 +158,20 @@ void DecoderThread::run() {
}
LOG("succeeded, emitting signal");
- postSignal( this, SIGNAL(succeeded()) );
+ postSignal( this, TQT_SIGNAL(succeeded()) );
}
-void DecoderThread::setRawData(const QByteArray& data) {
- QMutexLocker locker(&mMutex);
+void DecoderThread::setRawData(const TQByteArray& data) {
+ TQMutexLocker locker(&mMutex);
mRawData=data.copy();
}
-QImage DecoderThread::popLoadedImage() {
- QMutexLocker locker(&mMutex);
- QImage img=mImage;
- mImage=QImage();
+TQImage DecoderThread::popLoadedImage() {
+ TQMutexLocker locker(&mMutex);
+ TQImage img=mImage;
+ mImage=TQImage();
return img;
}
@@ -183,7 +183,7 @@ QImage DecoderThread::popLoadedImage() {
//
//---------------------------------------------------------------------
struct OwnerData {
- const QObject* owner;
+ const TQObject* owner;
BusyLevel priority;
};
@@ -229,24 +229,24 @@ public:
KURL mURL;
// The file timestamp
- QDateTime mTimestamp;
+ TQDateTime mTimestamp;
// The raw data we get
- QByteArray mRawData;
+ TQByteArray mRawData;
// The async decoder and it's waking timer
- QImageDecoder mDecoder;
- QTimer mDecoderTimer;
+ TQImageDecoder mDecoder;
+ TQTimer mDecoderTimer;
// The decoder thread
DecoderThread mDecoderThread;
// A rect of recently loaded pixels that the rest of the application has
// not been notified about with the imageChanged() signal
- QRect mLoadChangedRect;
+ TQRect mLoadChangedRect;
// The time since we last emitted the imageChanged() signal
- QTime mTimeSinceLastUpdate;
+ TQTime mTimeSinceLastUpdate;
// Whether the loading should be suspended
bool mSuspended;
@@ -256,27 +256,27 @@ public:
bool mWasFrameData;
- QImage mProcessedImage; // image frame currently being decoded
+ TQImage mProcessedImage; // image frame currently being decoded
- QRegion mLoadedRegion; // loaded parts of mProcessedImage
+ TQRegion mLoadedRegion; // loaded parts of mProcessedImage
ImageFrames mFrames;
- QCString mImageFormat;
+ TQCString mImageFormat;
ImageUtils::Orientation mOrientation;
- QString mMimeType;
+ TQString mMimeType;
MimeTypeUtils::Kind mURLKind;
- QValueVector< OwnerData > mOwners; // loaders may be shared
+ TQValueVector< OwnerData > mOwners; // loaders may be shared
void determineImageFormat() {
Q_ASSERT(mRawData.size()>0);
- QBuffer buffer(mRawData);
+ TQBuffer buffer(mRawData);
buffer.open(IO_ReadOnly);
- mImageFormat = QImageIO::imageFormat(&buffer);
+ mImageFormat = TQImageIO::imageFormat(TQT_TQIODEVICE(&buffer));
}
};
@@ -289,8 +289,8 @@ public:
ImageLoader::ImageLoader() {
LOG("");
d = new ImageLoaderPrivate(this);
- connect( BusyLevelManager::instance(), SIGNAL( busyLevelChanged(BusyLevel)),
- this, SLOT( slotBusyLevelChanged(BusyLevel)));
+ connect( BusyLevelManager::instance(), TQT_SIGNAL( busyLevelChanged(BusyLevel)),
+ this, TQT_SLOT( slotBusyLevelChanged(BusyLevel)));
}
@@ -313,12 +313,12 @@ void ImageLoader::startLoading() {
d->mTimestamp = Cache::instance()->timestamp( d->mURL );
slotBusyLevelChanged( BusyLevelManager::instance()->busyLevel());
- connect(&d->mDecoderTimer, SIGNAL(timeout()), this, SLOT(decodeChunk()) );
+ connect(&d->mDecoderTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(decodeChunk()) );
- connect(&d->mDecoderThread, SIGNAL(succeeded()),
- this, SLOT(slotDecoderThreadSucceeded()) );
- connect(&d->mDecoderThread, SIGNAL(failed()),
- this, SLOT(slotDecoderThreadFailed()) );
+ connect(&d->mDecoderThread, TQT_SIGNAL(succeeded()),
+ this, TQT_SLOT(slotDecoderThreadSucceeded()) );
+ connect(&d->mDecoderThread, TQT_SIGNAL(failed()),
+ this, TQT_SLOT(slotDecoderThreadFailed()) );
checkPendingStat();
}
@@ -328,8 +328,8 @@ void ImageLoader::checkPendingStat() {
KIO::Job* job=KIO::stat( d->mURL, false );
job->setWindow(KApplication::kApplication()->mainWidget());
- connect(job, SIGNAL(result(KIO::Job*)),
- this, SLOT(slotStatResult(KIO::Job*)) );
+ connect(job, TQT_SIGNAL(result(KIO::Job*)),
+ this, TQT_SLOT(slotStatResult(KIO::Job*)) );
d->mGetState = GET_STATING;
}
@@ -339,7 +339,7 @@ void ImageLoader::slotStatResult(KIO::Job* job) {
// Get modification time of the original file
KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
KIO::UDSEntry::ConstIterator it= entry.begin();
- QDateTime urlTimestamp;
+ TQDateTime urlTimestamp;
for (; it!=entry.end(); it++) {
if ((*it).m_uds == KIO::UDS_MODIFICATION_TIME) {
urlTimestamp.setTime_t( (*it).m_long );
@@ -395,11 +395,11 @@ void ImageLoader::checkPendingGet() {
KIO::Job* getJob=KIO::get( d->mURL, false, false);
getJob->setWindow(KApplication::kApplication()->mainWidget());
- connect(getJob, SIGNAL(data(KIO::Job*, const QByteArray&)),
- this, SLOT(slotDataReceived(KIO::Job*, const QByteArray&)) );
+ connect(getJob, TQT_SIGNAL(data(KIO::Job*, const TQByteArray&)),
+ this, TQT_SLOT(slotDataReceived(KIO::Job*, const TQByteArray&)) );
- connect(getJob, SIGNAL(result(KIO::Job*)),
- this, SLOT(slotGetResult(KIO::Job*)) );
+ connect(getJob, TQT_SIGNAL(result(KIO::Job*)),
+ this, TQT_SLOT(slotGetResult(KIO::Job*)) );
d->mTimeSinceLastUpdate.start();
d->mGetState = GET_GETTING;
@@ -441,15 +441,15 @@ void ImageLoader::slotGetResult(KIO::Job* job) {
// There is no way in KImageIO to get the mimeType from the image format.
// This function assumes KImageIO::types and KImageIO::mimeTypes return items
// in the same order (which they do, according to the source code).
-static QString mimeTypeFromFormat(const char* format) {
- QStringList formats = KImageIO::types(KImageIO::Reading);
- QStringList mimeTypes = KImageIO::mimeTypes(KImageIO::Reading);
- int pos = formats.findIndex(QString::fromAscii(format));
+static TQString mimeTypeFromFormat(const char* format) {
+ TQStringList formats = KImageIO::types(KImageIO::Reading);
+ TQStringList mimeTypes = KImageIO::mimeTypes(KImageIO::Reading);
+ int pos = formats.tqfindIndex(TQString::fromAscii(format));
Q_ASSERT(pos != -1);
return mimeTypes[pos];
}
-void ImageLoader::slotDataReceived(KIO::Job* job, const QByteArray& chunk) {
+void ImageLoader::slotDataReceived(KIO::Job* job, const TQByteArray& chunk) {
LOG2("size: " << chunk.size());
if (chunk.size()<=0) return;
@@ -459,9 +459,9 @@ void ImageLoader::slotDataReceived(KIO::Job* job, const QByteArray& chunk) {
if (oldSize==0) {
// Try to determine the data type
- QBuffer buffer(d->mRawData);
+ TQBuffer buffer(d->mRawData);
buffer.open(IO_ReadOnly);
- const char* format = QImageIO::imageFormat(&buffer);
+ const char* format = TQImageIO::imageFormat(TQT_TQIODEVICE(&buffer));
if (format) {
// This is a raster image, get the mime type now
d->mURLKind = MimeTypeUtils::KIND_RASTER_IMAGE;
@@ -498,7 +498,7 @@ void ImageLoader::decodeChunk() {
return;
}
- int chunkSize = QMIN(DECODE_CHUNK_SIZE, int(d->mRawData.size())-d->mDecodedSize);
+ int chunkSize = TQMIN(DECODE_CHUNK_SIZE, int(d->mRawData.size())-d->mDecodedSize);
int decodedSize = 0;
if (chunkSize>0) {
decodedSize = d->mDecoder.decode(
@@ -581,9 +581,9 @@ void ImageLoader::finish( bool ok ) {
if (!ok) {
d->mFrames.clear();
- d->mRawData = QByteArray();
- d->mImageFormat = QCString();
- d->mProcessedImage = QImage();
+ d->mRawData = TQByteArray();
+ d->mImageFormat = TQCString();
+ d->mProcessedImage = TQImage();
emit imageLoaded( false );
return;
}
@@ -599,10 +599,10 @@ void ImageLoader::finish( bool ok ) {
BusyLevel ImageLoader::priority() const {
BusyLevel mylevel = BUSY_NONE;
- for( QValueVector< OwnerData >::ConstIterator it = d->mOwners.begin();
+ for( TQValueVector< OwnerData >::ConstIterator it = d->mOwners.begin();
it != d->mOwners.end();
++it ) {
- mylevel = QMAX( mylevel, (*it).priority );
+ mylevel = TQMAX( mylevel, (*it).priority );
}
return mylevel;
}
@@ -633,7 +633,7 @@ void ImageLoader::resumeLoading() {
//---------------------------------------------------------------------
//
-// QImageConsumer
+// TQImageConsumer
//
//---------------------------------------------------------------------
void ImageLoader::end() {
@@ -656,7 +656,7 @@ void ImageLoader::end() {
// when we return from this function we will be in decodeChunk(), after the
// call to decode(), so we don't want to switch to a new impl yet, since
// this means deleting "this".
- QTimer::singleShot(0, this, SLOT(callFinish()) );
+ TQTimer::singleShot(0, this, TQT_SLOT(callFinish()) );
}
@@ -665,9 +665,9 @@ void ImageLoader::callFinish() {
}
-void ImageLoader::changed(const QRect& constRect) {
+void ImageLoader::changed(const TQRect& constRect) {
LOG2("");
- QRect rect = constRect;
+ TQRect rect = constRect;
if (d->mLoadedRegion.isEmpty()) {
// This is the first time we get called. Init mProcessedImage and emit
@@ -690,8 +690,8 @@ void ImageLoader::changed(const QRect& constRect) {
d->mOrientation = content.orientation();
if (MiscConfig::autoRotateImages() &&
d->mOrientation != ImageUtils::NOT_AVAILABLE && d->mOrientation != ImageUtils::NORMAL) {
- QSize size = content.size();
- d->mProcessedImage = QImage(size, d->mDecoder.image().depth());
+ TQSize size = content.size();
+ d->mProcessedImage = TQImage(size, d->mDecoder.image().depth());
}
d->mProcessedImage.setDotsPerMeterX(content.dotsPerMeterX());
d->mProcessedImage.setDotsPerMeterY(content.dotsPerMeterY());
@@ -711,7 +711,7 @@ void ImageLoader::changed(const QRect& constRect) {
// image, rotate the temp image and copy it to mProcessedImage
// Copy loaded rect
- QImage temp(rect.size(), d->mProcessedImage.depth());
+ TQImage temp(rect.size(), d->mProcessedImage.depth());
bitBlt(&temp, 0, 0,
&d->mDecoder.image(), rect.left(), rect.top(), rect.width(), rect.height());
@@ -719,9 +719,9 @@ void ImageLoader::changed(const QRect& constRect) {
temp = ImageUtils::transform(temp, d->mOrientation);
// Compute destination rect
- QWMatrix matrix = ImageUtils::transformMatrix(d->mOrientation);
+ TQWMatrix matrix = ImageUtils::transformMatrix(d->mOrientation);
- QRect imageRect = d->mDecoder.image().rect();
+ TQRect imageRect = d->mDecoder.image().rect();
imageRect = matrix.mapRect(imageRect);
rect = matrix.mapRect(rect);
@@ -740,17 +740,17 @@ void ImageLoader::changed(const QRect& constRect) {
LOG("emitting imageChanged " << d->mLoadChangedRect);
d->mTimeSinceLastUpdate.start();
emit imageChanged(d->mLoadChangedRect);
- d->mLoadChangedRect = QRect();
+ d->mLoadChangedRect = TQRect();
}
}
void ImageLoader::frameDone() {
- frameDone( QPoint( 0, 0 ), d->mDecoder.image().rect());
+ frameDone( TQPoint( 0, 0 ), d->mDecoder.image().rect());
}
-void ImageLoader::frameDone(const QPoint& offset, const QRect& rect) {
+void ImageLoader::frameDone(const TQPoint& offset, const TQRect& rect) {
LOG("");
- // Another case where the image loading in Qt's is a bit borken.
+ // Another case where the image loading in TQt's is a bit borken.
// It's possible to get several notes about a frame being done for one frame (with MNG).
if( !d->mWasFrameData ) {
// To make it even more fun, with MNG the sequence is actually
@@ -769,22 +769,22 @@ void ImageLoader::frameDone(const QPoint& offset, const QRect& rect) {
d->mWasFrameData = false;
if( !d->mLoadChangedRect.isEmpty()) {
emit imageChanged(d->mLoadChangedRect);
- d->mLoadChangedRect = QRect();
+ d->mLoadChangedRect = TQRect();
d->mTimeSinceLastUpdate.start();
}
- d->mLoadedRegion = QRegion();
+ d->mLoadedRegion = TQRegion();
- QImage image;
+ TQImage image;
if (d->mProcessedImage.isNull()) {
image = d->mDecoder.image().copy();
} else {
image = d->mProcessedImage.copy();
}
- if( offset != QPoint( 0, 0 ) || rect != image.rect()) {
+ if( offset != TQPoint( 0, 0 ) || rect != image.rect()) {
// Blit last frame below 'image'
if( !d->mFrames.isEmpty()) {
- QImage im = d->mFrames.last().image.copy();
+ TQImage im = d->mFrames.last().image.copy();
bitBlt( &im, offset.x(), offset.y(), &image, rect.x(), rect.y(), rect.width(), rect.height());
image = im;
}
@@ -809,7 +809,7 @@ void ImageLoader::setSize(int, int) {
}
-QImage ImageLoader::processedImage() const {
+TQImage ImageLoader::processedImage() const {
return d->mProcessedImage;
}
@@ -819,17 +819,17 @@ ImageFrames ImageLoader::frames() const {
}
-QCString ImageLoader::imageFormat() const {
+TQCString ImageLoader::imageFormat() const {
return d->mImageFormat;
}
-QByteArray ImageLoader::rawData() const {
+TQByteArray ImageLoader::rawData() const {
return d->mRawData;
}
-QString ImageLoader::mimeType() const {
+TQString ImageLoader::mimeType() const {
return d->mMimeType;
}
@@ -844,7 +844,7 @@ KURL ImageLoader::url() const {
}
-QRegion ImageLoader::loadedRegion() const {
+TQRegion ImageLoader::loadedRegion() const {
return d->mLoadedRegion;
}
@@ -854,16 +854,16 @@ bool ImageLoader::completed() const {
}
-void ImageLoader::ref( const QObject* owner, BusyLevel priority ) {
+void ImageLoader::ref( const TQObject* owner, BusyLevel priority ) {
OwnerData data;
data.owner = owner;
data.priority = priority;
d->mOwners.append( data );
- connect( owner, SIGNAL( destroyed()), SLOT( ownerDestroyed()));
+ connect( owner, TQT_SIGNAL( destroyed()), TQT_SLOT( ownerDestroyed()));
}
-void ImageLoader::deref( const QObject* owner ) {
- for( QValueVector< OwnerData >::Iterator it = d->mOwners.begin();
+void ImageLoader::deref( const TQObject* owner ) {
+ for( TQValueVector< OwnerData >::Iterator it = d->mOwners.begin();
it != d->mOwners.end();
++it ) {
if( (*it).owner == owner ) {
@@ -878,13 +878,13 @@ void ImageLoader::deref( const QObject* owner ) {
assert( false );
}
-void ImageLoader::release( const QObject* owner ) {
+void ImageLoader::release( const TQObject* owner ) {
disconnect( owner );
deref( owner );
}
void ImageLoader::ownerDestroyed() {
- deref( sender());
+ deref( TQT_TQOBJECT(sender()));
}
//---------------------------------------------------------------------
@@ -893,8 +893,8 @@ void ImageLoader::ownerDestroyed() {
//
//---------------------------------------------------------------------
-ImageLoader* ImageLoader::loader( const KURL& url, const QObject* owner, BusyLevel priority ) {
- if( sLoaders.contains( url )) {
+ImageLoader* ImageLoader::loader( const KURL& url, const TQObject* owner, BusyLevel priority ) {
+ if( sLoaders.tqcontains( url )) {
ImageLoader* loader = sLoaders[ url ];
loader->ref( owner, priority );
// resume if this owner has high priority
@@ -910,7 +910,7 @@ ImageLoader* ImageLoader::loader( const KURL& url, const QObject* owner, BusyLev
// This also helps with preloading jobs, since BUSY_LOADING busy level is not entered immediately
// when a new picture is selected, so preloading jobs without this delay could start working
// immediately.
- QTimer::singleShot( priority >= BUSY_LOADING ? 0 : 10, loader, SLOT( startLoading()));
+ TQTimer::singleShot( priority >= BUSY_LOADING ? 0 : 10, loader, TQT_SLOT( startLoading()));
return loader;
}