googlefetcher.h 2.18 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/***************************************************************************
    copyright            : (C) 2004 Nathan Toone
    email                : nathan@toonetown.com
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 GOOGLEFETCHER_H
#define GOOGLEFETCHER_H

Richard Lärkäng's avatar
Richard Lärkäng committed
18
#include <kdialog.h>
19

Laurent Montel's avatar
Laurent Montel committed
20
#include <Q3ValueList>
21

22 23
#include "filehandle.h"

24 25 26 27
namespace DOM {
    class HTMLDocument;
}

28 29
class QPixmap;

Laurent Montel's avatar
Laurent Montel committed
30
class KUrl;
31

32 33 34
class GoogleImage
{
public:
35
    explicit GoogleImage(QString thumbURL = QString(), QString size = QString());
Scott Wheeler's avatar
Scott Wheeler committed
36

37 38 39 40 41 42 43 44 45 46
    QString imageURL() const { return m_imageURL; }
    QString thumbURL() const { return m_thumbURL; }
    QString size() const { return m_size; }

private:
    QString m_imageURL;
    QString m_thumbURL;
    QString m_size;
};

Laurent Montel's avatar
Laurent Montel committed
47
typedef Q3ValueList<GoogleImage> GoogleImageList;
48 49

class GoogleFetcher : public QObject
50
{
51
    Q_OBJECT
52

53
public:
54
    enum ImageSize { All, Icon, Small, Medium, Large, XLarge };
55

56
    GoogleFetcher(const FileHandle &file);
57
    QPixmap pixmap();
58

59 60 61
signals:
    void signalNewSearch(GoogleImageList &images);

62
private:
63
    void displayWaitMessage();
64
    bool requestNewSearchTerms(bool noResults = false);
65

66 67 68
    // Returns true if there are results in the search, otherwise returns false.
    bool hasImageResults(DOM::HTMLDocument &search);

69 70 71
private slots:
    void slotLoadImageURLs(GoogleFetcher::ImageSize size = All);

72
private:
73
    FileHandle m_file;
74 75
    QString m_searchString;
    QString m_loadedQuery;
76 77
    ImageSize m_loadedSize;
    GoogleImageList m_imageList;
78 79 80
    uint m_selectedIndex;
};
#endif
81 82

// vim: set et sw=4 tw=0 sta: