summaryrefslogtreecommitdiffstats
path: root/juk/webimagefetcher.h
blob: 803fd434ab63e78364fb5d51ec925ca0d60adb81 (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
/***************************************************************************
    copyright            : (C) 2004 Nathan Toone
    email                : [email protected]
    copyright            : (C) 2007 Michael Pyne
    email                : [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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef WEBIMAGEFETCHER_H
#define WEBIMAGEFETCHER_H

#include <kdialogbase.h>

#include <tqpixmap.h>
#include <tqstringlist.h>
#include <tqregexp.h>

#include "filehandle.h"

class KURL;

class TQHttp;

class WebImageFetcherDialog;

class WebImage
{
public:
    WebImage();

    WebImage(const TQString &imageURL,
                const TQString &thumbURL,
		int width, int height);

    TQString imageURL() const { return m_imageURL; }
    TQString thumbURL() const { return m_thumbURL; }
    TQString size() const { return m_size; }

private:
    TQString m_imageURL;
    TQString m_thumbURL;
    TQString m_size;
};

typedef TQValueList<WebImage> WebImageList;

class WebImageFetcher : public QObject
{
    Q_OBJECT

public:
    WebImageFetcher(TQObject *parent);
    ~WebImageFetcher();

    void setFile(const FileHandle &file);
    void chooseCover();

public slots:
    void abortSearch();

signals:
    void signalNewSearch(WebImageList &images);
    void signalCoverChanged(int coverId);

private:
    void displayWaitMessage();
    void requestNewSearchTerms(bool noResults = false);

private slots:
    void slotLoadImageURLs();
    void slotWebRequestFinished(int id, bool error);
    void slotCoverChosen();
    void slotNewSearch();

private:
    FileHandle m_file;
    TQString m_searchString;
    TQString m_loadedQuery;
    WebImageList m_imageList;
    uint m_selectedIndex;
    TQHttp *m_connection;
    int m_connectionId;
    WebImageFetcherDialog *m_dialog;
};
#endif