00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef SALOMEAPP_LISTVIEW_H
00027 #define SALOMEAPP_LISTVIEW_H
00028
00029
00030
00031 #include <SUIT_PopupClient.h>
00032
00033 #include <QTreeWidget>
00034 #include <QTreeWidgetItem>
00035 #include <QString>
00036 #include <QLineEdit>
00037 #include <QComboBox>
00038
00039 class QToolButton;
00040
00041 class TColStd_ListOfInteger;
00042 class TColStd_ListOfReal;
00043
00044
00045 enum UpdateType {
00046 utCancel = -1,
00047 utNone = 0,
00048 utUpdateItem,
00049 utUpdateParent,
00050 utUpdateViewer,
00051 utUpdateAll
00052 };
00053
00054 class SalomeApp_ListViewItem;
00055 class SalomeApp_EntityEdit;
00056
00061 class SalomeApp_ListView : public QTreeWidget , public SUIT_PopupClient {
00062
00063 Q_OBJECT
00064
00065 public:
00066
00067 SalomeApp_ListView(QWidget *parent);
00068
00069 virtual ~SalomeApp_ListView();
00070
00071
00072 virtual void updateViewer();
00073
00074 virtual void updateSelected();
00075
00076
00077 virtual QString popupClientType() const;
00078 virtual void contextMenuPopup( QMenu* );
00079
00080
00081 void enableEditing(bool theFlag);
00082
00083 bool isEnableEditing();
00084
00085 void accept();
00086
00087
00088 void clear();
00089
00090
00091 bool eventFilter(QObject* object, QEvent* event) ;
00092
00093
00094
00095 QRect tip(QPoint aPos, QString& aText, QRect& dspRect, QFont& dspFnt) const;
00096
00097 protected:
00098
00099 void resizeEvent(QResizeEvent* e);
00100
00101 void viewportPaintEvent(QPaintEvent* e);
00102
00103 virtual UpdateType finishEditing(bool ok);
00104
00105
00106 bool isMouseEnabled();
00107
00108 void enableMouse(bool enable);
00109
00110 protected slots:
00111
00112 virtual void onSelectionChanged();
00113
00114 void onEditOk();
00115
00116 void onEditCancel();
00117
00118 void onHeaderSizeChange(int, int, int);
00119
00120 protected:
00121 SalomeApp_EntityEdit* myEdit;
00122 SalomeApp_ListViewItem* myEditedItem;
00123 bool myEditingEnabled;
00124 bool myMouseEnabled;
00125 };
00126
00127
00128 class SalomeApp_EditBox: public QLineEdit
00129 {
00130 Q_OBJECT
00131
00132 public:
00133 SalomeApp_EditBox(QWidget* parent);
00134
00135 protected:
00136 void keyPressEvent(QKeyEvent* e);
00137
00138 signals:
00139 void escapePressed();
00140 };
00141
00142 class SalomeApp_ComboBox: public QComboBox
00143 {
00144 Q_OBJECT
00145
00146 public:
00147 SalomeApp_ComboBox(bool rw, QWidget* parent = 0, const char* name = 0);
00148
00149 int findItem(const QString& theText);
00150 void insertItem(const QString& theValue, int theIndex = -1);
00151 void insertList(const QStringList& theList);
00152 void insertItem(const int theValue);
00153 void insertList(const TColStd_ListOfInteger& theList);
00154 void insertItem(const double theValue);
00155 void insertList(const TColStd_ListOfReal& theList);
00156 };
00157
00158 class SalomeApp_EntityEdit : public QWidget
00159 {
00160 Q_OBJECT
00161
00162 public:
00163
00164 enum {
00165 etLineEdit,
00166 etComboBox,
00167 etComboEdit
00168 };
00169
00170 enum {
00171 vtString,
00172 vtInteger,
00173 vtDouble
00174 };
00175
00176 enum {
00177 atBottom,
00178 atTop,
00179 atBeforeCurrent,
00180 atAfterCurrent
00181 };
00182
00183 enum {
00184 btApply = 0x0001,
00185 btCancel = 0x0002
00186 };
00187
00188 public:
00189 SalomeApp_EntityEdit( QWidget* parent,
00190 int controlType = etLineEdit,
00191 int valueType = vtString,
00192 bool butApply = false,
00193 bool butCancel = false);
00194 ~SalomeApp_EntityEdit();
00195
00196 void finishEditing();
00197 void clear();
00198 QString getText();
00199 void setText(const QString& theText );
00200 void insertItem( const QString& theValue,
00201 bool theSetCurrent = false,
00202 int theOrder = atBottom );
00203 void insertList( const QStringList& theList,
00204 const int theCurrent = -1 );
00205 void insertItem( const int theValue,
00206 bool theSetCurrent = false );
00207 void insertList( const TColStd_ListOfInteger& theList,
00208 const int theCurrent = -1 );
00209 void insertItem( const double theValue,
00210 bool theSetCurrent = false );
00211 void insertList( const TColStd_ListOfReal& theList,
00212 const int theCurrent = -1 );
00213 QWidget* getControl();
00214 void setFocus();
00215 void setValidator(const QValidator*);
00216 void showButtons(bool show);
00217 void setDuplicatesEnabled(bool enabled);
00218
00219 protected:
00220 void keyPressEvent ( QKeyEvent * e);
00221
00222 private slots:
00223 void onComboActivated(const QString&);
00224 void onTextChanged(const QString&);
00225 void onApply();
00226 void onCancel();
00227 signals:
00228 void returnPressed();
00229 void escapePressed();
00230
00231 private:
00232
00233 SalomeApp_EditBox* myEdit;
00234 SalomeApp_ComboBox* myCombo;
00235 QToolButton* myApplyBtn;
00236 QToolButton* myCancelBtn;
00237 QString myString;
00238 };
00239
00240 class SalomeApp_ListViewItem : public QTreeWidgetItem
00241 {
00242 public:
00243 SalomeApp_ListViewItem( SalomeApp_ListView* );
00244 SalomeApp_ListViewItem( SalomeApp_ListView*,
00245 SalomeApp_ListViewItem* );
00246 SalomeApp_ListViewItem( SalomeApp_ListView*,
00247 const QStringList&,
00248 const bool = false );
00249 SalomeApp_ListViewItem( SalomeApp_ListViewItem*,
00250 const QStringList&,
00251 const bool = false );
00252 SalomeApp_ListViewItem( SalomeApp_ListView*,
00253 SalomeApp_ListViewItem*,
00254 const QString&,
00255 const bool = false );
00256 SalomeApp_ListViewItem( SalomeApp_ListViewItem*,
00257 SalomeApp_ListViewItem*,
00258 const QString&,
00259 const bool = false);
00260 SalomeApp_ListViewItem( SalomeApp_ListView*,
00261 SalomeApp_ListViewItem*,
00262 const QString& theName,
00263 const QString& theValue,
00264 const bool = false);
00265 SalomeApp_ListViewItem( SalomeApp_ListViewItem*,
00266 SalomeApp_ListViewItem*,
00267 const QString&,
00268 const QString&,
00269 const bool = false);
00270 ~SalomeApp_ListViewItem();
00271
00272 QString fullName();
00273 void openAllLevels();
00274 virtual void updateAllLevels();
00275 bool isEditable() const;
00276 void setEditable(bool theEditable);
00277
00278
00279 bool isAccepted() const;
00280
00281 void setAccepted(bool theAccepted);
00282
00283
00284 virtual QString getName() const;
00285
00286 virtual UpdateType setName(const QString& theName);
00287
00288
00289 virtual QString getValue() const;
00290
00291 virtual UpdateType setValue(const QString& theValue);
00292
00293
00294 SalomeApp_EntityEdit* startEditing();
00295
00296 virtual void fillWidgetWithValues(SalomeApp_EntityEdit* theWidget);
00297
00298 virtual UpdateType finishEditing(SalomeApp_EntityEdit* theWidget);
00299
00300
00301 virtual int getEditingType();
00302
00303 virtual void setEditingType(const int);
00304
00305 virtual int getEditedColumn();
00306
00307 virtual int getValueType();
00308
00309 virtual void setValueType(const int);
00310
00311
00312 virtual int getUserType();
00313
00314 virtual void setUserType(const int);
00315
00316
00317 virtual int getButtons();
00318
00319 virtual void setButtons(const int);
00320
00321 QString tipText();
00322
00323 QRect tipRect();
00324
00325 QRect textRect(const int column) const;
00326
00327 QRect itemRect(const int column) const;
00328
00329 protected:
00330
00331 void init();
00332 int depth() const;
00333
00334 private:
00335 bool myEditable;
00336 bool myAccepted;
00337 int myEditingType;
00338 int myValueType;
00339 int myButtons;
00340 int myUserType;
00341 };
00342
00343
00344 #endif