| 1 | /****************************************************************************
|
|---|
| 2 | ** $Id: main.cpp 160 2006-12-11 20:15:57Z dmik $
|
|---|
| 3 | **
|
|---|
| 4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of an example program for Qt. This example
|
|---|
| 7 | ** program may be used, distributed and modified without limitation.
|
|---|
| 8 | **
|
|---|
| 9 | *****************************************************************************/
|
|---|
| 10 |
|
|---|
| 11 | #include <qapplication.h>
|
|---|
| 12 | #include <qtable.h>
|
|---|
| 13 |
|
|---|
| 14 | // Table size
|
|---|
| 15 |
|
|---|
| 16 | const int numRows = 1000000;
|
|---|
| 17 | const int numCols = 1000000;
|
|---|
| 18 |
|
|---|
| 19 | class MyTable : public QTable
|
|---|
| 20 | {
|
|---|
| 21 | public:
|
|---|
| 22 | MyTable( int r, int c ) : QTable( r, c ) {
|
|---|
| 23 | items.setAutoDelete( TRUE );
|
|---|
| 24 | widgets.setAutoDelete( TRUE );
|
|---|
| 25 | setCaption( tr( "A 1 Million x 1 Million Cell Table" ) );
|
|---|
| 26 | setLeftMargin( fontMetrics().width( "W999999W" ) );
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | void resizeData( int ) {}
|
|---|
| 30 | QTableItem *item( int r, int c ) const { return items.find( indexOf( r, c ) ); }
|
|---|
| 31 | void setItem( int r, int c, QTableItem *i ) { items.replace( indexOf( r, c ), i ); }
|
|---|
| 32 | void clearCell( int r, int c ) { items.remove( indexOf( r, c ) ); }
|
|---|
| 33 | void takeItem( QTableItem *item )
|
|---|
| 34 | {
|
|---|
| 35 | items.setAutoDelete( FALSE );
|
|---|
| 36 | items.remove( indexOf( item->row(), item->col() ) );
|
|---|
| 37 | items.setAutoDelete( TRUE );
|
|---|
| 38 | }
|
|---|
| 39 | void insertWidget( int r, int c, QWidget *w ) { widgets.replace( indexOf( r, c ), w ); }
|
|---|
| 40 | QWidget *cellWidget( int r, int c ) const { return widgets.find( indexOf( r, c ) ); }
|
|---|
| 41 | void clearCellWidget( int r, int c )
|
|---|
| 42 | {
|
|---|
| 43 | QWidget *w = widgets.take( indexOf( r, c ) );
|
|---|
| 44 | if ( w )
|
|---|
| 45 | w->deleteLater();
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | private:
|
|---|
| 49 | QIntDict<QTableItem> items;
|
|---|
| 50 | QIntDict<QWidget> widgets;
|
|---|
| 51 |
|
|---|
| 52 | };
|
|---|
| 53 |
|
|---|
| 54 | // The program starts here.
|
|---|
| 55 |
|
|---|
| 56 | int main( int argc, char **argv )
|
|---|
| 57 | {
|
|---|
| 58 | QApplication app( argc, argv );
|
|---|
| 59 |
|
|---|
| 60 | MyTable table( numRows, numCols );
|
|---|
| 61 | app.setMainWidget( &table );
|
|---|
| 62 | table.show();
|
|---|
| 63 | return app.exec();
|
|---|
| 64 | }
|
|---|