Version: 9.16.0
SalomeApp_ListView.h
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5//
6// This library is free software; you can redistribute it and/or
7// modify it under the terms of the GNU Lesser General Public
8// License as published by the Free Software Foundation; either
9// version 2.1 of the License, or (at your option) any later version.
10//
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// Lesser General Public License for more details.
15//
16// You should have received a copy of the GNU Lesser General Public
17// License along with this library; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19//
20// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21//
22
23// File : SalomeApp_ListView.h
24// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25//
26#ifndef SALOMEAPP_LISTVIEW_H
27#define SALOMEAPP_LISTVIEW_H
28
29//#include <QtxListView.h>
30
31#include <SUIT_PopupClient.h>
32
33#include <QTreeWidget>
34#include <QTreeWidgetItem>
35#include <QString>
36#include <QLineEdit>
37#include <QComboBox>
38
39#include <TColStd_ListOfInteger.hxx>
40#include <TColStd_ListOfReal.hxx>
41
42class QToolButton;
43
44// enumeration for ListView updating mode
46 utCancel = -1, // cancel updating
47 utNone = 0, // needs no any update
48 utUpdateItem, // update one item
49 utUpdateParent, // update parent item too
50 utUpdateViewer, // update all viewer
51 utUpdateAll // strong update
52};
53
56
61class SalomeApp_ListView : public QTreeWidget/*QtxListView*/ , public SUIT_PopupClient {
62
63 Q_OBJECT
64
65public:
66// constructor
68// destructor
69 virtual ~SalomeApp_ListView();
70
71// updates list viewer
72 virtual void updateViewer();
73// updtes currently selected item(s)
74 virtual void updateSelected();
75
76// fills popup with items
77 virtual QString popupClientType() const;
78 virtual void contextMenuPopup( QMenu* );
79
80// setting editing of items availbale/not available
81 void enableEditing(bool theFlag);
82// says if editing is enabled
83 bool isEnableEditing();
84// accepts user input by calling finishEditing(true)
85 void accept();
86
87// clears view
88 void clear();
89
90// event filter
91 bool eventFilter(QObject* object, QEvent* event) ;
92
93// gets current tooltip for list view
94// returns valid rect in success
95 QRect tip(QPoint aPos, QString& aText, QRect& dspRect, QFont& dspFnt) const;
96
97protected:
98// handler for resize event
99 void resizeEvent(QResizeEvent* e);
100// handler for paint event
101 void viewportPaintEvent(QPaintEvent* e);
102// finishes editing of entity
103 virtual UpdateType finishEditing(bool ok);
104
105// returns true if mouse events are enabled
106 bool isMouseEnabled();
107// enables/disables mouse events (excluding MouseMove)
108 void enableMouse(bool enable);
109
110protected slots:
111// called when selection changed in list
112 virtual void onSelectionChanged();
113// called when user finishes in editing of item
114 void onEditOk();
115// called when user cancels item editing
116 void onEditCancel();
117// called when columns sizes are changed
118 void onHeaderSizeChange(int, int, int);
119
120protected:
125};
126
127
129{
130 Q_OBJECT
131
132public:
133 SalomeApp_EditBox(QWidget* parent);
134
135protected:
136 void keyPressEvent(QKeyEvent* e);
137
138signals:
140};
141
143{
144 Q_OBJECT
145
146public:
147 SalomeApp_ComboBox(bool rw, QWidget* parent = 0, const char* name = 0);
148
149 int findItem(const QString& theText);
150 void insertItem(const QString& theValue, int theIndex = -1);
151 void insertList(const QStringList& theList);
152 void insertItem(const int theValue);
153 void insertList(const TColStd_ListOfInteger& theList);
154 void insertItem(const double theValue);
155 void insertList(const TColStd_ListOfReal& theList);
156};
157
159{
160 Q_OBJECT
161
162public:
163 // enum for edit control type
164 enum {
165 etLineEdit, // simple edit box
166 etComboBox, // non-editable combo box
167 etComboEdit // editable combo box
168 };
169 // enum for value type
170 enum {
171 vtString, // string
172 vtInteger, // integer value
173 vtDouble // double value
174 };
175 // enum for insertion order
176 enum {
181 };
182 // enum for edit box buttons (Apply = Cancel)
183 enum {
184 btApply = 0x0001,
185 btCancel = 0x0002
186 };
187
188public:
190 int controlType = etLineEdit,
191 int valueType = vtString,
192 bool butApply = false,
193 bool butCancel = false);
195
197 void clear();
198 QString getText();
199 void setText(const QString& theText );
200 void insertItem( const QString& theValue,
201 bool theSetCurrent = false,
202 int theOrder = atBottom );
203 void insertList( const QStringList& theList,
204 const int theCurrent = -1 );
205 void insertItem( const int theValue,
206 bool theSetCurrent = false );
207 void insertList( const TColStd_ListOfInteger& theList,
208 const int theCurrent = -1 );
209 void insertItem( const double theValue,
210 bool theSetCurrent = false );
211 void insertList( const TColStd_ListOfReal& theList,
212 const int theCurrent = -1 );
214 void setFocus();
215 void setValidator(const QValidator*);
216 void showButtons(bool show);
217 void setDuplicatesEnabled(bool enabled);
218
219protected:
220 void keyPressEvent ( QKeyEvent * e);
221
222private slots:
223 void onComboActivated(const QString&);
224 void onTextChanged(const QString&);
225 void onApply();
226 void onCancel();
227signals:
230
231private:
232 // Widgets
237 QString myString;
238};
239
241{
242public:
247 const QStringList&,
248 const bool = false );
250 const QStringList&,
251 const bool = false );
254 const QString&,
255 const bool = false );
258 const QString&,
259 const bool = false);
262 const QString& theName,
263 const QString& theValue,
264 const bool = false);
267 const QString&,
268 const QString&,
269 const bool = false);
271
272 QString fullName();
273 void openAllLevels();
274 virtual void updateAllLevels();
275 bool isEditable() const;
276 void setEditable(bool theEditable);
277
278 // returns true if entitiy is accepted after editing
279 bool isAccepted() const;
280 // set entity accepted or not after editing
281 void setAccepted(bool theAccepted);
282
283 // returns name of entity (as default it is text in first column)
284 virtual QString getName() const;
285 // sets name of entity (as default it is text in first column)
286 virtual UpdateType setName(const QString& theName);
287
288 // returns value of entity (as default it is text in second column)
289 virtual QString getValue() const;
290 // sets value of entity (as default it is text in second column)
291 virtual UpdateType setValue(const QString& theValue);
292
293 // creates control for editing and fills it with values
295 // fills widget with initial values (list or single value)
296 virtual void fillWidgetWithValues(SalomeApp_EntityEdit* theWidget);
297 // finishes editing of entity
299
300 // returns type of edit control (0 - edit box, 1 - combo box, 2 - editable combo box)
301 virtual int getEditingType();
302 // sets type of edit control (0 - edit box, 1 - combo box, 2 - editable combo box)
303 virtual void setEditingType(const int);
304 // returns edited column
305 virtual int getEditedColumn();
306 // returns type of edited value (string, int, double)
307 virtual int getValueType();
308 // sets type of edited value (string, int, double)
309 virtual void setValueType(const int);
310
311 // gets user type
312 virtual int getUserType();
313 // sets user type
314 virtual void setUserType(const int);
315
316 // returns buttons for editing widget
317 virtual int getButtons();
318 // sets buttons for editing widget
319 virtual void setButtons(const int);
320 // returns text for tooltip
321 QString tipText();
322 // calculates rectangle which should contain items tip
323 QRect tipRect();
324 // calculates rect of item text in viewport coordinates
325 QRect textRect(const int column) const;
326 // calculates full rect of item data in viewport coordinates
327 QRect itemRect(const int column) const;
328
329protected:
330 // initialization
331 void init();
332 int depth() const;
333
334private:
340 int myUserType; // user are welcome to put additional data here and use it in fillWidgetWithValues()
341};
342
343
344#endif
UpdateType
Definition: SalomeApp_ListView.h:45
@ utUpdateViewer
Definition: SalomeApp_ListView.h:50
@ utUpdateAll
Definition: SalomeApp_ListView.h:51
@ utCancel
Definition: SalomeApp_ListView.h:46
@ utUpdateItem
Definition: SalomeApp_ListView.h:48
@ utUpdateParent
Definition: SalomeApp_ListView.h:49
@ utNone
Definition: SalomeApp_ListView.h:47
For more information see QT documentation.
Definition: SUIT_PopupClient.h:37
Definition: SalomeApp_ListView.h:143
void insertList(const QStringList &theList)
Definition: SalomeApp_ListView.cxx:981
void insertItem(const QString &theValue, int theIndex=-1)
Definition: SalomeApp_ListView.cxx:971
int findItem(const QString &theText)
Definition: SalomeApp_ListView.cxx:960
SalomeApp_ComboBox(bool rw, QWidget *parent=0, const char *name=0)
Definition: SalomeApp_ListView.cxx:950
Definition: SalomeApp_ListView.h:129
void keyPressEvent(QKeyEvent *e)
Definition: SalomeApp_ListView.cxx:937
SalomeApp_EditBox(QWidget *parent)
Definition: SalomeApp_ListView.cxx:929
Definition: SalomeApp_ListView.h:159
void showButtons(bool show)
Definition: SalomeApp_ListView.cxx:1383
void keyPressEvent(QKeyEvent *e)
Definition: SalomeApp_ListView.cxx:1326
void setDuplicatesEnabled(bool enabled)
Definition: SalomeApp_ListView.cxx:1394
SalomeApp_EntityEdit(QWidget *parent, int controlType=etLineEdit, int valueType=vtString, bool butApply=false, bool butCancel=false)
Definition: SalomeApp_ListView.cxx:1051
QString getText()
Definition: SalomeApp_ListView.cxx:1160
QToolButton * myApplyBtn
Definition: SalomeApp_ListView.h:235
void setFocus()
Definition: SalomeApp_ListView.cxx:1300
void insertList(const QStringList &theList, const int theCurrent=-1)
Definition: SalomeApp_ListView.cxx:1213
@ atBottom
Definition: SalomeApp_ListView.h:177
@ atAfterCurrent
Definition: SalomeApp_ListView.h:180
@ atBeforeCurrent
Definition: SalomeApp_ListView.h:179
@ atTop
Definition: SalomeApp_ListView.h:178
void onApply()
Definition: SalomeApp_ListView.cxx:1370
QToolButton * myCancelBtn
Definition: SalomeApp_ListView.h:236
QString myString
Definition: SalomeApp_ListView.h:237
void onTextChanged(const QString &)
Definition: SalomeApp_ListView.cxx:1346
void onCancel()
Definition: SalomeApp_ListView.cxx:1357
void insertItem(const QString &theValue, bool theSetCurrent=false, int theOrder=atBottom)
Definition: SalomeApp_ListView.cxx:1190
SalomeApp_ComboBox * myCombo
Definition: SalomeApp_ListView.h:234
void setText(const QString &theText)
Definition: SalomeApp_ListView.cxx:1173
QWidget * getControl()
Definition: SalomeApp_ListView.cxx:1287
@ btCancel
Definition: SalomeApp_ListView.h:185
@ btApply
Definition: SalomeApp_ListView.h:184
void clear()
Definition: SalomeApp_ListView.cxx:1149
SalomeApp_EditBox * myEdit
Definition: SalomeApp_ListView.h:233
void setValidator(const QValidator *)
Definition: SalomeApp_ListView.cxx:1315
~SalomeApp_EntityEdit()
Definition: SalomeApp_ListView.cxx:1142
@ vtInteger
Definition: SalomeApp_ListView.h:172
@ vtDouble
Definition: SalomeApp_ListView.h:173
@ vtString
Definition: SalomeApp_ListView.h:171
void onComboActivated(const QString &)
Definition: SalomeApp_ListView.cxx:1338
@ etLineEdit
Definition: SalomeApp_ListView.h:165
@ etComboEdit
Definition: SalomeApp_ListView.h:167
@ etComboBox
Definition: SalomeApp_ListView.h:166
Definition: SalomeApp_ListView.h:241
void openAllLevels()
Definition: SalomeApp_ListView.cxx:617
virtual void updateAllLevels()
Definition: SalomeApp_ListView.cxx:632
virtual void setEditingType(const int)
Definition: SalomeApp_ListView.cxx:692
QRect itemRect(const int column) const
Definition: SalomeApp_ListView.cxx:895
QRect textRect(const int column) const
Definition: SalomeApp_ListView.cxx:858
virtual void setValueType(const int)
Definition: SalomeApp_ListView.cxx:717
virtual QString getValue() const
Definition: SalomeApp_ListView.cxx:582
~SalomeApp_ListViewItem()
Definition: SalomeApp_ListView.cxx:527
virtual void setUserType(const int)
Definition: SalomeApp_ListView.cxx:733
int myEditingType
Definition: SalomeApp_ListView.h:337
virtual int getValueType()
Definition: SalomeApp_ListView.cxx:709
SalomeApp_EntityEdit * startEditing()
Definition: SalomeApp_ListView.cxx:758
virtual int getEditedColumn()
Definition: SalomeApp_ListView.cxx:700
int myUserType
Definition: SalomeApp_ListView.h:340
virtual UpdateType setValue(const QString &theValue)
Definition: SalomeApp_ListView.cxx:590
int depth() const
Definition: SalomeApp_ListView.cxx:547
bool myEditable
Definition: SalomeApp_ListView.h:335
virtual int getEditingType()
Definition: SalomeApp_ListView.cxx:681
virtual QString getName() const
Definition: SalomeApp_ListView.cxx:561
virtual UpdateType setName(const QString &theName)
Definition: SalomeApp_ListView.cxx:569
bool isAccepted() const
Definition: SalomeApp_ListView.cxx:662
void setAccepted(bool theAccepted)
Definition: SalomeApp_ListView.cxx:670
virtual UpdateType finishEditing(SalomeApp_EntityEdit *theWidget)
Definition: SalomeApp_ListView.cxx:796
QRect tipRect()
Definition: SalomeApp_ListView.cxx:823
void init()
Definition: SalomeApp_ListView.cxx:534
QString fullName()
Definition: SalomeApp_ListView.cxx:603
void setEditable(bool theEditable)
Definition: SalomeApp_ListView.cxx:654
virtual void setButtons(const int)
Definition: SalomeApp_ListView.cxx:750
QString tipText()
Definition: SalomeApp_ListView.cxx:847
bool isEditable() const
Definition: SalomeApp_ListView.cxx:646
bool myAccepted
Definition: SalomeApp_ListView.h:336
int myValueType
Definition: SalomeApp_ListView.h:338
SalomeApp_ListViewItem(SalomeApp_ListView *)
Definition: SalomeApp_ListView.cxx:424
int myButtons
Definition: SalomeApp_ListView.h:339
virtual int getButtons()
Definition: SalomeApp_ListView.cxx:742
virtual int getUserType()
Definition: SalomeApp_ListView.cxx:725
virtual void fillWidgetWithValues(SalomeApp_EntityEdit *theWidget)
Definition: SalomeApp_ListView.cxx:786
Definition: SalomeApp_ListView.h:61
bool isEnableEditing()
Definition: SalomeApp_ListView.cxx:225
QRect tip(QPoint aPos, QString &aText, QRect &dspRect, QFont &dspFnt) const
Definition: SalomeApp_ListView.cxx:390
virtual QString popupClientType() const
Definition: SalomeApp_ListView.cxx:148
virtual void onSelectionChanged()
Definition: SalomeApp_ListView.cxx:241
bool myEditingEnabled
Definition: SalomeApp_ListView.h:123
bool eventFilter(QObject *object, QEvent *event)
Definition: SalomeApp_ListView.cxx:195
void enableMouse(bool enable)
Definition: SalomeApp_ListView.cxx:187
virtual void updateSelected()
Definition: SalomeApp_ListView.cxx:132
void onEditOk()
Definition: SalomeApp_ListView.cxx:309
void enableEditing(bool theFlag)
Definition: SalomeApp_ListView.cxx:210
bool isMouseEnabled()
Definition: SalomeApp_ListView.cxx:179
bool myMouseEnabled
Definition: SalomeApp_ListView.h:124
void accept()
Definition: SalomeApp_ListView.cxx:233
virtual void updateViewer()
Definition: SalomeApp_ListView.cxx:115
void onHeaderSizeChange(int, int, int)
Definition: SalomeApp_ListView.cxx:287
SalomeApp_EntityEdit * myEdit
Definition: SalomeApp_ListView.h:121
virtual UpdateType finishEditing(bool ok)
Definition: SalomeApp_ListView.cxx:325
SalomeApp_ListViewItem * myEditedItem
Definition: SalomeApp_ListView.h:122
void viewportPaintEvent(QPaintEvent *e)
Definition: SalomeApp_ListView.cxx:298
virtual ~SalomeApp_ListView()
Definition: SalomeApp_ListView.cxx:103
virtual void contextMenuPopup(QMenu *)
Definition: SalomeApp_ListView.cxx:156
void onEditCancel()
Definition: SalomeApp_ListView.cxx:317
void clear()
Definition: SalomeApp_ListView.cxx:166
void resizeEvent(QResizeEvent *e)
Definition: SalomeApp_ListView.cxx:274
SalomeApp_ListView(QWidget *parent)
Definition: SalomeApp_ListView.cxx:78