[190] | 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/qdatatable.h:1 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>qdatatable.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>qdatatable.h</h1>
|
---|
| 33 |
|
---|
| 34 | <p>This is the verbatim text of the qdatatable.h include file. It is provided only for illustration; the copyright remains with Trolltech.
|
---|
| 35 | <hr>
|
---|
| 36 | <pre>
|
---|
| 37 | /****************************************************************************
|
---|
| 38 | **
|
---|
| 39 | ** Definition of QDataTable class
|
---|
| 40 | **
|
---|
| 41 | ** Created : 2000-11-03
|
---|
| 42 | **
|
---|
| 43 | ** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved.
|
---|
| 44 | **
|
---|
| 45 | ** This file is part of the sql 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 QDATATABLE_H
|
---|
| 74 | #define QDATATABLE_H
|
---|
| 75 |
|
---|
| 76 | #ifndef QT_H
|
---|
| 77 | #include "qstring.h"
|
---|
| 78 | #include "qvariant.h"
|
---|
| 79 | #include "qtable.h"
|
---|
| 80 | #include "qsql.h"
|
---|
| 81 | #include "qsqlcursor.h"
|
---|
| 82 | #include "qsqlindex.h"
|
---|
| 83 | #include "qsqleditorfactory.h"
|
---|
| 84 | #include "qiconset.h"
|
---|
| 85 | #endif // QT_H
|
---|
| 86 |
|
---|
| 87 | #if !defined( QT_MODULE_SQL ) || defined( QT_LICENSE_PROFESSIONAL )
|
---|
| 88 | #define QM_EXPORT_SQL
|
---|
| 89 | #else
|
---|
| 90 | #define QM_EXPORT_SQL Q_EXPORT
|
---|
| 91 | #endif
|
---|
| 92 |
|
---|
| 93 | #ifndef QT_NO_SQL_VIEW_WIDGETS
|
---|
| 94 |
|
---|
| 95 | class QPainter;
|
---|
| 96 | class QSqlField;
|
---|
| 97 | class QSqlPropertyMap;
|
---|
| 98 | class QDataTablePrivate;
|
---|
| 99 |
|
---|
| 100 | class QM_EXPORT_SQL QDataTable : public QTable
|
---|
| 101 | {
|
---|
| 102 | Q_OBJECT
|
---|
| 103 |
|
---|
| 104 | Q_PROPERTY( QString nullText READ nullText WRITE setNullText )
|
---|
| 105 | Q_PROPERTY( QString trueText READ trueText WRITE setTrueText )
|
---|
| 106 | Q_PROPERTY( QString falseText READ falseText WRITE setFalseText )
|
---|
| 107 | Q_PROPERTY( DateFormat dateFormat READ dateFormat WRITE setDateFormat )
|
---|
| 108 | Q_PROPERTY( bool confirmEdits READ confirmEdits WRITE setConfirmEdits )
|
---|
| 109 | Q_PROPERTY( bool confirmInsert READ confirmInsert WRITE setConfirmInsert )
|
---|
| 110 | Q_PROPERTY( bool confirmUpdate READ confirmUpdate WRITE setConfirmUpdate )
|
---|
| 111 | Q_PROPERTY( bool confirmDelete READ confirmDelete WRITE setConfirmDelete )
|
---|
| 112 | Q_PROPERTY( bool confirmCancels READ confirmCancels WRITE setConfirmCancels )
|
---|
| 113 | Q_PROPERTY( bool autoEdit READ autoEdit WRITE setAutoEdit )
|
---|
| 114 | Q_PROPERTY( QString filter READ filter WRITE setFilter )
|
---|
| 115 | Q_PROPERTY( QStringList sort READ sort WRITE setSort )
|
---|
| 116 | Q_PROPERTY( int numCols READ numCols )
|
---|
| 117 | Q_PROPERTY( int numRows READ numRows )
|
---|
| 118 |
|
---|
| 119 | public:
|
---|
| 120 | QDataTable ( QWidget* parent=0, const char* name=0 );
|
---|
| 121 | QDataTable ( QSqlCursor* cursor, bool autoPopulate = FALSE, QWidget* parent=0, const char* name=0 );
|
---|
| 122 | ~QDataTable();
|
---|
| 123 |
|
---|
| 124 | virtual void addColumn( const QString& fieldName,
|
---|
| 125 | const QString& label = QString::null,
|
---|
| 126 | int width = -1,
|
---|
| 127 | const QIconSet& iconset = QIconSet() );
|
---|
| 128 | virtual void removeColumn( uint col );
|
---|
| 129 | virtual void setColumn( uint col, const QString& fieldName,
|
---|
| 130 | const QString& label = QString::null,
|
---|
| 131 | int width = -1,
|
---|
| 132 | const QIconSet& iconset = QIconSet() );
|
---|
| 133 |
|
---|
| 134 | QString nullText() const;
|
---|
| 135 | QString trueText() const;
|
---|
| 136 | QString falseText() const;
|
---|
| 137 | DateFormat dateFormat() const;
|
---|
| 138 | bool confirmEdits() const;
|
---|
| 139 | bool confirmInsert() const;
|
---|
| 140 | bool confirmUpdate() const;
|
---|
| 141 | bool confirmDelete() const;
|
---|
| 142 | bool confirmCancels() const;
|
---|
| 143 | bool autoDelete() const;
|
---|
| 144 | bool autoEdit() const;
|
---|
| 145 | QString filter() const;
|
---|
| 146 | QStringList sort() const;
|
---|
| 147 |
|
---|
| 148 | virtual void setSqlCursor( QSqlCursor* cursor = 0,
|
---|
| 149 | bool autoPopulate = FALSE, bool autoDelete = FALSE );
|
---|
| 150 | QSqlCursor* sqlCursor() const;
|
---|
| 151 |
|
---|
| 152 | virtual void setNullText( const QString& nullText );
|
---|
| 153 | virtual void setTrueText( const QString& trueText );
|
---|
| 154 | virtual void setFalseText( const QString& falseText );
|
---|
| 155 | virtual void setDateFormat( const DateFormat f );
|
---|
| 156 | virtual void setConfirmEdits( bool confirm );
|
---|
| 157 | virtual void setConfirmInsert( bool confirm );
|
---|
| 158 | virtual void setConfirmUpdate( bool confirm );
|
---|
| 159 | virtual void setConfirmDelete( bool confirm );
|
---|
| 160 | virtual void setConfirmCancels( bool confirm );
|
---|
| 161 | virtual void setAutoDelete( bool enable );
|
---|
| 162 | virtual void setAutoEdit( bool autoEdit );
|
---|
| 163 | virtual void setFilter( const QString& filter );
|
---|
| 164 | virtual void setSort( const QStringList& sort );
|
---|
| 165 | virtual void setSort( const QSqlIndex& sort );
|
---|
| 166 |
|
---|
| 167 | enum Refresh {
|
---|
| 168 | RefreshData = 1,
|
---|
| 169 | RefreshColumns = 2,
|
---|
| 170 | RefreshAll = 3
|
---|
| 171 | };
|
---|
| 172 | void refresh( Refresh mode );
|
---|
| 173 | void sortColumn ( int col, bool ascending = TRUE,
|
---|
| 174 | bool wholeRows = FALSE );
|
---|
| 175 | QString text ( int row, int col ) const;
|
---|
| 176 | QVariant value ( int row, int col ) const;
|
---|
| 177 | QSqlRecord* currentRecord() const;
|
---|
| 178 |
|
---|
| 179 | void installEditorFactory( QSqlEditorFactory * f );
|
---|
| 180 | void installPropertyMap( QSqlPropertyMap* m );
|
---|
| 181 |
|
---|
| 182 | int numCols() const;
|
---|
| 183 | int numRows() const;
|
---|
| 184 | void setNumCols( int c );
|
---|
| 185 | void setNumRows ( int r );
|
---|
| 186 | bool findBuffer( const QSqlIndex& idx, int atHint = 0 );
|
---|
| 187 |
|
---|
| 188 | void hideColumn( int col );
|
---|
| 189 | void showColumn( int col );
|
---|
| 190 | signals:
|
---|
| 191 | void currentChanged( QSqlRecord* record );
|
---|
| 192 | void primeInsert( QSqlRecord* buf );
|
---|
| 193 | void primeUpdate( QSqlRecord* buf );
|
---|
| 194 | void primeDelete( QSqlRecord* buf );
|
---|
| 195 | void beforeInsert( QSqlRecord* buf );
|
---|
| 196 | void beforeUpdate( QSqlRecord* buf );
|
---|
| 197 | void beforeDelete( QSqlRecord* buf );
|
---|
| 198 | void cursorChanged( QSql::Op mode );
|
---|
| 199 |
|
---|
| 200 | public slots:
|
---|
| 201 | virtual void find( const QString & str, bool caseSensitive,
|
---|
| 202 | bool backwards );
|
---|
| 203 | virtual void sortAscending( int col );
|
---|
| 204 | virtual void sortDescending( int col );
|
---|
| 205 | virtual void refresh();
|
---|
| 206 | void setColumnWidth( int col, int w );
|
---|
| 207 | void adjustColumn( int col );
|
---|
| 208 | void setColumnStretchable( int col, bool stretch );
|
---|
| 209 | void swapColumns( int col1, int col2, bool swapHeaders = FALSE );
|
---|
| 210 |
|
---|
| 211 | protected:
|
---|
| 212 | virtual bool insertCurrent();
|
---|
| 213 | virtual bool updateCurrent();
|
---|
| 214 | virtual bool deleteCurrent();
|
---|
| 215 |
|
---|
| 216 | virtual QSql::Confirm confirmEdit( QSql::Op m );
|
---|
| 217 | virtual QSql::Confirm confirmCancel( QSql::Op m );
|
---|
| 218 |
|
---|
| 219 | virtual void handleError( const QSqlError& e );
|
---|
| 220 |
|
---|
| 221 | virtual bool beginInsert();
|
---|
| 222 | virtual QWidget* beginUpdate ( int row, int col, bool replace );
|
---|
| 223 |
|
---|
| 224 | bool eventFilter( QObject *o, QEvent *e );
|
---|
| 225 | void keyPressEvent( QKeyEvent* );
|
---|
| 226 | void resizeEvent ( QResizeEvent * );
|
---|
| 227 | void contentsMousePressEvent( QMouseEvent* e );
|
---|
| 228 | void contentsContextMenuEvent( QContextMenuEvent* e );
|
---|
| 229 | void endEdit( int row, int col, bool accept, bool replace );
|
---|
| 230 | QWidget * createEditor( int row, int col, bool initFromCell ) const;
|
---|
| 231 | void activateNextCell();
|
---|
| 232 | int indexOf( uint i ) const; // ### make this public in 4.0
|
---|
| 233 | void reset();
|
---|
| 234 | void setSize( QSqlCursor* sql );
|
---|
| 235 | void repaintCell( int row, int col );
|
---|
| 236 | void paintCell ( QPainter * p, int row, int col, const QRect & cr,
|
---|
| 237 | bool selected, const QColorGroup &cg );
|
---|
| 238 | virtual void paintField( QPainter * p, const QSqlField* field, const QRect & cr,
|
---|
| 239 | bool selected );
|
---|
| 240 | void drawContents( QPainter * p, int cx, int cy, int cw, int ch );
|
---|
| 241 | virtual int fieldAlignment( const QSqlField* field );
|
---|
| 242 | void columnClicked ( int col );
|
---|
| 243 | void resizeData ( int len );
|
---|
| 244 |
|
---|
| 245 | QTableItem * item ( int row, int col ) const;
|
---|
| 246 | void setItem ( int row, int col, QTableItem * item );
|
---|
| 247 | void clearCell ( int row, int col ) ;
|
---|
| 248 | void setPixmap ( int row, int col, const QPixmap & pix );
|
---|
| 249 | void takeItem ( QTableItem * i );
|
---|
| 250 |
|
---|
| 251 | private slots:
|
---|
| 252 | void loadNextPage();
|
---|
| 253 | void setCurrentSelection( int row, int col );
|
---|
| 254 | void updateCurrentSelection();
|
---|
| 255 | void sliderPressed();
|
---|
| 256 | void sliderReleased();
|
---|
| 257 | void doInsertCurrent();
|
---|
| 258 | void doUpdateCurrent();
|
---|
| 259 |
|
---|
| 260 | private:
|
---|
| 261 | QString fieldToString( const QSqlField * field );
|
---|
| 262 | void init();
|
---|
| 263 | QWidget* beginEdit ( int row, int col, bool replace );
|
---|
| 264 | void updateRow( int row );
|
---|
| 265 | void endInsert();
|
---|
| 266 | void endUpdate();
|
---|
| 267 | QDataTablePrivate* d;
|
---|
| 268 |
|
---|
| 269 | #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
|
---|
| 270 | QDataTable( const QDataTable & );
|
---|
| 271 | QDataTable &operator=( const QDataTable & );
|
---|
| 272 | #endif
|
---|
| 273 | };
|
---|
| 274 |
|
---|
| 275 | #endif
|
---|
| 276 | #endif
|
---|
| 277 | </pre>
|
---|
| 278 | <!-- eof -->
|
---|
| 279 | <p><address><hr><div align=center>
|
---|
| 280 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 281 | <td>Copyright © 2007
|
---|
| 282 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 283 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 284 | </table></div></address></body>
|
---|
| 285 | </html>
|
---|