Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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