Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages   Examples  

qdbttable.h

00001 #ifndef _QDBTTABLE_H
00002 #define _QDBTTABLE_H
00003 
00004 #include <qarray.h>
00005 
00006 #include <qdbt/qdbtglobal.h>
00007 
00008 #if QT_VERSION >= 300
00009 #include <qttableview.h>
00010 #define QTableViewSuper QtTableView
00011 #else
00012 #include <qtableview.h>
00013 #define QTableViewSuper QTableView
00014 #endif
00015 
00016 #include <qdbt/qdbtsingleton.h>
00017 #include "qdbtcellmatrix.h"
00018 #include "qdbtdynatip.h"
00019 
00020 class QdbtBaseCell;
00021 class QdbtBaseTabular;
00022 class QdbtSelection;
00023 class QdbtPImpl;
00024 class QdbtEditorBase;
00025 
00026 class QTimer;
00027 
00028 class QdbtTable : public 
00029 // #error "Fill in the correct base name here!"
00030  QtTableView  // In case of Qt version 3 or greater, use this line
00031 // QTableView   // In case of Qt less than version 3, use this line
00032 // SORRY, this is not (yet?) possible via QTableViewSuper, since MOC does
00033 // not behave nicely then...
00034 {
00035   Q_OBJECT
00036 
00037   QdbtTable( const QdbtTable & );
00038   void operator=( const QdbtTable & );
00039 
00043   struct RowInfo
00044   {
00046     int  height;
00047   };
00048 
00054   friend class QdbtBaseTabular;
00058   friend void QdbtDynaTip::maybeTip( const QPoint & );
00064   friend class QdbtBaseCell;
00069   friend class QdbtSelection;
00070   friend class QdbtEditorBase;
00071   
00072   enum { NoScroll = 0,
00073          ScrollDown = 1, ScrollUp = 2,
00074          ScrollLeft = 4, ScrollRight = 8 };
00075 
00076 public:
00077   QdbtTable( QdbtPImpl *pimpl, const char *name = 0 );
00078   virtual ~QdbtTable();
00079 
00080 //    int   numRows();
00081 //    int   numCols();
00082   void  insertCol( int c );
00083   void  removeCol( int c );
00084   void  insertRow( int r, bool selectable = TRUE );
00085   void  removeRow( int r );
00086   void  changeCell( const QdbtBaseCell *const tc, int row, int col );
00087   void  setDimensions( int rows, int cols );
00088 //  int   columnWidth( int col ) const;
00089 //  int   rowHeight( int row ) const;
00090   int   columnWidthHint( int col );
00091 //  bool  rowSelected( int row ) const;
00092   void  setFont( const QFont &font );
00093   void  enableTooltips();
00094   void  disableTooltips();
00095 //    bool  selectByRow();
00096 //    bool  rowSelectable( int row ) const;
00097   void  editCell( int row, int col );
00098   void  exposeCell( int row, int col );
00099   void  exchangeCols( int col1, int col2 );
00100   int   xOffset();
00101   void  setScrollbarVisible( bool vertical, bool visible );
00102   QdbtBaseCell *cell( int row, int col );
00103 
00104  
00105   int  cellWidth( int );
00106   bool containsFocus() const;
00107   
00108 protected:
00109   virtual void timerEvent( QTimerEvent * );
00110 
00111   virtual void mousePressEvent( QMouseEvent * );
00112   virtual void mouseReleaseEvent( QMouseEvent * );
00113   virtual void mouseDoubleClickEvent( QMouseEvent * );
00114   virtual void mouseMoveEvent( QMouseEvent * );
00115   virtual void wheelEvent( QWheelEvent * );
00116   virtual void keyPressEvent( QKeyEvent * );
00117   virtual void keyReleaseEvent( QKeyEvent * );
00118   virtual void focusInEvent( QFocusEvent * );
00119   virtual void focusOutEvent( QFocusEvent * );
00120   virtual void enterEvent( QEvent * );
00121   virtual void leaveEvent( QEvent * );
00122   virtual void paintEvent( QPaintEvent * );
00123   virtual void resizeEvent( QResizeEvent * );
00124 
00125   virtual void setXOffset( int offset );
00126   virtual void setYOffset( int offset );
00127 
00128 
00129   void paintCell( QPainter*, int row, int col );
00130 
00131   int  cellHeight( int );
00132   int  cellXOffset( int );
00133   int  cellYOffset( int );
00134   virtual bool focusNextPrevChild( bool next );
00135   void triggerCellEditDone( int row, int col, int result, QString oldText );
00136   bool finishEditSession();
00137   void generateRightButtonClicked( int row, int col );
00138     
00139 public slots:
00140   void setColumnWidth( int c, int w );
00141   void setTableOffset( int );
00142   void updateTable();
00143   void exposeColumn( int );
00144   void setEnabled( bool state );
00145   
00146 signals:
00147   void activated( int );
00148   void cellActivated( int, int );
00149   void cellEditDone( int, int, int, const QString & );
00150   void yOffsetChanged( int offset );
00151   void xOffsetChanged( int offset );
00152   
00153 private slots:
00154   void cellEditDone();
00155   void cellEditCanceled();
00156   void tableScrolled( int xOffset );
00157   void searchTimerEvent();
00158   
00159 private:
00160   void resetFocus( int row, int col, bool expose );
00161   QRect needsTip( const QPoint &pos, QString &text );
00162   
00163   QArray<int>     columnWidths;
00164   QArray<RowInfo> rowInfo;
00165   QdbtCellMatrix  cells;
00166   int             startDragRow;
00167   int             startDragCol;
00168   int             scrollDirection;
00169   bool            timerRunning;
00170   QPoint          mouseAt;
00171   int             editingRow;
00172   int             editingCol;
00173   bool            editingEnabled;
00174   QString         _searchText;
00175 
00176   QdbtDynaTip    *_tip;
00177   QTimer         *_searchTimer;
00178   
00179   QdbtPImpl      *_pimpl;
00180 };
00181 
00182 #endif

Generated on Mon Apr 22 12:21:54 2002 for QdbtTabular by doxygen1.2.15-20020421