1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : VISU_TableDlg.h
21 // Author : Vadim SANDLER
24 #ifndef VISU_TABLEDLG_H
25 #define VISU_TABLEDLG_H
29 #include <SALOMEDSClient_Study.hxx>
32 #include <QItemDelegate>
47 class VISU_I_EXPORT VISU_TableDlg : public QDialog
52 class WidgetCointainer;
54 enum { tcTitle, tcTable, tcControls, tcButtons };
58 enum { ttNone, ttInt, ttReal, ttAll, ttAuto };
63 teAll = teAddRemove | teEditData | teRowColumn
66 VISU_TableDlg( QWidget* parent,
69 bool allowEdition = false,
71 Qt::Orientation orient = Qt::Horizontal,
72 bool showColumnTitles = true );
76 void keyPressEvent( QKeyEvent* e );
82 QString tableTitle( int type );
85 typedef QMap<int, TableWidget*> TableMap;
86 typedef QMap<int, WidgetCointainer*> ContMap;
90 QCheckBox* myEditCheck;
91 QCheckBox* myUpdateCheck;
93 QPushButton* myHelpBtn;
96 VISU::Table_i* myTable;
99 class VISU_I_EXPORT VISU_TableDlg::TableWidget : public QWidget
104 TableWidget( QWidget* parent = 0, Qt::Orientation orientation = Qt::Horizontal );
107 void initialize( _PTR(Study) study, VISU::Table_i* table, int type );
109 void setTableTitle( const QString& title );
110 QString getTableTitle();
111 void setNumRows( const int num );
113 void setNumCols( const int num );
115 void setRowTitles( QStringList& tlts );
116 void getRowTitles( QStringList& tlts );
117 void setColTitles( QStringList& tlts );
118 void getColTitles( QStringList& tlts );
119 void setUnitsTitle( const QString& tlt );
120 void setUnits( QStringList& units );
121 void getUnits( QStringList& units );
122 void setRowData( int row, QStringList& data );
123 void getRowData( int row, QStringList& data );
125 bool eventFilter( QObject* o, QEvent* e);
128 void setEditEnabled( bool enable );
129 void showColumnTitles( bool showTitles );
131 void updateButtonsState();
140 void columnClicked( int );
141 void rowClicked( int );
144 void updateTableFromServant( bool adjust );
148 VISU::Table_i* myTableObj;
149 _PTR(GenericAttribute) myAttr;
152 QLineEdit* myTitleEdit;
153 QTableWidget* myTable;
154 QPushButton* myAddRowBtn;
155 QPushButton* myAddColBtn;
156 QPushButton* myDelRowBtn;
157 QPushButton* myDelColBtn;
158 QPushButton* myAdjustBtn;
159 QPushButton* mySelectAllBtn;
160 QPushButton* myClearBtn;
161 QLabel* mySortPolicyLabel;
162 QComboBox* mySortPolicyCombo;
163 Qt::Orientation myOrientation;
166 class VISU_I_EXPORT NumDelegateItem: public QItemDelegate
169 enum NumValidator{ NV_Int, NV_Real };
171 NumDelegateItem( QObject* parent, NumValidator mode = NV_Int );
172 virtual ~NumDelegateItem();
174 virtual QWidget* createEditor( QWidget* parent,
175 const QStyleOptionViewItem& option,
176 const QModelIndex& index ) const;
177 virtual void setEditorData( QWidget* editor,
178 const QModelIndex& index ) const;
183 #endif // VISU_TABLEDLG_H