summaryrefslogtreecommitdiff
path: root/noncore/unsupported/showimg/ImageFileSelector.h
blob: 798ebcc56133ae46eb7f8a529f14996feb4a07b2 (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#ifndef IMAGEFILE_SELECTOR_H
#define IMAGEFILE_SELECTOR_H


#include <qtoolbutton.h>
#include <qlistview.h>
#include <qwidgetstack.h>
#include <qlayout.h>

#include "qpe/filemanager.h"
#include "qpe/applnk.h"

class QScrollView;
class QLabel;
//class QValueList;

class ThumbWidget : public QWidget
{
    Q_OBJECT
public:
    ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent=0,int width=-1);
    ~ThumbWidget() { }

    DocLnk file() const {
        return fl;
    } 
    

    signals:
    void clicked(const DocLnk &);

protected:
    void paintEvent( QPaintEvent * );
    void resizeEvent(QResizeEvent *);
    
    void mouseReleaseEvent(QMouseEvent* event);

private:
    QPixmap pixmap;
    QLabel  *description;
    DocLnk fl;    
};




class ImageFileSelectorItem : public QListViewItem
{
public:
    ImageFileSelectorItem( QListView *parent, const DocLnk& f );
    ~ImageFileSelectorItem();

    DocLnk file() const {
        return fl;
    } 
private:
    DocLnk fl;
};

class ImageFileSelector : public QWidgetStack
{
    Q_OBJECT

public:

    enum CURRENT_VIEW {
        THUMBNAIL,
        DETAILED,
        UNKNOWN
    };


    ImageFileSelector(CURRENT_VIEW scv=DETAILED, QWidget *parent=0, const char *name=0 );
    ~ImageFileSelector();

    void reread(bool purgeCache=false);
    int fileCount();
    const DocLnk *selected();

    void setView(CURRENT_VIEW v);

    CURRENT_VIEW view()  {
        return cView;
    }

    QValueList<DocLnk> fileList() const  {
        ((ImageFileSelector*)this)->fileCount(); // ensure all loaded when this is extended
        QValueList<DocLnk> list;
        ImageFileSelectorItem *item = (ImageFileSelectorItem *)detailed->firstChild();
        while (item) {
            list.append(item->file());
            item = (ImageFileSelectorItem *)item->nextSibling();
        }
        return list;
    }

public slots:

    void switchView();

signals:
    void fileSelected( const DocLnk & );
    void closeMe();

protected:

    void resizeEvent(QResizeEvent *);


private slots:
    void fileClicked( int, QListViewItem *, const QPoint &, int );
    // pressed to get 'right down'
    void filePressed( int, QListViewItem *, const QPoint &, int );
    void fileClicked( QListViewItem *);
    void thumbClicked(const DocLnk &);

private:

    void updateSizes();


    CURRENT_VIEW    cView;  
    int     count;

    QListView   *detailed;
    QScrollView *thumb;
    QList<ThumbWidget> tList;
    QWidget *background;
    QGridLayout *gl;

};
#endif // IMAGEFILE_SELECTOR_H