| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | 
|---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/include/qtable.h:1 --> | 
|---|
| 3 | <html> | 
|---|
| 4 | <head> | 
|---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | 
|---|
| 6 | <title>qtable.h Include File</title> | 
|---|
| 7 | <style type="text/css"><!-- | 
|---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; } | 
|---|
| 9 | a:link { color: #004faf; text-decoration: none } | 
|---|
| 10 | a:visited { color: #672967; text-decoration: none } | 
|---|
| 11 | body { background: #ffffff; color: black; } | 
|---|
| 12 | --></style> | 
|---|
| 13 | </head> | 
|---|
| 14 | <body> | 
|---|
| 15 |  | 
|---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> | 
|---|
| 17 | <tr bgcolor="#E5E5E5"> | 
|---|
| 18 | <td valign=center> | 
|---|
| 19 | <a href="index.html"> | 
|---|
| 20 | <font color="#004faf">Home</font></a> | 
|---|
| 21 | | <a href="classes.html"> | 
|---|
| 22 | <font color="#004faf">All Classes</font></a> | 
|---|
| 23 | | <a href="mainclasses.html"> | 
|---|
| 24 | <font color="#004faf">Main Classes</font></a> | 
|---|
| 25 | | <a href="annotated.html"> | 
|---|
| 26 | <font color="#004faf">Annotated</font></a> | 
|---|
| 27 | | <a href="groups.html"> | 
|---|
| 28 | <font color="#004faf">Grouped Classes</font></a> | 
|---|
| 29 | | <a href="functions.html"> | 
|---|
| 30 | <font color="#004faf">Functions</font></a> | 
|---|
| 31 | </td> | 
|---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>qtable.h</h1> | 
|---|
| 33 |  | 
|---|
| 34 | <p>This is the verbatim text of the qtable.h include file. It is provided only for illustration; the copyright remains with Trolltech. | 
|---|
| 35 | <hr> | 
|---|
| 36 | <pre> | 
|---|
| 37 | /**************************************************************************** | 
|---|
| 38 | ** | 
|---|
| 39 | ** Definition of QTable widget class | 
|---|
| 40 | ** | 
|---|
| 41 | ** Created : 000607 | 
|---|
| 42 | ** | 
|---|
| 43 | ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved. | 
|---|
| 44 | ** | 
|---|
| 45 | ** This file is part of the table module of the Qt GUI Toolkit. | 
|---|
| 46 | ** | 
|---|
| 47 | ** This file may be distributed under the terms of the Q Public License | 
|---|
| 48 | ** as defined by Trolltech ASA of Norway and appearing in the file | 
|---|
| 49 | ** LICENSE.QPL included in the packaging of this file. | 
|---|
| 50 | ** | 
|---|
| 51 | ** This file may be distributed and/or modified under the terms of the | 
|---|
| 52 | ** GNU General Public License version 2 as published by the Free Software | 
|---|
| 53 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 54 | ** packaging of this file. | 
|---|
| 55 | ** | 
|---|
| 56 | ** Licensees holding valid Qt Enterprise Edition licenses may use this | 
|---|
| 57 | ** file in accordance with the Qt Commercial License Agreement provided | 
|---|
| 58 | ** with the Software. | 
|---|
| 59 | ** | 
|---|
| 60 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 
|---|
| 61 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 
|---|
| 62 | ** | 
|---|
| 63 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 
|---|
| 64 | **   information about Qt Commercial License Agreements. | 
|---|
| 65 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 
|---|
| 66 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 
|---|
| 67 | ** | 
|---|
| 68 | ** Contact info@trolltech.com if any conditions of this licensing are | 
|---|
| 69 | ** not clear to you. | 
|---|
| 70 | ** | 
|---|
| 71 | **********************************************************************/ | 
|---|
| 72 |  | 
|---|
| 73 | #ifndef QTABLE_H | 
|---|
| 74 | #define QTABLE_H | 
|---|
| 75 |  | 
|---|
| 76 | #ifndef QT_H | 
|---|
| 77 | #include "qscrollview.h" | 
|---|
| 78 | #include "qpixmap.h" | 
|---|
| 79 | #include "qptrvector.h" | 
|---|
| 80 | #include "qheader.h" | 
|---|
| 81 | #include "qmemarray.h" | 
|---|
| 82 | #include "qptrlist.h" | 
|---|
| 83 | #include "qguardedptr.h" | 
|---|
| 84 | #include "qshared.h" | 
|---|
| 85 | #include "qintdict.h" | 
|---|
| 86 | #include "qstringlist.h" | 
|---|
| 87 | #endif // QT_H | 
|---|
| 88 |  | 
|---|
| 89 |  | 
|---|
| 90 | #ifndef QT_NO_TABLE | 
|---|
| 91 |  | 
|---|
| 92 | #if !defined( QT_MODULE_TABLE ) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_TABLE ) | 
|---|
| 93 | #define QM_EXPORT_TABLE | 
|---|
| 94 | #ifndef QM_TEMPLATE_EXTERN_TABLE | 
|---|
| 95 | #   define QM_TEMPLATE_EXTERN_TABLE | 
|---|
| 96 | #endif | 
|---|
| 97 | #else | 
|---|
| 98 | #define QM_EXPORT_TABLE Q_EXPORT | 
|---|
| 99 | #define QM_TEMPLATE_EXTERN_TABLE Q_TEMPLATE_EXTERN | 
|---|
| 100 | #endif | 
|---|
| 101 |  | 
|---|
| 102 | class QTableHeader; | 
|---|
| 103 | class QValidator; | 
|---|
| 104 | class QTable; | 
|---|
| 105 | class QPaintEvent; | 
|---|
| 106 | class QTimer; | 
|---|
| 107 | class QResizeEvent; | 
|---|
| 108 | class QComboBox; | 
|---|
| 109 | class QCheckBox; | 
|---|
| 110 | class QDragObject; | 
|---|
| 111 |  | 
|---|
| 112 | struct QTablePrivate; | 
|---|
| 113 | struct QTableHeaderPrivate; | 
|---|
| 114 |  | 
|---|
| 115 |  | 
|---|
| 116 | class QM_EXPORT_TABLE QTableSelection | 
|---|
| 117 | { | 
|---|
| 118 | public: | 
|---|
| 119 | QTableSelection(); | 
|---|
| 120 | QTableSelection( int start_row, int start_col, int end_row, int end_col ); | 
|---|
| 121 | void init( int row, int col ); | 
|---|
| 122 | void expandTo( int row, int col ); | 
|---|
| 123 | bool operator==( const QTableSelection &s ) const; | 
|---|
| 124 | bool operator!=( const QTableSelection &s ) const { return !(operator==(s)); } | 
|---|
| 125 |  | 
|---|
| 126 | int topRow() const { return tRow; } | 
|---|
| 127 | int bottomRow() const { return bRow; } | 
|---|
| 128 | int leftCol() const { return lCol; } | 
|---|
| 129 | int rightCol() const { return rCol; } | 
|---|
| 130 | int anchorRow() const { return aRow; } | 
|---|
| 131 | int anchorCol() const { return aCol; } | 
|---|
| 132 | int numRows() const; | 
|---|
| 133 | int numCols() const; | 
|---|
| 134 |  | 
|---|
| 135 | bool isActive() const { return active; } | 
|---|
| 136 | bool isEmpty() const { return numRows() == 0; } | 
|---|
| 137 |  | 
|---|
| 138 | private: | 
|---|
| 139 | uint active : 1; | 
|---|
| 140 | uint inited : 1; | 
|---|
| 141 | int tRow, lCol, bRow, rCol; | 
|---|
| 142 | int aRow, aCol; | 
|---|
| 143 | }; | 
|---|
| 144 |  | 
|---|
| 145 | #define Q_DEFINED_QTABLE_SELECTION | 
|---|
| 146 | #include "qwinexport.h" | 
|---|
| 147 |  | 
|---|
| 148 | class QM_EXPORT_TABLE QTableItem : public Qt | 
|---|
| 149 | { | 
|---|
| 150 | friend class QTable; | 
|---|
| 151 |  | 
|---|
| 152 | public: | 
|---|
| 153 | enum EditType { Never, OnTyping, WhenCurrent, Always }; | 
|---|
| 154 |  | 
|---|
| 155 | QTableItem( QTable *table, EditType et ); | 
|---|
| 156 | QTableItem( QTable *table, EditType et, const QString &text ); | 
|---|
| 157 | QTableItem( QTable *table, EditType et, const QString &text, | 
|---|
| 158 | const QPixmap &p ); | 
|---|
| 159 | virtual ~QTableItem(); | 
|---|
| 160 |  | 
|---|
| 161 | virtual QPixmap pixmap() const; | 
|---|
| 162 | virtual QString text() const; | 
|---|
| 163 | virtual void setPixmap( const QPixmap &p ); | 
|---|
| 164 | virtual void setText( const QString &t ); | 
|---|
| 165 | QTable *table() const { return t; } | 
|---|
| 166 |  | 
|---|
| 167 | virtual int alignment() const; | 
|---|
| 168 | virtual void setWordWrap( bool b ); | 
|---|
| 169 | bool wordWrap() const; | 
|---|
| 170 |  | 
|---|
| 171 | EditType editType() const; | 
|---|
| 172 | virtual QWidget *createEditor() const; | 
|---|
| 173 | virtual void setContentFromEditor( QWidget *w ); | 
|---|
| 174 | virtual void setReplaceable( bool ); | 
|---|
| 175 | bool isReplaceable() const; | 
|---|
| 176 |  | 
|---|
| 177 | virtual QString key() const; | 
|---|
| 178 | virtual QSize sizeHint() const; | 
|---|
| 179 |  | 
|---|
| 180 | virtual void setSpan( int rs, int cs ); | 
|---|
| 181 | int rowSpan() const; | 
|---|
| 182 | int colSpan() const; | 
|---|
| 183 |  | 
|---|
| 184 | virtual void setRow( int r ); | 
|---|
| 185 | virtual void setCol( int c ); | 
|---|
| 186 | int row() const; | 
|---|
| 187 | int col() const; | 
|---|
| 188 |  | 
|---|
| 189 | virtual void paint( QPainter *p, const QColorGroup &cg, | 
|---|
| 190 | const QRect &cr, bool selected ); | 
|---|
| 191 |  | 
|---|
| 192 | void updateEditor( int oldRow, int oldCol ); | 
|---|
| 193 |  | 
|---|
| 194 | virtual void setEnabled( bool b ); | 
|---|
| 195 | bool isEnabled() const; | 
|---|
| 196 |  | 
|---|
| 197 | virtual int rtti() const; | 
|---|
| 198 | static int RTTI; | 
|---|
| 199 |  | 
|---|
| 200 | private: | 
|---|
| 201 | QString txt; | 
|---|
| 202 | QPixmap pix; | 
|---|
| 203 | QTable *t; | 
|---|
| 204 | EditType edType; | 
|---|
| 205 | uint wordwrap : 1; | 
|---|
| 206 | uint tcha : 1; | 
|---|
| 207 | uint enabled : 1; | 
|---|
| 208 | int rw, cl; | 
|---|
| 209 | int rowspan, colspan; | 
|---|
| 210 | #if (QT_VERSION >= 0x040000) | 
|---|
| 211 | #error "Add a setAlignment() function in 4.0 (but no d pointer)" | 
|---|
| 212 | #endif | 
|---|
| 213 | }; | 
|---|
| 214 |  | 
|---|
| 215 | #define Q_DEFINED_QTABLE_ITEM | 
|---|
| 216 | #include "qwinexport.h" | 
|---|
| 217 |  | 
|---|
| 218 | class QM_EXPORT_TABLE QComboTableItem : public QTableItem | 
|---|
| 219 | { | 
|---|
| 220 | public: | 
|---|
| 221 | QComboTableItem( QTable *table, const QStringList &list, bool editable = FALSE ); | 
|---|
| 222 | ~QComboTableItem(); | 
|---|
| 223 | virtual QWidget *createEditor() const; | 
|---|
| 224 | virtual void setContentFromEditor( QWidget *w ); | 
|---|
| 225 | virtual void paint( QPainter *p, const QColorGroup &cg, | 
|---|
| 226 | const QRect &cr, bool selected ); | 
|---|
| 227 | virtual void setCurrentItem( int i ); | 
|---|
| 228 | virtual void setCurrentItem( const QString &i ); | 
|---|
| 229 | int currentItem() const; | 
|---|
| 230 | QString currentText() const; | 
|---|
| 231 | int count() const; | 
|---|
| 232 | #if !defined(Q_NO_USING_KEYWORD) | 
|---|
| 233 | using QTableItem::text; | 
|---|
| 234 | #endif | 
|---|
| 235 | QString text( int i ) const; | 
|---|
| 236 | virtual void setEditable( bool b ); | 
|---|
| 237 | bool isEditable() const; | 
|---|
| 238 | virtual void setStringList( const QStringList &l ); | 
|---|
| 239 |  | 
|---|
| 240 | int rtti() const; | 
|---|
| 241 | static int RTTI; | 
|---|
| 242 |  | 
|---|
| 243 | QSize sizeHint() const; | 
|---|
| 244 |  | 
|---|
| 245 | private: | 
|---|
| 246 | QComboBox *cb; | 
|---|
| 247 | QStringList entries; | 
|---|
| 248 | int current; | 
|---|
| 249 | bool edit; | 
|---|
| 250 | static QComboBox *fakeCombo; | 
|---|
| 251 | static QWidget *fakeComboWidget; | 
|---|
| 252 | static int fakeRef; | 
|---|
| 253 |  | 
|---|
| 254 | }; | 
|---|
| 255 |  | 
|---|
| 256 | class QM_EXPORT_TABLE QCheckTableItem : public QTableItem | 
|---|
| 257 | { | 
|---|
| 258 | public: | 
|---|
| 259 | QCheckTableItem( QTable *table, const QString &txt ); | 
|---|
| 260 | void setText( const QString &t ); | 
|---|
| 261 | virtual QWidget *createEditor() const; | 
|---|
| 262 | virtual void setContentFromEditor( QWidget *w ); | 
|---|
| 263 | virtual void paint( QPainter *p, const QColorGroup &cg, | 
|---|
| 264 | const QRect &cr, bool selected ); | 
|---|
| 265 | virtual void setChecked( bool b ); | 
|---|
| 266 | bool isChecked() const; | 
|---|
| 267 |  | 
|---|
| 268 | int rtti() const; | 
|---|
| 269 | static int RTTI; | 
|---|
| 270 |  | 
|---|
| 271 | QSize sizeHint() const; | 
|---|
| 272 |  | 
|---|
| 273 | private: | 
|---|
| 274 | QCheckBox *cb; | 
|---|
| 275 | bool checked; | 
|---|
| 276 |  | 
|---|
| 277 | }; | 
|---|
| 278 |  | 
|---|
| 279 | class QM_EXPORT_TABLE QTable : public QScrollView | 
|---|
| 280 | { | 
|---|
| 281 | Q_OBJECT | 
|---|
| 282 | Q_ENUMS( SelectionMode FocusStyle ) | 
|---|
| 283 | Q_PROPERTY( int numRows READ numRows WRITE setNumRows ) | 
|---|
| 284 | Q_PROPERTY( int numCols READ numCols WRITE setNumCols ) | 
|---|
| 285 | Q_PROPERTY( bool showGrid READ showGrid WRITE setShowGrid ) | 
|---|
| 286 | Q_PROPERTY( bool rowMovingEnabled READ rowMovingEnabled WRITE setRowMovingEnabled ) | 
|---|
| 287 | Q_PROPERTY( bool columnMovingEnabled READ columnMovingEnabled WRITE setColumnMovingEnabled ) | 
|---|
| 288 | Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly ) | 
|---|
| 289 | Q_PROPERTY( bool sorting READ sorting WRITE setSorting ) | 
|---|
| 290 | Q_PROPERTY( SelectionMode selectionMode READ selectionMode WRITE setSelectionMode ) | 
|---|
| 291 | Q_PROPERTY( FocusStyle focusStyle READ focusStyle WRITE setFocusStyle ) | 
|---|
| 292 | Q_PROPERTY( int numSelections READ numSelections ) | 
|---|
| 293 |  | 
|---|
| 294 | friend class QTableHeader; | 
|---|
| 295 | friend class QComboTableItem; | 
|---|
| 296 | friend class QCheckTableItem; | 
|---|
| 297 | friend class QTableItem; | 
|---|
| 298 |  | 
|---|
| 299 | public: | 
|---|
| 300 | QTable( QWidget* parent=0, const char* name=0 ); | 
|---|
| 301 | QTable( int numRows, int numCols, | 
|---|
| 302 | QWidget* parent=0, const char* name=0 ); | 
|---|
| 303 | ~QTable(); | 
|---|
| 304 |  | 
|---|
| 305 | QHeader *horizontalHeader() const; | 
|---|
| 306 | QHeader *verticalHeader() const; | 
|---|
| 307 |  | 
|---|
| 308 | enum SelectionMode { Single, Multi, SingleRow, MultiRow, NoSelection }; | 
|---|
| 309 | virtual void setSelectionMode( SelectionMode mode ); | 
|---|
| 310 | SelectionMode selectionMode() const; | 
|---|
| 311 |  | 
|---|
| 312 | virtual void setItem( int row, int col, QTableItem *item ); | 
|---|
| 313 | virtual void setText( int row, int col, const QString &text ); | 
|---|
| 314 | virtual void setPixmap( int row, int col, const QPixmap &pix ); | 
|---|
| 315 | virtual QTableItem *item( int row, int col ) const; | 
|---|
| 316 | virtual QString text( int row, int col ) const; | 
|---|
| 317 | virtual QPixmap pixmap( int row, int col ) const; | 
|---|
| 318 | virtual void clearCell( int row, int col ); | 
|---|
| 319 |  | 
|---|
| 320 | virtual QRect cellGeometry( int row, int col ) const; | 
|---|
| 321 | virtual int columnWidth( int col ) const; | 
|---|
| 322 | virtual int rowHeight( int row ) const; | 
|---|
| 323 | virtual int columnPos( int col ) const; | 
|---|
| 324 | virtual int rowPos( int row ) const; | 
|---|
| 325 | virtual int columnAt( int x ) const; | 
|---|
| 326 | virtual int rowAt( int y ) const; | 
|---|
| 327 |  | 
|---|
| 328 | virtual int numRows() const; | 
|---|
| 329 | virtual int numCols() const; | 
|---|
| 330 |  | 
|---|
| 331 | void updateCell( int row, int col ); | 
|---|
| 332 |  | 
|---|
| 333 | bool eventFilter( QObject * o, QEvent * ); | 
|---|
| 334 |  | 
|---|
| 335 | int currentRow() const { return curRow; } | 
|---|
| 336 | int currentColumn() const { return curCol; } | 
|---|
| 337 | void ensureCellVisible( int row, int col ); | 
|---|
| 338 |  | 
|---|
| 339 | bool isSelected( int row, int col ) const; | 
|---|
| 340 | bool isRowSelected( int row, bool full = FALSE ) const; | 
|---|
| 341 | bool isColumnSelected( int col, bool full = FALSE ) const; | 
|---|
| 342 | int numSelections() const; | 
|---|
| 343 | QTableSelection selection( int num ) const; | 
|---|
| 344 | virtual int addSelection( const QTableSelection &s ); | 
|---|
| 345 | virtual void removeSelection( const QTableSelection &s ); | 
|---|
| 346 | virtual void removeSelection( int num ); | 
|---|
| 347 | virtual int currentSelection() const; | 
|---|
| 348 |  | 
|---|
| 349 | void selectCells( int start_row, int start_col, int end_row, int end_col ); | 
|---|
| 350 | void selectRow( int row ); | 
|---|
| 351 | void selectColumn( int col ); | 
|---|
| 352 |  | 
|---|
| 353 | bool showGrid() const; | 
|---|
| 354 |  | 
|---|
| 355 | bool columnMovingEnabled() const; | 
|---|
| 356 | bool rowMovingEnabled() const; | 
|---|
| 357 |  | 
|---|
| 358 | virtual void sortColumn( int col, bool ascending = TRUE, | 
|---|
| 359 | bool wholeRows = FALSE ); | 
|---|
| 360 | bool sorting() const; | 
|---|
| 361 |  | 
|---|
| 362 | virtual void takeItem( QTableItem *i ); | 
|---|
| 363 |  | 
|---|
| 364 | virtual void setCellWidget( int row, int col, QWidget *e ); | 
|---|
| 365 | virtual QWidget *cellWidget( int row, int col ) const; | 
|---|
| 366 | virtual void clearCellWidget( int row, int col ); | 
|---|
| 367 |  | 
|---|
| 368 | virtual QRect cellRect( int row, int col ) const; | 
|---|
| 369 |  | 
|---|
| 370 | virtual void paintCell( QPainter *p, int row, int col, | 
|---|
| 371 | const QRect &cr, bool selected ); | 
|---|
| 372 | virtual void paintCell( QPainter *p, int row, int col, | 
|---|
| 373 | const QRect &cr, bool selected, const QColorGroup &cg ); | 
|---|
| 374 | virtual void paintFocus( QPainter *p, const QRect &r ); | 
|---|
| 375 | QSize sizeHint() const; | 
|---|
| 376 |  | 
|---|
| 377 | bool isReadOnly() const; | 
|---|
| 378 | bool isRowReadOnly( int row ) const; | 
|---|
| 379 | bool isColumnReadOnly( int col ) const; | 
|---|
| 380 |  | 
|---|
| 381 | void setEnabled( bool b ); | 
|---|
| 382 |  | 
|---|
| 383 | void repaintSelections(); | 
|---|
| 384 |  | 
|---|
| 385 | enum FocusStyle { FollowStyle, SpreadSheet }; | 
|---|
| 386 | virtual void setFocusStyle( FocusStyle fs ); | 
|---|
| 387 | FocusStyle focusStyle() const; | 
|---|
| 388 |  | 
|---|
| 389 | void updateHeaderStates(); | 
|---|
| 390 |  | 
|---|
| 391 | public slots: | 
|---|
| 392 | virtual void setNumRows( int r ); | 
|---|
| 393 | virtual void setNumCols( int r ); | 
|---|
| 394 | virtual void setShowGrid( bool b ); | 
|---|
| 395 | virtual void hideRow( int row ); | 
|---|
| 396 | virtual void hideColumn( int col ); | 
|---|
| 397 | virtual void showRow( int row ); | 
|---|
| 398 | virtual void showColumn( int col ); | 
|---|
| 399 | bool isRowHidden( int row ) const; | 
|---|
| 400 | bool isColumnHidden( int col ) const; | 
|---|
| 401 |  | 
|---|
| 402 | virtual void setColumnWidth( int col, int w ); | 
|---|
| 403 | virtual void setRowHeight( int row, int h ); | 
|---|
| 404 |  | 
|---|
| 405 | virtual void adjustColumn( int col ); | 
|---|
| 406 | virtual void adjustRow( int row ); | 
|---|
| 407 |  | 
|---|
| 408 | virtual void setColumnStretchable( int col, bool stretch ); | 
|---|
| 409 | virtual void setRowStretchable( int row, bool stretch ); | 
|---|
| 410 | bool isColumnStretchable( int col ) const; | 
|---|
| 411 | bool isRowStretchable( int row ) const; | 
|---|
| 412 | virtual void setSorting( bool b ); | 
|---|
| 413 | virtual void swapRows( int row1, int row2, bool swapHeader = FALSE ); | 
|---|
| 414 | virtual void swapColumns( int col1, int col2, bool swapHeader = FALSE ); | 
|---|
| 415 | virtual void swapCells( int row1, int col1, int row2, int col2 ); | 
|---|
| 416 |  | 
|---|
| 417 | virtual void setLeftMargin( int m ); | 
|---|
| 418 | virtual void setTopMargin( int m ); | 
|---|
| 419 | virtual void setCurrentCell( int row, int col ); | 
|---|
| 420 | void clearSelection( bool repaint = TRUE ); | 
|---|
| 421 | virtual void setColumnMovingEnabled( bool b ); | 
|---|
| 422 | virtual void setRowMovingEnabled( bool b ); | 
|---|
| 423 |  | 
|---|
| 424 | virtual void setReadOnly( bool b ); | 
|---|
| 425 | virtual void setRowReadOnly( int row, bool ro ); | 
|---|
| 426 | virtual void setColumnReadOnly( int col, bool ro ); | 
|---|
| 427 |  | 
|---|
| 428 | virtual void setDragEnabled( bool b ); | 
|---|
| 429 | bool dragEnabled() const; | 
|---|
| 430 |  | 
|---|
| 431 | virtual void insertRows( int row, int count = 1 ); | 
|---|
| 432 | virtual void insertColumns( int col, int count = 1 ); | 
|---|
| 433 | virtual void removeRow( int row ); | 
|---|
| 434 | virtual void removeRows( const QMemArray<int> &rows ); | 
|---|
| 435 | virtual void removeColumn( int col ); | 
|---|
| 436 | virtual void removeColumns( const QMemArray<int> &cols ); | 
|---|
| 437 |  | 
|---|
| 438 | virtual void editCell( int row, int col, bool replace = FALSE ); | 
|---|
| 439 |  | 
|---|
| 440 | void setRowLabels( const QStringList &labels ); | 
|---|
| 441 | void setColumnLabels( const QStringList &labels ); | 
|---|
| 442 |  | 
|---|
| 443 | protected: | 
|---|
| 444 | enum EditMode { NotEditing, Editing, Replacing }; | 
|---|
| 445 | void drawContents( QPainter *p, int cx, int cy, int cw, int ch ); | 
|---|
| 446 | void contentsMousePressEvent( QMouseEvent* ); | 
|---|
| 447 | void contentsMouseMoveEvent( QMouseEvent* ); | 
|---|
| 448 | void contentsMouseDoubleClickEvent( QMouseEvent* ); | 
|---|
| 449 | void contentsMouseReleaseEvent( QMouseEvent* ); | 
|---|
| 450 | void contentsContextMenuEvent( QContextMenuEvent * e ); | 
|---|
| 451 | void keyPressEvent( QKeyEvent* ); | 
|---|
| 452 | void focusInEvent( QFocusEvent* ); | 
|---|
| 453 | void focusOutEvent( QFocusEvent* ); | 
|---|
| 454 | void viewportResizeEvent( QResizeEvent * ); | 
|---|
| 455 | void showEvent( QShowEvent *e ); | 
|---|
| 456 | void paintEvent( QPaintEvent *e ); | 
|---|
| 457 | void setEditMode( EditMode mode, int row, int col ); | 
|---|
| 458 | #ifndef QT_NO_DRAGANDDROP | 
|---|
| 459 | virtual void contentsDragEnterEvent( QDragEnterEvent *e ); | 
|---|
| 460 | virtual void contentsDragMoveEvent( QDragMoveEvent *e ); | 
|---|
| 461 | virtual void contentsDragLeaveEvent( QDragLeaveEvent *e ); | 
|---|
| 462 | virtual void contentsDropEvent( QDropEvent *e ); | 
|---|
| 463 | virtual QDragObject *dragObject(); | 
|---|
| 464 | virtual void startDrag(); | 
|---|
| 465 | #endif | 
|---|
| 466 |  | 
|---|
| 467 | virtual void paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ); | 
|---|
| 468 | virtual void activateNextCell(); | 
|---|
| 469 | virtual QWidget *createEditor( int row, int col, bool initFromCell ) const; | 
|---|
| 470 | virtual void setCellContentFromEditor( int row, int col ); | 
|---|
| 471 | virtual QWidget *beginEdit( int row, int col, bool replace ); | 
|---|
| 472 | virtual void endEdit( int row, int col, bool accept, bool replace ); | 
|---|
| 473 |  | 
|---|
| 474 | virtual void resizeData( int len ); | 
|---|
| 475 | virtual void insertWidget( int row, int col, QWidget *w ); | 
|---|
| 476 | int indexOf( int row, int col ) const; | 
|---|
| 477 |  | 
|---|
| 478 | void windowActivationChange( bool ); | 
|---|
| 479 | bool isEditing() const; | 
|---|
| 480 | EditMode editMode() const; | 
|---|
| 481 | int currEditRow() const; | 
|---|
| 482 | int currEditCol() const; | 
|---|
| 483 |  | 
|---|
| 484 | protected slots: | 
|---|
| 485 | virtual void columnWidthChanged( int col ); | 
|---|
| 486 | virtual void rowHeightChanged( int row ); | 
|---|
| 487 | virtual void columnIndexChanged( int section, int fromIndex, int toIndex ); | 
|---|
| 488 | virtual void rowIndexChanged( int section, int fromIndex, int toIndex ); | 
|---|
| 489 | virtual void columnClicked( int col ); | 
|---|
| 490 |  | 
|---|
| 491 | signals: | 
|---|
| 492 | void currentChanged( int row, int col ); | 
|---|
| 493 | void clicked( int row, int col, int button, const QPoint &mousePos ); | 
|---|
| 494 | void doubleClicked( int row, int col, int button, const QPoint &mousePos ); | 
|---|
| 495 | void pressed( int row, int col, int button, const QPoint &mousePos ); | 
|---|
| 496 | void selectionChanged(); | 
|---|
| 497 | void valueChanged( int row, int col ); | 
|---|
| 498 | void contextMenuRequested( int row, int col, const QPoint &pos ); | 
|---|
| 499 | #ifndef QT_NO_DRAGANDDROP | 
|---|
| 500 | void dropped( QDropEvent *e ); | 
|---|
| 501 | #endif | 
|---|
| 502 |  | 
|---|
| 503 | private slots: | 
|---|
| 504 | void doAutoScroll(); | 
|---|
| 505 | void doValueChanged(); | 
|---|
| 506 | void updateGeometriesSlot(); | 
|---|
| 507 |  | 
|---|
| 508 | private: | 
|---|
| 509 | void contentsMousePressEventEx( QMouseEvent* ); | 
|---|
| 510 | void drawContents( QPainter* ); | 
|---|
| 511 | void updateGeometries(); | 
|---|
| 512 | void repaintSelections( QTableSelection *oldSelection, | 
|---|
| 513 | QTableSelection *newSelection, | 
|---|
| 514 | bool updateVertical = TRUE, | 
|---|
| 515 | bool updateHorizontal = TRUE ); | 
|---|
| 516 | QRect rangeGeometry( int topRow, int leftCol, | 
|---|
| 517 | int bottomRow, int rightCol, bool &optimize ); | 
|---|
| 518 | void fixRow( int &row, int y ); | 
|---|
| 519 | void fixCol( int &col, int x ); | 
|---|
| 520 |  | 
|---|
| 521 | void init( int numRows, int numCols ); | 
|---|
| 522 | QSize tableSize() const; | 
|---|
| 523 | void repaintCell( int row, int col ); | 
|---|
| 524 | void contentsToViewport2( int x, int y, int& vx, int& vy ); | 
|---|
| 525 | QPoint contentsToViewport2( const QPoint &p ); | 
|---|
| 526 | void viewportToContents2( int vx, int vy, int& x, int& y ); | 
|---|
| 527 | QPoint viewportToContents2( const QPoint &p ); | 
|---|
| 528 |  | 
|---|
| 529 | void updateRowWidgets( int row ); | 
|---|
| 530 | void updateColWidgets( int col ); | 
|---|
| 531 | bool isSelected( int row, int col, bool includeCurrent ) const; | 
|---|
| 532 | void setCurrentCell( int row, int col, bool updateSelections, bool ensureVisible = FALSE ); | 
|---|
| 533 | void fixCell( int &row, int &col, int key ); | 
|---|
| 534 | void delayedUpdateGeometries(); | 
|---|
| 535 | struct TableWidget | 
|---|
| 536 | { | 
|---|
| 537 | TableWidget( QWidget *w, int r, int c ) : wid( w ), row( r ), col ( c ) {} | 
|---|
| 538 | QWidget *wid; | 
|---|
| 539 | int row, col; | 
|---|
| 540 | }; | 
|---|
| 541 | void saveContents( QPtrVector<QTableItem> &tmp, | 
|---|
| 542 | QPtrVector<TableWidget> &tmp2 ); | 
|---|
| 543 | void updateHeaderAndResizeContents( QTableHeader *header, | 
|---|
| 544 | int num, int colRow, | 
|---|
| 545 | int width, bool &updateBefore ); | 
|---|
| 546 | void restoreContents( QPtrVector<QTableItem> &tmp, | 
|---|
| 547 | QPtrVector<TableWidget> &tmp2 ); | 
|---|
| 548 | void finishContentsResze( bool updateBefore ); | 
|---|
| 549 |  | 
|---|
| 550 | private: | 
|---|
| 551 | QPtrVector<QTableItem> contents; | 
|---|
| 552 | QPtrVector<QWidget> widgets; | 
|---|
| 553 | int curRow; | 
|---|
| 554 | int curCol; | 
|---|
| 555 | QTableHeader *leftHeader, *topHeader; | 
|---|
| 556 | EditMode edMode; | 
|---|
| 557 | int editCol, editRow; | 
|---|
| 558 | QPtrList<QTableSelection> selections; | 
|---|
| 559 | QTableSelection *currentSel; | 
|---|
| 560 | QTimer *autoScrollTimer; | 
|---|
| 561 | int lastSortCol; | 
|---|
| 562 | bool sGrid : 1; | 
|---|
| 563 | bool mRows : 1; | 
|---|
| 564 | bool mCols : 1; | 
|---|
| 565 | bool asc : 1; | 
|---|
| 566 | bool doSort : 1; | 
|---|
| 567 | bool unused : 1; | 
|---|
| 568 | bool readOnly : 1; | 
|---|
| 569 | bool shouldClearSelection : 1; | 
|---|
| 570 | bool dEnabled : 1; | 
|---|
| 571 | bool context_menu : 1; | 
|---|
| 572 | bool drawActiveSelection : 1; | 
|---|
| 573 | bool was_visible : 1; | 
|---|
| 574 | SelectionMode selMode; | 
|---|
| 575 | int pressedRow, pressedCol; | 
|---|
| 576 | QTablePrivate *d; | 
|---|
| 577 | QIntDict<int> roRows; | 
|---|
| 578 | QIntDict<int> roCols; | 
|---|
| 579 | int startDragRow; | 
|---|
| 580 | int startDragCol; | 
|---|
| 581 | QPoint dragStartPos; | 
|---|
| 582 | int oldCurrentRow, oldCurrentCol; | 
|---|
| 583 | QWidget *unused_topLeftCorner; //### remove in 4.0 | 
|---|
| 584 | FocusStyle focusStl; | 
|---|
| 585 | QSize unused_cachedSizeHint; // ### remove in 4.0 | 
|---|
| 586 |  | 
|---|
| 587 | #if defined(Q_DISABLE_COPY) | 
|---|
| 588 | QTable( const QTable & ); | 
|---|
| 589 | QTable &operator=( const QTable & ); | 
|---|
| 590 | #endif | 
|---|
| 591 | }; | 
|---|
| 592 |  | 
|---|
| 593 | #define Q_DEFINED_QTABLE | 
|---|
| 594 | #include "qwinexport.h" | 
|---|
| 595 | #endif // QT_NO_TABLE | 
|---|
| 596 | #endif // TABLE_H | 
|---|
| 597 | </pre> | 
|---|
| 598 | <!-- eof --> | 
|---|
| 599 | <p><address><hr><div align=center> | 
|---|
| 600 | <table width=100% cellspacing=0 border=0><tr> | 
|---|
| 601 | <td>Copyright © 2007 | 
|---|
| 602 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a> | 
|---|
| 603 | <td align=right><div align=right>Qt 3.3.8</div> | 
|---|
| 604 | </table></div></address></body> | 
|---|
| 605 | </html> | 
|---|