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

NCPkgTable.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:       NCPkgTable.h
00014 
00015    Author:     Gabriele Strattner <gs@suse.de>
00016    Maintainer: Michael Andres <ma@suse.de>
00017 
00018 /-*/
00019 #ifndef NCPkgTable_h
00020 #define NCPkgTable_h
00021 
00022 #include <iosfwd>
00023 
00024 #include "NCPadWidget.h"
00025 #include "NCTablePad.h"
00026 #include "NCTable.h"
00027 #include "PkgNames.h"
00028 
00029 #include <map>          
00030 #include <string>
00031 #include <utility>      // for STL pair
00032 
00033 #include <Y2PM.h>
00034 #include <y2pm/RpmDb.h>
00035 #include <y2pm/PMManager.h>
00036 #include <y2pm/PMSelectable.h>
00037 
00038 #include "ObjectStatStrategy.h"
00039 
00040 
00041 class PackageSelector;
00042 
00043 
00050 class NCPkgTableTag : public NCTableCol {
00051 
00052   private:
00053 
00054     PMSelectable::UI_Status status;
00055     PMObjectPtr dataPointer;
00056     
00057     // returns the corresponding string value to given package status
00058     string statusToStr( PMSelectable::UI_Status stat ) const;
00059     
00060   public:
00061 
00062     NCPkgTableTag( PMObjectPtr pkgPtr,
00063                    PMSelectable::UI_Status stat = PMSelectable::S_NoInst );
00064 
00065     virtual ~NCPkgTableTag() {}
00066 
00067     virtual void DrawAt( NCursesWindow & w, const wrect at,
00068                          NCTableStyle & tableStyle,
00069                          NCTableLine::STATE linestate,
00070                          unsigned colidx ) const; 
00071 
00072     void setStatus( PMSelectable::UI_Status  stat )     { status = stat; }
00073     PMSelectable::UI_Status getStatus() const   { return status; }
00074     PMObjectPtr getDataPointer() const          { return dataPointer; }
00075 };
00076 
00084 class NCPkgTable : public NCTable {
00085 
00086 public:
00087     enum NCPkgTableType {
00088         T_Packages,
00089         T_Availables,
00090         T_Patches,
00091         T_Dependency,
00092         T_SelDependency,
00093         T_Update,
00094         T_PatchPkgs,
00095         T_DepsPackages,
00096         T_Selections,
00097         T_Unknown
00098     };
00099 
00100     enum NCPkgTableListAction {
00101         A_Install,
00102         A_DontInstall,
00103         A_Delete,
00104         A_DontDelete,
00105         A_Update,
00106         A_DontUpdate,
00107         A_Unknown
00108     };
00109 
00110     enum NCPkgTableListType {
00111         L_Changes,
00112         L_Installed,
00113         L_Unknown
00114     };
00115     
00116 private:
00117 
00118     NCPkgTable & operator=( const NCPkgTable & );
00119     NCPkgTable            ( const NCPkgTable & );
00120     
00121     PackageSelector * packager;         // connection to the PackageSelector,
00122 
00123     ObjectStatStrategy * statusStrategy;        // particular methods to get the status
00124 
00125     NCPkgTableType tableType;   // the type (e.g. table of packages, patches)
00126     
00127     // returns the first column of line with 'index' (the tag)
00128     NCPkgTableTag * getTag ( const int & index );
00129 
00130 protected:
00131 
00132 
00133 public:
00134 
00138     NCPkgTable( NCWidget * parent, const YWidgetOpt & opt );
00139 
00140     virtual ~NCPkgTable();
00141 
00142 
00150     virtual void addLine( PMSelectable::UI_Status status,
00151                           const vector<string> & elements,
00152                           PMObjectPtr objPtr );
00153 
00157    void drawList( ) { return DrawPad(); }
00158     
00162     virtual void itemsCleared();
00163 
00171     virtual void cellChanged( int index, int colnum, const YCPString & newtext );
00172 
00179     NClabel getCellContents( int index, int colnum );
00180 
00187     virtual NCursesEvent wHandleInput( wint_t key );
00188 
00194     void setPackager( PackageSelector * pkg ) { packager = pkg; }
00195 
00204     bool changeStatus( PMSelectable::UI_Status newstat,
00205                        const PMObjectPtr & objPtr,
00206                        bool singleChange );
00207     
00208     bool changeObjStatus( int key );
00209 
00210     bool changeListObjStatus( NCPkgTableListAction key );
00211 
00212     bool toggleObjStatus( );
00213 
00218     bool updateTable();
00219 
00225     PMSelectable::UI_Status getStatus( int index );
00226 
00232     PMSelectable::UI_Status getAvailableStatus( const PMObjectPtr & objPtr );
00233     
00239     bool SourceInstall( bool install );
00240     
00249     bool setTableType( NCPkgTableType type, ObjectStatStrategy * strategy ) {
00250         if ( !strategy )
00251             return false;
00252         
00253         delete statusStrategy;
00254         statusStrategy = strategy;
00255         tableType = type;
00256 
00257         return true;
00258     }
00259 
00265     PMObjectPtr getDataPointer( int index );
00266 
00271     unsigned int getNumLines( ) { return pad->Lines(); }
00272 
00277     bool fillDefaultList( );
00278 
00283     void fillHeader( );
00284 
00290    bool createListEntry ( PMPackagePtr pkgPtr );
00291 
00297    bool createPatchEntry ( PMYouPatchPtr pkgPtr );
00298 
00304    bool createInfoEntry ( string text );
00305 
00310    bool showInformation ( );
00311 };
00312 
00314 
00315 #endif // NCPkgTable_h

Generated on Wed Sep 5 17:18:55 2007 for yast2-ncurses by doxygen 1.3.6