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

qdbtbasetabular.h

00001 #ifndef _QDBTBASETABULAR_H
00002 #define _QDBTBASETABULAR_H
00003 
00004 #include <qframe.h>
00005 #include <qguardedptr.h>
00006 
00007 #include <qdbt/qdbtglobal.h>
00008 #include <qdbt/qdbtsingleton.h>
00009 #include <qdbt/qdbtselection.h>
00010 #include <qdbt/qdbtsection.h>
00011 #include <qdbt/qdbttabularinfo.h>
00012 #include <qdbt/qdbtbasecell.h>
00013 
00014 class QCursor;
00015 class QSize;
00016 class QString;
00017 
00018 // some internal classes used to implement this widget
00019 
00020 class QdbtBaseTabular;
00021 class QdbtBaseCell;
00022 class QdbtSlideBar;
00023 class QdbtHeader;
00024 class QdbtTable;
00025 class QdbtTabularSelectDialog;
00026 class QdbtSection;
00027 class QdbtCascade;
00028 class QdbtLineEdit;
00029 class QdbtDynaTip;
00030 class QdbtPImpl;
00031 
00032 class QDBT_EXPORT QdbtBaseTabular : public QFrame, public QdbtSingletonObject
00033 {
00034   friend class QdbtHeader;
00035   friend class QdbtTable;
00036   friend class QdbtSection;
00037   friend class QdbtCascade;
00040   friend class QdbtTabularSelectDialog;
00043   friend QdbtSection::QdbtSection( QdbtBaseTabular *, const char * );
00046   friend QdbtSection::QdbtSection( QString, QdbtBaseTabular *, const char * );
00049   friend const QdbtPImpl *QdbtBaseCell::pimpl( QdbtBaseTabular * ) const;
00052   friend QdbtSelection::QdbtSelection( QdbtBaseTabular * );
00055   friend const QdbtPImpl *QdbtTabularInfo::pimpl(
00056     QGuardedPtr<QdbtBaseTabular> );
00057 
00058   
00059   Q_OBJECT
00060 
00061 public:
00062   enum HeaderMode        { MODE_QDBTTABULAR = 0x0000,
00063                            MODE_QLISTVIEW = 0x0001 };
00064   enum EditResult        { NotChanged = 0, Changed = 1, EditESCed = 2,
00065                            LoseFocus = 3 };
00066   enum TraverseReasons   { KeyPress, MouseClick, MouseDrag };
00067 
00068   enum ConfigureSwitches { SELECT_NONE                     = 0x00000000,
00069                            
00070                            SELECT_BY_ROW                   = 0x00000001,
00071                            SELECT_MULTIPLE                 = 0x00000002,
00072                            CLEAR_SELECTION_UNLESS_CTRL     = 0x00000004,
00073                            SHIFT_CLICK_MARKS_REGION        = 0x00000008,
00074                            
00075                            ALLOW_DESELECT                  = 0x00000010,
00076                            ENABLE_JUMP_SCROLL              = 0x00000020,
00077                            
00078                            SHOW_HEADER                     = 0x00000100,
00079                            SHOW_CASCADE                    = 0x00000200,
00080                            SHOW_VERTICAL_SCROLLBAR         = 0x00000400,
00081                            SHOW_HORIZONTAL_SCROLLBAR       = 0x00000800,
00082                            
00083                            ENABLE_TOOLTIPS                 = 0x00001000,
00084                            SELECTION_FOLLOW_KEYBOARD_FOCUS = 0x00002000,
00085                            TRAVERSE_ROW_ONLY               = 0x00004000,
00086                            TRAVERSE_COLUMN_ONLY            = 0x00008000 };
00087 
00088   QdbtBaseTabular( QWidget *parent = 0, const char *name = 0, WFlags w = 0 );
00089   ~QdbtBaseTabular();
00090 
00091   void setHeaderFont( const QFont &font );
00092   const QFont headerFont() const;
00093   void setCellFont( const QFont &font );
00094   const QFont cellFont() const;
00095   virtual void setDimensions( int rows, int cols );
00096   
00097   void changeSection( QdbtSection *section, int col );
00098   QdbtSection *section( int col ) const;
00099   void insertRow( int row = -1, bool selectable = TRUE );
00100   void removeRow( int row );
00101   virtual void insertCol( int col = -1 );
00102   virtual void removeCol( int col );
00103   int  numRows() const;
00104   int  numCols() const;
00105   
00106   const QdbtBaseCell *cell( int row, int col );
00107   void changeCell( const QdbtBaseCell * const tc, int row, int col );
00108   void setKeyboardFocus( int row, int col );
00109   void exposeCell( int row, int col );
00110   
00111   int  columnWidth( int col ) const;
00112   int  columnWidthHint( int col ) const;
00113   int  rowHeight( int row ) const;
00114   
00115   bool rowSelected( int row ) const;
00116   void setRowSelected( int row, bool enable );
00117   
00118   void setAutoUpdate( bool state );
00119   bool autoUpdate() const;
00120   QSize sizeHint() const;
00121   
00122   const QFont cascadeFont() const;
00123   void setCascadeText( int col, const QString &text );
00124   void setCascadeMode( int col, const int mode );
00125   void setCascadeAlignment( int col, const int align );
00126   void setCascadeFont( const QFont &font );
00127   
00128   void setHeaderCursor( const QCursor &newCursor );
00129   void setHeaderAppearance( HeaderMode headerMode );
00130   HeaderMode headerAppearance();
00131   virtual void exchangeCols( int col1, int col2 );
00132   
00133   bool currentKeyboardFocus( int &row, int &col );
00134   
00135   void clearSelection( bool set = FALSE );
00136   
00137   void setColumnVisible( int column, bool visible );
00138   bool columnVisible( int column ) const;
00139   
00140   inline const QColor& notEditableColor() const
00141     {
00142       return _nonEditColor;
00143     }
00144   
00145   void setNotEditableColor( const QColor &col );
00146 
00147   void setJumpScrollTimeout( int mSeconds );
00148   int jumpScrollTimeout() const;
00149     
00150   int  configuration() const;
00151   void modifyConfiguration( ConfigureSwitches add    = SELECT_NONE,
00152                             ConfigureSwitches revoke = SELECT_NONE );
00153   void setDefaultCell( const QdbtBaseCell & );
00154 
00155   bool containsFocus() const;
00156 
00157   void performTrace( const QString & str )
00158     {
00159       emit traceMessage( str );
00160     }
00161 
00162 public slots:
00163   void update();
00164   
00165   void redrawHeader();
00166   
00167   void redrawCascade();
00168   void setEnabled( bool state );
00169 
00170   void fitAll();
00171   void editCell( int row, int col, bool traverse );
00172   void editCell( int row, int col );
00173   void stopEdit( bool accept );
00174 
00175   
00176 protected slots:
00177   void setYOffset( int offset );
00178   void setXOffset( int offset );
00179   void setColumnWidth( int col, int width );
00180   
00181 private slots:
00182   void treatSelected( int row, bool state );
00183   void treatCellSelected( int row, int col, bool state );
00184 
00185 signals:
00186   void sectionClicked( int col );
00187   void selected( int row, bool state );
00188   void activated( int row );
00189   void cellSelected( int row, int col, bool state );
00190   void cellActivated( int row, int col );
00191   void cellEditDone( int row, int col, int action, const QString &oldText );
00192   void yOffsetChanged( int offset );
00193   void xOffsetChanged( int offset );
00194   void columnWidthChanged( int col, int width );
00195   void rightButtonClicked( int col, int row );
00196   void traceMessage( const QString & );
00197   
00198 protected:
00199   virtual void enterTableEvent( QEvent * );
00200   virtual void leaveTableEvent( QEvent * );
00201   QSize cellSize( int row, int col ) const;
00202   QPoint cellOffset( int row, int col ) const;
00203   int xOffset() const;
00204   int yOffset() const;
00205   int findRow( int yPos ) const;
00206   int findCol( int xPos ) const;
00207   int headerHeight() const;
00208   virtual bool keyboardFocusTraversal( const int reason,
00209                                        const int sourceRow,
00210                                        const int sourceCol,
00211                                        int &destRow, int &destCol );
00212   virtual bool moveFocusForJumpScroll( const int row, const int col,
00213                                        int &newRow, int &newCol );
00214   void generateRightButtonClicked( int row, int col );
00215   
00216 private:
00217   void          startSlideBar( int minx, int xpos, bool cascadeMode = FALSE );
00218 
00219   QColor                                 _nonEditColor;
00220   int                                    _configuration, _jumpScrollTimeout;
00221   int                                    prevSelectedRow, prevSelectedCol;
00222   HeaderMode                             _headerMode;
00223   static QValueList< QdbtBaseTabular * > _tabulars;
00224 
00225   static QValueList< QdbtBaseTabular * >& tabulars();
00226 
00227   QdbtPImpl                              *_pimpl;
00228 
00229 protected:
00230   const QdbtPImpl * pimpl() const { return _pimpl; }
00231 };
00232 
00233 #endif
00234 

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