OpendTect-6_4  6.4
uitreeitemmanager.h
Go to the documentation of this file.
1 #ifndef uitreeitemmanager_h
2 #define uitreeitemmanager_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Kristofer Tingdahl
9  Date: 4-11-2002
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 
14 -*/
15 
16 #include "uitoolsmod.h"
17 #include "sets.h"
18 #include "iopar.h"
19 #include "callback.h"
20 #include "bufstring.h"
21 #include "task.h"
22 #include "thread.h"
23 
30 class uiTreeViewItem;
31 class uiTreeView;
32 class uiParent;
33 
34 mExpClass(uiTools) uiTreeItem : public CallBacker
35 {
36 public:
37  uiTreeItem(const uiString& nm=
39  virtual ~uiTreeItem();
40  virtual void prepareForShutdown();
44  virtual bool askContinueAndSaveIfNeeded(bool withcancel);
45  void setName( const uiString& nm ) { name_ = nm; }
46  uiString name() const;
47 
48  bool areAllParentsChecked();
49 
50  void entryInEditMode(int col);
51 
52  virtual int selectionKey() const { return -1; }
53  virtual bool select();
55  virtual bool isSelected() const;
56  void setChecked(bool yn,bool trigger=false);
57  virtual bool isChecked() const;
58  NotifierAccess* checkStatusChange();
59  NotifierAccess* keyPressed();
60  void expand();
61  bool isExpanded() const;
62  void collapse();
63  bool isCollapsed() const;
64 
65  bool hasChildren() const;
66  bool hasGrandChildren() const;
67  bool allChildrenExpanded() const;
68  bool allChildrenCollapsed() const;
69  bool allChildrenChecked() const;
70  bool allChildrenUnchecked() const;
71 
72  virtual int siblingIndex() const;
73  /*\returns the index of this item among
74  its siblings.
75  \note this index is not neseccarely the same
76  as the item's index in the parent's
77  child-list. */
78 
79  virtual uiTreeItem* siblingAbove();
80  virtual uiTreeItem* siblingBelow();
81  virtual void moveItem(uiTreeItem* after);
82  virtual void moveItemToTop();
83  uiTreeItem* lastChild();
84 
85  int nrChildren() const { return children_.size(); }
86  const uiTreeItem* getChild(int) const;
87  uiTreeItem* getChild(int);
88  ObjectSet<uiTreeItem>& getChildren() { return children_; }
89  const ObjectSet<uiTreeItem>& getChildren() const { return children_; }
90 
91  virtual bool addChild(uiTreeItem* child,bool below);
101  virtual void removeChild(uiTreeItem*);
102  virtual void removeAllChildren();
103 
104  virtual const uiTreeItem* findChild(const char* name) const;
107  virtual const uiTreeItem* findChild(int selkey) const;
110  virtual uiTreeItem* findChild(const char* name);
113  virtual uiTreeItem* findChild(int selkey);
116  virtual void findChildren(const char*,
121  template<class T> inline void setProperty(const char* key,const T&);
130  inline void setPropertyPtr(const char* key,void*);
134  template<class T> inline bool getProperty(const char* key, T& res) const;
147  inline bool getPropertyPtr(const char* key,void*&) const;
156  virtual void updateColumnText(int col);
157  virtual void updateCheckStatus();
158 
159  virtual void translateText() { updateColumnText( 0 ); }
160  uiTreeViewItem* getItem() { return uitreeviewitem_; }
161  const uiTreeViewItem* getItem() const { return uitreeviewitem_; }
162 
163 protected:
164 
165  virtual int uiTreeViewItemType() const;
168  virtual uiParent* getUiParent() const;
169 
170  virtual bool addChld(uiTreeItem*,bool below,bool downwards);
182  virtual const char* parentType() const = 0;
184  virtual bool useParentType() const { return true; }
185  virtual bool init() { return true; }
186 
187  virtual bool rightClick(uiTreeViewItem*);
188  virtual bool anyButtonClick(uiTreeViewItem*);
189  virtual bool doubleClick(uiTreeViewItem*);
190  virtual void setTreeViewItem(uiTreeViewItem*);
191  virtual void removeItem(uiTreeViewItem*);
192  virtual void renameItem(uiTreeViewItem*);
193 
194  virtual bool showSubMenu() { return true; }
195  virtual bool selectWithKey(int selkey);
196 
197  virtual bool isSelectable() const { return false; }
198  virtual bool isExpandable() const { return true; }
199 
200  virtual void updateSelection(int selectionKey,
201  bool dw=false );
203  virtual bool shouldSelect(int selectionkey) const;
208 
211 
214  friend class uiTreeTopItem;
215  friend class uiODTreeTop;
216 
217 private:
218 
219  bool addChildImpl(CallBacker*,uiTreeItem*,bool,bool);
220 
221 public:
222  void updateSelTreeColumnText(int col);
224 };
225 
227 {
228 public:
229  uiTreeItemRemover(uiTreeItem* parent,uiTreeItem* child);
230  int nextStep();
231 
232 protected:
235 };
236 
237 
238 
240 {
241 public:
242  uiTreeTopItem(uiTreeView*, bool=false );
243  ~uiTreeTopItem();
244 
245  virtual bool addChild(uiTreeItem*,bool below);
246  virtual void updateSelection(int selectionkey, bool=false );
248  virtual void updateColumnText(int col);
249  bool isChecked() const { return true; }
250 
251  void disabRightClick(bool yn) { disabrightclick_=yn; }
252  void disabAnyClick(bool yn) { disabanyclick_=yn; }
253  uiTreeView* getTreeView() const { return listview_; }
254 
255 protected:
256 
257  virtual bool addChld(uiTreeItem*,bool below,bool downwards);
258  virtual void removeItem(uiTreeViewItem*);
259 
261  void rightClickCB(CallBacker*);
263  void doubleClickCB(CallBacker*);
264  void itemRenamed(CallBacker*);
265  void handleSelectionChanged(bool frmbtclk);
266 
267  virtual const char* parentType() const { return 0; }
268  virtual uiParent* getUiParent() const;
269 
274 
275 };
276 
277 
279 {
280 public:
281  virtual ~uiTreeItemFactory() {}
282  virtual const char* name() const = 0;
283  virtual uiTreeItem* create() const = 0;
284 };
285 
286 
288 {
289 public:
291  ~uiTreeFactorySet();
292  void addFactory(uiTreeItemFactory* ptr,
293  int placementindex=-1,
294  int pol2d=1);
303  void remove( const char* );
304 
305  int nrFactories() const;
306  const uiTreeItemFactory* getFactory(int) const;
307  int getPlacementIdx(int) const;
308  int getPol2D(int) const;
309 
312 
313 protected:
314 
318 
319 };
320 
321 
322 template<class T>
323 bool inline uiTreeItem::getProperty( const char* propertykey, T& res ) const
324 {
325  if ( properties_.get( propertykey, res ))
326  return true;
327 
328  return parent_ ? parent_->getProperty( propertykey, res ) : false;
329 }
330 
331 
332 inline bool uiTreeItem::getPropertyPtr(const char* propertykey,void*& res) const
333 {
334  if ( properties_.getPtr( propertykey, res ))
335  return true;
336 
337  return parent_ ? parent_->getPropertyPtr( propertykey, res ) : false;
338 }
339 
340 
341 #include <typeinfo>
342 
343 template<class T>
344 void inline uiTreeItem::setProperty( const char* propertykey, const T& val )
345 {
346  if ( typeid(T)==typeid(void*) )
347  properties_.set( propertykey, (od_int64)val );
348  else
349  properties_.set( propertykey, val );
350 }
351 
352 
353 void inline uiTreeItem::setPropertyPtr( const char* propertykey, void* val )
354 {
355  properties_.setPtr( propertykey, val );
356 }
357 
358 #endif
#define mExpClass(module)
Definition: commondefs.h:160
int nrChildren() const
Definition: uitreeitemmanager.h:85
CNotifier< uiTreeFactorySet, int > removenotifier
Definition: uitreeitemmanager.h:311
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
ObjectSet< uiTreeItem > children_
Definition: uitreeitemmanager.h:213
void rightClickCB(CallBacker *)
uiTreeViewItem * uitreeviewitem_
Definition: uitreeitemmanager.h:212
bool getPropertyPtr(const char *key, void *&) const
Definition: uitreeitemmanager.h:332
void disabAnyClick(bool yn)
Definition: uitreeitemmanager.h:252
virtual void updateSelection(int selectionkey, bool=false)
Interface class for Notifier. See comments there.
Definition: callback.h:161
IOPar properties_
Definition: uitreeitemmanager.h:207
#define od_int64
Definition: plftypes.h:36
ObjectSet< uiTreeItemFactory > factories_
Definition: uitreeitemmanager.h:315
virtual int selectionKey() const
Definition: uitreeitemmanager.h:52
static const uiString & emptyString()
Definition: uistring.h:109
Definition: uistring.h:89
Definition: uiparent.h:26
uiTreeItem * child_
Definition: uitreeitemmanager.h:234
bool get(const char *, int &) const
bool isChecked() const
Definition: uitreeitemmanager.h:249
TypeSet< int > pol2ds_
Definition: uitreeitemmanager.h:317
virtual bool addChild(uiTreeItem *, bool below)
uiString name() const
virtual bool isExpandable() const
Definition: uitreeitemmanager.h:198
The generalization of something (e.g. a computation) where the steps must be done in sequence...
Definition: task.h:124
virtual bool showSubMenu()
Definition: uitreeitemmanager.h:194
Definition: uitreeview.h:201
void setName(const uiString &nm)
Definition: uitreeitemmanager.h:45
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
uiTreeTopItem(uiTreeView *, bool=false)
TypeSet< int > placementidxs_
Definition: uitreeitemmanager.h:316
uiTreeViewItem * getItem()
Definition: uitreeitemmanager.h:160
const uiTreeViewItem * getItem() const
Definition: uitreeitemmanager.h:161
Definition: uitreeitemmanager.h:226
virtual bool init()
Definition: uitreeitemmanager.h:185
Definition: uitreeitemmanager.h:278
void setPtr(const char *, void *)
void anyButtonClickCB(CallBacker *)
Definition: uiodtreeitem.h:50
bool addChildImpl(CallBacker *, uiTreeItem *, bool, bool)
bool disabselcngresp_
Definition: uitreeitemmanager.h:273
Definition: uitreeview.h:33
virtual void removeItem(uiTreeViewItem *)
void updateSelTreeColumnText(int col)
bool getProperty(const char *key, T &res) const
Definition: uitreeitemmanager.h:323
virtual uiParent * getUiParent() const
virtual void updateColumnText(int col)
uiString name_
Definition: uitreeitemmanager.h:210
void addChild(uiBaseObject &)
void selectionChanged(CallBacker *)
void doubleClickCB(CallBacker *)
ObjectSet< uiTreeItem > & getChildren()
Definition: uitreeitemmanager.h:88
static uiHor3DInterpol * create(uiParent *)
uiTreeItem * parent_
Definition: uitreeitemmanager.h:209
bool getPtr(const char *, void *&) const
bool disabrightclick_
Definition: uitreeitemmanager.h:271
Definition: uitreeitemmanager.h:239
uiTreeView * listview_
Definition: uitreeitemmanager.h:270
void handleSelectionChanged(bool frmbtclk)
virtual bool isSelectable() const
Definition: uitreeitemmanager.h:197
void setPropertyPtr(const char *key, void *)
Definition: uitreeitemmanager.h:353
virtual ~uiTreeItemFactory()
Definition: uitreeitemmanager.h:281
Definition: i_layout.h:28
virtual bool useParentType() const
Definition: uitreeitemmanager.h:184
uiTreeItem * parentTreeItem()
Definition: uitreeitemmanager.h:223
void itemRenamed(CallBacker *)
void set(const char *ky, const char *val)
Definition: uitreeitemmanager.h:287
void setProperty(const char *key, const T &)
Definition: uitreeitemmanager.h:344
virtual const char * parentType() const
Definition: uitreeitemmanager.h:267
bool disabanyclick_
Definition: uitreeitemmanager.h:272
const ObjectSet< uiTreeItem > & getChildren() const
Definition: uitreeitemmanager.h:89
uiTreeItem * parent_
Definition: uitreeitemmanager.h:233
Definition: uitreeitemmanager.h:34
virtual bool addChld(uiTreeItem *, bool below, bool downwards)
virtual void translateText()
Definition: uitreeitemmanager.h:159
uiTreeView * getTreeView() const
Definition: uitreeitemmanager.h:253
void disabRightClick(bool yn)
Definition: uitreeitemmanager.h:251
CNotifier< uiTreeFactorySet, int > addnotifier
Definition: uitreeitemmanager.h:310

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