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

YQPkgObjList.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013   File:       YQPkgObjList.h
00014 
00015   Author:     Stefan Hundhammer <sh@suse.de>
00016 
00017 /-*/
00018 
00019 // -*- c++ -*-
00020 
00021 
00022 #ifndef YQPkgObjList_h
00023 #define YQPkgObjList_h
00024 
00025 #include <qpixmap.h>
00026 #include <QY2ListView.h>
00027 #include <y2pm/PMObject.h>
00028 #include <y2pm/PMSelectable.h>
00029 #include <y2util/FSize.h>
00030 
00031 class YQPkgObjListItem;
00032 class QAction;
00033 class QPopupMenu;
00034 using std::string;
00035 
00036 
00041 class YQPkgObjList : public QY2ListView
00042 {
00043     Q_OBJECT
00044 
00045 protected:
00049     YQPkgObjList( QWidget * parent );
00050 
00054     virtual ~YQPkgObjList();
00055 
00056 
00057 public:
00058 
00059     // Column numbers
00060 
00061     int statusCol()             const   { return _statusCol;            }
00062     int nameCol()               const   { return _nameCol;              }
00063     int summaryCol()            const   { return _summaryCol;           }
00064     int sizeCol()               const   { return _sizeCol;              }
00065     int versionCol()            const   { return _versionCol;           }
00066     int instVersionCol()        const   { return _instVersionCol;       }
00067 
00074     bool editable() const { return _editable; }
00075 
00079     void setEditable( bool editable = true ) { _editable = editable; }
00080 
00085     void setCurrentStatus( PMSelectable::UI_Status      newStatus,
00086                            bool                         selectNextItem = false );
00087 
00095     void setAllItemStatus( PMSelectable::UI_Status newStatus, bool force = false );
00096 
00101     virtual QPopupMenu * addAllInListSubMenu( QPopupMenu * menu );
00102 
00109     virtual QPixmap statusIcon( PMSelectable::UI_Status status,
00110                                 bool                    enabled     = true,
00111                                 bool                    bySelection = false );
00112 
00116     virtual QString statusText( PMSelectable::UI_Status status ) const;
00117 
00118 
00119 public slots:
00120 
00130     void addPkgObjItem( PMObjectPtr pmObj );
00131 
00136     void addPassiveItem( const QString & name,
00137                          const QString & summary = QString::null,
00138                          FSize           size    = -1 );
00139     
00143     virtual void pkgObjClicked( int             button,
00144                                 QListViewItem * item,
00145                                 int             col,
00146                                 const QPoint &  pos );
00147 
00152     virtual void clear();
00153 
00157     virtual void updateActions( YQPkgObjListItem * item );
00158 
00165     virtual void updateActions();
00166 
00171     void selectNextItem();
00172 
00176     void sendStatusChanged() { emit statusChanged(); }
00177 
00181     virtual void message( const QString & text );
00182 
00183 
00184     // Direct access to some states for menu actions
00185 
00186     void setCurrentInstall()       { setCurrentStatus( PMSelectable::S_Install       ); }
00187     void setCurrentDontInstall()   { setCurrentStatus( PMSelectable::S_NoInst        ); }
00188     void setCurrentKeepInstalled() { setCurrentStatus( PMSelectable::S_KeepInstalled ); }
00189     void setCurrentDelete()        { setCurrentStatus( PMSelectable::S_Del           ); }
00190     void setCurrentUpdate()        { setCurrentStatus( PMSelectable::S_Update        ); }
00191     void setCurrentTaboo()         { setCurrentStatus( PMSelectable::S_Taboo         ); }
00192     void setCurrentProtected()     { setCurrentStatus( PMSelectable::S_Protected     ); }
00193 
00194     void setListInstall()          { setAllItemStatus( PMSelectable::S_Install       ); }
00195     void setListDontInstall()      { setAllItemStatus( PMSelectable::S_NoInst        ); }
00196     void setListKeepInstalled()    { setAllItemStatus( PMSelectable::S_KeepInstalled ); }
00197     void setListDelete()           { setAllItemStatus( PMSelectable::S_Del           ); }
00198     void setListUpdate()           { setAllItemStatus( PMSelectable::S_Update        ); }
00199     void setListUpdateForce()      { setAllItemStatus( PMSelectable::S_Update, true  ); }
00200     void setListTaboo()            { setAllItemStatus( PMSelectable::S_Taboo         ); }
00201     void setListProtected()        { setAllItemStatus( PMSelectable::S_Protected     ); }
00202 
00203 
00204 protected slots:
00205 
00209     virtual void selectionChangedInternal( QListViewItem * item );
00210 
00211 
00212 signals:
00213 
00214 
00219     void selectionChanged( PMObjectPtr pmObj );
00220 
00224     void statusChanged();
00225 
00226 
00227 protected:
00228 
00235     virtual void keyPressEvent( QKeyEvent * ev );
00236 
00241     virtual QPopupMenu * installedContextMenu();
00242 
00247     virtual QPopupMenu * notInstalledContextMenu();
00248 
00252     virtual void createNotInstalledContextMenu();
00253 
00257     virtual void createInstalledContextMenu();
00258 
00263     void createActions();
00264 
00270     QAction * createAction( PMSelectable::UI_Status     status,
00271                             const QString &             key     = QString::null,
00272                             bool                        enabled = false );
00273 
00278     QAction * createAction( const QString &     text,
00279                             const QPixmap &     icon            = QPixmap(),
00280                             const QPixmap &     insensitiveIcon = QPixmap(),
00281                             const QString &     key             = QString::null,
00282                             bool                enabled         = false );
00283 
00284 
00285     // Data members
00286 
00287     int         _statusCol;
00288     int         _nameCol;
00289     int         _summaryCol;
00290     int         _sizeCol;
00291     int         _versionCol;
00292     int         _instVersionCol;
00293     bool        _editable;
00294 
00295 
00296     QPopupMenu *        _installedContextMenu;
00297     QPopupMenu *        _notInstalledContextMenu;
00298 
00299 
00300 public:
00301 
00302     QAction *           actionSetCurrentInstall;
00303     QAction *           actionSetCurrentDontInstall;
00304     QAction *           actionSetCurrentKeepInstalled;
00305     QAction *           actionSetCurrentDelete;
00306     QAction *           actionSetCurrentUpdate;
00307     QAction *           actionSetCurrentTaboo;
00308     QAction *           actionSetCurrentProtected;
00309 
00310     QAction *           actionSetListInstall;
00311     QAction *           actionSetListDontInstall;
00312     QAction *           actionSetListKeepInstalled;
00313     QAction *           actionSetListDelete;
00314     QAction *           actionSetListUpdate;
00315     QAction *           actionSetListUpdateForce;
00316     QAction *           actionSetListTaboo;
00317     QAction *           actionSetListProtected;
00318 };
00319 
00320 
00321 
00322 class YQPkgObjListItem: public QY2ListViewItem
00323 {
00324 public:
00325 
00330     YQPkgObjListItem( YQPkgObjList * pkgObjList, PMObjectPtr pmObj );
00331 
00335     virtual ~YQPkgObjListItem();
00336 
00340     PMObjectPtr pmObj() { return _pmObj; }
00341 
00345     const PMObjectPtr constPMObj() const { return _pmObj; }
00346 
00352     bool editable() const { return _editable; }
00353 
00357     void setEditable( bool editable = true ) { _editable = editable; }
00358 
00362     PMSelectable::UI_Status status() const;
00363 
00368     bool bySelection() const;
00369     
00373     virtual void setStatus( PMSelectable::UI_Status newStatus );
00374 
00380     virtual void updateStatus();
00381 
00385     virtual void setStatusIcon();
00386 
00390     virtual void cycleStatus();
00391 
00395     bool candidateIsNewer() const { return _candidateIsNewer; }
00396 
00400     bool installedIsNewer() const { return _installedIsNewer; }
00401 
00406     void setText( int column, const string text );
00407 
00412     void setText( int column, const QString & text )
00413         { QListViewItem::setText( column, text ); }
00414 
00418     void setText( int column, const PkgEdition & edition );
00419 
00424     void showNotifyTexts( PMSelectable::UI_Status status );
00425 
00434     bool showLicenseAgreement( PMSelectable::UI_Status status );
00435 
00445     virtual int compare( QListViewItem *        other,
00446                          int                    col,
00447                          bool                   ascending ) const;
00448 
00456     int versionPoints() const;
00457 
00464     virtual void updateData();
00465 
00472     virtual QString toolTip( int column );
00473 
00474 
00475     // Columns
00476 
00477     int statusCol()             const   { return _pkgObjList->statusCol();      }
00478     int nameCol()               const   { return _pkgObjList->nameCol();        }
00479     int summaryCol()            const   { return _pkgObjList->summaryCol();     }
00480     int sizeCol()               const   { return _pkgObjList->sizeCol();        }
00481     int versionCol()            const   { return _pkgObjList->versionCol();     }
00482     int instVersionCol()        const   { return _pkgObjList->instVersionCol(); }
00483 
00484 
00485 protected:
00486 
00490     void init();
00491 
00492 
00493     // Data members
00494 
00495     YQPkgObjList *      _pkgObjList;
00496     PMObjectPtr         _pmObj;
00497     bool                _editable;
00498     bool                _candidateIsNewer;
00499     bool                _installedIsNewer;
00500 };
00501 
00502 
00503 
00504 #endif // ifndef YQPkgObjList_h

Generated on Wed Nov 12 06:11:16 2008 for yast2-qt by  doxygen 1.3.9.1