00001 #ifndef _QDBTSELECTION_H
00002 #define _QDBTSELECTION_H
00003
00004 #include <qobject.h>
00005 #include <qvaluelist.h>
00006
00007 #include <qdbt/qdbtglobal.h>
00008
00009 class QdbtBaseTabular;
00010 class QKeyEvent;
00011 class QMouseEvent;
00012 class QdbtPImpl;
00013
00014 class QDBT_EXPORT QdbtSelection : public QObject
00015 {
00016 Q_OBJECT
00017
00018 QdbtSelection( const QdbtSelection & );
00019 void operator=( const QdbtSelection & );
00020
00021 QdbtPImpl *_pimpl;
00022
00023 public:
00024 virtual ~QdbtSelection();
00025
00026 enum change_t
00027 {
00028 SINGLE_ROW_INSERT,
00029 SINGLE_ROW_DELETE,
00030 SINGLE_COL_INSERT,
00031 SINGLE_COL_DELETE,
00032 DIMENSION_SET
00033 };
00034
00035 virtual bool cellSelected( int row, int col ) = 0;
00036 virtual bool cellSelectable( int row, int col ) = 0;
00037 virtual void setCellSelected( int row, int col, bool sel ) = 0;
00038 virtual void setCellSelectable( int row, int col, bool sel ) = 0;
00039 virtual void setSelection( bool state );
00040 virtual void tableChanged( change_t op, int row, int col );
00041 virtual void keyEvent( QKeyEvent &, int row, int col );
00042 virtual void mouseEvent( QMouseEvent &, int row, int col );
00043 virtual void dump();
00044
00045 signals:
00046 void signalCellSelected( int, int, bool );
00047 void signalRowSelected( int, bool );
00048
00049 protected:
00050 QdbtSelection( QdbtBaseTabular *t );
00051 void repaintCell( int row, int col );
00052 QdbtBaseTabular *context() const;
00053
00054 private slots:
00055 void slotCheckCellSelect( int, int, bool );
00056 void slotCheckRowSelect( int, bool );
00057
00077 };
00078
00079 class QDBT_EXPORT QdbtSingleCellSelection : public QdbtSelection
00080 {
00081 Q_OBJECT
00082
00084 typedef QValueList< bool > row_t;
00085 QValueList< row_t > _selectable;
00086 int _rows;
00087 int _cols;
00088 int _rowSelected, _colSelected;
00089
00090 public:
00091 QdbtSingleCellSelection( QdbtBaseTabular * );
00092 virtual ~QdbtSingleCellSelection();
00093
00094 virtual bool cellSelected( int row, int col );
00095 virtual bool cellSelectable( int row, int col );
00096 virtual void setCellSelected( int row, int col, bool sel );
00097 virtual void setCellSelectable( int row, int col, bool sel );
00098
00099 virtual void tableChanged( change_t op, int row, int col );
00100 virtual void keyEvent( QKeyEvent &, int row, int col );
00101 virtual void mouseEvent( QMouseEvent &, int row, int col );
00102
00119 };
00120
00121 class QDBT_EXPORT QdbtCellSelection : public QdbtSelection
00122 {
00123 Q_OBJECT
00124
00126 typedef QValueList< bool > row_t;
00127 QValueList< row_t > _selection, _selectable;
00128 int _rows;
00129 int _cols;
00130 int _dragStartRow, _dragStartCol;
00131 bool _selectionForDrag;
00132
00133 public:
00134 QdbtCellSelection( QdbtBaseTabular * );
00135 virtual ~QdbtCellSelection();
00136
00137 virtual bool cellSelected( int row, int col );
00138 virtual bool cellSelectable( int row, int col );
00139 virtual void setCellSelected( int row, int col, bool sel );
00140 virtual void setCellSelectable( int row, int col, bool sel );
00141
00142 virtual void tableChanged( change_t op, int row, int col );
00143 virtual void keyEvent( QKeyEvent &, int row, int col );
00144 virtual void mouseEvent( QMouseEvent &, int row, int col );
00145
00169 };
00170
00171 class QDBT_EXPORT QdbtRowSelection : public QdbtSelection
00172 {
00173 Q_OBJECT
00174
00175 QValueList< bool > _selection;
00176 QValueList< bool > _selectable;
00177 int _rows;
00178 int _dragStart;
00179 bool _selectionForDrag;
00180 public:
00181 QdbtRowSelection( QdbtBaseTabular * );
00182 virtual ~QdbtRowSelection();
00183
00184 virtual bool cellSelected( int row, int col );
00185 virtual bool cellSelectable( int row, int col );
00186 virtual void setCellSelected( int row, int col, bool sel );
00187 virtual void setCellSelectable( int row, int col, bool sel );
00188
00189 virtual void tableChanged( change_t op, int row, int col );
00190 virtual void keyEvent( QKeyEvent &, int row, int col );
00191 virtual void mouseEvent( QMouseEvent &, int row, int col );
00192 protected:
00193 virtual void dump();
00194
00195 bool rowSelection( int row ) const;
00196 bool rowSelectable( int row ) const;
00197 void setRowSelection( int row, bool selection );
00198 void setRowSelectable( int row, bool selection );
00199 void toggleRowSelection( int row );
00200
00217 };
00218
00219 class QDBT_EXPORT QdbtSingleRowSelection : public QdbtSelection
00220 {
00221 Q_OBJECT
00222
00223 int _currentSelection;
00224 int _rows;
00225 QValueList< bool > _selectable;
00226 public:
00227 QdbtSingleRowSelection( QdbtBaseTabular * );
00228 virtual ~QdbtSingleRowSelection();
00229
00230 virtual bool cellSelected( int row, int col );
00231 virtual bool cellSelectable( int row, int col );
00232 virtual void setCellSelected( int row, int col, bool sel );
00233 virtual void setCellSelectable( int row, int col, bool sel );
00234
00235 virtual void tableChanged( change_t op, int row, int col );
00236 virtual void keyEvent( QKeyEvent &, int row, int col );
00237 virtual void mouseEvent( QMouseEvent &, int row, int col );
00238 protected:
00239 virtual void dump();
00240
00241 bool rowSelection( int row ) const;
00242 bool rowSelectable( int row ) const;
00243 int rowSelected() const;
00244 void setRowSelection( int row, bool selection );
00245 void setRowSelection( int row, bool selection, bool force );
00246 void setRowSelectable( int row, bool selection );
00247
00258 };
00259
00260
00261
00262 #endif