OpendTect-6_4  6.4
uitreeview.h
Go to the documentation of this file.
1 #ifndef uitreeview_h
2 #define uitreeview_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H. Lammertink
9  Date: 29/01/2002
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "uibasemod.h"
16 #include "uiobj.h"
17 #include "bufstringset.h"
18 #include "keyenum.h"
19 #include "draw.h"
20 #include "uistring.h"
21 
22 mFDQtclass(QTreeWidget)
23 mFDQtclass(QTreeWidgetItem)
24 mFDQtclass(QTreeWidgetItemIterator)
25 mFDQtclass(QString)
26 mFDQtclass(QStringList)
27 
28 class uiPixmap;
29 class uiTreeViewBody;
30 class uiTreeViewItem;
31 namespace ColTab { class Sequence; }
32 
33 mExpClass(uiBase) uiTreeView : public uiObject
35 public:
36  uiTreeView(uiParent* parnt,
37  const char* nm="uiTreeView",
38  int preferredNrLines=0,
39  bool rootdecorated=true);
40  virtual ~uiTreeView();
41 
42  void setEmpty();
43  void setNrLines(int);
44 
45  bool rootDecorated() const;
46  void setRootDecorated(bool yn);
47  void showHeader(bool yn); // default is true
48 
49  void addColumns(const uiStringSet&);
50  void addColumns(const BufferStringSet&);
51  void setNrColumns(int); // when columns have no name
52  int nrColumns() const;
53 
54  void removeColumn(int index);
55  void setColumnText(int column,const uiString& label);
56  uiString getColumnText(int column) const;
57  void setColumnWidth(int column,int width);
58  void setFixedColumnWidth(int column,int width);
59  int columnWidth(int column) const;
60 
61  enum WidthMode { Manual, Fixed, Stretch, ResizeToContents,
62  Custom };
63  void setColumnWidthMode(WidthMode);
64  void setColumnWidthMode(int column,WidthMode);
65  WidthMode columnWidthMode(int column) const;
66 
67  void setColumnAlignment(Alignment::HPos);
68  void setColumnAlignment(int,Alignment::HPos);
69  Alignment::HPos columnAlignment(int) const;
70 
71  enum ScrollMode { Auto, AlwaysOff, AlwaysOn };
72  void setHScrollBarMode(ScrollMode);
73  void setVScrollBarMode(ScrollMode);
74 
76  { NoSelection=0, Single, Multi, Extended, Contiguous };
78  { SelectItems, SelectRows, SelectColumns };
79  void setSelectionMode(SelectionMode);
80  SelectionMode selectionMode() const;
81  void setSelectionBehavior(SelectionBehavior);
82  SelectionBehavior selectionBehavior() const;
83 
84  void clearSelection();
85  void setSelected(uiTreeViewItem*,bool);
86  bool isSelected(const uiTreeViewItem*) const;
87  uiTreeViewItem* selectedItem() const;
88  int nrSelected() const;
89  void getSelectedItems(ObjectSet<uiTreeViewItem>&) const;
90  void removeSelectedItems();
91 
92  int nrItems() const;
93  void setCurrentItem(uiTreeViewItem*,int column=0);
94  uiTreeViewItem* currentItem() const;
95  int currentColumn() const;
96  int indexOfItem(uiTreeViewItem*) const;
97  uiTreeViewItem* getItem(int) const;
98  uiTreeViewItem* firstItem() const;
99  uiTreeViewItem* lastItem() const;
100  uiTreeViewItem* findItem(const char*,int,bool) const;
101 
102  void setItemMargin(int);
103  int itemMargin() const;
104 
105  void setShowToolTips(bool);
106  bool showToolTips() const;
107 
108  void clear();
109  void selectAll();
110  void deselectAll(); // added for compatibility only
111  void checkAll();
112  void uncheckAll();
113 
114  void expandAll();
115  void collapseAll();
116  void expandTo(int treedepth);
117  void ensureItemVisible(const uiTreeViewItem*);
118 
119  // For MOVING an item to another point in the tree
120  void takeItem(uiTreeViewItem*);
121  void insertItem(int,uiTreeViewItem*);
122 
123  uiParent* parent() { return parent_; }
124  void translateText();
125  bool handleLongTabletPress();
126 
128  void triggerUpdate();
129 
131  uiTreeViewItem* itemNotified() { return lastitemnotified_; }
132  int columnNotified() { return column_; }
133  void unNotify() { lastitemnotified_ = 0; }
134 
135  void setNotifiedItem(mQtclass(QTreeWidgetItem*));
136  void setNotifiedColumn(int col) { column_ = col; }
137 
154 
155 protected:
156 
160  int column_;
162  bool allowDoubleClick() const;
163  // Checks clicked mouseposition
164 
165  void cursorSelectionChanged(CallBacker*);
166  void itemChangedCB(CallBacker*);
167  void updateCheckStatus(uiTreeViewItem*);
168 
169  uiTreeViewBody* lvbody() { return body_; }
170  const uiTreeViewBody* lvbody() const { return body_; }
171 
172  void updateHeaderLabels();
173 
174 private:
175 
176 
177  friend class i_treeVwMessenger;
178  friend class uiTreeViewBody;
179  friend class uiTreeViewItem;
181 
182  uiTreeViewBody* body_;
183 
185 
186  // 0: use nr itms in tree
187  uiTreeViewBody& mkbody(uiParent*,const char*,int);
188 
189 public:
190 
191  const char* columnText(int column) const;
192  //Commandline driver usage only
193 
194 };
195 
196 
203 public:
204  friend class uiTreeView;
205 
206  enum Type { Standard, CheckBox };
207 
208  mExpClass(uiBase) Setup
209  { mODTextTranslationClass(Setup);
210  public:
214  bool setchecked=true )
215  : type_(tp)
216  , after_(0)
217  , setcheck_(setchecked)
218  { label( txt ); }
219 
222  mDefSetupMemb(BufferString,iconname)
223  mDefSetupMemb(bool,setcheck)
225 
226  Setup& label( const uiString& txt )
227  {
228  if ( !txt.isEmpty() )
229  labels_ += txt;
230  return *this;
231  }
232  };
233 
235  uiTreeViewItem(uiTreeView* parent,const Setup&);
236  virtual ~uiTreeViewItem();
237 
238  mQtclass(QTreeWidgetItem*) qItem() { return qtreeitem_; }
239  const mQtclass(QTreeWidgetItem*) qItem() const { return qtreeitem_; }
240 
241  int nrChildren() const;
242 
243  void setBGColor(int column,const Color&);
244 
245  void edit(int col);
246 
247  void setCheckable(bool);
248  bool isCheckable() const;
249  bool isChecked(bool qtstatus=true) const;
251  void setChecked(bool,bool trigger=false);
253  void checkAll(bool yn,bool trigger=false);
254 
255  void setToolTip(int column,const uiString&);
256 
257  void translateText();
258 
259  static void updateToolTips();
260 
261  void insertItem(int,uiTreeViewItem*);
262  void takeItem(uiTreeViewItem*);
263  void removeItem(uiTreeViewItem*);
264  void moveItem(uiTreeViewItem* after);
265  int siblingIndex() const;
268  void setText( const uiString&,
269  int column=0 );
270  void setText( int i, int column=0 )
271  { setText( toUiString(i), column ); }
272  void setText( float f, int column=0 )
273  { setText( toUiString(f), column ); }
274  void setText( double d, int column=0 )
275  { setText( toUiString(d), column ); }
276 
277  const char* text(int column=0) const;
278 
279  void setIcon(int column,const char* iconname);
280  void setPixmap(int column,const uiPixmap&);
281  void setPixmap(int column,const Color&,
282  int width=16,int height=10);
283  void setPixmap(int column,const ColTab::Sequence&,
284  int width=16,int height=10);
285 
286  virtual const char* key(int,bool) const { return 0; }
287  virtual int compare( uiTreeViewItem*,int column,bool) const
288  { return mUdf(int); }
289 
290  void setOpen(bool yn=true);
291  bool isOpen() const;
292 
293  void setSelected(bool yn);
294  bool isSelected() const;
295 
296  uiTreeViewItem* getChild(int) const;
297  uiTreeViewItem* firstChild() const;
298  uiTreeViewItem* lastChild() const;
299  uiTreeViewItem* nextSibling() const;
300  uiTreeViewItem* prevSibling() const;
301  uiTreeViewItem* parent() const;
302 
303  uiTreeViewItem* itemAbove();
304  uiTreeViewItem* itemBelow();
305 
306  uiTreeView* treeView() const;
307 
308  void setSelectable(bool yn);
309  bool isSelectable() const;
310 
311  void setDragEnabled(bool);
312  void setDropEnabled(bool);
313  bool dragEnabled() const;
314  bool dropEnabled() const;
315 
316  void setVisible(bool yn);
317  bool isVisible() const;
318 
319  void setRenameEnabled(int column,bool);
320  bool renameEnabled(int column) const;
321 
322  void setEnabled(bool);
323  bool isEnabled() const;
324 
325 
330 
331  static mQtclass(QTreeWidgetItem*) qitemFor(uiTreeViewItem*);
332  static const mQtclass(QTreeWidgetItem*) qitemFor(const uiTreeViewItem*);
333 
334  static uiTreeViewItem* itemFor(mQtclass(QTreeWidgetItem*));
335  static const uiTreeViewItem* itemFor(const mQtclass(QTreeWidgetItem*));
336 
337 protected:
338 
339  mQtclass(QTreeWidgetItem*) qtreeitem_;
340 
341  void init(const Setup&);
342  void updateFlags();
343  bool updateToolTip(int column);
344 
345  uiStringSet texts_;
346  uiStringSet tooltips_;
347 
348  bool isselectable_;
349  bool iseditable_;
350  bool isdragenabled_;
351  bool isdropenabled_;
352  bool ischeckable_;
353  bool isenabled_;
354  bool checked_;
355 };
356 
357 
358 mExpClass(uiBase) uiTreeViewItemIterator : public CallBacker
359 {
360 public:
363 
364  uiTreeViewItem* next();
365 
366 protected:
368 
369 private:
370  mQtclass(QTreeWidgetItemIterator*) iter_;
371 };
372 
373 #endif
#define mExpClass(module)
Definition: commondefs.h:160
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
SelectionMode
Definition: uitreeview.h:75
uiTreeView & view_
Definition: uitreeview.h:367
static void updateToolTips()
#define mQtclass(cls)
Definition: commondefs.h:229
virtual int height() const
Actual size in pixels.
uiTreeViewItem * itemNotified()
item last notified. See notifiers below
Definition: uitreeview.h:131
Notifier< uiTreeView > expanded
Definition: uitreeview.h:151
mQtclass(QTreeWidgetItem *) qItem()
Definition: uitreeview.h:238
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
Export_Basic uiString toUiString(ViewStyle)
Maps from [0,1] -> Color.
Definition: coltabsequence.h:37
void setToolTip(const uiString &)
Notifier< uiTreeView > leftButtonClicked
Definition: uitreeview.h:145
Notifier< uiTreeViewItem > keyPressed
Definition: uitreeview.h:327
uiTreeViewBody * body_
Definition: uitreeview.h:182
void setText(float f, int column=0)
Definition: uitreeview.h:272
Notifier< uiTreeView > itemRenamed
Definition: uitreeview.h:141
Definition: uitreeview.h:358
bool init()
void updateToolTip(CallBacker *=0)
SelectionBehavior
Definition: uitreeview.h:77
Notifier< uiTreeView > returnPressed
Definition: uitreeview.h:142
Notifier< uiTreeView > collapsed
Definition: uitreeview.h:152
uiParent * parent()
Definition: uitreeview.h:123
void checkAll()
void clear(std::ios &)
uiTreeViewBody * lvbody()
Definition: uitreeview.h:169
static const uiString & emptyString()
Definition: uistring.h:109
Notifier< uiTreeView > mouseButtonClicked
Definition: uitreeview.h:148
The base class for most UI elements.
Definition: uiobj.h:38
uiStringSet labels_
Definition: uitreeview.h:184
Definition: uistring.h:89
Definition: uiparent.h:26
Set of BufferString objects.
Definition: bufstringset.h:28
Definition: uitreeview.h:78
Definition: uitreeview.h:206
Notifier< uiTreeView > contextMenuRequested
Definition: uitreeview.h:149
Notifier< uiTreeView > leftButtonPressed
Definition: uitreeview.h:146
bool isSelected(const uiTreeViewItem *) const
void setText(double d, int column=0)
Definition: uitreeview.h:274
OD::ButtonState buttonstate_
Definition: uitreeview.h:161
void translateText()
Definition: uitreeview.h:201
ButtonState
Definition: keyenum.h:20
virtual int compare(uiTreeViewItem *, int column, bool) const
Definition: uitreeview.h:287
Notifier< uiTreeView > mouseButtonPressed
Definition: uitreeview.h:147
void setText(int i, int column=0)
Definition: uitreeview.h:270
friend class uiTreeViewItem
Definition: uitreeview.h:179
Notifier< uiTreeView > itemChanged
Definition: uitreeview.h:140
Notifier< uiTreeViewItem > stateChanged
only works for CheckBox type
Definition: uitreeview.h:326
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:272
void setSelected(uiTreeViewItem *, bool)
Notifier< uiTreeView > doubleClicked
Definition: uitreeview.h:150
BufferString rettxt
Definition: uitreeview.h:157
HPos
Definition: draw.h:26
void takeItem(uiTreeViewItem *)
void insertItem(int, uiTreeViewItem *)
Notifier< uiTreeView > rightButtonClicked
Definition: uitreeview.h:143
#define mDefSetupMemb(typ, memb)
Definition: commondefs.h:137
Definition: uitreeview.h:33
Off-screen pixel-based paint device.
Definition: uipixmap.h:34
virtual int width() const
Actual size in pixels.
uiParent * parent_
Definition: uitreeview.h:159
uiTreeViewItem * lastitemnotified_
Definition: uitreeview.h:158
Notifier< uiTreeView > currentChanged
Definition: uitreeview.h:139
friend class uiTreeViewItemIterator
Definition: uitreeview.h:180
Definition: uitreeview.h:76
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
virtual const char * key(int, bool) const
Definition: uitreeview.h:286
brief Helper class for uiTreeView to relay Qt&#39;s messages.
Definition: i_qtreeview.h:28
const mQtclass(QTreeWidgetItem *) qItem() const
Definition: uitreeview.h:239
int columnNotified()
Definition: uitreeview.h:132
mFDQtclass(QTreeWidget) mFDQtclass(QTreeWidgetItem) mFDQtclass(QTreeWidgetItemIterator) mFDQtclass(QString) mFDQtclass(QStringList) class uiPixmap
Color Table
Definition: coltab.h:22
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:26
Definition: uistring.h:218
Type
Definition: uitreeview.h:206
ScrollMode
Definition: uitreeview.h:71
const uiTreeViewBody * lvbody() const
Definition: uitreeview.h:170
int column_
Definition: uitreeview.h:160
Notifier< uiTreeView > selectionChanged
Definition: uitreeview.h:138
Setup(const uiString &txt=uiString::emptyString(), uiTreeViewItem::Type tp=uiTreeViewItem::Standard, bool setchecked=true)
Definition: uitreeview.h:211
void setNotifiedColumn(int col)
Definition: uitreeview.h:136
WidthMode
Definition: uitreeview.h:61
void unNotify()
Definition: uitreeview.h:133
Definition: uitreeview.h:208
Definition: pythonaccess.h:37
Notifier< uiTreeView > unusedKey
Definition: uitreeview.h:153
Notifier< uiTreeView > rightButtonPressed
Definition: uitreeview.h:144

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019