Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

QY2ListView.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                          contributed Qt widgets                      |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013   File:       QY2ListView.h
00014 
00015   Author:     Stefan Hundhammer <sh@suse.de>
00016 
00017   This is a pure Qt widget - it can be used independently of YaST2.
00018 
00019 /-*/
00020 
00021 // -*- c++ -*-
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 
00142     virtual QSize minimumSizeHint() const;
00143 
00147     virtual bool eventFilter( QObject * obj, QEvent * event );
00148 
00149 
00150 protected slots:
00151 
00157     void columnWidthChanged( int col, int oldSize, int newSize );
00158 
00159 protected:
00160 
00165     virtual void contentsMousePressEvent( QMouseEvent * e );
00166 
00171     virtual void contentsMouseReleaseEvent( QMouseEvent * );
00172 
00177     virtual void contentsMouseDoubleClickEvent( QMouseEvent * );
00178 
00179 
00180 
00181     // Data members
00182 
00183     QListViewItem *             _mousePressedItem;
00184     int                         _mousePressedCol;
00185     int                         _mousePressedButton;
00186 
00187     std::vector<int>            _savedColumnWidth;
00188     int                         _nextSerial;
00189 
00190     QY2ListViewToolTip *        _toolTip;
00191     bool                        _mouseButton1PressedInHeader;
00192     bool                        _finalSizeChangeExpected;
00193 };
00194 
00195 
00196 
00200 class QY2ListViewItem: public QListViewItem
00201 {
00202 public:
00203 
00211     QY2ListViewItem( QY2ListView *              parentListView,
00212                      const QString &            text = QString::null,
00213                      bool                       sortByInsertionSequence = false );
00214 
00215 
00223     QY2ListViewItem( QListViewItem *            parentItem,
00224                      const QString &            text = QString::null,
00225                      bool                       sortByInsertionSequence = false );
00226 
00230     virtual ~QY2ListViewItem();
00231 
00238     virtual void updateStatus() {}
00239 
00246     virtual void updateData() {}
00247 
00257     virtual int compare( QListViewItem *        other,
00258                          int                    col,
00259                          bool                   ascending ) const;
00260 
00265     int serial() const { return _serial; }
00266 
00270     bool sortByInsertionSequence() const { return _sortByInsertionSequence; }
00271 
00276     void setSortByInsertionSequence( bool doit )
00277         { _sortByInsertionSequence = doit; }
00278 
00283     void setTextColor( const QColor & col )
00284         { _textColor = col; }
00285 
00290     void setBackgroundColor( const QColor & col )
00291         { _backgroundColor = col; }
00292 
00299     virtual QString toolTip( int column ) { return QString::null; }
00300 
00301 
00302 protected:
00303 
00310     virtual void paintCell( QPainter *          painter,
00311                             const QColorGroup & colorGroup,
00312                             int                 column,
00313                             int                 width,
00314                             int                 alignment );
00315 
00316     // Data members
00317 
00318     int         _serial;
00319     bool        _sortByInsertionSequence;
00320 
00321     QColor      _textColor;
00322     QColor      _backgroundColor;
00323 };
00324 
00325 
00326 
00330 class QY2CheckListItem: public QCheckListItem
00331 {
00332 public:
00333 
00341     QY2CheckListItem( QY2ListView *             parentListView,
00342                       const QString &           text,
00343                       QCheckListItem::Type      type,
00344                       bool                      sortByInsertionSequence = false );
00345 
00346 
00354     QY2CheckListItem( QListViewItem *           parentItem,
00355                       const QString &           text,
00356                       QCheckListItem::Type      type,
00357                       bool                      sortByInsertionSequence = false );
00358 
00359 
00367     QY2CheckListItem( QCheckListItem *          parentItem,
00368                       const QString &           text,
00369                       QCheckListItem::Type      type,
00370                       bool                      sortByInsertionSequence = false );
00371 
00375     virtual ~QY2CheckListItem();
00376 
00383     virtual void updateStatus() {}
00384 
00391     virtual void updateData() {}
00392 
00402     virtual int compare( QListViewItem *        other,
00403                          int                    col,
00404                          bool                   ascending ) const;
00405 
00410     int serial() const { return _serial; }
00411 
00415     bool sortByInsertionSequence() const { return _sortByInsertionSequence; }
00416 
00421     void setSortByInsertionSequence( bool doit )
00422         { _sortByInsertionSequence = doit; }
00423 
00428     void setTextColor( const QColor & col )
00429         { _textColor = col; }
00430 
00435     void setBackgroundColor( const QColor & col )
00436         { _backgroundColor = col; }
00437 
00444     virtual QString toolTip( int column ) { return QString(); }
00445 
00446 
00447 protected:
00448 
00455     virtual void paintCell( QPainter *          painter,
00456                             const QColorGroup & colorGroup,
00457                             int                 column,
00458                             int                 width,
00459                             int                 alignment );
00460 
00461     // Data members
00462 
00463     int         _serial;
00464     bool        _sortByInsertionSequence;
00465 
00466     QColor      _textColor;
00467     QColor      _backgroundColor;
00468 };
00469 
00470 
00476 class QY2ListViewToolTip : public QToolTip
00477 {
00478 public:
00479 
00483     QY2ListViewToolTip::QY2ListViewToolTip( QY2ListView * parent )
00484         : QToolTip( parent->viewport() ), _listView( parent )  {}
00485 
00489     virtual ~QY2ListViewToolTip() {}
00490 
00491 
00492 protected:
00493 
00499     virtual void maybeTip( const QPoint & p );
00500 
00501     
00502     // Data members
00503     
00504     QY2ListView * _listView;
00505 };
00506 
00507 #endif // ifndef QY2ListView_h

Generated on Wed Sep 14 10:59:02 2005 for yast2-qt by  doxygen 1.4.4