00001 #ifndef IMAGEFILE_SELECTOR_H
00002 #define IMAGEFILE_SELECTOR_H
00003
00004
00005 #include <qtoolbutton.h>
00006 #include <qlistview.h>
00007 #include <qwidgetstack.h>
00008 #include <qlayout.h>
00009
00010 #include "qpe/filemanager.h"
00011 #include "qpe/applnk.h"
00012
00013 class QScrollView;
00014 class QLabel;
00015
00016
00017 class ThumbWidget : public QWidget
00018 {
00019 Q_OBJECT
00020 public:
00021 ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent=0,int width=-1);
00022 ~ThumbWidget() { }
00023
00024 DocLnk file() const {
00025 return fl;
00026 }
00027
00028
00029 signals:
00030 void clicked(const DocLnk &);
00031
00032 protected:
00033 void paintEvent( QPaintEvent * );
00034 void resizeEvent(QResizeEvent *);
00035
00036 void mouseReleaseEvent(QMouseEvent* event);
00037
00038 private:
00039 QPixmap pixmap;
00040 QLabel *description;
00041 DocLnk fl;
00042 };
00043
00044
00045
00046
00047 class ImageFileSelectorItem : public QListViewItem
00048 {
00049 public:
00050 ImageFileSelectorItem( QListView *parent, const DocLnk& f );
00051 ~ImageFileSelectorItem();
00052
00053 DocLnk file() const {
00054 return fl;
00055 }
00056 private:
00057 DocLnk fl;
00058 };
00059
00060 class ImageFileSelector : public QWidgetStack
00061 {
00062 Q_OBJECT
00063
00064 public:
00065
00066 enum CURRENT_VIEW {
00067 THUMBNAIL,
00068 DETAILED,
00069 UNKNOWN
00070 };
00071
00072
00073 ImageFileSelector(CURRENT_VIEW scv=DETAILED, QWidget *parent=0, const char *name=0 );
00074 ~ImageFileSelector();
00075
00076 void reread(bool purgeCache=false);
00077 int fileCount();
00078 const DocLnk *selected();
00079
00080 void setView(CURRENT_VIEW v);
00081
00082 CURRENT_VIEW view() {
00083 return cView;
00084 }
00085
00086 QValueList<DocLnk> fileList() const {
00087 ((ImageFileSelector*)this)->fileCount();
00088 QValueList<DocLnk> list;
00089 ImageFileSelectorItem *item = (ImageFileSelectorItem *)detailed->firstChild();
00090 while (item) {
00091 list.append(item->file());
00092 item = (ImageFileSelectorItem *)item->nextSibling();
00093 }
00094 return list;
00095 }
00096
00097 public slots:
00098
00099 void switchView();
00100
00101 signals:
00102 void fileSelected( const DocLnk & );
00103 void closeMe();
00104
00105 protected:
00106
00107 void resizeEvent(QResizeEvent *);
00108
00109
00110 private slots:
00111 void fileClicked( int, QListViewItem *, const QPoint &, int );
00112
00113 void filePressed( int, QListViewItem *, const QPoint &, int );
00114 void fileClicked( QListViewItem *);
00115 void thumbClicked(const DocLnk &);
00116
00117 private:
00118
00119 void updateSizes();
00120
00121
00122 CURRENT_VIEW cView;
00123 int count;
00124
00125 QListView *detailed;
00126 QScrollView *thumb;
00127 QList<ThumbWidget> tList;
00128 QWidget *background;
00129 QGridLayout *gl;
00130
00131 };
00132 #endif // IMAGEFILE_SELECTOR_H
00133
00134