00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef QY2ListView_h
00025 #define QY2ListView_h
00026
00027 #include <qlistview.h>
00028 #include <qtooltip.h>
00029 #include <qpoint.h>
00030 #include <qcolor.h>
00031 #include <vector>
00032
00033
00034 class QY2ListViewItem;
00035 class QY2ListViewToolTip;
00036
00037
00041 class QY2ListView : public QListView
00042 {
00043 Q_OBJECT
00044
00045 public:
00046
00050 QY2ListView( QWidget * parent );
00051
00055 virtual ~QY2ListView();
00056
00057
00058 public slots:
00059
00065 virtual void selectSomething();
00066
00071 virtual void clear();
00072
00078 void updateToplevelItemStates();
00079
00085 void updateToplevelItemData();
00086
00090 void saveColumnWidths();
00091
00096 void restoreColumnWidths();
00097
00098
00099 signals:
00100
00104 void columnClicked ( int button,
00105 QListViewItem * item,
00106 int col,
00107 const QPoint & pos );
00108
00112 void columnDoubleClicked ( int button,
00113 QListViewItem * item,
00114 int col,
00115 const QPoint & pos );
00116
00117 public:
00118
00130 virtual QString toolTip( QListViewItem * item, int column );
00131
00136 int nextSerial() { return _nextSerial++; }
00137
00138
00143 virtual QSize minimumSizeHint() const;
00144
00145
00146 protected slots:
00147
00153 void columnWidthChanged( int col, int oldSize, int newSize );
00154
00155 protected:
00156
00161 virtual void contentsMousePressEvent( QMouseEvent * e );
00162
00167 virtual void contentsMouseReleaseEvent( QMouseEvent * );
00168
00173 virtual void contentsMouseDoubleClickEvent( QMouseEvent * );
00174
00175
00176
00177
00178
00179 QListViewItem * _mousePressedItem;
00180 int _mousePressedCol;
00181 int _mousePressedButton;
00182
00183 std::vector<int> _savedColumnWidth;
00184 int _nextSerial;
00185
00186 QY2ListViewToolTip * _toolTip;
00187 };
00188
00189
00190
00194 class QY2ListViewItem: public QListViewItem
00195 {
00196 public:
00197
00205 QY2ListViewItem( QY2ListView * parentListView,
00206 const QString & text = QString::null,
00207 bool sortByInsertionSequence = false );
00208
00209
00217 QY2ListViewItem( QListViewItem * parentItem,
00218 const QString & text = QString::null,
00219 bool sortByInsertionSequence = false );
00220
00224 virtual ~QY2ListViewItem();
00225
00232 virtual void updateStatus() {}
00233
00240 virtual void updateData() {}
00241
00251 virtual int compare( QListViewItem * other,
00252 int col,
00253 bool ascending ) const;
00254
00259 int serial() const { return _serial; }
00260
00264 bool sortByInsertionSequence() const { return _sortByInsertionSequence; }
00265
00270 void setSortByInsertionSequence( bool doit )
00271 { _sortByInsertionSequence = doit; }
00272
00277 void setTextColor( const QColor & col )
00278 { _textColor = col; }
00279
00284 void setBackgroundColor( const QColor & col )
00285 { _backgroundColor = col; }
00286
00293 virtual QString toolTip( int column ) { return QString::null; }
00294
00295
00296 protected:
00297
00304 virtual void paintCell( QPainter * painter,
00305 const QColorGroup & colorGroup,
00306 int column,
00307 int width,
00308 int alignment );
00309
00310
00311
00312 int _serial;
00313 bool _sortByInsertionSequence;
00314
00315 QColor _textColor;
00316 QColor _backgroundColor;
00317 };
00318
00319
00320
00324 class QY2CheckListItem: public QCheckListItem
00325 {
00326 public:
00327
00335 QY2CheckListItem( QY2ListView * parentListView,
00336 const QString & text,
00337 QCheckListItem::Type type,
00338 bool sortByInsertionSequence = false );
00339
00340
00348 QY2CheckListItem( QListViewItem * parentItem,
00349 const QString & text,
00350 QCheckListItem::Type type,
00351 bool sortByInsertionSequence = false );
00352
00353
00361 QY2CheckListItem( QCheckListItem * parentItem,
00362 const QString & text,
00363 QCheckListItem::Type type,
00364 bool sortByInsertionSequence = false );
00365
00369 virtual ~QY2CheckListItem();
00370
00377 virtual void updateStatus() {}
00378
00385 virtual void updateData() {}
00386
00396 virtual int compare( QListViewItem * other,
00397 int col,
00398 bool ascending ) const;
00399
00404 int serial() const { return _serial; }
00405
00409 bool sortByInsertionSequence() const { return _sortByInsertionSequence; }
00410
00415 void setSortByInsertionSequence( bool doit )
00416 { _sortByInsertionSequence = doit; }
00417
00422 void setTextColor( const QColor & col )
00423 { _textColor = col; }
00424
00429 void setBackgroundColor( const QColor & col )
00430 { _backgroundColor = col; }
00431
00438 virtual QString toolTip( int column ) { return QString(); }
00439
00440
00441 protected:
00442
00449 virtual void paintCell( QPainter * painter,
00450 const QColorGroup & colorGroup,
00451 int column,
00452 int width,
00453 int alignment );
00454
00455
00456
00457 int _serial;
00458 bool _sortByInsertionSequence;
00459
00460 QColor _textColor;
00461 QColor _backgroundColor;
00462 };
00463
00464
00470 class QY2ListViewToolTip : public QToolTip
00471 {
00472 public:
00473
00477 QY2ListViewToolTip::QY2ListViewToolTip( QY2ListView * parent )
00478 : QToolTip( parent->viewport() ), _listView( parent ) {}
00479
00480 protected:
00481
00487 virtual void maybeTip( const QPoint & p );
00488
00489 QY2ListView * _listView;
00490 };
00491
00492 #endif // ifndef QY2ListView_h