src/GUITOOLS/VisuGUI_TableDlg.h

Go to the documentation of this file.
00001 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00002 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
00003 // 
00004 //  This library is free software; you can redistribute it and/or 
00005 //  modify it under the terms of the GNU Lesser General Public 
00006 //  License as published by the Free Software Foundation; either 
00007 //  version 2.1 of the License. 
00008 // 
00009 //  This library is distributed in the hope that it will be useful, 
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00012 //  Lesser General Public License for more details. 
00013 // 
00014 //  You should have received a copy of the GNU Lesser General Public 
00015 //  License along with this library; if not, write to the Free Software 
00016 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
00017 // 
00018 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00019 //
00020 //  File   : VisuGUI_TableDlg.h
00021 //  Author : Vadim SANDLER
00022 //  Module : VISU
00023 
00024 #ifndef VisuGUI_TABLE_DLG_H
00025 #define VisuGUI_TABLE_DLG_H
00026 
00027 #include <qdialog.h>
00028 #include <qlineedit.h>
00029 #include <qpushbutton.h>
00030 
00031 class VisuGUI_Table;
00032 class VisuGUI_TableWidget;
00033 
00034 #include <SALOMEDSClient_SObject.hxx>
00035 
00036 class VisuGUI_TableDlg : public QDialog
00037 { 
00038   Q_OBJECT
00039 
00040 public:
00041 
00042   enum { ttNone, ttInt, ttReal, ttBoth, ttAuto };
00043 
00044   VisuGUI_TableDlg( QWidget* parent, 
00045               _PTR(SObject) obj, 
00046               bool edit = false,
00047               int which = ttAuto, 
00048               Orientation orient = Horizontal,
00049               bool showColumnTitles = true );
00050   ~VisuGUI_TableDlg();
00051 
00052 private:
00053   void keyPressEvent( QKeyEvent* e );
00054 
00055 public slots:
00056   void onOK();
00057   void onHelp(); 
00058 
00059 private:
00060   void initDlg();
00061 
00062 private:
00063   VisuGUI_TableWidget*   myIntTable;
00064   VisuGUI_TableWidget*   myRealTable;
00065   QPushButton*           myOKBtn;
00066   QPushButton*           myCancelBtn;
00067   QPushButton*           myHelpBtn;
00068 
00069   _PTR(SObject) myObject;
00070 };
00071  
00072 class VisuGUI_TableWidget : public QWidget
00073 {
00074   Q_OBJECT
00075 public:
00076   VisuGUI_TableWidget( QWidget* parent = 0, 
00077                  const char* name = 0, 
00078                  bool edit = false, 
00079                  Orientation orient = Horizontal,
00080                  bool showColumnTitles = true );
00081   ~VisuGUI_TableWidget();
00082 
00083   void    setTableTitle( const QString& title );
00084   QString getTableTitle();
00085   void    setNumRows( const int num );
00086   int     getNumRows();
00087   void    setNumCols( const int num );
00088   int     getNumCols();
00089   void    setRowTitles( QStringList& tlts );
00090   void    getRowTitles( QStringList& tlts );
00091   void    setColTitles( QStringList& tlts );
00092   void    getColTitles( QStringList& tlts );
00093   void    setUnitsTitle( const QString& tlt );
00094   void    setUnits( QStringList& units );
00095   void    getUnits( QStringList& units );
00096   void    setRowData( int row, QStringList& data );
00097   void    getRowData( int row, QStringList& data );
00098 
00099   VisuGUI_Table*   getTable()     { return myTable; } 
00100   QLineEdit*       getTitleEdit() { return myTitleEdit; }
00101 
00102   bool    eventFilter( QObject* o, QEvent* e);
00103 
00104 public slots:
00105   void updateButtonsState();
00106   void addRow();
00107   void addCol();
00108   void delRow();
00109   void delCol();
00110   void adjustTable();
00111   void selectAll();
00112   void clearTable();
00113 
00114 private:
00115   QLineEdit*       myTitleEdit;
00116   VisuGUI_Table*   myTable;
00117   QPushButton*     myAddRowBtn;
00118   QPushButton*     myAddColBtn;
00119   QPushButton*     myDelRowBtn;
00120   QPushButton*     myDelColBtn;
00121   QPushButton*     myAdjustBtn;
00122   QPushButton*     mySelectAllBtn;
00123   QPushButton*     myClearBtn;
00124   Orientation      myOrientation;
00125 };
00126 
00127 #endif // VisuGUI_TABLE_DLG_H
00128