Version: 6.3.1

src/VISU_I/VISU_TableDlg.h

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 //  File   : VISU_TableDlg.h
00021 //  Author : Vadim SANDLER
00022 //  Module : VISU
00023 //
00024 #ifndef VISU_TABLEDLG_H
00025 #define VISU_TABLEDLG_H
00026 
00027 #include "VISU_I.hxx"
00028 
00029 #include <SALOMEDSClient_Study.hxx>
00030 
00031 #include <QDialog>
00032 #include <QItemDelegate>
00033 #include <QMap>
00034 
00035 class QLabel;
00036 class QLineEdit;
00037 class QPushButton;
00038 class QCheckBox;
00039 class QComboBox;
00040 class QTableWidget;
00041 
00042 namespace VISU
00043 {
00044   class Table_i;
00045 }
00046 
00047 class VISU_I_EXPORT VISU_TableDlg : public QDialog
00048 { 
00049   Q_OBJECT
00050 
00051   class TableWidget;
00052   class WidgetCointainer;
00053 
00054   enum { tcTitle, tcTable, tcControls, tcButtons };
00055 
00056 public:
00057 
00058   enum { ttNone, ttInt, ttReal, ttAll, ttAuto };
00059   enum { teNone      = 0x00,
00060          teAddRemove = 0x01,
00061          teEditData  = 0x02,
00062          teRowColumn = 0x04,
00063          teAll       = teAddRemove | teEditData | teRowColumn
00064   };
00065 
00066   VISU_TableDlg( QWidget* parent, 
00067                  _PTR(Study) study, 
00068                  VISU::Table_i* table,
00069                  bool allowEdition = false,
00070                  int which = ttAuto, 
00071                  Qt::Orientation orient = Qt::Horizontal,
00072                  bool showColumnTitles = true );
00073   ~VISU_TableDlg();
00074 
00075 protected:
00076   void keyPressEvent( QKeyEvent* e );
00077 
00078 private slots:
00079   void help(); 
00080 
00081 private:
00082   QString tableTitle( int type );
00083 
00084 private:
00085   typedef QMap<int, TableWidget*>      TableMap;
00086   typedef QMap<int, WidgetCointainer*> ContMap;
00087 
00088   TableMap               myTableMap;
00089   ContMap                myContMap;
00090   QCheckBox*             myEditCheck;
00091   QCheckBox*             myUpdateCheck;
00092   QPushButton*           myOKBtn;
00093   QPushButton*           myHelpBtn;
00094 
00095   _PTR(Study)            myStudy;
00096   VISU::Table_i*         myTable;
00097 };
00098  
00099 class VISU_I_EXPORT VISU_TableDlg::TableWidget : public QWidget
00100 {
00101   Q_OBJECT
00102 
00103 public:
00104   TableWidget( QWidget* parent = 0, Qt::Orientation orientation = Qt::Horizontal );
00105   ~TableWidget();
00106 
00107   void    initialize( _PTR(Study) study, VISU::Table_i* table, int type );
00108 
00109   void    setTableTitle( const QString& title );
00110   QString getTableTitle();
00111   void    setNumRows( const int num );
00112   int     getNumRows();
00113   void    setNumCols( const int num );
00114   int     getNumCols();
00115   void    setRowTitles( QStringList& tlts );
00116   void    getRowTitles( QStringList& tlts );
00117   void    setColTitles( QStringList& tlts );
00118   void    getColTitles( QStringList& tlts );
00119   void    setUnitsTitle( const QString& tlt );
00120   void    setUnits( QStringList& units );
00121   void    getUnits( QStringList& units );
00122   void    setRowData( int row, QStringList& data );
00123   void    getRowData( int row, QStringList& data );
00124 
00125   bool    eventFilter( QObject* o, QEvent* e);
00126 
00127 public slots:
00128   void    setEditEnabled( bool enable );
00129   void    showColumnTitles( bool showTitles );
00130 
00131   void    updateButtonsState();
00132   void    addRow();
00133   void    addCol();
00134   void    delRow();
00135   void    delCol();
00136   void    adjustTable();
00137   void    selectAll();
00138   void    clearTable();
00139 
00140   void    columnClicked( int );
00141   void    rowClicked( int );
00142 
00143 protected:
00144   void    updateTableFromServant( bool adjust );
00145 
00146 private:
00147   _PTR(Study)            myStudy;
00148   VISU::Table_i*         myTableObj;
00149   _PTR(GenericAttribute) myAttr;
00150   int                    myType;
00151 
00152   QLineEdit*       myTitleEdit;
00153   QTableWidget*    myTable;
00154   QPushButton*     myAddRowBtn;
00155   QPushButton*     myAddColBtn;
00156   QPushButton*     myDelRowBtn;
00157   QPushButton*     myDelColBtn;
00158   QPushButton*     myAdjustBtn;
00159   QPushButton*     mySelectAllBtn;
00160   QPushButton*     myClearBtn;
00161   QLabel*          mySortPolicyLabel;
00162   QComboBox*       mySortPolicyCombo;
00163   Qt::Orientation  myOrientation;
00164 };
00165 
00166 class VISU_I_EXPORT NumDelegateItem: public QItemDelegate
00167 {
00168 public:
00169   enum NumValidator{ NV_Int, NV_Real };
00170 
00171   NumDelegateItem( QObject* parent, NumValidator mode = NV_Int );
00172   virtual ~NumDelegateItem();
00173 
00174   virtual QWidget* createEditor( QWidget* parent,
00175                                  const QStyleOptionViewItem& option,
00176                                  const QModelIndex& index ) const;
00177   virtual void     setEditorData( QWidget* editor,
00178                                   const QModelIndex& index ) const;
00179 private:
00180   int myMode;
00181 };
00182 
00183 #endif // VISU_TABLEDLG_H
00184 
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS