1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>
Qt Toolkit - qtable.h include file
</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>qtable.h</h1><br clear="all">
This is the verbatim text of the qtable.h include file. It is
provided only for illustration; the copyright
remains with Trolltech.
<hr>
<pre>
/****************************************************************************
**
** Definition of QTable widget class
**
** Created : 000607
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
** This file is part of the table module of the Qt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid Qt Enterprise Edition licenses may use this
** file in accordance with the Qt Commercial License Agreement provided
** with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef QTABLE_H
#define QTABLE_H
#ifndef QT_H
#include <qscrollview.h>
#include <qpixmap.h>
#include <qvector.h>
#include <qheader.h>
#include <qarray.h>
#include <qlist.h>
#include <qguardedptr.h>
#include <qshared.h>
#endif // QT_H
#ifndef QT_NO_TABLE
class QTableHeader;
class <a href="qvalidator.html">QValidator</a>;
class <a href="qtable.html">QTable</a>;
class <a href="qpaintevent.html">QPaintEvent</a>;
class <a href="qtimer.html">QTimer</a>;
class <a href="qresizeevent.html">QResizeEvent</a>;
struct QTablePrivate;
struct QTableHeaderPrivate;
class Q_EXPORT <a href="qtableselection.html">QTableSelection</a>
{
public:
QTableSelection();
void init( int row, int col );
void expandTo( int row, int col );
bool operator==( const QTableSelection &s ) const;
int topRow() const { return tRow; }
int bottomRow() const { return bRow; }
int leftCol() const { return lCol; }
int rightCol() const { return rCol; }
int anchorRow() const { return aRow; }
int anchorCol() const { return aCol; }
bool isActive() const { return active; }
private:
uint active : 1;
uint inited : 1;
int tRow, lCol, bRow, rCol;
int aRow, aCol;
};
class Q_EXPORT <a href="qtableitem.html">QTableItem</a> : public <a href="qt.html">Qt</a>
{
public:
enum EditType { Never, OnTyping, WhenCurrent, Always };
QTableItem( QTable *table, EditType et, const QString &text );
QTableItem( QTable *table, EditType et, const QString &text,
const QPixmap &p );
virtual ~QTableItem();
virtual QPixmap pixmap() const;
virtual QString text() const;
virtual void setPixmap( const QPixmap &p );
virtual void setText( const QString &t );
QTable *table() const { return t; }
virtual int alignment() const;
virtual void setWordWrap( bool b );
bool wordWrap() const;
EditType editType() const;
virtual QWidget *createEditor() const;
virtual void setContentFromEditor( QWidget *w );
virtual void setReplaceable( bool );
bool isReplaceable() const;
virtual QString key() const;
virtual QSize sizeHint() const;
virtual void setSpan( int rs, int cs );
int rowSpan() const;
int colSpan() const;
virtual void setRow( int r );
virtual void setCol( int c );
int row() const;
int col() const;
virtual void paint( QPainter *p, const QColorGroup &cg,
const QRect &cr, bool selected );
void updateEditor( int oldRow, int oldCol );
private:
QString txt;
QPixmap pix;
QTable *t;
EditType edType;
uint wordwrap : 1;
uint tcha : 1;
int rw, cl;
int rowspan, colspan;
};
#if defined(Q_TEMPLATEDLL)
// MOC_SKIP_BEGIN
template class Q_EXPORT QVector<QTableItem>;
template class Q_EXPORT QVector<QWidget>;
template class Q_EXPORT QList<QTableSelection>;
// MOC_SKIP_END
#endif
class Q_EXPORT <a href="qtable.html">QTable</a> : public <a href="qscrollview.html">QScrollView</a>
{
Q_OBJECT
Q_PROPERTY( int numRows READ numRows WRITE setNumRows )
Q_PROPERTY( int numCols READ numCols WRITE setNumCols )
Q_PROPERTY( bool showGrid READ showGrid WRITE setShowGrid )
Q_PROPERTY( bool rowMovingEnabled READ rowMovingEnabled WRITE setRowMovingEnabled )
Q_PROPERTY( bool columnMovingEnabled READ columnMovingEnabled WRITE setColumnMovingEnabled )
friend class QTableHeader;
public:
QTable( QWidget *parent = 0, const char *name = 0 );
QTable( int numRows, int numCols,
QWidget *parent = 0, const char *name = 0 );
~QTable();
QHeader *horizontalHeader() const;
QHeader *verticalHeader() const;
enum SelectionMode { Single, Multi, NoSelection };
virtual void setSelectionMode( SelectionMode mode );
SelectionMode selectionMode() const;
virtual void setItem( int row, int col, QTableItem *item );
virtual void setText( int row, int col, const QString &text );
virtual void setPixmap( int row, int col, const QPixmap &pix );
virtual QTableItem *item( int row, int col ) const;
virtual QString text( int row, int col ) const;
virtual QPixmap pixmap( int row, int col ) const;
virtual void clearCell( int row, int col );
virtual QRect cellGeometry( int row, int col ) const;
virtual int columnWidth( int col ) const;
virtual int rowHeight( int row ) const;
virtual int columnPos( int col ) const;
virtual int rowPos( int row ) const;
virtual int columnAt( int pos ) const;
virtual int rowAt( int pos ) const;
int numRows() const;
int numCols() const;
void updateCell( int row, int col );
bool eventFilter( QObject * o, QEvent * );
int currentRow() const { return curRow; }
int currentColumn() const { return curCol; }
void ensureCellVisible( int row, int col );
bool isSelected( int row, int col ) const;
bool isRowSelected( int row, bool full = FALSE ) const;
bool isColumnSelected( int col, bool full = FALSE ) const;
int numSelections() const;
QTableSelection selection( int num ) const;
virtual int addSelection( const QTableSelection &s );
virtual void removeSelection( const QTableSelection &s );
virtual void removeSelection( int num );
virtual int currentSelection() const;
bool showGrid() const;
bool columnMovingEnabled() const;
bool rowMovingEnabled() const;
virtual void sortColumn( int col, bool ascending = TRUE,
bool wholeRows = FALSE );
bool sorting() const;
virtual void takeItem( QTableItem *i );
virtual void setCellWidget( int row, int col, QWidget *e );
virtual QWidget *cellWidget( int row, int col ) const;
virtual void clearCellWidget( int row, int col );
virtual void paintCell( QPainter *p, int row, int col,
const QRect &cr, bool selected );
virtual void paintFocus( QPainter *p, const QRect &r );
QSize sizeHint() const;
public slots:
virtual void setNumRows( int r );
virtual void setNumCols( int r );
virtual void setShowGrid( bool b );
virtual void hideRow( int row );
virtual void hideColumn( int col );
virtual void showRow( int row );
virtual void showColumn( int col );
virtual void setColumnWidth( int col, int w );
virtual void setRowHeight( int row, int h );
virtual void adjustColumn( int col );
virtual void adjustRow( int row );
virtual void setColumnStretchable( int col, bool stretch );
virtual void setRowStretchable( int row, bool stretch );
bool isColumnStretchable( int col ) const;
bool isRowStretchable( int row ) const;
virtual void setSorting( bool b );
virtual void swapRows( int row1, int row2 );
virtual void swapColumns( int col1, int col2 );
virtual void swapCells( int row1, int col1, int row2, int col2 );
virtual void setLeftMargin( int m );
virtual void setTopMargin( int m );
virtual void setCurrentCell( int row, int col );
void clearSelection( bool repaint = TRUE );
virtual void setColumnMovingEnabled( bool b );
virtual void setRowMovingEnabled( bool b );
protected:
void drawContents( QPainter *p, int cx, int cy, int cw, int ch );
void contentsMousePressEvent( QMouseEvent* );
void contentsMouseMoveEvent( QMouseEvent* );
void contentsMouseDoubleClickEvent( QMouseEvent* );
void contentsMouseReleaseEvent( QMouseEvent* );
void keyPressEvent( QKeyEvent* );
void focusInEvent( QFocusEvent* );
void focusOutEvent( QFocusEvent* );
void resizeEvent( QResizeEvent * );
void showEvent( QShowEvent *e );
virtual void paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch );
virtual void activateNextCell();
virtual QWidget *createEditor( int row, int col, bool initFromCell ) const;
virtual void setCellContentFromEditor( int row, int col );
virtual QWidget *beginEdit( int row, int col, bool replace );
virtual void endEdit( int row, int col, bool accept, bool replace );
virtual void resizeData( int len );
virtual void insertWidget( int row, int col, QWidget *w );
int indexOf( int row, int col ) const;
protected slots:
virtual void columnWidthChanged( int col );
virtual void rowHeightChanged( int row );
virtual void columnIndexChanged( int s, int oi, int ni );
virtual void rowIndexChanged( int s, int oi, int ni );
virtual void columnClicked( int col );
signals:
void currentChanged( int row, int col );
void clicked( int row, int col, int button, const QPoint &mousePos );
void doubleClicked( int row, int col, int button, const QPoint &mousePos );
void pressed( int row, int col, int button, const QPoint &mousePos );
void selectionChanged();
void valueChanged( int row, int col );
private slots:
void doAutoScroll();
private:
enum EditMode { NotEditing, Editing, Replacing };
void updateGeometries();
void repaintSelections( QTableSelection *oldSelection,
QTableSelection *newSelection,
bool updateVertical = TRUE,
bool updateHorizontal = TRUE );
QRect rangeGeometry( int topRow, int leftCol,
int bottomRow, int rightCol, bool &optimize );
void fixRow( int &row, int y );
void fixCol( int &col, int x );
void init( int numRows, int numCols );
QSize tableSize() const;
bool isEditing() const;
void repaintCell( int row, int col );
void contentsToViewport2( int x, int y, int& vx, int& vy );
QPoint contentsToViewport2( const QPoint &p );
void viewportToContents2( int vx, int vy, int& x, int& y );
QPoint viewportToContents2( const QPoint &p );
void updateRowWidgets( int row );
void updateColWidgets( int col );
private:
QVector<QTableItem> contents;
QVector<QWidget> widgets;
int curRow;
int curCol;
QTableHeader *leftHeader, *topHeader;
EditMode edMode;
int editCol, editRow;
QList<QTableSelection> selections;
QTableSelection *currentSel;
QTimer *autoScrollTimer;
bool sGrid, mRows, mCols;
int lastSortCol;
bool asc;
bool doSort;
bool mousePressed;
SelectionMode selMode;
int pressedRow, pressedCol;
QTablePrivate *d;
};
#if defined(Q_TEMPLATEDLL)
// MOC_SKIP_BEGIN
template class Q_EXPORT QArray<int>;
template class Q_EXPORT QArray<bool>;
// MOC_SKIP_END
#endif
class Q_EXPORT QTableHeader : public <a href="qheader.html">QHeader</a>
{
Q_OBJECT
public:
enum SectionState {
Normal,
Bold,
Selected
};
QTableHeader( int, QTable *t, QWidget *parent=0, const char *name=0 );
~QTableHeader() {};
void addLabel( const QString &s , int size );
void setSectionState( int s, SectionState state );
SectionState sectionState( int s ) const;
int sectionSize( int section ) const;
int sectionPos( int section ) const;
int sectionAt( int section ) const;
void setSectionStretchable( int s, bool b );
bool isSectionStretchable( int s ) const;
signals:
void sectionSizeChanged( int s );
protected:
void paintEvent( QPaintEvent *e );
void paintSection( QPainter *p, int index, QRect fr );
void mousePressEvent( QMouseEvent *e );
void mouseMoveEvent( QMouseEvent *e );
void mouseReleaseEvent( QMouseEvent *e );
void mouseDoubleClickEvent( QMouseEvent *e );
void resizeEvent( QResizeEvent *e );
private slots:
void doAutoScroll();
void sectionWidthChanged( int col, int os, int ns );
void indexChanged( int sec, int oldIdx, int newIdx );
void updateStretches();
void updateWidgetStretches();
private:
void updateSelections();
void saveStates();
void setCaching( bool b );
void swapSections( int oldIdx, int newIdx );
bool doSelection( QMouseEvent *e );
private:
QArray<int> states, oldStates;
QArray<bool> stretchable;
QArray<int> sectionSizes, sectionPoses;
bool mousePressed;
int pressPos, startPos, endPos;
QTable *table;
QTimer *autoScrollTimer;
QWidget *line1, *line2;
bool caching;
int resizedSection;
bool isResizing;
int numStretches;
QTimer *stretchTimer, *widgetStretchTimer;
QTableHeaderPrivate *d;
};
#endif // QT_NO_TABLE
#endif // TABLE_H
</pre>
<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 2000 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.1</div>
</table></div></address></body></html>
|