Choreonoid  1.8
ItemTreeView.h
Go to the documentation of this file.
1 #ifndef CNOID_BASE_ITEM_TREE_VIEW_H
2 #define CNOID_BASE_ITEM_TREE_VIEW_H
3 
4 #include "View.h"
5 #include "RootItem.h"
6 #include "ItemTreeWidget.h"
7 #include "exportdecl.h"
8 
9 namespace cnoid {
10 
11 class CNOID_EXPORT ItemTreeView : public View
12 {
13 public:
14  static void initializeClass(ExtensionManager* ext);
15 
16  static ItemTreeView* instance();
17 
18  // deprecated
20  return instance();
21  }
22 
23  ItemTreeView();
24  ~ItemTreeView();
25 
26  ItemTreeWidget* itemTreeWidget();
27 
28  template<class ItemType>
30  std::function<void(ItemType* item, MenuManager& menuManager, ItemFunctionDispatcher menuFunction)> func){
31  itemTreeWidget()->customizeContextMenu(func);
32  }
33 
34  void setExpanded(Item* item, bool on = true);
35 
36  template <class ItemType>
37  [[deprecated("Use RootItem::selectedItems")]]
39  return RootItem::instance()->selectedItems<ItemType>();
40  }
41  [[deprecated("Use RootItem::selectedItems")]]
42  const ItemList<>& selectedItems() const {
44  }
45  template <class ItemType>
46  [[deprecated]]
47  ItemType* selectedItem(bool fromMultiItems = false) const {
48  return selectedItems<ItemType>().toSingle(fromMultiItems);
49  }
50  template <class ItemType>
51  [[deprecated("Use Item::selectedDescendantItems")]]
52  ItemList<ItemType> selectedSubItems(const Item* topItem) const {
53  return topItem->selectedDescendantItems<ItemType>();
54  }
55  template <class ItemType>
56  [[deprecated]]
57  ItemType* selectedSubItem(Item* topItem, bool fromMultiItems = false) const {
58  return selectedSubItems<ItemType>(topItem).toSingle(fromMultiItems);
59  }
60  [[deprecated("Use Item::isSelected")]]
61  bool isItemSelected(const Item* item) const {
62  return item->isSelected();
63  }
64  [[deprecated("Use Item::setSelected")]]
65  bool selectItem(Item* item, bool on = true) {
66  item->setSelected(on);
67  return true;
68  }
69  [[deprecated("Use Item::setSubTreeItemsSelected for the root item")]]
70  void selectAllItems() {
72  }
73  [[deprecated("Use Item::setSubTreeItemsSelected for the root item")]]
74  void clearSelection() {
76  }
77 
79 
80  template <class ItemType>
81  [[deprecated("Use RootItem::checkedItems")]]
83  return RootItem::instance()->checkedItems<ItemType>(checkId);
84  }
85  [[deprecated("Use Item::isChecked")]]
86  bool isItemChecked(const Item* item, int checkId = Item::PrimaryCheck) const {
87  return item->isChecked(checkId);
88  }
89  [[deprecated("Use Item::setChecked")]]
90  bool checkItem(Item* item, bool on = true, int checkId = Item::PrimaryCheck) {
91  item->setChecked(checkId, on);
92  return true;
93  }
94  [[deprecated("Use RootItem::sigSelectedItemsChanged")]]
95  SignalProxy<void(const ItemList<>&)> sigSelectionChanged() const {
97  }
98  [[deprecated("Use RootItem::sigCheckToggled")]]
99  SignalProxy<void(Item* item, bool isChecked)> sigCheckToggled(int checkId = Item::PrimaryCheck) const {
100  return RootItem::instance()->sigCheckToggled(checkId);
101  }
102  [[deprecated("Use Item::sigCheckToggled")]]
103  SignalProxy<void(bool isChecked)> sigCheckToggled(Item* item, int checkId = Item::PrimaryCheck) const {
104  return item->sigCheckToggled(checkId);
105  }
106 
107 protected:
108  virtual bool storeState(Archive& archive) override;
109  virtual bool restoreState(const Archive& archive) override;
110 
111 private:
112  class Impl;
113  Impl* impl;
114 };
115 
116 }
117 
118 #endif
cnoid::Item::sigCheckToggled
SignalProxy< void(bool on)> sigCheckToggled(int checkId=PrimaryCheck)
Definition: Item.cpp:1144
cnoid::ItemTreeView::isItemSelected
bool isItemSelected(const Item *item) const
Definition: ItemTreeView.h:61
cnoid::ItemTreeView::checkedItems
ItemList< ItemType > checkedItems(int checkId=Item::PrimaryCheck) const
Definition: ItemTreeView.h:82
cnoid::RootItem::selectedItems
ItemList< ItemType > selectedItems()
Definition: RootItem.h:44
cnoid::ItemTreeView::selectedItems
const ItemList & selectedItems() const
Definition: ItemTreeView.h:42
cnoid::ItemTreeView::sigSelectionChanged
SignalProxy< void(const ItemList<> &)> sigSelectionChanged() const
Definition: ItemTreeView.h:95
cnoid::ItemTreeView::selectedSubItem
ItemType * selectedSubItem(Item *topItem, bool fromMultiItems=false) const
Definition: ItemTreeView.h:57
cnoid::ExtensionManager
Definition: ExtensionManager.h:23
cnoid::ItemTreeView::selectItem
bool selectItem(Item *item, bool on=true)
Definition: ItemTreeView.h:65
cnoid::RootItem::instance
static RootItem * instance()
Definition: RootItem.cpp:134
cnoid::ItemTreeView::selectAllItems
void selectAllItems()
Definition: ItemTreeView.h:70
cnoid::View
Definition: View.h:27
cnoid::RootItem::sigCheckToggled
SignalProxy< void(Item *item, bool on)> sigCheckToggled(int checkId=PrimaryCheck)
Definition: RootItem.cpp:589
cnoid::Archive
Definition: Archive.h:22
cnoid::ItemTreeView
Definition: ItemTreeView.h:11
cnoid::Item::setChecked
void setChecked(bool on)
Definition: Item.cpp:475
cnoid::MenuManager
Definition: MenuManager.h:14
cnoid::ItemTreeView::selectedItem
ItemType * selectedItem(bool fromMultiItems=false) const
Definition: ItemTreeView.h:47
cnoid::ItemTreeView::clearSelection
void clearSelection()
Definition: ItemTreeView.h:74
cnoid::ItemTreeView::CheckId
CheckId
Definition: ItemTreeView.h:78
cnoid::Item::isSelected
bool isSelected() const
Definition: Item.h:98
cnoid::ItemTreeView::sigCheckToggled
SignalProxy< void(Item *item, bool isChecked)> sigCheckToggled(int checkId=Item::PrimaryCheck) const
Definition: ItemTreeView.h:99
RootItem.h
cnoid::RootItem::checkedItems
ItemList< ItemType > checkedItems(int checkId=PrimaryCheck)
Definition: RootItem.h:73
cnoid::Item::selectedDescendantItems
ItemList selectedDescendantItems(std::function< bool(Item *item)> pred=nullptr) const
Definition: Item.cpp:1267
cnoid::Item::setSubTreeItemsSelected
void setSubTreeItemsSelected(bool on)
Definition: Item.cpp:430
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::Item
Definition: Item.h:29
cnoid::Item::isChecked
bool isChecked(int checkId=PrimaryCheck) const
Definition: Item.cpp:457
cnoid::ItemList
Definition: Item.h:20
cnoid::ItemTreeView::mainInstance
static ItemTreeView * mainInstance()
Definition: ItemTreeView.h:19
cnoid::Item::LogicalSumOfAllChecks
@ LogicalSumOfAllChecks
Definition: Item.h:106
cnoid::ItemTreeView::selectedSubItems
ItemList< ItemType > selectedSubItems(const Item *topItem) const
Definition: ItemTreeView.h:52
cnoid::ItemTreeWidget
Definition: ItemTreeWidget.h:19
cnoid::ItemTreeView::sigCheckToggled
SignalProxy< void(bool isChecked)> sigCheckToggled(Item *item, int checkId=Item::PrimaryCheck) const
Definition: ItemTreeView.h:103
cnoid::Item::setSelected
void setSelected(bool on, bool isCurrent=false)
Definition: Item.cpp:409
cnoid::ItemTreeView::isItemChecked
bool isItemChecked(const Item *item, int checkId=Item::PrimaryCheck) const
Definition: ItemTreeView.h:86
cnoid::RootItem::sigSelectedItemsChanged
SignalProxy< void(const ItemList<> &selectedItems)> sigSelectedItemsChanged()
Definition: RootItem.cpp:442
cnoid::ItemTreeView::selectedItems
ItemList< ItemType > selectedItems() const
Definition: ItemTreeView.h:38
cnoid::SignalProxy
Definition: Signal.h:470
ItemTreeWidget.h
View.h
cnoid::ItemTreeView::customizeContextMenu
void customizeContextMenu(std::function< void(ItemType *item, MenuManager &menuManager, ItemFunctionDispatcher menuFunction)> func)
Definition: ItemTreeView.h:29
cnoid::Item::PrimaryCheck
@ PrimaryCheck
Definition: Item.h:106
cnoid::ItemTreeView::checkItem
bool checkItem(Item *item, bool on=true, int checkId=Item::PrimaryCheck)
Definition: ItemTreeView.h:90
cnoid::ItemFunctionDispatcher
PolymorphicItemFunctionSet::Dispatcher ItemFunctionDispatcher
Definition: PolymorphicItemFunctionSet.h:16