summaryrefslogtreecommitdiffstats
path: root/ksquirrel/sq_thumbnailloadjob.h
blob: e256cbdaff71bc4268a9109f28736e79650f61b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
    copyright            : (C) 2004 by Baryshev Dmitry
    KSquirrel - image viewer for KDE
*/

/*  This file is part of the KDE project
    Copyright (C) 2000 David Faure <[email protected]>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#ifndef SQ_THUMBNAILLOADJOB_H
#define SQ_THUMBNAILLOADJOB_H

#include <tqimage.h>

#include <kio/job.h>

#include "sq_thumbnailinfo.h"

class KFileItem;
class KTempFile;

class SQ_DirThumbs;
class SQ_FileThumbView;

typedef TQPtrList<KFileItem> KFileItemList;

/*
 *  SQ_ThumbnailLoadJob is a job for loading thumbnails
 *  in given directory.
 */

class SQ_ThumbnailLoadJob : public KIO::Job
{
    Q_OBJECT
  TQ_OBJECT

    public:
        SQ_ThumbnailLoadJob(const KFileItemList &itemList, SQ_FileThumbView *parnt);
        ~SQ_ThumbnailLoadJob();

        virtual void kill(bool q = true);

        void start();
        void itemRemoved(const KFileItem* item);
        void itemsRemoved(const KFileItemList &list);
        void appendItem(const KFileItem* item);
        void appendItems(const KFileItemList &items);
        void prependItems(const KFileItemList &items);

        void pop(const KFileItemList &items);

    private:
        void determineNextIcon();
        bool statResultThumbnail();
        void createThumbnail(const KURL &);
        void emitThumbnailLoaded(SQ_Thumbnail &);
        void emitThumbnailLoadingFailed();
        void insertOrSync(const KURL &, SQ_Thumbnail &th);
        void nextFile(bool b);

    signals:
        void thumbnailLoaded(const KFileItem* item, const SQ_Thumbnail &t);
        void done();

    private slots:
        void slotResult(KIO::Job *job);
        void slotData(KIO::Job *job, const TQByteArray &data);

    private:
        enum { STATE_STATORIG, STATE_PREDOWNLOAD, STATE_DOWNLOAD } mState;

        KFileItemList mItems;
        KFileItem *mCurrentItem;
        KURL mCurrentURL;
        KURL mThumbURL;
        KURL mTempURL;
        KIO::filesize_t totalSize, size;
        KTempFile         *tmp;
        time_t mOriginalTime;
        TQString mime;
        bool continueDownload, donothing;

        SQ_DirThumbs *dir;
        SQ_Thumbnail mBrokenThumbnail;
        SQ_FileThumbView *tqparent;
};

#endif