1
// vim: set tabstop=4 shiftwidth=4 noexpandtab
2
/* Gwenview - A simple image viewer for KDE
3
Copyright 2000-2004 Aur�lien G�teau
4
This class is based on the ImagePreviewJob class from Konqueror.
5
Original copyright follows.
7
/* This file is part of the KDE project
8
Copyright (C) 2000 David Faure <faure@kde.org>
10
This program is free software; you can redistribute it and/or modify
11
it under the terms of the GNU General Public License as published by
12
the Free Software Foundation; either version 2 of the License, or
13
(at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
#ifndef THUMBNAILLOADJOB_H
26
#define THUMBNAILLOADJOB_H
35
#include "tsthread/tsthread.h"
36
#include "tsthread/tswaitcondition.h"
37
#include "thumbnailsize.h"
41
typedef QPtrList<KFileItem> KFileItemList;
43
class ThumbnailThread : public TSThread {
47
const QString& originalURI,
50
const QString& originalMimeType,
51
const QString& pixPath,
52
const QString& thumbnailPath);
56
void done( const QImage& );
58
bool isJPEG(const QString& name);
59
bool loadJPEG(const QString &pixPath, QImage&, int& width, int& height);
63
QString mThumbnailPath;
67
QString mOriginalMimeType;
69
TSWaitCondition mCond;
73
* A job that determines the thumbnails for the images in the current directory
75
class ThumbnailLoadJob : public KIO::Job {
79
* Create a job for determining the pixmaps of the images in the @p itemList
81
ThumbnailLoadJob( const KFileItemList* itemList,ThumbnailSize size);
82
virtual ~ThumbnailLoadJob();
85
* Call this to get started
90
* To be called whenever an item is removed from the view
92
void itemRemoved(const KFileItem* item);
96
* Add an item to a running job
98
void appendItem(const KFileItem* item);
102
* Set item to be the next processed job. Returns false
103
* if there's no such item in mItems
105
bool setNextItem(const KFileItem* item);
108
* Temporarily suspends loading. Used if there's a more
109
* important action going on (loading an image etc.).
114
* Resumes loading if suspended.
119
* Returns the thumbnail base dir
121
static QString thumbnailBaseDir();
125
* Delete the thumbnail for the @p url
127
static void deleteImageThumbnail(const KURL& url);
131
* Emitted when the thumbnail for the @p item has been loaded
133
void thumbnailLoaded(const KFileItem* item, const QPixmap&, const QSize&);
136
void slotResult( KIO::Job *job );
137
void checkThumbnail();
138
void thumbnailReady( const QImage& im );
141
enum { STATE_STATORIG, STATE_DOWNLOADORIG, STATE_DELETETEMP, STATE_CREATETHUMB, STATE_NEXTTHUMB } mState;
144
KFileItemList mItems;
147
const KFileItem *mCurrentItem;
149
// The next item to be processed
150
const KFileItem *mNextItem;
152
// The URL of the current item (always equivalent to m_items.first()->item()->url())
155
// The URI of the original image (might be different from mCurrentURL.url())
156
QString mOriginalURI;
158
// The modification time of the original image
159
time_t mOriginalTime;
161
// The thumbnail path
162
QString mThumbnailPath;
164
// The URL of the temporary file for remote urls
168
ThumbnailSize mThumbnailSize;
170
QPixmap mBrokenPixmap;
174
ThumbnailThread mThumbnailThread;
176
void determineNextIcon();
177
void startCreatingThumbnail(const QString& path);
179
void emitThumbnailLoaded(const QImage& img);
180
void emitThumbnailLoadingFailed();