summaryrefslogtreecommitdiffstats
path: root/kuickshow/src/kuickfile.h
blob: 86d23da71e99c12a84343b60fcc6597b7cf845e6 (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
/****************************************************************************
** $Id: .emacs,v 1.3 2002/02/20 15:06:53 gis Exp $
**
** Created : 2006
**
** Copyright (C) 2006 Carsten Pfeiffer <pfeiffer@kde.org>
**
****************************************************************************/

#ifndef KUICKFILE_H
#define KUICKFILE_H

#include <tqobject.h>
#include <tqstring.h>

#include <kurl.h>
#include <kprogress.h>

namespace KIO {
    class Job;
    class FileCopyJob;
}

class KuickFile : public TQObject
{
    Q_OBJECT
  

public:
	enum DownloadStatus
	{
		OK = 1,
		CANCELED,
		ERROR	
	};

    KuickFile(const KURL& url);

    /**
     * Cleans up resources and removes any temporary file, if available.
     */
    ~KuickFile();

    const KURL& url() const { return m_url; }


    TQString localFile() const;

    bool download();

    /**
     * @return true if download is in progress
     */
    bool isDownloading() const { return m_job != 0L; }

    /**
     * @return true if a local file is available, that is,
     * @ref #localFile will return a non-empty name
     * ### HERE ADD mostlylocal thing!
     */
    bool isAvailable() const { return !localFile().isEmpty(); }

    /**
     * @return true if @ref #isAvailable() returns true AND @ref #url() is a remote URL,
     * i.e. the file really has been downloaded.
     */
    bool hasDownloaded() const;

    /**
     * Opens a modal dialog window, blocking user interaction until the download
     * has finished. If the file is already available, this function will return true
     * immediately.
     * @return true when the download has finished or false when the user aborted the dialog
     */
    KuickFile::DownloadStatus waitForDownload( TQWidget *parent );

//    bool needsDownload();

signals:
    /**
     * Signals that download has finished for that file. Will only be emitted for non-local files!
     */
    void downloaded( KuickFile * );

private slots:
    void slotResult( KIO::Job *job );
    void slotProgress( KIO::Job *job, unsigned long percent );

private:
    KURL m_url;
    TQString m_localFile;
    KIO::FileCopyJob *m_job;
    KProgress *m_progress;
    int m_currentProgress;

};

bool operator==( const KuickFile& first, const KuickFile& second );

#endif // KUICKFILE_H