YTable.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:       YTable.h
00014 
00015   Author:     Mathias Kettner <kettner@suse.de>
00016   Maintainer: Stefan Hundhammer <sh@suse.de>
00017 
00018 /-*/
00019 
00020 #ifndef YTable_h
00021 #define YTable_h
00022 
00023 #include "YWidget.h"
00024 #include <ycp/YCPString.h>
00025 #include <ycp/YCPList.h>
00026 
00027 class YMacroRecorder;
00028 
00029 
00033 class YTableRow
00034 {
00035     YCPValue id;
00036     vector<string> elements;
00037     YTableRow( YCPValue id, vector<string> elements )
00038         : id( id ), elements( elements ) {};
00039     friend class YTable;
00040 
00044     YCPTerm makeTerm() const;
00045 };
00046 
00047 
00048 
00052 class YTable : public YWidget
00053 {
00054 public:
00055 
00060     YTable( const YWidgetOpt & opt, int num_cols );
00061 
00066     virtual char *widgetClass() { return "YTable"; }
00067 
00072     bool addItem( const YCPValue & item );
00073 
00078     virtual bool addItems( const YCPList & itemlist );
00079 
00083     void addItem( const YCPValue & id, vector<string> elements );
00084 
00088     YCPValue changeWidget( const YCPSymbol & property, const YCPValue & newvalue );
00089 
00093     YCPValue changeWidgetTerm( const YCPTerm & property, const YCPValue & newvalue );
00094 
00098     YCPValue queryWidget( const YCPSymbol & property );
00099 
00103     YCPValue queryWidgetTerm( const YCPTerm & property );
00104 
00108     int numCols() const;
00109     
00114     const char *userInputProperty() { return YUIProperty_CurrentItem; }
00115     
00116         
00117 protected:
00124     virtual void itemAdded( vector<string> elements, int index ) = 0;
00125 
00130     virtual void itemsCleared() = 0;
00131 
00136     virtual void cellChanged( int index, int colnum, const YCPString & newtext ) = 0;
00137 
00142     virtual int getCurrentItem() = 0;
00143 
00147     virtual void setCurrentItem( int index ) = 0;
00148 
00149 
00150 protected:
00154     vector<YTableRow> rows;
00155 
00159     int num_cols;
00160 
00164     int numItems() const;
00165 
00172     int itemWithId( const YCPValue & id, bool report_error );
00173 
00174 
00175 private:
00176 
00182     virtual void saveUserInput( YMacroRecorder *macroRecorder );
00183 };
00184 
00185 
00186 #endif // YTable_h

Generated on Fri Jun 16 18:07:45 2006 for yast2-core by  doxygen 1.4.6