summaryrefslogtreecommitdiffabout
path: root/qtcompat
authorzautrix <zautrix>2004-06-26 19:01:18 (UTC)
committer zautrix <zautrix>2004-06-26 19:01:18 (UTC)
commitb9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff)
tree2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /qtcompat
downloadkdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2
Initial revision
Diffstat (limited to 'qtcompat') (more/less context) (show whitespace changes)
-rw-r--r--qtcompat/qcombotableitem.cpp481
-rw-r--r--qtcompat/qcombotableitem.h571
-rw-r--r--qtcompat/qgridview.cpp362
-rw-r--r--qtcompat/qgridview.h138
-rw-r--r--qtcompat/qinputdialog.cpp495
-rw-r--r--qtcompat/qinputdialog.h105
-rw-r--r--qtcompat/qinputdialog.h.wech14
-rw-r--r--qtcompat/qksplitter.h23
-rw-r--r--qtcompat/qmemarray.h8
-rw-r--r--qtcompat/qpair.h96
-rw-r--r--qtcompat/qptrlist.h10
-rw-r--r--qtcompat/qptrstack.h9
-rw-r--r--qtcompat/qptrvector.h8
-rw-r--r--qtcompat/qtcompat.pro31
-rw-r--r--qtcompat/qtcompat.pro.back19
-rw-r--r--qtcompat/qtooltipcompat.cpp42
-rw-r--r--qtcompat/qtooltipcompat.h34
17 files changed, 2446 insertions, 0 deletions
diff --git a/qtcompat/qcombotableitem.cpp b/qtcompat/qcombotableitem.cpp
new file mode 100644
index 0000000..348ea24
--- a/dev/null
+++ b/qtcompat/qcombotableitem.cpp
@@ -0,0 +1,481 @@
1/****************************************************************************
2**
3** Implementation of QTable widget class
4**
5** Created : 000607
6**
7** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
8**
9** This file is part of the table module of the Qt GUI Toolkit.
10**
11** This file may be distributed under the terms of the Q Public License
12** as defined by Trolltech AS of Norway and appearing in the file
13** LICENSE.QPL included in the packaging of this file.
14**
15** This file may be distributed and/or modified under the terms of the
16** GNU General Public License version 2 as published by the Free Software
17** Foundation and appearing in the file LICENSE.GPL included in the
18** packaging of this file.
19**
20** Licensees holding valid Qt Enterprise Edition licenses may use this
21** file in accordance with the Qt Commercial License Agreement provided
22** with the Software.
23**
24** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26**
27** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
28** information about Qt Commercial License Agreements.
29** See http://www.trolltech.com/qpl/ for QPL licensing information.
30** See http://www.trolltech.com/gpl/ for GPL licensing information.
31**
32** Contact info@trolltech.com if any conditions of this licensing are
33** not clear to you.
34**
35**********************************************************************/
36/*US
37#include "qglobal.h"
38#if defined(Q_CC_BOR)
39// needed for qsort() because of a std namespace problem on Borland
40#include "qplatformdefs.h"
41#endif
42*/
43#include "qcombotableitem.h"
44
45#include "qcombobox.h"
46#include "qstyle.h"
47
48/*US
49
50#ifndef QT_NO_TABLE
51
52#include "qpainter.h"
53#include "qlineedit.h"
54#include "qcursor.h"
55#include "qapplication.h"
56#include "qtimer.h"
57#include "qobjectlist.h"
58#include "qiconset.h"
59#include "qcombobox.h"
60#include "qcheckbox.h"
61#include "qdragobject.h"
62#include "qevent.h"
63#include "qlistbox.h"
64#include "qstyle.h"
65
66#include <stdlib.h>
67#include <limits.h>
68
69static bool qt_update_cell_widget = TRUE;
70
71class QM_EXPORT_TABLE QTableHeader : public QHeader
72{
73 friend class QTable;
74 Q_OBJECT
75
76public:
77 enum SectionState {
78 Normal,
79 Bold,
80 Selected
81 };
82
83 QTableHeader( int, QTable *t, QWidget* parent=0, const char* name=0 );
84 ~QTableHeader() {};
85 void addLabel( const QString &s, int size );
86 void setLabel( int section, const QString & s, int size = -1 );
87 void setLabel( int section, const QIconSet & iconset, const QString & s,
88 int size = -1 );
89 void removeLabel( int section );
90
91 void setSectionState( int s, SectionState state );
92 void setSectionStateToAll( SectionState state );
93 SectionState sectionState( int s ) const;
94
95 int sectionSize( int section ) const;
96 int sectionPos( int section ) const;
97 int sectionAt( int section ) const;
98
99 void setSectionStretchable( int s, bool b );
100 bool isSectionStretchable( int s ) const;
101
102 void updateCache();
103
104signals:
105 void sectionSizeChanged( int s );
106
107protected:
108 void paintEvent( QPaintEvent *e );
109 void paintSection( QPainter *p, int index, const QRect& fr );
110 void mousePressEvent( QMouseEvent *e );
111 void mouseMoveEvent( QMouseEvent *e );
112 void mouseReleaseEvent( QMouseEvent *e );
113 void mouseDoubleClickEvent( QMouseEvent *e );
114 void resizeEvent( QResizeEvent *e );
115
116private slots:
117 void doAutoScroll();
118 void sectionWidthChanged( int col, int os, int ns );
119 void indexChanged( int sec, int oldIdx, int newIdx );
120 void updateStretches();
121 void updateWidgetStretches();
122
123private:
124 void updateSelections();
125 void saveStates();
126 void setCaching( bool b );
127 void swapSections( int oldIdx, int newIdx, bool swapTable = TRUE );
128 bool doSelection( QMouseEvent *e );
129 void sectionLabelChanged( int section );
130 void resizeArrays( int n );
131
132private:
133 QMemArray<int> states, oldStates;
134 QMemArray<bool> stretchable;
135 QMemArray<int> sectionSizes, sectionPoses;
136 bool mousePressed;
137 int pressPos, startPos, endPos;
138 QTable *table;
139 QTimer *autoScrollTimer;
140 QWidget *line1, *line2;
141 bool caching;
142 int resizedSection;
143 bool isResizing;
144 int numStretches;
145 QTimer *stretchTimer, *widgetStretchTimer;
146 QTableHeaderPrivate *d;
147
148};
149
150#ifdef _WS_QWS_
151# define NO_LINE_WIDGET
152#endif
153
154
155
156struct QTablePrivate
157{
158 QTablePrivate() : hasRowSpan( FALSE ), hasColSpan( FALSE ),
159 redirectMouseEvent( FALSE )
160 {
161 hiddenRows.setAutoDelete( TRUE );
162 hiddenCols.setAutoDelete( TRUE );
163 }
164 uint hasRowSpan : 1;
165 uint hasColSpan : 1;
166 uint redirectMouseEvent : 1;
167 QIntDict<int> hiddenRows, hiddenCols;
168 QTimer *geomTimer;
169};
170
171struct QTableHeaderPrivate
172{
173#ifdef NO_LINE_WIDGET
174 int oldLinePos;
175#endif
176};
177
178static bool isRowSelection( QTable::SelectionMode selMode )
179{
180 return selMode == QTable::SingleRow || selMode == QTable::MultiRow;
181}
182*/
183
184
185/*!
186 \class QComboTableItem
187 \brief The QComboTableItem class provides a means of using
188 comboboxes in QTables.
189
190 \ingroup advanced
191 \module table
192
193 A QComboTableItem is a table item which looks and behaves like a
194 combobox. The advantage of using QComboTableItems rather than real
195 comboboxes is that a QComboTableItem uses far less resources than
196 real comboboxes in \l{QTable}s. When the cell has the focus it
197 displays a real combobox which the user can interact with. When
198 the cell does not have the focus the cell \e looks like a
199 combobox. Only text items (i.e. no pixmaps) may be used in
200 QComboTableItems.
201
202 QComboTableItem items have the edit type \c WhenCurrent (see
203 \l{EditType}). The QComboTableItem's list of items is provided by
204 a QStringList passed to the constructor.
205
206 The list of items may be changed using setStringList(). The
207 current item can be set with setCurrentItem() and retrieved with
208 currentItem(). The text of the current item can be obtained with
209 currentText(), and the text of a particular item can be retrieved
210 with text().
211
212 If isEditable() is TRUE the QComboTableItem will permit the user
213 to either choose an existing list item, or create a new list item
214 by entering their own text; otherwise the user may only choose one
215 of the existing list items.
216
217 To populate a table cell with a QComboTableItem use
218 QTable::setItem().
219
220 QComboTableItems may be deleted with QTable::clearCell().
221
222 QComboTableItems can be distinguished from \l{QTableItem}s and
223 \l{QCheckTableItem}s using their Run Time Type Identification
224 number (see rtti()).
225
226 \img qtableitems.png Table Items
227
228 \sa QCheckTableItem QTableItem QComboBox
229*/
230
231QComboBox *QComboTableItem::fakeCombo = 0;
232QWidget *fakeComboWidget = 0;
233
234/*!
235 Creates a combo table item for the table \a table. The combobox's
236 list of items is passed in the \a list argument. If \a editable is
237 TRUE the user may type in new list items; if \a editable is FALSE
238 the user may only select from the list of items provided.
239
240 By default QComboTableItems cannot be replaced by other table
241 items since isReplaceable() returns FALSE by default.
242
243 \sa QTable::clearCell() EditType
244*/
245
246QComboTableItem::QComboTableItem( QTable *table, const QStringList &list, bool editable )
247 : QTableItem( table, WhenCurrent, "" ), entries( list ), current( 0 ), edit( editable )
248{
249 setReplaceable( FALSE );
250 if ( !fakeCombo ) {
251 fakeComboWidget = new QWidget( 0, 0 );
252 fakeCombo = new QComboBox( FALSE, fakeComboWidget, 0 );
253 fakeCombo->hide();
254 }
255}
256
257/*!
258 Sets the list items of this QComboTableItem to the strings in the
259 string list \a l.
260*/
261
262void QComboTableItem::setStringList( const QStringList &l )
263{
264 entries = l;
265 current = 0;
266 if ( table()->cellWidget( row(), col() ) ) {
267 cb->clear();
268 cb->insertStringList( entries );
269 }
270 table()->updateCell( row(), col() );
271}
272
273/*! \reimp */
274
275QWidget *QComboTableItem::createEditor() const
276{
277 // create an editor - a combobox in our case
278 ( (QComboTableItem*)this )->cb = new QComboBox( edit, table()->viewport(), "qt_editor_cb" );
279 cb->insertStringList( entries );
280 cb->setCurrentItem( current );
281 QObject::connect( cb, SIGNAL( activated( int ) ), table(), SLOT( doValueChanged() ) );
282 return cb;
283}
284
285/*! \reimp */
286
287void QComboTableItem::setContentFromEditor( QWidget *w )
288{
289 if ( w->inherits( "QComboBox" ) ) {
290 QComboBox *cb = (QComboBox*)w;
291 entries.clear();
292 for ( int i = 0; i < cb->count(); ++i )
293 entries << cb->text( i );
294 current = cb->currentItem();
295 setText( *entries.at( current ) );
296 }
297}
298
299/*! \reimp */
300
301void QComboTableItem::paint( QPainter *p, const QColorGroup &cg,
302 const QRect &cr, bool selected )
303{
304 fakeCombo->resize( cr.width(), cr.height() );
305
306 QColorGroup c( cg );
307 if ( selected ) {
308 c.setBrush( QColorGroup::Base, cg.brush( QColorGroup::Highlight ) );
309 c.setColor( QColorGroup::Text, cg.highlightedText() );
310 }
311
312/*US QStyle::SFlags flags = QStyle::Style_Default;
313 if(isEnabled() && table()->isEnabled())
314 flags |= QStyle::Style_Enabled;
315*/
316//US table()->style().drawComplexControl( QStyle::CC_ComboBox, p, fakeCombo, fakeCombo->rect(), c, flags );
317
318 table()->style().drawComboButton(p, fakeCombo->x(), fakeCombo->y(), fakeCombo->width(), fakeCombo->height(), c, FALSE, FALSE, (/*US isEnabled() && */table()->isEnabled()), 0);
319 p->save();
320/*US
321 QRect textR = table()->style().querySubControlMetrics(QStyle::CC_ComboBox, fakeCombo,
322 QStyle::SC_ComboBoxEditField);
323
324*/
325 int align = alignment(); // alignment() changes entries
326//US p->drawText( textR, wordWrap() ? ( align | WordBreak ) : align, *entries.at( current ) );
327 QRect textR = QRect( fakeCombo->x()+2, fakeCombo->y(), fakeCombo->width()- 17, fakeCombo->height() );
328 //qDebug("x %d -- %d wid %d -- %d ", cr.x(),fakeCombo->x(), cr.width(), fakeCombo->width() );
329 p->drawText( textR, wordWrap() ? ( align | WordBreak ) : align, *entries.at( current ) );
330 p->restore();
331}
332
333/*!
334 Sets the list item \a i to be the combo table item's current list
335 item.
336
337 \sa currentItem()
338*/
339
340void QComboTableItem::setCurrentItem( int i )
341{
342 QWidget *w = table()->cellWidget( row(), col() );
343 if ( w && w->inherits( "QComboBox" ) ) {
344 ( (QComboBox*)w )->setCurrentItem( i );
345 current = i;
346 setText( ( (QComboBox*)w )->currentText() );
347 } else {
348 current = i;
349 setText( *entries.at( i ) );
350 table()->updateCell( row(), col() );
351 }
352}
353
354/*!
355 \overload
356
357 Sets the list item whose text is \a s to be the combo table item's
358 current list item. Does nothing if no list item has the text \a s.
359
360 \sa currentItem()
361*/
362
363void QComboTableItem::setCurrentItem( const QString &s )
364{
365 int i = entries.findIndex( s );
366 if ( i != -1 )
367 setCurrentItem( i );
368}
369
370/*!
371 Returns the index of the combo table item's current list item.
372
373 \sa setCurrentItem()
374*/
375
376int QComboTableItem::currentItem() const
377{
378 QWidget *w = table()->cellWidget( row(), col() );
379 if ( w && w->inherits( "QComboBox" ) )
380 return ( (QComboBox*)w )->currentItem();
381 return current;
382}
383
384/*!
385 Returns the text of the combo table item's current list item.
386
387 \sa currentItem() text()
388*/
389
390QString QComboTableItem::currentText() const
391{
392 QWidget *w = table()->cellWidget( row(), col() );
393 if ( w && w->inherits( "QComboBox" ) )
394 return ( (QComboBox*)w )->currentText();
395 return *entries.at( current );
396}
397
398/*!
399 Returns the total number of list items in the combo table item.
400*/
401
402int QComboTableItem::count() const
403{
404 QWidget *w = table()->cellWidget( row(), col() );
405 if ( w && w->inherits( "QComboBox" ) )
406 return ( (QComboBox*)w )->count();
407 return (int)entries.count(); //### size_t/int cast
408}
409
410/*!
411 Returns the text of the combo's list item at index \a i.
412
413 \sa currentText()
414*/
415
416QString QComboTableItem::text( int i ) const
417{
418 QWidget *w = table()->cellWidget( row(), col() );
419 if ( w && w->inherits( "QComboBox" ) )
420 return ( (QComboBox*)w )->text( i );
421 return *entries.at( i );
422}
423
424/*!
425 If \a b is TRUE the combo table item can be edited, i.e. the user
426 may enter a new text item themselves. If \a b is FALSE the user may
427 may only choose one of the existing items.
428
429 \sa isEditable()
430*/
431
432void QComboTableItem::setEditable( bool b )
433{
434 edit = b;
435}
436
437/*!
438 Returns TRUE if the user can add their own list items to the
439 combobox's list of items; otherwise returns FALSE.
440
441 \sa setEditable()
442*/
443
444bool QComboTableItem::isEditable() const
445{
446 return edit;
447}
448
449int QComboTableItem::RTTI = 1;
450
451/*!
452 \fn int QComboTableItem::rtti() const
453
454 Returns 1.
455
456 Make your derived classes return their own values for rtti()to
457 distinguish between different table item subclasses. You should
458 use values greater than 1000, preferably a large random number, to
459 allow for extensions to this class.
460
461
462 \sa QTableItem::rtti()
463*/
464
465int QComboTableItem::rtti() const
466{
467 return RTTI;
468}
469
470/*! \reimp */
471
472QSize QComboTableItem::sizeHint() const
473{
474 fakeCombo->insertItem( currentText() );
475 fakeCombo->setCurrentItem( fakeCombo->count() - 1 );
476 QSize sh = fakeCombo->sizeHint();
477 fakeCombo->removeItem( fakeCombo->count() - 1 );
478//US return sh.expandedTo( QApplication::globalStrut() );
479 return sh;
480}
481
diff --git a/qtcompat/qcombotableitem.h b/qtcompat/qcombotableitem.h
new file mode 100644
index 0000000..5688c1c
--- a/dev/null
+++ b/qtcompat/qcombotableitem.h
@@ -0,0 +1,571 @@
1/****************************************************************************
2**
3** Definition of QTable widget class
4**
5** Created : 000607
6**
7** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
8**
9** This file is part of the table module of the Qt GUI Toolkit.
10**
11** This file may be distributed under the terms of the Q Public License
12** as defined by Trolltech AS of Norway and appearing in the file
13** LICENSE.QPL included in the packaging of this file.
14**
15** This file may be distributed and/or modified under the terms of the
16** GNU General Public License version 2 as published by the Free Software
17** Foundation and appearing in the file LICENSE.GPL included in the
18** packaging of this file.
19**
20** Licensees holding valid Qt Enterprise Edition licenses may use this
21** file in accordance with the Qt Commercial License Agreement provided
22** with the Software.
23**
24** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26**
27** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
28** information about Qt Commercial License Agreements.
29** See http://www.trolltech.com/qpl/ for QPL licensing information.
30** See http://www.trolltech.com/gpl/ for GPL licensing information.
31**
32** Contact info@trolltech.com if any conditions of this licensing are
33** not clear to you.
34**
35**********************************************************************/
36
37#ifndef QTCOMPAT_QCOMBOTABLEITEM_H
38#define QTCOMPAT_QCOMBOTABLEITEM_H
39
40#include "qtable.h"
41#include "qstringlist.h"
42
43class QComboBox;
44class QWidget;
45class QPainter;
46
47#define QM_EXPORT_TABLE Q_EXPORT
48
49/*US
50
51#ifndef QT_H
52#include "qscrollview.h"
53#include "qpixmap.h"
54#include "qptrvector.h"
55#include "qheader.h"
56#include "qmemarray.h"
57#include "qptrlist.h"
58#include "qguardedptr.h"
59#include "qshared.h"
60#include "qintdict.h"
61#include "qstringlist.h"
62#endif // QT_H
63
64#ifndef QT_NO_TABLE
65
66#if !defined( QT_MODULE_TABLE ) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_TABLE )
67#define QM_EXPORT_TABLE
68#ifndef QM_TEMPLATE_EXTERN_TABLE
69# define QM_TEMPLATE_EXTERN_TABLE
70#endif
71#else
72#define QM_EXPORT_TABLE Q_EXPORT
73#define QM_TEMPLATE_EXTERN_TABLE Q_TEMPLATE_EXTERN
74#endif
75
76class QTableHeader;
77class QValidator;
78class QTable;
79class QPaintEvent;
80class QTimer;
81class QResizeEvent;
82class QComboBox;
83class QCheckBox;
84class QDragObject;
85
86struct QTablePrivate;
87struct QTableHeaderPrivate;
88
89
90class QM_EXPORT_TABLE QTableSelection
91{
92public:
93 QTableSelection();
94 QTableSelection( int start_row, int start_col, int end_row, int end_col );
95 void init( int row, int col );
96 void expandTo( int row, int col );
97 bool operator==( const QTableSelection &s ) const;
98 bool operator!=( const QTableSelection &s ) const { return !(operator==(s)); }
99
100 int topRow() const { return tRow; }
101 int bottomRow() const { return bRow; }
102 int leftCol() const { return lCol; }
103 int rightCol() const { return rCol; }
104 int anchorRow() const { return aRow; }
105 int anchorCol() const { return aCol; }
106 int numRows() const;
107 int numCols() const;
108
109 bool isActive() const { return active; }
110 bool isEmpty() const { return numRows() == 0; }
111
112private:
113 uint active : 1;
114 uint inited : 1;
115 int tRow, lCol, bRow, rCol;
116 int aRow, aCol;
117};
118
119#define Q_DEFINED_QTABLE_SELECTION
120#include "qwinexport.h"
121
122
123class QM_EXPORT_TABLE QTableItem : public Qt
124{
125 friend class QTable;
126
127public:
128 enum EditType { Never, OnTyping, WhenCurrent, Always };
129
130 QTableItem( QTable *table, EditType et );
131 QTableItem( QTable *table, EditType et, const QString &text );
132 QTableItem( QTable *table, EditType et, const QString &text,
133 const QPixmap &p );
134 virtual ~QTableItem();
135
136 virtual QPixmap pixmap() const;
137 virtual QString text() const;
138 virtual void setPixmap( const QPixmap &p );
139 virtual void setText( const QString &t );
140 QTable *table() const { return t; }
141
142 virtual int alignment() const;
143 virtual void setWordWrap( bool b );
144 bool wordWrap() const;
145
146 EditType editType() const;
147 virtual QWidget *createEditor() const;
148 virtual void setContentFromEditor( QWidget *w );
149 virtual void setReplaceable( bool );
150 bool isReplaceable() const;
151
152 virtual QString key() const;
153 virtual QSize sizeHint() const;
154
155 virtual void setSpan( int rs, int cs );
156 int rowSpan() const;
157 int colSpan() const;
158
159 virtual void setRow( int r );
160 virtual void setCol( int c );
161 int row() const;
162 int col() const;
163
164 virtual void paint( QPainter *p, const QColorGroup &cg,
165 const QRect &cr, bool selected );
166
167 void updateEditor( int oldRow, int oldCol );
168
169 virtual void setEnabled( bool b );
170 bool isEnabled() const;
171
172 virtual int rtti() const;
173 static int RTTI;
174
175private:
176 QString txt;
177 QPixmap pix;
178 QTable *t;
179 EditType edType;
180 uint wordwrap : 1;
181 uint tcha : 1;
182 uint enabled : 1;
183 int rw, cl;
184 int rowspan, colspan;
185#if (QT_VERSION >= 0x040000)
186#error "Add a setAlignment() function in 4.0 (but no d pointer)"
187#endif
188};
189
190#define Q_DEFINED_QTABLE_ITEM
191#include "qwinexport.h"
192*/
193class QM_EXPORT_TABLE QComboTableItem : public QTableItem
194{
195public:
196 QComboTableItem( QTable *table, const QStringList &list, bool editable = FALSE );
197 virtual QWidget *createEditor() const;
198 virtual void setContentFromEditor( QWidget *w );
199 virtual void paint( QPainter *p, const QColorGroup &cg,
200 const QRect &cr, bool selected );
201 virtual void setCurrentItem( int i );
202 virtual void setCurrentItem( const QString &i );
203 int currentItem() const;
204 QString currentText() const;
205 int count() const;
206#if !defined(Q_NO_USING_KEYWORD)
207 //using QTableItem::text;
208#endif
209
210
211 QString text( int i ) const;
212 virtual void setEditable( bool b );
213 bool isEditable() const;
214 virtual void setStringList( const QStringList &l );
215
216 int rtti() const;
217 static int RTTI;
218
219 QSize sizeHint() const;
220
221private:
222 QComboBox *cb;
223 QStringList entries;
224 int current;
225 bool edit;
226 static QComboBox *fakeCombo;
227
228};
229/*US
230
231class QM_EXPORT_TABLE QCheckTableItem : public QTableItem
232{
233public:
234 QCheckTableItem( QTable *table, const QString &txt );
235 void setText( const QString &t );
236 virtual QWidget *createEditor() const;
237 virtual void setContentFromEditor( QWidget *w );
238 virtual void paint( QPainter *p, const QColorGroup &cg,
239 const QRect &cr, bool selected );
240 virtual void setChecked( bool b );
241 bool isChecked() const;
242
243 int rtti() const;
244 static int RTTI;
245
246 QSize sizeHint() const;
247
248private:
249 QCheckBox *cb;
250 bool checked;
251
252};
253
254class QM_EXPORT_TABLE QTable : public QScrollView
255{
256 Q_OBJECT
257 Q_ENUMS( SelectionMode FocusStyle )
258 Q_PROPERTY( int numRows READ numRows WRITE setNumRows )
259 Q_PROPERTY( int numCols READ numCols WRITE setNumCols )
260 Q_PROPERTY( bool showGrid READ showGrid WRITE setShowGrid )
261 Q_PROPERTY( bool rowMovingEnabled READ rowMovingEnabled WRITE setRowMovingEnabled )
262 Q_PROPERTY( bool columnMovingEnabled READ columnMovingEnabled WRITE setColumnMovingEnabled )
263 Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
264 Q_PROPERTY( bool sorting READ sorting WRITE setSorting )
265 Q_PROPERTY( SelectionMode selectionMode READ selectionMode WRITE setSelectionMode )
266 Q_PROPERTY( FocusStyle focusStyle READ focusStyle WRITE setFocusStyle )
267 Q_PROPERTY( int numSelections READ numSelections )
268
269 friend class QTableHeader;
270 friend class QComboTableItem;
271 friend class QCheckTableItem;
272 friend class QTableItem;
273
274public:
275 QTable( QWidget* parent=0, const char* name=0 );
276 QTable( int numRows, int numCols,
277 QWidget* parent=0, const char* name=0 );
278 ~QTable();
279
280 QHeader *horizontalHeader() const;
281 QHeader *verticalHeader() const;
282
283 enum SelectionMode { Single, Multi, SingleRow, MultiRow, NoSelection };
284 virtual void setSelectionMode( SelectionMode mode );
285 SelectionMode selectionMode() const;
286
287 virtual void setItem( int row, int col, QTableItem *item );
288 virtual void setText( int row, int col, const QString &text );
289 virtual void setPixmap( int row, int col, const QPixmap &pix );
290 virtual QTableItem *item( int row, int col ) const;
291 virtual QString text( int row, int col ) const;
292 virtual QPixmap pixmap( int row, int col ) const;
293 virtual void clearCell( int row, int col );
294
295 virtual QRect cellGeometry( int row, int col ) const;
296 virtual int columnWidth( int col ) const;
297 virtual int rowHeight( int row ) const;
298 virtual int columnPos( int col ) const;
299 virtual int rowPos( int row ) const;
300 virtual int columnAt( int x ) const;
301 virtual int rowAt( int y ) const;
302
303 virtual int numRows() const;
304 virtual int numCols() const;
305
306 void updateCell( int row, int col );
307
308 bool eventFilter( QObject * o, QEvent * );
309
310 int currentRow() const { return curRow; }
311 int currentColumn() const { return curCol; }
312 void ensureCellVisible( int row, int col );
313
314 bool isSelected( int row, int col ) const;
315 bool isRowSelected( int row, bool full = FALSE ) const;
316 bool isColumnSelected( int col, bool full = FALSE ) const;
317 int numSelections() const;
318 QTableSelection selection( int num ) const;
319 virtual int addSelection( const QTableSelection &s );
320 virtual void removeSelection( const QTableSelection &s );
321 virtual void removeSelection( int num );
322 virtual int currentSelection() const;
323
324 void selectCells( int start_row, int start_col, int end_row, int end_col );
325 void selectRow( int row );
326 void selectColumn( int col );
327
328 bool showGrid() const;
329
330 bool columnMovingEnabled() const;
331 bool rowMovingEnabled() const;
332
333 virtual void sortColumn( int col, bool ascending = TRUE,
334 bool wholeRows = FALSE );
335 bool sorting() const;
336
337 virtual void takeItem( QTableItem *i );
338
339 virtual void setCellWidget( int row, int col, QWidget *e );
340 virtual QWidget *cellWidget( int row, int col ) const;
341 virtual void clearCellWidget( int row, int col );
342
343 virtual QRect cellRect( int row, int col ) const;
344
345 virtual void paintCell( QPainter *p, int row, int col,
346 const QRect &cr, bool selected );
347 virtual void paintCell( QPainter *p, int row, int col,
348 const QRect &cr, bool selected, const QColorGroup &cg );
349 virtual void paintFocus( QPainter *p, const QRect &r );
350 QSize sizeHint() const;
351
352 bool isReadOnly() const;
353 bool isRowReadOnly( int row ) const;
354 bool isColumnReadOnly( int col ) const;
355
356 void setEnabled( bool b );
357
358 void repaintSelections();
359
360 enum FocusStyle { FollowStyle, SpreadSheet };
361 virtual void setFocusStyle( FocusStyle fs );
362 FocusStyle focusStyle() const;
363
364 void updateHeaderStates();
365
366public slots:
367 virtual void setNumRows( int r );
368 virtual void setNumCols( int r );
369 virtual void setShowGrid( bool b );
370 virtual void hideRow( int row );
371 virtual void hideColumn( int col );
372 virtual void showRow( int row );
373 virtual void showColumn( int col );
374
375 virtual void setColumnWidth( int col, int w );
376 virtual void setRowHeight( int row, int h );
377
378 virtual void adjustColumn( int col );
379 virtual void adjustRow( int row );
380
381 virtual void setColumnStretchable( int col, bool stretch );
382 virtual void setRowStretchable( int row, bool stretch );
383 bool isColumnStretchable( int col ) const;
384 bool isRowStretchable( int row ) const;
385 virtual void setSorting( bool b );
386 virtual void swapRows( int row1, int row2, bool swapHeader = FALSE );
387 virtual void swapColumns( int col1, int col2, bool swapHeader = FALSE );
388 virtual void swapCells( int row1, int col1, int row2, int col2 );
389
390 virtual void setLeftMargin( int m );
391 virtual void setTopMargin( int m );
392 virtual void setCurrentCell( int row, int col );
393 void clearSelection( bool repaint = TRUE );
394 virtual void setColumnMovingEnabled( bool b );
395 virtual void setRowMovingEnabled( bool b );
396
397 virtual void setReadOnly( bool b );
398 virtual void setRowReadOnly( int row, bool ro );
399 virtual void setColumnReadOnly( int col, bool ro );
400
401 virtual void setDragEnabled( bool b );
402 bool dragEnabled() const;
403
404 virtual void insertRows( int row, int count = 1 );
405 virtual void insertColumns( int col, int count = 1 );
406 virtual void removeRow( int row );
407 virtual void removeRows( const QMemArray<int> &rows );
408 virtual void removeColumn( int col );
409 virtual void removeColumns( const QMemArray<int> &cols );
410
411 virtual void editCell( int row, int col, bool replace = FALSE );
412
413 void setRowLabels( const QStringList &labels );
414 void setColumnLabels( const QStringList &labels );
415
416protected:
417 enum EditMode { NotEditing, Editing, Replacing };
418 void drawContents( QPainter *p, int cx, int cy, int cw, int ch );
419 void contentsMousePressEvent( QMouseEvent* );
420 void contentsMouseMoveEvent( QMouseEvent* );
421 void contentsMouseDoubleClickEvent( QMouseEvent* );
422 void contentsMouseReleaseEvent( QMouseEvent* );
423 void contentsContextMenuEvent( QContextMenuEvent * e );
424 void keyPressEvent( QKeyEvent* );
425 void focusInEvent( QFocusEvent* );
426 void focusOutEvent( QFocusEvent* );
427 void viewportResizeEvent( QResizeEvent * );
428 void showEvent( QShowEvent *e );
429 void paintEvent( QPaintEvent *e );
430 void setEditMode( EditMode mode, int row, int col );
431#ifndef QT_NO_DRAGANDDROP
432 virtual void contentsDragEnterEvent( QDragEnterEvent *e );
433 virtual void contentsDragMoveEvent( QDragMoveEvent *e );
434 virtual void contentsDragLeaveEvent( QDragLeaveEvent *e );
435 virtual void contentsDropEvent( QDropEvent *e );
436 virtual QDragObject *dragObject();
437 virtual void startDrag();
438#endif
439
440 virtual void paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch );
441 virtual void activateNextCell();
442 virtual QWidget *createEditor( int row, int col, bool initFromCell ) const;
443 virtual void setCellContentFromEditor( int row, int col );
444 virtual QWidget *beginEdit( int row, int col, bool replace );
445 virtual void endEdit( int row, int col, bool accept, bool replace );
446
447 virtual void resizeData( int len );
448 virtual void insertWidget( int row, int col, QWidget *w );
449 int indexOf( int row, int col ) const;
450
451 void windowActivationChange( bool );
452 bool isEditing() const;
453 EditMode editMode() const;
454 int currEditRow() const;
455 int currEditCol() const;
456
457protected slots:
458 virtual void columnWidthChanged( int col );
459 virtual void rowHeightChanged( int row );
460 virtual void columnIndexChanged( int section, int fromIndex, int toIndex );
461 virtual void rowIndexChanged( int section, int fromIndex, int toIndex );
462 virtual void columnClicked( int col );
463
464signals:
465 void currentChanged( int row, int col );
466 void clicked( int row, int col, int button, const QPoint &mousePos );
467 void doubleClicked( int row, int col, int button, const QPoint &mousePos );
468 void pressed( int row, int col, int button, const QPoint &mousePos );
469 void selectionChanged();
470 void valueChanged( int row, int col );
471 void contextMenuRequested( int row, int col, const QPoint &pos );
472#ifndef QT_NO_DRAGANDDROP
473 void dropped( QDropEvent *e );
474#endif
475
476private slots:
477 void doAutoScroll();
478 void doValueChanged();
479 void updateGeometriesSlot();
480
481private:
482 void contentsMousePressEventEx( QMouseEvent* );
483 void drawContents( QPainter* );
484 void updateGeometries();
485 void repaintSelections( QTableSelection *oldSelection,
486 QTableSelection *newSelection,
487 bool updateVertical = TRUE,
488 bool updateHorizontal = TRUE );
489 QRect rangeGeometry( int topRow, int leftCol,
490 int bottomRow, int rightCol, bool &optimize );
491 void fixRow( int &row, int y );
492 void fixCol( int &col, int x );
493
494 void init( int numRows, int numCols );
495 QSize tableSize() const;
496 void repaintCell( int row, int col );
497 void contentsToViewport2( int x, int y, int& vx, int& vy );
498 QPoint contentsToViewport2( const QPoint &p );
499 void viewportToContents2( int vx, int vy, int& x, int& y );
500 QPoint viewportToContents2( const QPoint &p );
501
502 void updateRowWidgets( int row );
503 void updateColWidgets( int col );
504 bool isSelected( int row, int col, bool includeCurrent ) const;
505 void setCurrentCell( int row, int col, bool updateSelections );
506 void fixCell( int &row, int &col, int key );
507 void delayedUpdateGeometries();
508 struct TableWidget
509 {
510 TableWidget( QWidget *w, int r, int c ) : wid( w ), row( r ), col ( c ) {}
511 QWidget *wid;
512 int row, col;
513 };
514 void saveContents( QPtrVector<QTableItem> &tmp,
515 QPtrVector<TableWidget> &tmp2 );
516 void updateHeaderAndResizeContents( QTableHeader *header,
517 int num, int colRow,
518 int width, bool &updateBefore );
519 void restoreContents( QPtrVector<QTableItem> &tmp,
520 QPtrVector<TableWidget> &tmp2 );
521 void finishContentsResze( bool updateBefore );
522
523private:
524 QPtrVector<QTableItem> contents;
525 QPtrVector<QWidget> widgets;
526 int curRow;
527 int curCol;
528 QTableHeader *leftHeader, *topHeader;
529 EditMode edMode;
530 int editCol, editRow;
531 QPtrList<QTableSelection> selections;
532 QTableSelection *currentSel;
533 QTimer *autoScrollTimer;
534 int lastSortCol;
535 bool sGrid : 1;
536 bool mRows : 1;
537 bool mCols : 1;
538 bool asc : 1;
539 bool doSort : 1;
540 bool mousePressed : 1;
541 bool readOnly : 1;
542 bool shouldClearSelection : 1;
543 bool dEnabled : 1;
544 bool context_menu : 1;
545 bool drawActiveSelection : 1;
546 bool was_visible : 1;
547 SelectionMode selMode;
548 int pressedRow, pressedCol;
549 QTablePrivate *d;
550 QIntDict<int> roRows;
551 QIntDict<int> roCols;
552 int startDragRow;
553 int startDragCol;
554 QPoint dragStartPos;
555 int oldCurrentRow, oldCurrentCol;
556 QWidget *unused_topLeftCorner; //### remove in 4.0
557 FocusStyle focusStl;
558 QSize unused_cachedSizeHint; // ### remove in 4.0
559
560#if defined(Q_DISABLE_COPY)
561 QTable( const QTable & );
562 QTable &operator=( const QTable & );
563#endif
564};
565
566#define Q_DEFINED_QTABLE
567#include "qwinexport.h"
568#endif // QT_NO_TABLE
569
570*/
571#endif // QTCOMPAT_QCOMBOTABLEITEM_H
diff --git a/qtcompat/qgridview.cpp b/qtcompat/qgridview.cpp
new file mode 100644
index 0000000..bee3698
--- a/dev/null
+++ b/qtcompat/qgridview.cpp
@@ -0,0 +1,362 @@
1/****************************************************************************
2** $Id$
3**
4** Implementation of QGridView class
5**
6** Created: 010523
7**
8** Copyright (C) 1992-2001 Trolltech AS. All rights reserved.
9**
10** This file is part of the widgets module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38
39#include "qgridview.h"
40
41#ifndef QT_NO_GRIDVIEW
42
43#include "qpainter.h"
44
45/*!
46 \class QGridView qgridview.h
47 \brief The QGridView class provides an abstract base for fixed-size
48 grids.
49
50 \ingroup abstractwidgets
51
52 A grid view consists of a number of abstract cells organized in rows
53 and columns. The cells have a fixed size and are identified with a
54 row index and a column index. The top-left cell is in row 0, column
55 0. The bottom-right cell is in row numRows()-1, column numCols()-1.
56
57 You can define \l numRows, \l numCols, \l cellWidth and
58 \l cellHeight. Reimplement the pure virtual function paintCell() to
59 draw the content of a cell.
60
61 With ensureCellVisible(), you can ensure a certain cell is
62 visible. With rowAt() and columnAt() you can find a cell based on
63 the given x- and y-coordinates.
64
65 If you need to monitor changes to the grid's dimensions (i.e. when
66 numRows or numCols is changed), reimplement the dimensionChange()
67 change handler.
68
69 Note: the row, column indices are always given in the order, row
70 (vertical offset) then column (horizontal offset). This order is the
71 opposite of all pixel operations, which are given in the order x
72 (horizontal offset), y (vertical offset).
73
74 QGridView is a very simple abstract class based on QScrollView. It
75 is designed to simplify the task of drawing many cells of the same
76 size in a potentially scrollable canvas. If you need rows and
77 columns in different sizes, use a QTable instead. If you need a
78 simple list of items, use a QListBox. If you need to present
79 hierachical data use a QListView, and if you need random objects at
80 random positions, consider using either a QIconView or a QCanvas.
81
82*/
83
84
85/*!
86 Constructs a grid view.
87
88 The \a parent, \a name and widget flag, \a f, arguments are passed to the
89 QScrollView constructor.
90*/
91QGridView::QGridView( QWidget *parent, const char *name, WFlags f )
92 :QScrollView( parent, name ,f ),nrows(5),ncols(5),cellw(12),cellh(12)
93{
94 viewport()->setBackgroundMode( PaletteBase );
95 setBackgroundMode( PaletteBackground );
96 viewport()->setFocusProxy( this );
97}
98
99/*!
100 Destroys the grid view.
101*/
102QGridView::~QGridView()
103{
104}
105
106void QGridView::updateGrid()
107{
108 resizeContents( ncols * cellw, nrows * cellh );
109}
110
111/*! \property QGridView::numRows
112 \brief The number of rows in the grid
113
114 \sa numCols
115*/
116void QGridView::setNumRows( int numRows )
117{
118 int oldnrows = nrows;
119 nrows = numRows;
120 dimensionChange( oldnrows, ncols );
121 updateGrid();
122}
123
124/*! \property QGridView::numCols
125 \brief The number of columns in the grid
126
127 \sa numRows
128*/
129void QGridView::setNumCols( int numCols )
130{
131 int oldncols = ncols;
132 ncols = numCols;
133 dimensionChange( nrows, oldncols );
134 updateGrid();
135}
136
137/*! \property QGridView::cellWidth
138 \brief The width of a grid column
139
140 All columns in a grid view have the same width.
141
142 \sa cellHeight
143*/
144void QGridView::setCellWidth( int cellWidth )
145{
146 cellw = cellWidth;
147 updateGrid();
148 updateContents( contentsX(), contentsY(), visibleWidth(), visibleHeight() );
149}
150
151/*! \property QGridView::cellHeight
152 \brief The height of a grid row
153
154 All rows in a grid view have the same height.
155
156 \sa cellWidth
157*/
158void QGridView::setCellHeight( int cellHeight )
159{
160 cellh = cellHeight;
161 updateGrid();
162 updateContents( contentsX(), contentsY(), visibleWidth(), visibleHeight() );
163}
164
165/*!
166 Returns the geometry of cell (\a row, \a column) in the content
167 coordinate system.
168
169 \sa cellRect()
170 */
171QRect QGridView::cellGeometry( int row, int column )
172{
173 QRect r;
174 if ( row >= 0 && row < nrows && column >= 0 && column < ncols )
175 r.setRect( cellw * column, cellh * row, cellw, cellh );
176 return r;
177}
178
179/*! Repaints cell (\a row, \a column).
180
181 If \a erase is TRUE, Qt erases the area of the cell before the
182 paintCell() call; otherwise no erasing takes place.
183
184 \sa QWidget::repaint()
185 */
186void QGridView::repaintCell( int row, int column, bool erase )
187{
188 QScrollView::repaintContents( cellGeometry( row, column ), erase );
189}
190
191/*! Updates cell (\a row, \a column).
192
193 \sa QWidget::update()
194 */
195void QGridView::updateCell( int row, int column )
196{
197 updateContents( cellGeometry( row, column ) );
198}
199
200/*!
201 Ensure cell (\a row, \a column) is visible, scrolling the grid view
202 if necessary.
203 */
204void QGridView::ensureCellVisible( int row, int column )
205{
206 QRect r = cellGeometry( row, column );
207 ensureVisible( r.x(), r.y(), r.width(), r.height() );
208}
209
210/*! This function fills the \a cw pixels wide and \a ch pixels high
211 rectangle starting at position (\a cx, \a cy) with the
212 background color using the painter \a p.
213
214 paintEmptyArea() is invoked by drawContents() to erase
215 or fill unused areas.
216*/
217
218void QGridView::paintEmptyArea( QPainter *p, int cx ,int cy, int cw, int ch)
219{
220 if ( gridSize().width() >= contentsWidth() && gridSize().height() >= contentsHeight() )
221 return;
222 // Region of the rect we should draw
223 contentsToViewport( cx, cy, cx, cy );
224 QRegion reg( QRect( cx, cy, cw, ch ) );
225 // Subtract the table from it
226 reg = reg.subtract( QRect( contentsToViewport( QPoint( 0, 0 ) ), gridSize() ) );
227
228 // And draw the rectangles (transformed as needed)
229 QArray<QRect> r = reg.rects();
230 QBrush brush = colorGroup().brush( QColorGroup::Background );
231 for ( int i = 0; i < (int)r.count(); ++i)
232 p->fillRect( r[ i ], brush );
233}
234
235/*!\reimp
236 */
237void QGridView::drawContents( QPainter *p, int cx, int cy, int cw, int ch )
238{
239 int colfirst = columnAt( cx );
240 int collast = columnAt( cx + cw );
241 int rowfirst = rowAt( cy );
242 int rowlast = rowAt( cy + ch );
243
244 if ( rowfirst == -1 || colfirst == -1 ) {
245 paintEmptyArea( p, cx, cy, cw, ch );
246 return;
247 }
248
249 if ( collast < 0 || collast >= ncols )
250 collast = ncols-1;
251 if ( rowlast < 0 || rowlast >= nrows )
252 rowlast = nrows-1;
253
254 // Go through the rows
255 for ( int r = rowfirst; r <= rowlast; ++r ) {
256 // get row position and height
257 int rowp = r * cellh;
258
259 // Go through the columns in the row r
260 // if we know from where to where, go through [colfirst, collast],
261 // else go through all of them
262 for ( int c = colfirst; c <= collast; ++c ) {
263 // get position and width of column c
264 int colp = c * cellw;
265 // Translate painter and draw the cell
266 p->translate( colp, rowp );
267 paintCell( p, r, c );
268 p->translate( -colp, -rowp );
269 }
270 }
271
272 // Paint empty rects
273 paintEmptyArea( p, cx, cy, cw, ch );
274}
275
276/*!
277 \reimp
278
279 (Implemented to get rid of a compiler warning.)
280*/
281void QGridView::drawContents( QPainter * )
282{
283}
284
285/*! \fn void QGridView::dimensionChange( int oldNumRows, int oldNumCols )
286
287 This change handler is called whenever any of the grid's dimensions
288 changes. \a oldNumRows and \a oldNumCols contain the old dimensions,
289 numRows() and numCols() contain the new dimensions.
290 */
291void QGridView::dimensionChange( int, int ) {}
292
293
294
295/*! \fn int QGridView::rowAt( int y ) const
296
297 Returns the number of the row at position \a y. \a y must be given in
298 content coordinates.
299
300 \sa columnAt()
301 */
302
303/*! \fn int QGridView::columnAt( int x ) const
304
305 Returns the number of the column at position \a x. \a x must be
306 given in content coordinates.
307
308 \sa rowAt()
309 */
310
311/*!
312 \fn void QGridView::paintCell( QPainter *p, int row, int col )
313
314 This pure virtual function is called to paint the single cell at
315 (\a row, \a col) using painter \a p. The painter must be open when
316 paintCell() is called and must remain open.
317
318 The coordinate system is \link QPainter::translate() translated \endlink
319 so that the origin is at the top-left corner of the cell to be
320 painted, i.e. \e cell coordinates. Do not scale or shear the coordinate
321 system (or if you do, restore the transformation matrix before you
322 return).
323
324 The painter is not clipped by default in order to get maximum
325 efficiency. If you want clipping, use
326
327 \code
328 p->setClipRect( cellRect(), QPainter::CoordPainter );
329 //... your drawing code
330 p->setClipping( FALSE );
331
332 \endcode
333
334*/
335
336/*! \fn QRect QGridView::cellRect() const
337
338 Returns the geometry of a cell in a cell's coordinate system. This
339 is a convenience function useful in paintCell(). It is equivalent to
340 QRect( 0, 0, cellWidth(), cellHeight() ).
341
342 \sa cellGeometry()
343
344 */
345
346/*!\fn QSize QGridView::gridSize() const
347
348 Returns the size of the grid in pixels.
349
350 */
351
352/*!
353 \overload
354 Repaints the contents. If \a erase is TRUE the
355 background is cleared using the background color.
356*/
357void QGridView::repaintContents( bool erase )
358{
359 QScrollView::repaintContents( contentsX(), contentsY(), visibleWidth(), visibleHeight(), erase );
360}
361
362#endif // QT_NO_GRIDVIEW
diff --git a/qtcompat/qgridview.h b/qtcompat/qgridview.h
new file mode 100644
index 0000000..e9d6ca1
--- a/dev/null
+++ b/qtcompat/qgridview.h
@@ -0,0 +1,138 @@
1/**********************************************************************
2** $Id$
3**
4** Definition of QGridView class
5**
6** Created: 2001.05.23
7**
8** Copyright (C) 1992-2001 Trolltech AS. All rights reserved.
9**
10** This file is part of the widgets module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#ifndef QGRIDVIEW_H
39#define QGRIDVIEW_H
40
41#ifndef QT_H
42#include "qscrollview.h"
43#endif // QT_H
44
45#ifndef QT_NO_GRIDVIEW
46
47class QGridViewPrivate;
48
49class Q_EXPORT QGridView : public QScrollView
50{
51 Q_OBJECT
52 Q_PROPERTY( int numRows READ numRows WRITE setNumRows )
53 Q_PROPERTY( int numCols READ numCols WRITE setNumCols )
54 Q_PROPERTY( int cellWidth READ cellWidth WRITE setCellWidth )
55 Q_PROPERTY( int cellHeight READ cellHeight WRITE setCellHeight )
56public:
57
58 QGridView( QWidget *parent=0, const char *name=0, WFlags f=0 );
59 ~QGridView();
60
61 int numRows() const;
62 virtual void setNumRows( int );
63 int numCols() const;
64 virtual void setNumCols( int );
65
66 int cellWidth() const;
67 virtual void setCellWidth( int );
68 int cellHeight() const;
69 virtual void setCellHeight( int );
70
71 QRect cellRect() const;
72 QRect cellGeometry( int row, int column );
73 QSize gridSize() const;
74
75 int rowAt( int y ) const;
76 int columnAt( int x ) const;
77
78 void repaintCell( int row, int column, bool erase=TRUE );
79 void updateCell( int row, int column );
80 void ensureCellVisible( int row, int column );
81
82 void repaintContents( bool erase=TRUE );
83
84protected:
85 virtual void paintCell( QPainter *, int row, int col ) = 0;
86 virtual void paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch );
87
88 void drawContents( QPainter *p, int cx, int cy, int cw, int ch );
89
90 virtual void dimensionChange( int, int );
91
92private:
93 void drawContents( QPainter* );
94 void updateGrid();
95
96 int nrows;
97 int ncols;
98 int cellw;
99 int cellh;
100 QGridViewPrivate* d;
101
102 private:// Disabled copy constructor and operator=
103#if defined(Q_DISABLE_COPY)
104 QGridView( const QGridView & );
105 QGridView &operator=( const QGridView & );
106#endif
107};
108
109inline int QGridView::cellWidth() const
110{ return cellw; }
111
112inline int QGridView::cellHeight() const
113{ return cellh; }
114
115inline int QGridView::rowAt( int y ) const
116{ return y / cellh; }
117
118inline int QGridView::columnAt( int x ) const
119{ return x / cellw; }
120
121inline int QGridView::numRows() const
122{ return nrows; }
123
124inline int QGridView::numCols() const
125{return ncols; }
126
127inline QRect QGridView::cellRect() const
128{ return QRect( 0, 0, cellw, cellh ); }
129
130inline QSize QGridView::gridSize() const
131{ return QSize( ncols * cellw, nrows * cellh ); }
132
133
134
135#endif // QT_NO_GRIDVIEW
136
137
138#endif // QTABLEVIEW_H
diff --git a/qtcompat/qinputdialog.cpp b/qtcompat/qinputdialog.cpp
new file mode 100644
index 0000000..770b281
--- a/dev/null
+++ b/qtcompat/qinputdialog.cpp
@@ -0,0 +1,495 @@
1/****************************************************************************
2** $Id$
3**
4** Implementation of QInputDialog class
5**
6** Created : 991212
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the dialogs module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#include "qinputdialog.h"
39
40#include <qlayout.h>
41#include <qlabel.h>
42#include <qlineedit.h>
43#include <qpushbutton.h>
44#include <qspinbox.h>
45#include <qcombobox.h>
46#include <qwidgetstack.h>
47#include <qvalidator.h>
48#include <qapplication.h>
49
50class QInputDialogPrivate
51{
52public:
53 friend class QInputDialog;
54 QLineEdit *lineEdit;
55 QSpinBox *spinBox;
56 QComboBox *comboBox, *editComboBox;
57 QPushButton *ok;
58 QWidgetStack *stack;
59 QInputDialog::Type type;
60};
61
62/*!
63 \class QInputDialog qinputdialog.h
64 \brief A convenience dialog to get a simple input from the user
65 \ingroup dialogs
66
67 The QInputDialog is a simple dialog which can be used if you
68 need a simple input from the user. This can be text, a number or
69 an item from a list. Also a label has to be set to tell the user
70 what he/she should input.
71
72 In this Qt version only the 4 static convenience functions
73 getText(), getInteger(), getDouble() and getItem() of QInputDialog
74 are available.
75
76 Use it like this:
77
78 \code
79 bool ok = FALSE;
80 QString text = QInputDialog::getText( tr( "Make an input" ), tr( "Please enter your name" ), QString::null, &ok, this );
81 if ( ok && !text.isEmpty() )
82 ;// user entered something and pressed ok
83 else
84 ;// user entered nothing or pressed cancel
85 \endcode
86
87 There are more static convenience methods!
88
89 \sa getText(), getInteger(), getDouble(), getItem()
90*/
91
92/*!
93 \enum QInputDialog::Type
94
95 This enum type specifies the type of the dialog
96 (which kind of input can be done):
97
98 <ul>
99 <li>\c LineEdit - A QLineEdit is used for taking the input, so a textual or
100 (e.g. using a QValidator) a numerical input can be done. Using lineEdit()
101 the QLineEdit can be accessed.
102 <li>\c SpinBox - A QSpinBox is used for taking the input, so a decimal
103 input can be done. Using spinBox() the QSpinBox can be accessed.
104 <li>\c ComboBox - A read-only QComboBox is used for taking the input,
105 so one item of a list can be chosen. Using comboBox() the QComboBox
106 can be accessed.
107 <li>\c EditableComboBox - An editable QComboBox is used for taking the input,
108 so either one item of a list can be chosen or a text can be entered. Using
109 editableComboBox() the QComboBox can be accessed.
110 </ul>
111*/
112
113/*!
114 Constructs the dialog. \a label is the text which is shown to the user (it should mention
115 to the user what he/she should input), \a parent the parent widget of the dialog, \a name
116 the name of it and if you set \a modal to TRUE, the dialog pops up modally, else it pops
117 up modeless. With \a type you specify the type of the dialog.
118
119 \sa getText(), getInteger(), getDouble(), getItem()
120*/
121
122QInputDialog::QInputDialog( const QString &label, QWidget* parent, const char* name,
123 bool modal, Type type)
124 : QDialog( parent, name, modal )
125{
126 if ( parent && parent->icon() &&!parent->icon()->isNull() )
127 setIcon( *parent->icon() );
128 else if ( qApp->mainWidget() && qApp->mainWidget()->icon() && !qApp->mainWidget()->icon()->isNull() )
129 QDialog::setIcon( *qApp->mainWidget()->icon() );
130
131 d = new QInputDialogPrivate;
132 d->lineEdit = 0;
133 d->spinBox = 0;
134 d->comboBox = 0;
135
136 QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 );
137
138 QLabel* l = new QLabel( label, this );
139 vbox->addWidget( l );
140
141 d->stack = new QWidgetStack( this );
142 vbox->addWidget( d->stack );
143 d->lineEdit = new QLineEdit( d->stack );
144 d->spinBox = new QSpinBox( d->stack );
145 d->comboBox = new QComboBox( FALSE, d->stack );
146 d->editComboBox = new QComboBox( TRUE, d->stack );
147
148 QHBoxLayout *hbox = new QHBoxLayout( 6 );
149 vbox->addLayout( hbox, AlignRight );
150
151 d->ok = new QPushButton( tr( "&OK" ), this );
152 d->ok->setDefault( TRUE );
153 QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this );
154
155 QSize bs( d->ok->sizeHint() );
156 if ( cancel->sizeHint().width() > bs.width() )
157 bs.setWidth( cancel->sizeHint().width() );
158
159 d->ok->setFixedSize( bs );
160 cancel->setFixedSize( bs );
161
162 hbox->addWidget( new QWidget( this ) );
163 hbox->addWidget( d->ok );
164 hbox->addWidget( cancel );
165
166 connect( d->lineEdit, SIGNAL( returnPressed() ),
167 this, SLOT( tryAccept() ) );
168 connect( d->lineEdit, SIGNAL( textChanged( const QString & ) ),
169 this, SLOT( textChanged( const QString & ) ) );
170
171 connect( d->ok, SIGNAL( clicked() ), this, SLOT( accept() ) );
172 connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
173
174//US ToDo make size dependent of targetplatform
175//US resize( QMAX( sizeHint().width(), 400 ), sizeHint().height() );
176 resize( sizeHint().width(), sizeHint().height() );
177
178 setType( type );
179}
180
181/*!
182 Returns the line edit, which is used in the LineEdit mode
183*/
184
185QLineEdit *QInputDialog::lineEdit() const
186{
187 return d->lineEdit;
188}
189
190/*!
191 Returns the spinbox, which is used in the SpinBox mode
192*/
193
194QSpinBox *QInputDialog::spinBox() const
195{
196 return d->spinBox;
197}
198
199/*!
200 Returns the combobox, which is used in the ComboBox mode
201*/
202
203QComboBox *QInputDialog::comboBox() const
204{
205 return d->comboBox;
206}
207
208/*!
209 Returns the combobox, which is used in the EditableComboBox mode
210*/
211
212QComboBox *QInputDialog::editableComboBox() const
213{
214 return d->editComboBox;
215}
216
217/*!
218 Sets the input type of the dialog to \a t.
219*/
220
221void QInputDialog::setType( Type t )
222{
223 switch ( t ) {
224 case LineEdit:
225 d->stack->raiseWidget( d->lineEdit );
226 d->lineEdit->setFocus();
227 break;
228 case SpinBox:
229 d->stack->raiseWidget( d->spinBox );
230 d->spinBox->setFocus();
231 break;
232 case ComboBox:
233 d->stack->raiseWidget( d->comboBox );
234 d->comboBox->setFocus();
235 break;
236 case EditableComboBox:
237 d->stack->raiseWidget( d->editComboBox );
238 d->editComboBox->setFocus();
239 break;
240 }
241
242 d->type = t;
243}
244
245/*!
246 Returns the input type of the dialog.
247
248 \sa setType()
249*/
250
251QInputDialog::Type QInputDialog::type() const
252{
253 return d->type;
254}
255
256/*!
257 Destructor.
258*/
259
260QInputDialog::~QInputDialog()
261{
262 delete d;
263}
264
265/*!
266 Static convenience function to get a textual input from the user. \a caption is the text
267 which is displayed in the title bar of the dialog. \a label is the text which
268 is shown to the user (it should mention to the user what he/she should input), \a text
269 the default text which will be initially set to the line edit, \a ok a pointer to
270 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
271 user pressed cancel, \a parent the parent widget of the dialog and \a name
272 the name of it. The dialogs pops up modally!
273
274 This method returns the text which has been entered in the line edit.
275
276 You will use this static method like this:
277
278 \code
279 bool ok = FALSE;
280 QString text = QInputDialog::getText( tr( "Please enter your name" ), QString::null, &ok, this );
281 if ( ok && !text.isEmpty() )
282 ;// user entered something and pressed ok
283 else
284 ;// user entered nothing or pressed cancel
285 \endcode
286*/
287
288QString QInputDialog::getText( const QString &caption, const QString &label, const QString &text,
289 bool *ok, QWidget *parent, const char *name )
290{
291 return getText( caption, label, QLineEdit::Normal, text, ok, parent, name );
292}
293
294/*!
295 Like above, but accepts an a \a mode which the line edit will use to display text.
296
297 \sa getText()
298*/
299
300QString QInputDialog::getText( const QString &caption, const QString &label, QLineEdit::EchoMode mode,
301 const QString &text, bool *ok, QWidget *parent, const char *name )
302{
303 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit );
304 dlg->setCaption( caption );
305 dlg->lineEdit()->setText( text );
306 dlg->lineEdit()->setEchoMode( mode );
307 if ( !text.isEmpty() )
308 dlg->lineEdit()->selectAll();
309
310 bool ok_ = FALSE;
311 QString result;
312 ok_ = dlg->exec() == QDialog::Accepted;
313 if ( ok )
314 *ok = ok_;
315 if ( ok_ )
316 result = dlg->lineEdit()->text();
317
318 delete dlg;
319 return result;
320}
321
322/*!
323 Static convenience function to get an integral input from the user. \a caption is the text
324 which is displayed in the title bar of the dialog. \a label is the text which
325 is shown to the user (it should mention to the user what he/she should input), \a num
326 the default number which will be initially set to the spinbox, \a from and \a to the
327 range in which the entered number has to be, \a step the step in which the number can
328 be increased/decreased by the spinbox, \a ok a pointer to
329 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
330 user pressed cancel, \a parent the parent widget of the dialog and \a name
331 the name of it. The dialogs pops up modally!
332
333 This method returns the number which has been entered by the user.
334
335 You will use this static method like this:
336
337 \code
338 bool ok = FALSE;
339 int res = QInputDialog::getInteger( tr( "Please enter a number" ), 22, 0, 1000, 2, &ok, this );
340 if ( ok )
341 ;// user entered something and pressed ok
342 else
343 ;// user pressed cancel
344 \endcode
345*/
346
347int QInputDialog::getInteger( const QString &caption, const QString &label, int num, int from, int to, int step,
348 bool *ok, QWidget *parent, const char *name )
349{
350 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, SpinBox );
351 dlg->setCaption( caption );
352 dlg->spinBox()->setRange( from, to );
353 dlg->spinBox()->setSteps( step, 0 );
354 dlg->spinBox()->setValue( num );
355
356 bool ok_ = FALSE;
357 int result;
358 ok_ = dlg->exec() == QDialog::Accepted;
359 if ( ok )
360 *ok = ok_;
361 result = dlg->spinBox()->value();
362
363 delete dlg;
364 return result;
365}
366
367/*!
368 Static convenience function to get a decimal input from the user. \a caption is the text
369 which is displayed in the title bar of the dialog. \a label is the text which
370 is shown to the user (it should mention to the user what he/she should input), \a num
371 the default decimal number which will be initially set to the line edit, \a from and \a to the
372 range in which the entered number has to be, \a decimals the number of decimal which
373 the number may have, \a ok a pointer to
374 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
375 user pressed cancel, \a parent the parent widget of the dialog and \a name
376 the name of it. The dialogs pops up modally!
377
378 This method returns the number which has been entered by the user.
379
380 You will use this static method like this:
381
382 \code
383 bool ok = FALSE;
384 double res = QInputDialog::getDouble( tr( "Please enter a decimal number" ), 33.7, 0, 1000, 2, &ok, this );
385 if ( ok )
386 ;// user entered something and pressed ok
387 else
388 ;// user pressed cancel
389 \endcode
390*/
391
392double QInputDialog::getDouble( const QString &caption, const QString &label, double num,
393 double from, double to, int decimals,
394 bool *ok, QWidget *parent, const char *name )
395{
396 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, LineEdit );
397 dlg->setCaption( caption );
398 dlg->lineEdit()->setValidator( new QDoubleValidator( from, to, decimals, dlg->lineEdit() ) );
399 dlg->lineEdit()->setText( QString::number( num, 'f', decimals ) );
400 dlg->lineEdit()->selectAll();
401
402 bool accepted = ( dlg->exec() == QDialog::Accepted );
403 if ( ok )
404 *ok = accepted;
405
406 double result = dlg->lineEdit()->text().toDouble();
407
408 delete dlg;
409 return result;
410}
411
412/*!
413 Static convenience function to let the user select an item from a string list. \a caption is the text
414 which is displayed in the title bar of the dialog. \a label is the text which
415 is shown to the user (it should mention to the user what he/she should input), \a list the
416 string list which is inserted into the combobox, \a current the number of the item which should
417 be initially the current item, \a editable specifies if the combobox should be editable (if it is TRUE)
418 or read-only (if \a editable is FALSE), \a ok a pointer to
419 a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the
420 user pressed cancel, \a parent the parent widget of the dialog and \a name
421 the name of it. The dialogs pops up modally!
422
423 This method returns the text of the current item, or if \a editable was TRUE, the current
424 text of the combobox.
425
426 You will use this static method like this:
427
428 \code
429 QStringList lst;
430 lst << "First" << "Second" << "Third" << "Fourth" << "Fifth";
431 bool ok = FALSE;
432 QString res = QInputDialog::getItem( tr( "Please select an item" ), lst, 1, TRUE, &ok, this );
433 if ( ok )
434 ;// user selected an item and pressed ok
435 else
436 ;// user pressed cancel
437 \endcode
438*/
439
440QString QInputDialog::getItem( const QString &caption, const QString &label, const QStringList &list,
441 int current, bool editable,
442 bool *ok, QWidget *parent, const char *name )
443{
444 QInputDialog *dlg = new QInputDialog( label, parent, name, TRUE, editable ? EditableComboBox : ComboBox );
445 dlg->setCaption( caption );
446 if ( editable ) {
447 dlg->editableComboBox()->insertStringList( list );
448 dlg->editableComboBox()->setCurrentItem( current );
449 } else {
450 dlg->comboBox()->insertStringList( list );
451 dlg->comboBox()->setCurrentItem( current );
452 }
453
454 bool ok_ = FALSE;
455 QString result;
456 ok_ = dlg->exec() == QDialog::Accepted;
457 if ( ok )
458 *ok = ok_;
459 if ( editable )
460 result = dlg->editableComboBox()->currentText();
461 else
462 result = dlg->comboBox()->currentText();
463
464 delete dlg;
465 return result;
466}
467
468/*!
469 \internal
470*/
471
472void QInputDialog::textChanged( const QString &s )
473{
474 bool on;
475 if ( d->lineEdit->validator() ) {
476 QString str = d->lineEdit->text();
477 int index = d->lineEdit->cursorPosition();
478 on = ( d->lineEdit->validator()->validate(str, index) ==
479 QValidator::Acceptable );
480 } else {
481 on = !s.isEmpty();
482 }
483 d->ok->setEnabled( on );
484}
485
486/*!
487 \internal
488*/
489
490void QInputDialog::tryAccept()
491{
492 if ( !d->lineEdit->text().isEmpty() )
493 accept();
494}
495
diff --git a/qtcompat/qinputdialog.h b/qtcompat/qinputdialog.h
new file mode 100644
index 0000000..3ff5b58
--- a/dev/null
+++ b/qtcompat/qinputdialog.h
@@ -0,0 +1,105 @@
1/****************************************************************************
2** $Id$
3**
4** Definition of QInputDialog class
5**
6** Created : 991212
7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9**
10** This file is part of the dialogs module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37#ifndef QTCOMPAT_QINPUTDIALOG_H
38#define QTCOMPAT_QINPUTDIALOG_H
39
40#ifndef QT_H
41#include <qdialog.h>
42#include <qstring.h>
43#include <qlineedit.h>
44#endif // QT_H
45
46class QInputDialogPrivate;
47
48class QSpinBox;
49class QComboBox;
50
51class Q_EXPORT QInputDialog : public QDialog
52{
53#if defined(_CC_MSVC_)
54 friend class QInputDialog;
55#endif
56 Q_OBJECT
57
58private:
59 enum Type { LineEdit, SpinBox, ComboBox, EditableComboBox };
60
61 QInputDialog( const QString &label, QWidget* parent = 0, const char* name = 0,
62 bool modal = TRUE, Type type = LineEdit );
63 ~QInputDialog();
64
65 QLineEdit *lineEdit() const;
66 QSpinBox *spinBox() const;
67 QComboBox *comboBox() const;
68 QComboBox *editableComboBox() const;
69
70 void setType( Type t );
71 Type type() const;
72
73public:
74 static QString getText( const QString &caption, const QString &label, const QString &text = QString::null,
75 bool *ok = 0, QWidget *parent = 0, const char *name = 0 ); // ### merge with below in 3.0
76 static QString getText( const QString &caption, const QString &label, QLineEdit::EchoMode echo, //### make default Normal in 3.0
77 const QString &text = QString::null, bool *ok = 0, QWidget *parent = 0, const char *name = 0 );
78
79 static int getInteger( const QString &caption, const QString &label, int num = 0, int from = -2147483647,
80 int to = 2147483647,
81 int step = 1, bool *ok = 0, QWidget *parent = 0, const char *name = 0 );
82 static double getDouble( const QString &caption, const QString &label, double num = 0,
83 double from = -2147483647, double to = 2147483647,
84 int decimals = 1, bool *ok = 0, QWidget *parent = 0, const char *name = 0 );
85 static QString getItem( const QString &caption, const QString &label, const QStringList &list,
86 int current = 0, bool editable = TRUE,
87 bool *ok = 0, QWidget *parent = 0, const char *name = 0 );
88
89private slots:
90 void textChanged( const QString &s );
91 void tryAccept();
92
93private:
94 QInputDialogPrivate *d;
95 // just to avoid warnings...
96 friend class QInputDialogPrivate;
97
98 private:// Disabled copy constructor and operator=
99#if defined(Q_DISABLE_COPY)
100 QInputDialog( const QInputDialog & );
101 QInputDialog &operator=( const QInputDialog & );
102#endif
103};
104
105#endif // QTCOMPAT_QINPUTDIALOG_H
diff --git a/qtcompat/qinputdialog.h.wech b/qtcompat/qinputdialog.h.wech
new file mode 100644
index 0000000..47a332b
--- a/dev/null
+++ b/qtcompat/qinputdialog.h.wech
@@ -0,0 +1,14 @@
1#ifndef MICROKDE_QINPUTDIALOG_H
2#define MICROKDE_QINPUTDIALOG_H
3
4class QInputDialog
5{
6 public:
7
8 static QString getText( const QString &, const QString & )
9 {
10 return QString::null;
11 }
12};
13
14#endif
diff --git a/qtcompat/qksplitter.h b/qtcompat/qksplitter.h
new file mode 100644
index 0000000..b62c65e
--- a/dev/null
+++ b/qtcompat/qksplitter.h
@@ -0,0 +1,23 @@
1#ifndef QTCOMPAT_QSPLITTER_H
2#define QTCOMPAT_QSPLITTER_H
3
4#include <qwidget.h>
5
6class QKSplitter : public QWidget
7{
8 public:
9 enum { KeepSize };
10
11 QKSplitter (int, QWidget *parent=0, const char *name=0) :
12 QWidget( parent, name ) {}
13 QKSplitter( QWidget *parent=0, const char *name=0 ) :
14 QWidget( parent, name ) {}
15
16 void setResizeMode( QWidget *, int ) {}
17 void setOpaqueResize() {}
18
19 void setSizes (const QValueList<int> &) {}
20 QValueList<int> sizes() { QValueList<int> ret; return ret; }
21};
22
23#endif
diff --git a/qtcompat/qmemarray.h b/qtcompat/qmemarray.h
new file mode 100644
index 0000000..05adc6a
--- a/dev/null
+++ b/qtcompat/qmemarray.h
@@ -0,0 +1,8 @@
1#ifndef QTCOMPAT_QMEMARRAY_H
2#define QTCOMPAT_QMEMARRAY_H
3
4#include <qarray.h>
5
6#define QMemArray QArray
7
8#endif
diff --git a/qtcompat/qpair.h b/qtcompat/qpair.h
new file mode 100644
index 0000000..9518179
--- a/dev/null
+++ b/qtcompat/qpair.h
@@ -0,0 +1,96 @@
1/****************************************************************************
2**
3** Definition of QPair class
4**
5**
6** Copyright (C) 1992-2001 Trolltech AS. All rights reserved.
7**
8** This file is part of the tools module of the Qt GUI Toolkit.
9**
10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file.
13**
14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file.
18**
19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20** licenses may use this file in accordance with the Qt Commercial License
21** Agreement provided with the Software.
22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30**
31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you.
33**
34**********************************************************************/
35
36#ifndef QPAIR_H
37#define QPAIR_H
38
39#ifndef QT_H
40#include "qglobal.h"
41#include "qdatastream.h"
42#endif // QT_H
43
44template <class T1, class T2>
45struct QPair
46{
47 typedef T1 first_type;
48 typedef T2 second_type;
49
50 QPair()
51 : first( T1() ), second( T2() )
52 {}
53 QPair( const T1& t1, const T2& t2 )
54 : first( t1 ), second( t2 )
55 {}
56
57 T1 first;
58 T2 second;
59};
60
61template <class T1, class T2>
62inline bool operator==( const QPair<T1, T2>& x, const QPair<T1, T2>& y )
63{
64 return x.first == y.first && x.second == y.second;
65}
66
67template <class T1, class T2>
68inline bool operator<( const QPair<T1, T2>& x, const QPair<T1, T2>& y )
69{
70 return x.first < y.first ||
71 ( !( y.first < x.first ) && x.second < y.second );
72}
73
74template <class T1, class T2>
75inline QPair<T1, T2> qMakePair( const T1& x, const T2& y )
76{
77 return QPair<T1, T2>( x, y );
78}
79
80#ifndef QT_NO_DATASTREAM
81template <class T1, class T2>
82inline QDataStream& operator>>( QDataStream& s, QPair<T1, T2>& p )
83{
84 s >> p.first >> p.second;
85 return s;
86}
87
88template <class T1, class T2>
89inline QDataStream& operator<<( QDataStream& s, const QPair<T1, T2>& p )
90{
91 s << p.first << p.second;
92 return s;
93}
94#endif
95
96#endif
diff --git a/qtcompat/qptrlist.h b/qtcompat/qptrlist.h
new file mode 100644
index 0000000..8ce6868
--- a/dev/null
+++ b/qtcompat/qptrlist.h
@@ -0,0 +1,10 @@
1#ifndef QTCOMPAT_QPTRLIST_H
2#define QTCOMPAT_QPTRLIST_H
3
4#include <qlist.h>
5
6#define QPtrList QList
7#define QPtrListIterator QListIterator
8#define QPtrCollection QCollection
9
10#endif
diff --git a/qtcompat/qptrstack.h b/qtcompat/qptrstack.h
new file mode 100644
index 0000000..92070b3
--- a/dev/null
+++ b/qtcompat/qptrstack.h
@@ -0,0 +1,9 @@
1#ifndef QTCOMPAT_QPTRSTACK_H
2#define QTCOMPAT_QPTRSTACK_H
3
4#include <qstack.h>
5
6#define QPtrStack QStack
7#define QPtrStackIterator QStackIterator
8
9#endif
diff --git a/qtcompat/qptrvector.h b/qtcompat/qptrvector.h
new file mode 100644
index 0000000..c869f36
--- a/dev/null
+++ b/qtcompat/qptrvector.h
@@ -0,0 +1,8 @@
1#ifndef QTCOMPAT_QPTRVECTOR_H
2#define QTCOMPAT_QPTRVECTOR_H
3
4#include <qvector.h>
5
6#define QPtrVector QVector
7
8#endif
diff --git a/qtcompat/qtcompat.pro b/qtcompat/qtcompat.pro
new file mode 100644
index 0000000..f985bb4
--- a/dev/null
+++ b/qtcompat/qtcompat.pro
@@ -0,0 +1,31 @@
1 TEMPLATE= lib
2 CONFIG += qt warn_on
3OBJECTS_DIR = obj/$(PLATFORM)
4MOC_DIR = moc/$(PLATFORM)
5 TARGET = microqtcompat
6DESTDIR=$(QPEDIR)/lib
7
8
9INTERFACES = \
10
11HEADERS = \
12 qcombotableitem.h \
13 qgridview.h \
14 qmemarray.h \
15 qptrlist.h \
16 qksplitter.h \
17 qptrvector.h \
18 qinputdialog.h \
19 qtooltipcompat.h
20
21# qsplitter.h
22
23
24
25
26SOURCES = \
27 qinputdialog.cpp \
28 qcombotableitem.cpp \
29 qgridview.cpp \
30 qtooltipcompat.cpp
31
diff --git a/qtcompat/qtcompat.pro.back b/qtcompat/qtcompat.pro.back
new file mode 100644
index 0000000..6da7ce0
--- a/dev/null
+++ b/qtcompat/qtcompat.pro.back
@@ -0,0 +1,19 @@
1 TEMPLATE= lib
2 CONFIG = qt warn_on release
3OBJECTS_DIR = obj/$(PLATFORM)
4MOC_DIR = moc
5DESTDIR=$(QPEDIR)/lib
6
7INTERFACES = \
8
9HEADERS = \
10 qgridview.h \
11 qinputdialog.h \
12 qmemarray.h \
13 qptrlist.h \
14 qptrvector.h \
15 qsplitter.h \
16
17SOURCES = \
18 qgridview.cpp \
19
diff --git a/qtcompat/qtooltipcompat.cpp b/qtcompat/qtooltipcompat.cpp
new file mode 100644
index 0000000..a2de608
--- a/dev/null
+++ b/qtcompat/qtooltipcompat.cpp
@@ -0,0 +1,42 @@
1
2
3/******
4 *
5 * rob's QToolTip class
6 *
7 * Apparently Sharp concluded that ToolTips were not useful on the Zaurus and
8 * left them out of their Qtopia. Unfortunately, QWhatsThis uses the
9 * QToolTips::palette(), that function returns all 0's, and that means that
10 * QWhatsThis windows come up with black background and black foreground. By
11 * re-implementing this class, QWhatsThis calls this QToolTip::palette(), and
12 * gets a useful result.
13 *
14 * Include this class in your own Zaurus application and QWhatsThis should work
15 * for you as well.
16 *
17 * The contents of this file are released without restriction to the public
18 * domain.
19 *
20 * Copyright (c) rob miller October, 2003
21 *
22 *****/
23#ifdef ADD_TOOLTIP
24
25#include "qtooltipcompat.h"
26QPalette QToolTip::palette() {
27 static bool init = false;
28 static QPalette pt;
29 if (! init) { // only initialise once
30 init=true;
31 //rDebug("initialising my qtt-palette()"); //rDebug() is just qDebug() with a compile switch
32 QColor fg = QColor(0x00,0x00,0x00);
33 QColor bg = QColor(0xff,0xff,0xdc);
34
35 pt.setColor(QColorGroup::Background,bg);
36 pt.setBrush(QColorGroup::Foreground,fg);
37 }
38
39 return pt;
40}
41#endif
42
diff --git a/qtcompat/qtooltipcompat.h b/qtcompat/qtooltipcompat.h
new file mode 100644
index 0000000..4d44146
--- a/dev/null
+++ b/qtcompat/qtooltipcompat.h
@@ -0,0 +1,34 @@
1#ifndef QTCOMPAT_QTOOLTIP_H
2#define QTCOMPAT_QTOOLTIP_H
3
4/******
5 *
6 * rob's QToolTip class
7 *
8 * Apparently Sharp concluded that ToolTips were not useful on the Zaurus and
9 * left them out of their Qtopia. Unfortunately, QWhatsThis uses the
10 * QToolTips::palette(), that function returns all 0's, and that means that
11 * QWhatsThis windows come up with black background and black foreground. By
12 * re-implementing this class, QWhatsThis calls this QToolTip::palette(), and
13 * gets a useful result.
14 *
15 * Include this class in your own Zaurus application and QWhatsThis should work
16 * for you as well.
17 *
18 * The contents of this file are released without restriction to the public
19 * domain.
20 *
21 * Copyright (c) rob miller October, 2003
22 *
23 *****/
24#ifdef ADD_TOOLTIP
25
26#include <qpalette.h>
27class QToolTip: public Qt {
28 public:
29 static QPalette palette();
30};
31
32#endif
33
34#endif