00001 #ifndef _QDBTHEADER
00002 #define _QDBTHEADER
00003
00004 #include <qarray.h>
00005 #include <qcursor.h>
00006 #include <qlist.h>
00007 #include <qstring.h>
00008 #include <qwidget.h>
00009
00010 #include <qdbt/qdbtglobal.h>
00011 #include <qdbt/qdbtsection.h>
00012
00013 class QdbtBaseTabular;
00014 class QdbtCascade;
00015 class QdbtPImpl;
00016
00017 class QdbtHeader : public QWidget
00018 {
00019 Q_OBJECT
00020
00021 QdbtHeader( const QdbtHeader & );
00022 void operator=( const QdbtHeader & );
00023
00024 friend class QdbtSection;
00025
00026 typedef QList<QdbtSection> SectionList;
00027
00028 struct QdbtHeadCell
00029 {
00030 int width;
00031 int position;
00032 bool resizable, visible;
00033 };
00034
00035 public:
00036 QdbtHeader( QdbtPImpl *pimpl, const char *name = 0 );
00037 virtual ~QdbtHeader();
00038 int heightHint() const;
00039 int columnWidthHint( int col );
00040 void insertCol( int col );
00041 void removeCol( int col );
00042 void setColumnWidth( int c, int w );
00043 void setColumns( int num );
00044 void setFont( const QFont &font );
00045 void changeSection( QdbtSection *section, int col );
00046 QdbtSection *section( int col );
00047 void setCursorShape( const QCursor shape );
00048
00049 void setHeaderAuxBox( bool on_flag );
00050 bool headerAuxBox();
00051
00052 void exchangeCols( int col1, int col2 );
00053
00054 void setColumnVisible( int column, bool visible );
00055 bool columnVisible( int column ) const;
00056
00057 int columnWidth( int column ) const;
00058
00059 public slots:
00060 void resizeSection( int x );
00061 void setHeaderOffset( int );
00062 void setEnabled( bool state );
00063
00064 signals:
00065 void sectionClicked( int );
00066 void signalColumnWidth( int col, int secWidth );
00067
00068 protected:
00069 void resizeEvent( QResizeEvent * );
00070 void mousePressEvent( QMouseEvent * );
00071 void mouseReleaseEvent( QMouseEvent * );
00072 void mouseMoveEvent( QMouseEvent * );
00073 void updateDividerCursor( int );
00074 void paintEvent( QPaintEvent * );
00075 void keyPressEvent( QKeyEvent * );
00076
00077 private slots:
00078 void sectionClicked( QdbtSection * );
00079 void setResizable( QdbtSection *, bool );
00080 void initFocusPolicy();
00081
00082 private:
00083 void updateHeader();
00084 int computeHeight();
00085 void propagateColumnWidthChange( int col, int width );
00086
00087 int barHeight;
00088 int divider;
00089 QCursor cursorShape;
00090 SectionList sections;
00091 QArray<QdbtHeadCell> headCells;
00092 bool headerBoxFlag;
00093 QdbtPImpl *_pimpl;
00094 };
00095
00096 #endif