koIconChooser.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __ko_iconchooser_h__
00022 #define __ko_iconchooser_h__
00023
00024 #include <qgridview.h>
00025 #include <qptrlist.h>
00026 #include <qpixmap.h>
00027 #include <koffice_export.h>
00028
00029 class KoIconItem
00030 {
00031 public:
00032 KoIconItem() {}
00033 virtual ~KoIconItem() {}
00034
00035 bool hasValidPixmap() {return validPixmap; }
00036 bool validPixmap;
00037 bool hasValidThumb() {return validThumb; }
00038 bool validThumb;
00039
00040 virtual int spacing() const {return 0; }
00041 virtual void setSpacing(int) {}
00042 virtual QPixmap &pixmap() const = 0;
00043 virtual QPixmap &thumbPixmap() const = 0;
00044
00045 virtual int compare(const KoIconItem *) const { return 0; }
00046 };
00047
00048 class KoPixmapWidget : public QFrame
00049 {
00050 public:
00051 KoPixmapWidget(const QPixmap &aPixmap, QWidget *parent = 0L, const char *name = 0L);
00052 ~KoPixmapWidget();
00053
00054 protected:
00055 void paintEvent(QPaintEvent *e);
00056
00057 private:
00058 QPixmap mPixmap;
00059 };
00060
00061 class KOPAINTER_EXPORT KoIconChooser: public QGridView
00062 {
00063 Q_OBJECT
00064 public:
00065
00066 KoIconChooser(QSize iconSize, QWidget *parent = 0L, const char *name = 0L, bool sort = false);
00067 virtual ~KoIconChooser();
00068
00069 bool autoDelete() const {return mIconList.autoDelete(); }
00070 void setAutoDelete(bool b) {mIconList.setAutoDelete(b); }
00071
00072 void addItem(KoIconItem *item);
00073 bool removeItem(KoIconItem *item);
00074 void clear();
00075
00076 KoIconItem *currentItem();
00077 void setCurrentItem(KoIconItem *item);
00078
00079 void setDragEnabled(bool allow) { mDragEnabled = allow; }
00080 bool dragEnabled() const { return mDragEnabled; }
00081
00082 signals:
00083 void selected(KoIconItem *item);
00084
00085 protected:
00086 void keyPressEvent(QKeyEvent *e);
00087 void mousePressEvent( QMouseEvent *e);
00088 void mouseReleaseEvent( QMouseEvent *e);
00089 void mouseMoveEvent( QMouseEvent *e);
00090 void resizeEvent(QResizeEvent *e);
00091 void paintCell(QPainter *p, int row, int col);
00092 virtual void startDrag();
00093
00094 private:
00095 KoIconItem *itemAt(int row, int col);
00096 KoIconItem *itemAt(int index);
00097 int cellIndex(int row, int col);
00098 void calculateCells();
00099 void showFullPixmap(const QPixmap &pix, const QPoint &p);
00100 int sortInsertionIndex(const KoIconItem *item);
00101
00102 private:
00103 QPtrList<KoIconItem> mIconList;
00104 KoPixmapWidget *mPixmapWidget;
00105 int mItemWidth;
00106 int mItemHeight;
00107 int mItemCount;
00108 int mNCols;
00109 int mCurRow;
00110 int mCurCol;
00111 int mMargin;
00112 QPoint mDragStartPos;
00113 bool mMouseButtonDown;
00114 bool mDragEnabled;
00115 bool mSort;
00116 };
00117
00118
00119
00120
00121 class KOPAINTER_EXPORT KoPatternChooser : public QWidget
00122 {
00123 Q_OBJECT
00124 public:
00125 KoPatternChooser( const QPtrList<KoIconItem> &list, QWidget *parent, const char *name = 0 );
00126 ~KoPatternChooser();
00127
00128 KoIconItem *currentPattern();
00129 void setCurrentPattern( KoIconItem * );
00130 void addPattern( KoIconItem * );
00131
00132 private:
00133 KoIconChooser *chooser;
00134
00135 signals:
00136 void selected( KoIconItem * );
00137 };
00138
00139
00140 #endif
This file is part of the documentation for lib Library Version 1.4.2.